From 6b17492383ab052668f42cf67fd8d9cacebd31a6 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Tue, 25 Mar 2014 17:24:26 +0400 Subject: [PATCH] https://github.com/PHPOffice/PHPWord/issues/58 - fix for unit tests. --- tests/PhpWord/Tests/Reader/Word2007Test.php | 33 +++++++++++---------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/tests/PhpWord/Tests/Reader/Word2007Test.php b/tests/PhpWord/Tests/Reader/Word2007Test.php index 1afbb1b1ae..3e94c95761 100644 --- a/tests/PhpWord/Tests/Reader/Word2007Test.php +++ b/tests/PhpWord/Tests/Reader/Word2007Test.php @@ -18,10 +18,12 @@ public function tearDown() */ public function testCanRead() { - $dir = __DIR__ . "/../_files/documents"; - $object = new Word2007; - $file = $dir . \DIRECTORY_SEPARATOR . 'reader.docx'; - $this->assertTrue($object->canRead($file)); + $object = new Word2007(); + $fqFilename = join( + DIRECTORY_SEPARATOR, + array(PHPWORD_TESTS_BASE_DIR, '_files', 'documents', 'reader.docx') + ); + $this->assertTrue($object->canRead($fqFilename)); } /** @@ -29,21 +31,22 @@ public function testCanRead() */ public function testCanReadFailed() { - $dir = __DIR__ . "/../_files/documents"; - $object = new Word2007; - $file = $dir . \DIRECTORY_SEPARATOR . 'foo.docx'; - $this->assertFalse($object->canRead($file)); - $object = IOFactory::load($file); + $object = new Word2007(); + $fqFilename = join( + DIRECTORY_SEPARATOR, + array(PHPWORD_TESTS_BASE_DIR, '_files', 'documents', 'foo.docx') + ); + $this->assertFalse($object->canRead($fqFilename)); + $object = IOFactory::load($fqFilename); } - /** - * Test load document - */ public function testLoad() { - $dir = __DIR__ . "/../_files/documents"; - $file = $dir . \DIRECTORY_SEPARATOR . 'reader.docx'; - $object = IOFactory::load($file); + $fqFilename = join( + DIRECTORY_SEPARATOR, + array(PHPWORD_TESTS_BASE_DIR, '_files', 'documents', 'reader.docx') + ); + $object = IOFactory::load($fqFilename); $this->assertInstanceOf('PhpOffice\\PhpWord\\PhpWord', $object); } }