PHPWord/tests/PhpWord/Tests/Shared/XMLReaderTest.php

76 lines
2.3 KiB
PHP
Raw Normal View History

2014-04-12 10:23:31 +07:00
<?php
/**
* This file is part of PHPWord - A pure PHP library for reading and writing
* word processing documents.
*
* PHPWord is free software distributed under the terms of the GNU Lesser
* General Public License version 3 as published by the Free Software Foundation.
*
* For the full copyright and license information, please read the LICENSE
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
2014-04-12 10:23:31 +07:00
*
* @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2014 PHPWord contributors
2014-05-04 21:03:28 +04:00
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
2014-04-12 10:23:31 +07:00
*/
namespace PhpOffice\PhpWord\Tests\Shared;
use PhpOffice\PhpWord\Shared\XMLReader;
/**
* Test class for PhpOffice\PhpWord\Shared\XMLReader
*
* @runTestsInSeparateProcesses
* @since 0.10.0
*/
class XMLReaderTest extends \PHPUnit_Framework_TestCase
{
2014-05-31 17:39:54 +07:00
/**
* Test get DOMDocument from ZipArchive exception
*
* @expectedException \PhpOffice\PhpWord\Exception\Exception
* @expectedExceptionMessage Cannot find archive file.
*/
public function testGetDomFromZipException()
{
$filename = __DIR__ . "/../_files/documents/foo.zip";
$object = new XMLReader();
$object->getDomFromZip($filename, 'yadayadaya');
}
2014-04-12 10:23:31 +07:00
/**
* Test get DOMDocument from ZipArchive returns false
*/
public function testGetDomFromZipReturnsFalse()
{
$filename = __DIR__ . "/../_files/documents/reader.docx.zip";
$object = new XMLReader();
$this->assertFalse($object->getDomFromZip($filename, 'yadayadaya'));
}
/**
* Test get elements returns empty
*/
public function testGetElementsReturnsEmpty()
{
$object = new XMLReader();
$this->assertEquals(array(), $object->getElements('w:document'));
}
/**
* Test get element returns null
*/
public function testGetElementReturnsNull()
{
$filename = __DIR__ . "/../_files/documents/reader.docx.zip";
$object = new XMLReader();
$object->getDomFromZip($filename, '[Content_Types].xml');
$element = $object->getElements('*')->item(0);
$this->assertNull($object->getElement('yadayadaya', $element));
}
}