diff --git a/test/PhpWord/Tests/MediaTest.php b/test/PhpWord/Tests/MediaTest.php index bc78ee5b..0bde5539 100644 --- a/test/PhpWord/Tests/MediaTest.php +++ b/test/PhpWord/Tests/MediaTest.php @@ -42,12 +42,12 @@ class MediaTest extends \PHPUnit_Framework_TestCase public function testAddSectionMediaElement() { $section = new Section(0); - $section->addImage(\PHPWORD_TESTS_BASE_DIR . "/data/images/mars_noext_jpg"); - $section->addImage(\PHPWORD_TESTS_BASE_DIR . "/data/images/mars.jpg"); - $section->addImage(\PHPWORD_TESTS_BASE_DIR . "/data/images/mario.gif"); - $section->addImage(\PHPWORD_TESTS_BASE_DIR . "/data/images/firefox.png"); - $section->addImage(\PHPWORD_TESTS_BASE_DIR . "/data/images/duke_nukem.bmp"); - $section->addImage(\PHPWORD_TESTS_BASE_DIR . "/data/images/angela_merkel.tif"); + $section->addImage(__DIR__ . "/_files/images/mars_noext_jpg"); + $section->addImage(__DIR__ . "/_files/images/mars.jpg"); + $section->addImage(__DIR__ . "/_files/images/mario.gif"); + $section->addImage(__DIR__ . "/_files/images/firefox.png"); + $section->addImage(__DIR__ . "/_files/images/duke_nukem.bmp"); + $section->addImage(__DIR__ . "/_files/images/angela_merkel.tif"); $elements = $section->getElements(); $this->assertEquals(6, count($elements)); diff --git a/test/PhpWord/Tests/PhpWordTest.php b/test/PhpWord/Tests/PhpWordTest.php index 7f8de84a..2857c4e8 100644 --- a/test/PhpWord/Tests/PhpWordTest.php +++ b/test/PhpWord/Tests/PhpWordTest.php @@ -130,10 +130,8 @@ class PhpWordTest extends \PHPUnit_Framework_TestCase */ public function testLoadTemplate() { - $templateFqfn = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'templates', 'blank.docx') - ); + $templateFqfn = __DIR__ . "/_files/templates/blank.docx"; + $phpWord = new PhpWord(); $this->assertInstanceOf( 'PhpOffice\\PhpWord\\Template', diff --git a/test/PhpWord/Tests/Reader/Word2007Test.php b/test/PhpWord/Tests/Reader/Word2007Test.php index 41bc1257..1afbb1b1 100644 --- a/test/PhpWord/Tests/Reader/Word2007Test.php +++ b/test/PhpWord/Tests/Reader/Word2007Test.php @@ -18,10 +18,7 @@ class Word2007Test extends \PHPUnit_Framework_TestCase */ public function testCanRead() { - $dir = join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'documents') - ); + $dir = __DIR__ . "/../_files/documents"; $object = new Word2007; $file = $dir . \DIRECTORY_SEPARATOR . 'reader.docx'; $this->assertTrue($object->canRead($file)); @@ -32,10 +29,7 @@ class Word2007Test extends \PHPUnit_Framework_TestCase */ public function testCanReadFailed() { - $dir = join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'documents') - ); + $dir = __DIR__ . "/../_files/documents"; $object = new Word2007; $file = $dir . \DIRECTORY_SEPARATOR . 'foo.docx'; $this->assertFalse($object->canRead($file)); @@ -47,10 +41,7 @@ class Word2007Test extends \PHPUnit_Framework_TestCase */ public function testLoad() { - $dir = join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'documents') - ); + $dir = __DIR__ . "/../_files/documents"; $file = $dir . \DIRECTORY_SEPARATOR . 'reader.docx'; $object = IOFactory::load($file); $this->assertInstanceOf('PhpOffice\\PhpWord\\PhpWord', $object); diff --git a/test/PhpWord/Tests/Section/FooterTest.php b/test/PhpWord/Tests/Section/FooterTest.php index 8d012d28..b2531757 100644 --- a/test/PhpWord/Tests/Section/FooterTest.php +++ b/test/PhpWord/Tests/Section/FooterTest.php @@ -30,7 +30,6 @@ class FooterTest extends \PHPUnit_Framework_TestCase $this->assertCount(1, $oFooter->getElements()); $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Text', $element); - } public function testAddTextNotUTF8() @@ -72,10 +71,7 @@ class FooterTest extends \PHPUnit_Framework_TestCase public function testAddImage() { - $src = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'images', 'earth.jpg') - ); + $src = __DIR__ . "/../_files/images/earth.jpg"; $oFooter = new Footer(1); $element = $oFooter->addImage($src); diff --git a/test/PhpWord/Tests/Section/HeaderTest.php b/test/PhpWord/Tests/Section/HeaderTest.php index e195277e..9b40c140 100644 --- a/test/PhpWord/Tests/Section/HeaderTest.php +++ b/test/PhpWord/Tests/Section/HeaderTest.php @@ -68,10 +68,7 @@ class HeaderTest extends \PHPUnit_Framework_TestCase public function testAddImage() { - $src = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'images', 'earth.jpg') - ); + $src = __DIR__ . "/../_files/images/earth.jpg"; $oHeader = new Header(1); $element = $oHeader->addImage($src); @@ -111,10 +108,7 @@ class HeaderTest extends \PHPUnit_Framework_TestCase public function testAddWatermark() { - $src = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'images', 'earth.jpg') - ); + $src = __DIR__ . "/../_files/images/earth.jpg"; $oHeader = new Header(1); $element = $oHeader->addWatermark($src); diff --git a/test/PhpWord/Tests/Section/ImageTest.php b/test/PhpWord/Tests/Section/ImageTest.php index 6dc0ed5c..5d1d58e5 100644 --- a/test/PhpWord/Tests/Section/ImageTest.php +++ b/test/PhpWord/Tests/Section/ImageTest.php @@ -10,10 +10,7 @@ class ImageTest extends \PHPUnit_Framework_TestCase { public function testConstruct() { - $src = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'images', 'firefox.png') - ); + $src = __DIR__ . "/../_files/images/firefox.png"; $oImage = new Image($src); $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Image', $oImage); @@ -25,10 +22,7 @@ class ImageTest extends \PHPUnit_Framework_TestCase public function testConstructWithStyle() { - $src = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'images', 'firefox.png') - ); + $src = __DIR__ . "/../_files/images/firefox.png"; $oImage = new Image( $src, array('width' => 210, 'height' => 210, 'align' => 'center', @@ -43,12 +37,12 @@ class ImageTest extends \PHPUnit_Framework_TestCase */ public function testValidImageTypes() { - new Image(\PHPWORD_TESTS_BASE_DIR . "/data/images/mars_noext_jpg"); - new Image(\PHPWORD_TESTS_BASE_DIR . "/data/images/mars.jpg"); - new Image(\PHPWORD_TESTS_BASE_DIR . "/data/images/mario.gif"); - new Image(\PHPWORD_TESTS_BASE_DIR . "/data/images/firefox.png"); - new Image(\PHPWORD_TESTS_BASE_DIR . "/data/images/duke_nukem.bmp"); - new Image(\PHPWORD_TESTS_BASE_DIR . "/data/images/angela_merkel.tif"); + new Image(__DIR__ . "/../_files/images/mars_noext_jpg"); + new Image(__DIR__ . "/../_files/images/mars.jpg"); + new Image(__DIR__ . "/../_files/images/mario.gif"); + new Image(__DIR__ . "/../_files/images/firefox.png"); + new Image(__DIR__ . "/../_files/images/duke_nukem.bmp"); + new Image(__DIR__ . "/../_files/images/angela_merkel.tif"); } /** @@ -57,7 +51,7 @@ class ImageTest extends \PHPUnit_Framework_TestCase */ public function testImageNotFound() { - new Image(\PHPWORD_TESTS_BASE_DIR . "/data/images/thisisnotarealimage"); + new Image(__DIR__ . "/../_files/images/thisisnotarealimage"); } /** @@ -66,26 +60,22 @@ class ImageTest extends \PHPUnit_Framework_TestCase */ public function testInvalidImageTypes() { - new Image(\PHPWORD_TESTS_BASE_DIR . "/data/images/alexz-johnson.pcx"); + new Image(__DIR__ . "/../_files/images/alexz-johnson.pcx"); } public function testStyle() { - $oImage = new Image(\join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'images', 'earth.jpg') - ), array('width' => 210, 'height' => 210, 'align' => 'center')); + $oImage = new Image( + __DIR__ . "/../_files/images/earth.jpg", + array('width' => 210, 'height' => 210, 'align' => 'center') + ); $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Image', $oImage->getStyle()); } public function testRelationID() { - $oImage = new Image(\join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'images', 'earth.jpg') - )); - + $oImage = new Image(__DIR__ . "/../_files/images/earth.jpg"); $iVal = rand(1, 1000); $oImage->setRelationId($iVal); $this->assertEquals($oImage->getRelationId(), $iVal); @@ -93,11 +83,7 @@ class ImageTest extends \PHPUnit_Framework_TestCase public function testWatermark() { - $oImage = new Image(\join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'images', 'earth.jpg') - )); - + $oImage = new Image(__DIR__ . "/../_files/images/earth.jpg"); $oImage->setIsWatermark(true); $this->assertEquals($oImage->getIsWatermark(), true); } diff --git a/test/PhpWord/Tests/Section/MemoryImageTest.php b/test/PhpWord/Tests/Section/MemoryImageTest.php index 5d1c7fcd..5dfef076 100644 --- a/test/PhpWord/Tests/Section/MemoryImageTest.php +++ b/test/PhpWord/Tests/Section/MemoryImageTest.php @@ -7,10 +7,7 @@ class MemoryImageTest extends \PHPUnit_Framework_TestCase { public function testPNG() { - $src = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'images', 'firefox.png') - ); + $src = __DIR__ . "/../_files/images/firefox.png"; $oMemoryImage = new MemoryImage($src); $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\MemoryImage', $oMemoryImage); @@ -24,10 +21,7 @@ class MemoryImageTest extends \PHPUnit_Framework_TestCase public function testGIF() { - $src = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'images', 'mario.gif') - ); + $src = __DIR__ . "/../_files/images/mario.gif"; $oMemoryImage = new MemoryImage($src); $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\MemoryImage', $oMemoryImage); @@ -41,10 +35,7 @@ class MemoryImageTest extends \PHPUnit_Framework_TestCase public function testJPG() { - $src = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'images', 'earth.jpg') - ); + $src = __DIR__ . "/../_files/images/earth.jpg"; $oMemoryImage = new MemoryImage($src); $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\MemoryImage', $oMemoryImage); @@ -58,10 +49,7 @@ class MemoryImageTest extends \PHPUnit_Framework_TestCase public function testBMP() { - $oMemoryImage = new MemoryImage(\join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'images', 'duke_nukem.bmp') - )); + $oMemoryImage = new MemoryImage(__DIR__ . "/../_files/images/duke_nukem.bmp"); $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\MemoryImage', $oMemoryImage); $this->assertEquals($oMemoryImage->getImageCreateFunction(), null); @@ -72,20 +60,16 @@ class MemoryImageTest extends \PHPUnit_Framework_TestCase public function testStyle() { - $oMemoryImage = new MemoryImage(\join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'images', 'earth.jpg') - ), array('width' => 210, 'height' => 210, 'align' => 'center')); - + $oMemoryImage = new MemoryImage( + __DIR__ . "/../_files/images/earth.jpg", + array('width' => 210, 'height' => 210, 'align' => 'center') + ); $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Image', $oMemoryImage->getStyle()); } public function testRelationID() { - $oMemoryImage = new MemoryImage(\join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'images', 'earth.jpg') - )); + $oMemoryImage = new MemoryImage(__DIR__ . "/../_files/images/earth.jpg"); $iVal = rand(1, 1000); $oMemoryImage->setRelationId($iVal); diff --git a/test/PhpWord/Tests/Section/ObjectTest.php b/test/PhpWord/Tests/Section/ObjectTest.php index 0b7065b3..fbf34228 100644 --- a/test/PhpWord/Tests/Section/ObjectTest.php +++ b/test/PhpWord/Tests/Section/ObjectTest.php @@ -7,10 +7,7 @@ class ObjectTest extends \PHPUnit_Framework_TestCase { public function testConstructWithSupportedFiles() { - $src = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'documents', 'sheet.xls') - ); + $src = __DIR__ . "/../_files/documents/sheet.xls"; $oObject = new Object($src); $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Object', $oObject); @@ -20,10 +17,7 @@ class ObjectTest extends \PHPUnit_Framework_TestCase public function testConstructWithNotSupportedFiles() { - $src = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'xsl', 'passthrough.xsl') - ); + $src = __DIR__ . "/../_files/xsl/passthrough.xsl"; $oObject = new Object($src); $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Object', $oObject); @@ -33,10 +27,7 @@ class ObjectTest extends \PHPUnit_Framework_TestCase public function testConstructWithSupportedFilesAndStyle() { - $src = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'documents', 'sheet.xls') - ); + $src = __DIR__ . "/../_files/documents/sheet.xls"; $oObject = new Object($src, array('width' => '230px')); $this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\Object', $oObject); @@ -46,10 +37,7 @@ class ObjectTest extends \PHPUnit_Framework_TestCase public function testRelationId() { - $src = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'documents', 'sheet.xls') - ); + $src = __DIR__ . "/../_files/documents/sheet.xls"; $oObject = new Object($src); $iVal = rand(1, 1000); @@ -59,10 +47,7 @@ class ObjectTest extends \PHPUnit_Framework_TestCase public function testImageRelationId() { - $src = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'documents', 'sheet.xls') - ); + $src = __DIR__ . "/../_files/documents/sheet.xls"; $oObject = new Object($src); $iVal = rand(1, 1000); @@ -72,10 +57,7 @@ class ObjectTest extends \PHPUnit_Framework_TestCase public function testObjectId() { - $src = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'documents', 'sheet.xls') - ); + $src = __DIR__ . "/../_files/documents/sheet.xls"; $oObject = new Object($src); $iVal = rand(1, 1000); diff --git a/test/PhpWord/Tests/Section/Table/CellTest.php b/test/PhpWord/Tests/Section/Table/CellTest.php index 61ec05dd..9f1a6da5 100644 --- a/test/PhpWord/Tests/Section/Table/CellTest.php +++ b/test/PhpWord/Tests/Section/Table/CellTest.php @@ -89,10 +89,7 @@ class CellTest extends \PHPUnit_Framework_TestCase public function testAddImageSection() { - $src = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'images', 'earth.jpg') - ); + $src = __DIR__ . "/../../_files/images/earth.jpg"; $oCell = new Cell('section', 1); $element = $oCell->addImage($src); @@ -102,10 +99,7 @@ class CellTest extends \PHPUnit_Framework_TestCase public function testAddImageHeader() { - $src = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'images', 'earth.jpg') - ); + $src = __DIR__ . "/../../_files/images/earth.jpg"; $oCell = new Cell('header', 1); $element = $oCell->addImage($src); @@ -115,10 +109,7 @@ class CellTest extends \PHPUnit_Framework_TestCase public function testAddImageFooter() { - $src = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'images', 'earth.jpg') - ); + $src = __DIR__ . "/../../_files/images/earth.jpg"; $oCell = new Cell('footer', 1); $element = $oCell->addImage($src); @@ -161,10 +152,7 @@ class CellTest extends \PHPUnit_Framework_TestCase public function testAddObjectXLS() { - $src = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'documents', 'sheet.xls') - ); + $src = __DIR__ . "/../../_files/documents/sheet.xls"; $oCell = new Cell('section', 1); $element = $oCell->addObject($src); diff --git a/test/PhpWord/Tests/Section/TextRunTest.php b/test/PhpWord/Tests/Section/TextRunTest.php index 24ee824a..cdfe2ebc 100644 --- a/test/PhpWord/Tests/Section/TextRunTest.php +++ b/test/PhpWord/Tests/Section/TextRunTest.php @@ -75,10 +75,8 @@ class TextRunTest extends \PHPUnit_Framework_TestCase public function testAddImage() { - $src = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'images', 'earth.jpg') - ); + $src = __DIR__ . "/../_files/images/earth.jpg"; + $oTextRun = new TextRun(); $element = $oTextRun->addImage($src); diff --git a/test/PhpWord/Tests/SectionTest.php b/test/PhpWord/Tests/SectionTest.php index 4f5d31c8..216956e7 100644 --- a/test/PhpWord/Tests/SectionTest.php +++ b/test/PhpWord/Tests/SectionTest.php @@ -73,14 +73,8 @@ class SectionTest extends \PHPUnit_Framework_TestCase */ public function testAddElements() { - $objectSource = join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'documents', 'sheet.xls') - ); - $imageSource = join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'images', 'PhpWord.png') - ); + $objectSource = __DIR__ . "/_files/documents/sheet.xls"; + $imageSource = __DIR__ . "/_files/images/PhpWord.png"; $imageUrl = 'http://php.net//images/logos/php-med-trans-light.gif'; $section = new Section(0); diff --git a/test/PhpWord/Tests/Shared/FileTest.php b/test/PhpWord/Tests/Shared/FileTest.php index b03d3525..97cdf375 100644 --- a/test/PhpWord/Tests/Shared/FileTest.php +++ b/test/PhpWord/Tests/Shared/FileTest.php @@ -14,7 +14,7 @@ class FileTest extends \PHPUnit_Framework_TestCase */ public function testFileExists() { - $dir = join(\DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_BASE_DIR, 'data', 'templates')); + $dir = __DIR__ . "/../_files/templates"; chdir($dir); $this->assertTrue(File::file_exists('blank.docx')); } @@ -23,7 +23,7 @@ class FileTest extends \PHPUnit_Framework_TestCase */ public function testNoFileExists() { - $dir = join(\DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_BASE_DIR, 'data', 'templates')); + $dir = __DIR__ . "/../_files/templates"; chdir($dir); $this->assertFalse(File::file_exists('404.docx')); } @@ -33,7 +33,7 @@ class FileTest extends \PHPUnit_Framework_TestCase */ public function testRealpath() { - $dir = join(\DIRECTORY_SEPARATOR, array(\PHPWORD_TESTS_BASE_DIR, 'data', 'templates')); + $dir = realpath(__DIR__ . "/../_files/templates"); chdir($dir); $file = 'blank.docx'; $expected = $dir . \DIRECTORY_SEPARATOR . $file; diff --git a/test/PhpWord/Tests/Style/FontTest.php b/test/PhpWord/Tests/Style/FontTest.php index c6e27b97..4d2d2615 100644 --- a/test/PhpWord/Tests/Style/FontTest.php +++ b/test/PhpWord/Tests/Style/FontTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpWord\Tests\Style; use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Style\Font; -use PhpWord\Tests\TestHelperDOCX; +use PhpOffice\PhpWord\Tests\TestHelperDOCX; /** * @runTestsInSeparateProcesses diff --git a/test/PhpWord/Tests/Style/ParagraphTest.php b/test/PhpWord/Tests/Style/ParagraphTest.php index 0ff5d779..7c14ae71 100644 --- a/test/PhpWord/Tests/Style/ParagraphTest.php +++ b/test/PhpWord/Tests/Style/ParagraphTest.php @@ -4,7 +4,7 @@ namespace PhpOffice\PhpWord\Tests\Style; use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Style\Paragraph; use PhpOffice\PhpWord\Style\Tab; -use PhpWord\Tests\TestHelperDOCX; +use PhpOffice\PhpWord\Tests\TestHelperDOCX; /** * @runTestsInSeparateProcesses diff --git a/test/PhpWord/Tests/Style/TabsTest.php b/test/PhpWord/Tests/Style/TabsTest.php index 3d3fce3e..7ee387a9 100644 --- a/test/PhpWord/Tests/Style/TabsTest.php +++ b/test/PhpWord/Tests/Style/TabsTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpWord\Tests\Style; use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Style\Tab; -use PhpWord\Tests\TestHelperDOCX; +use PhpOffice\PhpWord\Tests\TestHelperDOCX; /** * @runTestsInSeparateProcesses diff --git a/test/PhpWord/Tests/TemplateTest.php b/test/PhpWord/Tests/TemplateTest.php index 63993894..ec11d30b 100644 --- a/test/PhpWord/Tests/TemplateTest.php +++ b/test/PhpWord/Tests/TemplateTest.php @@ -15,19 +15,11 @@ final class TemplateTest extends \PHPUnit_Framework_TestCase */ final public function testTemplateCanBeSavedInTemporaryLocation() { - $templateFqfn = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'templates', 'with_table_macros.docx') - ); + $templateFqfn = __DIR__ . "/_files/templates/with_table_macros.docx"; $document = new Template($templateFqfn); $xslDOMDocument = new \DOMDocument(); - $xslDOMDocument->load( - \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'xsl', 'remove_tables_by_needle.xsl') - ) - ); + $xslDOMDocument->load(__DIR__ . "/_files/xsl/remove_tables_by_needle.xsl"); foreach (array('${employee.', '${scoreboard.') as $needle) { $document->applyXslStyleSheet($xslDOMDocument, array('needle' => $needle)); } @@ -63,10 +55,7 @@ final class TemplateTest extends \PHPUnit_Framework_TestCase */ final public function testXslStyleSheetCanBeApplied($actualDocumentFqfn) { - $expectedDocumentFqfn = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'documents', 'without_table_macros.docx') - ); + $expectedDocumentFqfn = __DIR__ . "/_files/documents/without_table_macros.docx"; $actualDocumentZip = new \ZipArchive(); $actualDocumentZip->open($actualDocumentFqfn); @@ -93,20 +82,10 @@ final class TemplateTest extends \PHPUnit_Framework_TestCase */ final public function testXslStyleSheetCanNotBeAppliedOnFailureOfSettingParameterValue() { - $template = new Template( - \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'templates', 'blank.docx') - ) - ); + $template = new Template(__DIR__ . "/_files/templates/blank.docx"); $xslDOMDocument = new \DOMDocument(); - $xslDOMDocument->load( - \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'xsl', 'passthrough.xsl') - ) - ); + $xslDOMDocument->load(__DIR__ . "/_files/xsl/passthrough.xsl"); /* * We have to use error control below, because \XSLTProcessor::setParameter omits warning on failure. @@ -123,20 +102,10 @@ final class TemplateTest extends \PHPUnit_Framework_TestCase */ final public function testXslStyleSheetCanNotBeAppliedOnFailureOfLoadingXmlFromTemplate() { - $template = new Template( - \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'templates', 'corrupted_main_document_part.docx') - ) - ); + $template = new Template(__DIR__ . "/_files/templates/corrupted_main_document_part.docx"); $xslDOMDocument = new \DOMDocument(); - $xslDOMDocument->load( - \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'xsl', 'passthrough.xsl') - ) - ); + $xslDOMDocument->load(__DIR__ . "/_files/xsl/passthrough.xsl"); /* * We have to use error control below, because \DOMDocument::loadXML omits warning on failure. @@ -153,10 +122,7 @@ final class TemplateTest extends \PHPUnit_Framework_TestCase */ public function testCloneRow() { - $template = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'templates', 'clone-merge.docx') - ); + $template = __DIR__ . "/_files/templates/clone-merge.docx"; $expectedVar = array('tableHeader', 'userId', 'userName', 'userLocation'); $docName = 'clone-test-result.docx'; diff --git a/test/PhpWord/Tests/Writer/ODText/ContentTest.php b/test/PhpWord/Tests/Writer/ODText/ContentTest.php index 2cfc1758..83f69fa7 100644 --- a/test/PhpWord/Tests/Writer/ODText/ContentTest.php +++ b/test/PhpWord/Tests/Writer/ODText/ContentTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpWord\Tests\Writer\ODText; use PhpOffice\PhpWord\PhpWord; -use PhpWord\Tests\TestHelperDOCX; +use PhpOffice\PhpWord\Tests\TestHelperDOCX; /** * @coversDefaultClass \PhpOffice\PhpWord\Writer\ODText\Content @@ -24,14 +24,8 @@ class ContentTest extends \PHPUnit_Framework_TestCase */ public function testWriteContent() { - $imageSrc = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'images', 'PhpWord.png') - ); - $objectSrc = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'documents', 'sheet.xls') - ); + $imageSrc = __DIR__ . "/../../_files/images/PhpWord.png"; + $objectSrc = __DIR__ . "/../../_files/documents/sheet.xls"; $expected = 'Expected'; $phpWord = new PhpWord(); diff --git a/test/PhpWord/Tests/Writer/ODTextTest.php b/test/PhpWord/Tests/Writer/ODTextTest.php index e07dd13c..5881a2b5 100644 --- a/test/PhpWord/Tests/Writer/ODTextTest.php +++ b/test/PhpWord/Tests/Writer/ODTextTest.php @@ -49,18 +49,9 @@ class ODTextTest extends \PHPUnit_Framework_TestCase */ public function testSave() { - $imageSrc = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'images', 'PhpWord.png') - ); - $objectSrc = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'documents', 'sheet.xls') - ); - $file = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'temp.odt') - ); + $imageSrc = __DIR__ . "/../_files/images/PhpWord.png"; + $objectSrc = __DIR__ . "/../_files/documents/sheet.xls"; + $file = __DIR__ . "/../_files/temp.odt"; $phpWord = new PhpWord(); $phpWord->addFontStyle('Font', array('size' => 11)); diff --git a/test/PhpWord/Tests/Writer/RTFTest.php b/test/PhpWord/Tests/Writer/RTFTest.php index ed6d9873..436a4954 100644 --- a/test/PhpWord/Tests/Writer/RTFTest.php +++ b/test/PhpWord/Tests/Writer/RTFTest.php @@ -62,18 +62,9 @@ class RTFTest extends \PHPUnit_Framework_TestCase */ public function testSave() { - $imageSrc = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'images', 'PhpWord.png') - ); - $objectSrc = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'documents', 'sheet.xls') - ); - $file = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'temp.rtf') - ); + $imageSrc = __DIR__ . "/../_files/images/PhpWord.png"; + $objectSrc = __DIR__ . "/../_files/documents/sheet.xls"; + $file = __DIR__ . "/../_files/temp.rtf"; $phpWord = new PhpWord(); $phpWord->addFontStyle('Font', array('size' => 11)); diff --git a/test/PhpWord/Tests/Writer/Word2007/BaseTest.php b/test/PhpWord/Tests/Writer/Word2007/BaseTest.php index c66cb309..31049be8 100644 --- a/test/PhpWord/Tests/Writer/Word2007/BaseTest.php +++ b/test/PhpWord/Tests/Writer/Word2007/BaseTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpWord\Tests\Writer\Word2007; use PhpOffice\PhpWord\PhpWord; -use PhpWord\Tests\TestHelperDOCX; +use PhpOffice\PhpWord\Tests\TestHelperDOCX; /** * @coversDefaultClass \PhpOffice\PhpWord\Writer\Word2007\Base @@ -46,10 +46,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase { $pStyle = 'pStyle'; $aStyle = array('align' => 'justify', 'spaceBefore' => 120, 'spaceAfter' => 120); - $imageSrc = join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'images', 'earth.jpg') - ); + $imageSrc = __DIR__ . "/../../_files/images/earth.jpg"; $phpWord = new PhpWord(); $phpWord->addParagraphStyle($pStyle, $aStyle); @@ -297,7 +294,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase $phpWord = new PhpWord(); $section = $phpWord->createSection(); $section->addImage( - \PHPWORD_TESTS_BASE_DIR . '/data/images/earth.jpg', + __DIR__ . "/../../_files/images/earth.jpg", array( 'marginTop' => -1, 'marginLeft' => -1, @@ -319,10 +316,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase */ public function testWriteWatermark() { - $imageSrc = join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'images', 'earth.jpg') - ); + $imageSrc = __DIR__ . "/../../_files/images/earth.jpg"; $phpWord = new PhpWord(); $section = $phpWord->createSection(); diff --git a/test/PhpWord/Tests/Writer/Word2007/DocumentTest.php b/test/PhpWord/Tests/Writer/Word2007/DocumentTest.php index a8e5c398..7c34d298 100644 --- a/test/PhpWord/Tests/Writer/Word2007/DocumentTest.php +++ b/test/PhpWord/Tests/Writer/Word2007/DocumentTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpWord\Tests\Writer\Word2007; use PhpOffice\PhpWord\PhpWord; -use PhpWord\Tests\TestHelperDOCX; +use PhpOffice\PhpWord\Tests\TestHelperDOCX; /** * @runTestsInSeparateProcesses @@ -38,10 +38,7 @@ class DocumentTest extends \PHPUnit_Framework_TestCase */ public function testElements() { - $objectSrc = join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'documents', 'sheet.xls') - ); + $objectSrc = __DIR__ . "/../../_files/documents/sheet.xls"; $phpWord = new PhpWord(); $phpWord->addTitleStyle(1, array('color' => '333333', 'bold'=>true)); diff --git a/test/PhpWord/Tests/Writer/Word2007/FooterTest.php b/test/PhpWord/Tests/Writer/Word2007/FooterTest.php index 9221817e..043f4713 100644 --- a/test/PhpWord/Tests/Writer/Word2007/FooterTest.php +++ b/test/PhpWord/Tests/Writer/Word2007/FooterTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpWord\Tests\Writer\Word2007; use PhpOffice\PhpWord\Writer\Word2007\Footer; use PhpOffice\PhpWord\Writer\Word2007; -use PhpWord\Tests\TestHelperDOCX; +use PhpOffice\PhpWord\Tests\TestHelperDOCX; /** * Class FooterTest @@ -19,10 +19,7 @@ class FooterTest extends \PHPUnit_Framework_TestCase */ public function testWriteFooter() { - $imageSrc = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'images', 'PhpWord.png') - ); + $imageSrc = __DIR__ . "/../../_files/images/PhpWord.png"; $container = new \PhpOffice\PhpWord\Section\Footer(1); $container->addText(''); $container->addPreserveText(''); diff --git a/test/PhpWord/Tests/Writer/Word2007/FootnotesTest.php b/test/PhpWord/Tests/Writer/Word2007/FootnotesTest.php index aab28481..11557e69 100644 --- a/test/PhpWord/Tests/Writer/Word2007/FootnotesTest.php +++ b/test/PhpWord/Tests/Writer/Word2007/FootnotesTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpWord\Tests\Writer\Word2007; use PhpOffice\PhpWord\PhpWord; -use PhpWord\Tests\TestHelperDOCX; +use PhpOffice\PhpWord\Tests\TestHelperDOCX; /** * @runTestsInSeparateProcesses diff --git a/test/PhpWord/Tests/Writer/Word2007/HeaderTest.php b/test/PhpWord/Tests/Writer/Word2007/HeaderTest.php index 20abcdf7..59a45fc3 100644 --- a/test/PhpWord/Tests/Writer/Word2007/HeaderTest.php +++ b/test/PhpWord/Tests/Writer/Word2007/HeaderTest.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpWord\Tests\Writer\Word2007; use PhpOffice\PhpWord\Writer\Word2007\Header; use PhpOffice\PhpWord\Writer\Word2007; -use PhpWord\Tests\TestHelperDOCX; +use PhpOffice\PhpWord\Tests\TestHelperDOCX; /** * Class HeaderTest @@ -19,10 +19,7 @@ class HeaderTest extends \PHPUnit_Framework_TestCase */ public function testWriteHeader() { - $imageSrc = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'images', 'PhpWord.png') - ); + $imageSrc = __DIR__ . "/../../_files/images/PhpWord.png"; $container = new \PhpOffice\PhpWord\Section\Header(1); $container->addText('Test'); diff --git a/test/PhpWord/Tests/Writer/Word2007/StylesTest.php b/test/PhpWord/Tests/Writer/Word2007/StylesTest.php index 874f112f..81107f93 100644 --- a/test/PhpWord/Tests/Writer/Word2007/StylesTest.php +++ b/test/PhpWord/Tests/Writer/Word2007/StylesTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpWord\Tests\Writer\Word2007; use PhpOffice\PhpWord\PhpWord; -use PhpWord\Tests\TestHelperDOCX; +use PhpOffice\PhpWord\Tests\TestHelperDOCX; /** * @runTestsInSeparateProcesses diff --git a/test/PhpWord/Tests/Writer/Word2007Test.php b/test/PhpWord/Tests/Writer/Word2007Test.php index 859f78a4..7f866e65 100644 --- a/test/PhpWord/Tests/Writer/Word2007Test.php +++ b/test/PhpWord/Tests/Writer/Word2007Test.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpWord\Tests\Writer; use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Writer\Word2007; -use PhpWord\Tests\TestHelperDOCX; +use PhpOffice\PhpWord\Tests\TestHelperDOCX; /** * @coversDefaultClass \PhpOffice\PhpWord\Writer\Word2007 @@ -64,10 +64,7 @@ class Word2007Test extends \PHPUnit_Framework_TestCase $textrun->addText('Test 3'); $writer = new Word2007($phpWord); - $file = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'data', 'temp.docx') - ); + $file = __DIR__ . "/../_files/temp.docx"; $writer->save($file); $this->assertTrue(file_exists($file)); unlink($file); @@ -89,7 +86,7 @@ class Word2007Test extends \PHPUnit_Framework_TestCase $phpWord = new PhpWord(); $section = $phpWord->createSection(); foreach ($images as $source => $target) { - $section->addImage(\PHPWORD_TESTS_BASE_DIR . "/data/images/{$source}"); + $section->addImage(__DIR__ . "/../_files/images/{$source}"); } $doc = TestHelperDOCX::getDocument($phpWord); @@ -97,7 +94,7 @@ class Word2007Test extends \PHPUnit_Framework_TestCase foreach ($images as $source => $target) { $this->assertFileEquals( - \PHPWORD_TESTS_BASE_DIR . "/data/images/{$source}", + __DIR__ . "/../_files/images/{$source}", $mediaPath . "/section_image{$target}" ); }