Fixed unit tests

This commit is contained in:
Gabriel Bull 2014-03-23 12:37:31 -04:00
parent 66c73c07c5
commit d75c00caf4
26 changed files with 92 additions and 257 deletions

View File

@ -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));

View File

@ -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',

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);
}

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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';

View File

@ -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();

View File

@ -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));

View File

@ -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));

View File

@ -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();

View File

@ -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));

View File

@ -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('');

View File

@ -2,7 +2,7 @@
namespace PhpOffice\PhpWord\Tests\Writer\Word2007;
use PhpOffice\PhpWord\PhpWord;
use PhpWord\Tests\TestHelperDOCX;
use PhpOffice\PhpWord\Tests\TestHelperDOCX;
/**
* @runTestsInSeparateProcesses

View File

@ -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');

View File

@ -2,7 +2,7 @@
namespace PhpOffice\PhpWord\Tests\Writer\Word2007;
use PhpOffice\PhpWord\PhpWord;
use PhpWord\Tests\TestHelperDOCX;
use PhpOffice\PhpWord\Tests\TestHelperDOCX;
/**
* @runTestsInSeparateProcesses

View File

@ -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}"
);
}