@@ -51,6 +51,80 @@ public function testFontRTL()
51
51
$ this ->assertTrue ($ doc ->elementExists ($ path , $ file ));
52
52
}
53
53
54
+ public function testFontRTLNamed ()
55
+ {
56
+ $ phpWord = new \PhpOffice \PhpWord \PhpWord ();
57
+ $ stnam = 'fstyle ' ;
58
+ $ phpWord ->addFontStyle ($ stnam , array (
59
+ 'rtl ' => true ,
60
+ 'name ' => 'Courier New ' ,
61
+ 'size ' => 8 ,
62
+ ));
63
+ $ section = $ phpWord ->addSection ();
64
+ $ txt = 'היום יום שני ' ; // Translation = Today is Monday
65
+ $ section ->addText ($ txt , $ stnam );
66
+ $ doc = TestHelperDOCX::getDocument ($ phpWord , 'Word2007 ' );
67
+
68
+ $ element = '/w:document/w:body/w:p/w:r ' ;
69
+ $ txtelem = $ element . '/w:t ' ;
70
+ $ styelem = $ element . '/w:rPr ' ;
71
+ $ this ->assertTrue ($ doc ->elementExists ($ txtelem ));
72
+ $ this ->assertEquals ($ txt , $ doc ->getElement ($ txtelem )->textContent );
73
+ $ this ->assertTrue ($ doc ->elementExists ($ styelem ));
74
+ $ this ->assertTrue ($ doc ->elementExists ($ styelem . '/w:rStyle ' ));
75
+ $ this ->assertEquals ($ stnam , $ doc ->getElementAttribute ($ styelem . '/w:rStyle ' , 'w:val ' ));
76
+ $ this ->assertTrue ($ doc ->elementExists ($ styelem . '/w:rtl ' ));
77
+ }
78
+
79
+ public function testFontNotRTLNamed ()
80
+ {
81
+ $ phpWord = new \PhpOffice \PhpWord \PhpWord ();
82
+ $ stnam = 'fstyle ' ;
83
+ $ phpWord ->addFontStyle ($ stnam , array (
84
+ //'rtl' => true,
85
+ 'name ' => 'Courier New ' ,
86
+ 'size ' => 8 ,
87
+ ));
88
+ $ section = $ phpWord ->addSection ();
89
+ $ txt = 'היום יום שני ' ; // Translation = Today is Monday
90
+ $ section ->addText ($ txt , $ stnam );
91
+ $ doc = TestHelperDOCX::getDocument ($ phpWord , 'Word2007 ' );
92
+
93
+ $ element = '/w:document/w:body/w:p/w:r ' ;
94
+ $ txtelem = $ element . '/w:t ' ;
95
+ $ styelem = $ element . '/w:rPr ' ;
96
+ $ this ->assertTrue ($ doc ->elementExists ($ txtelem ));
97
+ $ this ->assertEquals ($ txt , $ doc ->getElement ($ txtelem )->textContent );
98
+ $ this ->assertTrue ($ doc ->elementExists ($ styelem ));
99
+ $ this ->assertTrue ($ doc ->elementExists ($ styelem . '/w:rStyle ' ));
100
+ $ this ->assertEquals ($ stnam , $ doc ->getElementAttribute ($ styelem . '/w:rStyle ' , 'w:val ' ));
101
+ $ this ->assertFalse ($ doc ->elementExists ($ styelem . '/w:rtl ' ));
102
+ }
103
+
104
+ public function testNoProof ()
105
+ {
106
+ $ phpWord = new \PhpOffice \PhpWord \PhpWord ();
107
+ $ fontStyle = array (
108
+ 'noProof ' => true ,
109
+ 'name ' => 'Courier New ' ,
110
+ 'size ' => 8 ,
111
+ );
112
+ $ section = $ phpWord ->addSection ();
113
+ $ txt = 'spellung error ' ;
114
+ $ section ->addText ($ txt , $ fontStyle );
115
+ $ doc = TestHelperDOCX::getDocument ($ phpWord , 'Word2007 ' );
116
+
117
+ $ element = '/w:document/w:body/w:p/w:r ' ;
118
+ $ txtelem = $ element . '/w:t ' ;
119
+ $ styelem = $ element . '/w:rPr ' ;
120
+ $ noproofelem = $ styelem . '/w:noProof ' ;
121
+ $ this ->assertTrue ($ doc ->elementExists ($ txtelem ));
122
+ $ this ->assertEquals ($ txt , $ doc ->getElement ($ txtelem )->textContent );
123
+ $ this ->assertTrue ($ doc ->elementExists ($ styelem ));
124
+ $ this ->assertTrue ($ doc ->elementExists ($ noproofelem ));
125
+ $ this ->assertEquals ('1 ' , $ doc ->getElementAttribute ($ noproofelem , 'w:val ' ));
126
+ }
127
+
54
128
/**
55
129
* Test writing font with language
56
130
*/
0 commit comments