Skip to content

Commit 300ac8b

Browse files
Roman SyroeshkoRoman Syroeshko
authored andcommitted
Merge pull request #172 from RomanSyroeshko/develop
Fix for unit tests.
2 parents c76b618 + 6b17492 commit 300ac8b

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

tests/PhpWord/Tests/Reader/Word2007Test.php

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,35 @@ public function tearDown()
1818
*/
1919
public function testCanRead()
2020
{
21-
$dir = __DIR__ . "/../_files/documents";
22-
$object = new Word2007;
23-
$file = $dir . \DIRECTORY_SEPARATOR . 'reader.docx';
24-
$this->assertTrue($object->canRead($file));
21+
$object = new Word2007();
22+
$fqFilename = join(
23+
DIRECTORY_SEPARATOR,
24+
array(PHPWORD_TESTS_BASE_DIR, '_files', 'documents', 'reader.docx')
25+
);
26+
$this->assertTrue($object->canRead($fqFilename));
2527
}
2628

2729
/**
2830
* @expectedException \PhpOffice\PhpWord\Exceptions\Exception
2931
*/
3032
public function testCanReadFailed()
3133
{
32-
$dir = __DIR__ . "/../_files/documents";
33-
$object = new Word2007;
34-
$file = $dir . \DIRECTORY_SEPARATOR . 'foo.docx';
35-
$this->assertFalse($object->canRead($file));
36-
$object = IOFactory::load($file);
34+
$object = new Word2007();
35+
$fqFilename = join(
36+
DIRECTORY_SEPARATOR,
37+
array(PHPWORD_TESTS_BASE_DIR, '_files', 'documents', 'foo.docx')
38+
);
39+
$this->assertFalse($object->canRead($fqFilename));
40+
$object = IOFactory::load($fqFilename);
3741
}
3842

39-
/**
40-
* Test load document
41-
*/
4243
public function testLoad()
4344
{
44-
$dir = __DIR__ . "/../_files/documents";
45-
$file = $dir . \DIRECTORY_SEPARATOR . 'reader.docx';
46-
$object = IOFactory::load($file);
45+
$fqFilename = join(
46+
DIRECTORY_SEPARATOR,
47+
array(PHPWORD_TESTS_BASE_DIR, '_files', 'documents', 'reader.docx')
48+
);
49+
$object = IOFactory::load($fqFilename);
4750
$this->assertInstanceOf('PhpOffice\\PhpWord\\PhpWord', $object);
4851
}
4952
}

0 commit comments

Comments
 (0)