Merge pull request #107 from gabrielbull/develop

Fixed bug with footer preserve text
This commit is contained in:
Progi1984 2014-03-11 20:27:02 +01:00
commit da7c0ad558
4 changed files with 27 additions and 9 deletions

View File

@ -285,6 +285,9 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
$SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false;
$arrText = $textrun->getText();
if (!is_array($arrText)) {
$arrText = array($arrText);
}
$objWriter->startElement('w:p');

View File

@ -108,4 +108,19 @@ class BaseTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($expected, $element->getAttribute('w:val'));
}
}
}
public function testWritePreserveText()
{
$PHPWord = new PHPWord();
$section = $PHPWord->createSection();
$footer = $section->createFooter();
$footer->addPreserveText('{PAGE}');
$doc = TestHelperDOCX::getDocument($PHPWord);
$preserve = $doc->getElement("w:p/w:r[2]/w:instrText", 'word/footer1.xml');
$this->assertEquals('PAGE', $preserve->nodeValue);
$this->assertEquals('preserve', $preserve->getAttribute('xml:space'));
}
}

View File

@ -15,8 +15,8 @@ class TestHelperDOCX
public static function getDocument(PHPWord $PHPWord)
{
self::$file = tempnam(sys_get_temp_dir(), 'PHPWord');
if(!is_dir(sys_get_temp_dir().'/PHPWord_Unit_Test/')){
mkdir(sys_get_temp_dir().'/PHPWord_Unit_Test/');
if (!is_dir(sys_get_temp_dir() . '/PHPWord_Unit_Test/')) {
mkdir(sys_get_temp_dir() . '/PHPWord_Unit_Test/');
}
$objWriter = \PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
@ -29,16 +29,16 @@ class TestHelperDOCX
$zip->close();
}
return new Xml_Document(sys_get_temp_dir().'/PHPWord_Unit_Test/');
return new Xml_Document(sys_get_temp_dir() . '/PHPWord_Unit_Test/');
}
public static function clear()
{
if(file_exists(self::$file)){
unlink(self::$file);
if (file_exists(self::$file)) {
unlink(self::$file);
}
if(is_dir(sys_get_temp_dir().'/PHPWord_Unit_Test/')){
self::deleteDir(sys_get_temp_dir().'/PHPWord_Unit_Test/');
if (is_dir(sys_get_temp_dir() . '/PHPWord_Unit_Test/')) {
self::deleteDir(sys_get_temp_dir() . '/PHPWord_Unit_Test/');
}
}

View File

@ -24,7 +24,7 @@
"ext-xml": "*"
},
"require-dev": {
"phpunit/phpunit": "3.7.28"
"phpunit/phpunit": "3.7.*"
},
"recommend": {
"ext-zip": "*",