File tree Expand file tree Collapse file tree 4 files changed +27
-9
lines changed
Classes/PHPWord/Writer/Word2007 Expand file tree Collapse file tree 4 files changed +27
-9
lines changed Original file line number Diff line number Diff line change @@ -285,6 +285,9 @@ protected function _writePreserveText(PHPWord_Shared_XMLWriter $objWriter = null
285
285
$ SpIsObject = ($ styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false ;
286
286
287
287
$ arrText = $ textrun ->getText ();
288
+ if (!is_array ($ arrText )) {
289
+ $ arrText = array ($ arrText );
290
+ }
288
291
289
292
$ objWriter ->startElement ('w:p ' );
290
293
Original file line number Diff line number Diff line change @@ -108,4 +108,19 @@ public function testWriteParagraphStyle_Pagination()
108
108
$ this ->assertEquals ($ expected , $ element ->getAttribute ('w:val ' ));
109
109
}
110
110
}
111
- }
111
+
112
+ public function testWritePreserveText ()
113
+ {
114
+ $ PHPWord = new PHPWord ();
115
+ $ section = $ PHPWord ->createSection ();
116
+ $ footer = $ section ->createFooter ();
117
+
118
+ $ footer ->addPreserveText ('{PAGE} ' );
119
+
120
+ $ doc = TestHelperDOCX::getDocument ($ PHPWord );
121
+ $ preserve = $ doc ->getElement ("w:p/w:r[2]/w:instrText " , 'word/footer1.xml ' );
122
+
123
+ $ this ->assertEquals ('PAGE ' , $ preserve ->nodeValue );
124
+ $ this ->assertEquals ('preserve ' , $ preserve ->getAttribute ('xml:space ' ));
125
+ }
126
+ }
Original file line number Diff line number Diff line change @@ -15,8 +15,8 @@ class TestHelperDOCX
15
15
public static function getDocument (PHPWord $ PHPWord )
16
16
{
17
17
self ::$ file = tempnam (sys_get_temp_dir (), 'PHPWord ' );
18
- if (!is_dir (sys_get_temp_dir (). '/PHPWord_Unit_Test/ ' )){
19
- mkdir (sys_get_temp_dir (). '/PHPWord_Unit_Test/ ' );
18
+ if (!is_dir (sys_get_temp_dir () . '/PHPWord_Unit_Test/ ' )) {
19
+ mkdir (sys_get_temp_dir () . '/PHPWord_Unit_Test/ ' );
20
20
}
21
21
22
22
$ objWriter = \PHPWord_IOFactory::createWriter ($ PHPWord , 'Word2007 ' );
@@ -29,16 +29,16 @@ public static function getDocument(PHPWord $PHPWord)
29
29
$ zip ->close ();
30
30
}
31
31
32
- return new Xml_Document (sys_get_temp_dir (). '/PHPWord_Unit_Test/ ' );
32
+ return new Xml_Document (sys_get_temp_dir () . '/PHPWord_Unit_Test/ ' );
33
33
}
34
34
35
35
public static function clear ()
36
36
{
37
- if (file_exists (self ::$ file )){
38
- unlink (self ::$ file );
37
+ if (file_exists (self ::$ file )) {
38
+ unlink (self ::$ file );
39
39
}
40
- if (is_dir (sys_get_temp_dir (). '/PHPWord_Unit_Test/ ' )){
41
- self ::deleteDir (sys_get_temp_dir (). '/PHPWord_Unit_Test/ ' );
40
+ if (is_dir (sys_get_temp_dir () . '/PHPWord_Unit_Test/ ' )) {
41
+ self ::deleteDir (sys_get_temp_dir () . '/PHPWord_Unit_Test/ ' );
42
42
}
43
43
}
44
44
Original file line number Diff line number Diff line change 24
24
"ext-xml" : " *"
25
25
},
26
26
"require-dev" : {
27
- "phpunit/phpunit" : " 3.7.28 "
27
+ "phpunit/phpunit" : " 3.7.* "
28
28
},
29
29
"recommend" : {
30
30
"ext-zip" : " *" ,
You can’t perform that action at this time.
0 commit comments