2014-03-12 00:12:55 +07:00
|
|
|
<?php
|
2014-03-23 11:59:22 -04:00
|
|
|
namespace PhpOffice\PhpWord\Tests\Reader;
|
2014-03-12 00:12:55 +07:00
|
|
|
|
2014-03-18 17:26:03 +04:00
|
|
|
use PhpOffice\PhpWord\Reader\Word2007;
|
|
|
|
|
use PhpOffice\PhpWord\IOFactory;
|
2014-03-12 00:12:55 +07:00
|
|
|
|
|
|
|
|
class Word2007Test extends \PHPUnit_Framework_TestCase
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Init
|
|
|
|
|
*/
|
|
|
|
|
public function tearDown()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Test canRead() method
|
|
|
|
|
*/
|
|
|
|
|
public function testCanRead()
|
|
|
|
|
{
|
2014-03-23 12:37:31 -04:00
|
|
|
$dir = __DIR__ . "/../_files/documents";
|
2014-03-18 17:26:03 +04:00
|
|
|
$object = new Word2007;
|
2014-03-23 10:32:08 +04:00
|
|
|
$file = $dir . \DIRECTORY_SEPARATOR . 'reader.docx';
|
2014-03-12 00:12:55 +07:00
|
|
|
$this->assertTrue($object->canRead($file));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2014-03-23 10:32:08 +04:00
|
|
|
* @expectedException \PhpOffice\PhpWord\Exceptions\Exception
|
2014-03-12 00:12:55 +07:00
|
|
|
*/
|
|
|
|
|
public function testCanReadFailed()
|
|
|
|
|
{
|
2014-03-23 12:37:31 -04:00
|
|
|
$dir = __DIR__ . "/../_files/documents";
|
2014-03-18 17:26:03 +04:00
|
|
|
$object = new Word2007;
|
2014-03-23 10:32:08 +04:00
|
|
|
$file = $dir . \DIRECTORY_SEPARATOR . 'foo.docx';
|
2014-03-12 00:12:55 +07:00
|
|
|
$this->assertFalse($object->canRead($file));
|
2014-03-18 17:26:03 +04:00
|
|
|
$object = IOFactory::load($file);
|
2014-03-12 00:12:55 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Test load document
|
|
|
|
|
*/
|
|
|
|
|
public function testLoad()
|
|
|
|
|
{
|
2014-03-23 12:37:31 -04:00
|
|
|
$dir = __DIR__ . "/../_files/documents";
|
2014-03-23 10:32:08 +04:00
|
|
|
$file = $dir . \DIRECTORY_SEPARATOR . 'reader.docx';
|
2014-03-18 17:26:03 +04:00
|
|
|
$object = IOFactory::load($file);
|
2014-03-22 10:06:08 +04:00
|
|
|
$this->assertInstanceOf('PhpOffice\\PhpWord\\PhpWord', $object);
|
2014-03-12 00:12:55 +07:00
|
|
|
}
|
2014-03-23 17:37:26 +07:00
|
|
|
}
|