@@ -36,7 +36,13 @@ public function testCanCreatePdfFromHtmlString()
36
36
$ this ->assertFileExists ($ outFile );
37
37
38
38
$ tmpFile = $ pdf ->getPdfFilename ();
39
- $ this ->assertRegExp ("# $ binary '[^ ]+' ' $ tmpFile'# " , (string ) $ pdf ->getCommand ());
39
+ $ regex = "# $ binary '[^ ]+' ' $ tmpFile'# " ;
40
+ $ command = (string ) $ pdf ->getCommand ();
41
+ if (phpUnitVersion ('< ' , 9 )) {
42
+ $ this ->assertRegExp ($ regex , $ command );
43
+ } else {
44
+ $ this ->assertMatchesRegularExpression ($ regex , $ command );
45
+ }
40
46
unlink ($ outFile );
41
47
}
42
48
public function testCanCreatePdfFromXmlString ()
@@ -50,7 +56,13 @@ public function testCanCreatePdfFromXmlString()
50
56
$ this ->assertFileExists ($ outFile );
51
57
52
58
$ tmpFile = $ pdf ->getPdfFilename ();
53
- $ this ->assertRegExp ("# $ binary '[^ ]+' ' $ tmpFile'# " , (string ) $ pdf ->getCommand ());
59
+ $ regex = "# $ binary '[^ ]+' ' $ tmpFile'# " ;
60
+ $ command = (string ) $ pdf ->getCommand ();
61
+ if (phpUnitVersion ('< ' , 9 )) {
62
+ $ this ->assertRegExp ($ regex , $ command );
63
+ } else {
64
+ $ this ->assertMatchesRegularExpression ($ regex , $ command );
65
+ }
54
66
unlink ($ outFile );
55
67
}
56
68
public function testCanCreatePdfFromUrl ()
@@ -101,7 +113,13 @@ public function testCanAddPagesFromHtmlString()
101
113
$ this ->assertFileExists ($ outFile );
102
114
103
115
$ tmpFile = $ pdf ->getPdfFilename ();
104
- $ this ->assertRegExp ("# $ binary '[^ ]+' '[^ ]+' ' $ tmpFile'# " , (string ) $ pdf ->getCommand ());
116
+ $ regex = "# $ binary '[^ ]+' '[^ ]+' ' $ tmpFile'# " ;
117
+ $ command = (string ) $ pdf ->getCommand ();
118
+ if (phpUnitVersion ('< ' , 9 )) {
119
+ $ this ->assertRegExp ($ regex , $ command );
120
+ } else {
121
+ $ this ->assertMatchesRegularExpression ($ regex , $ command );
122
+ }
105
123
unlink ($ outFile );
106
124
}
107
125
public function testCanAddPagesFromUrl ()
@@ -130,7 +148,13 @@ public function testCanAddPageFromHtmlString()
130
148
$ pdf ->binary = $ binary ;
131
149
$ pdf ->addPage ('<html><h1>test</h1></html> ' );
132
150
$ pdf ->saveAs ($ outFile );
133
- $ this ->assertRegexp ('/tmp_wkhtmlto_pdf_.*?\.html/ ' , $ pdf ->getCommand ()->getExecCommand ());
151
+ $ regex = "/tmp_wkhtmlto_pdf_.*?\.html/ " ;
152
+ $ command = (string ) $ pdf ->getCommand ()->getExecCommand ();
153
+ if (phpUnitVersion ('< ' , 9 )) {
154
+ $ this ->assertRegExp ($ regex , $ command );
155
+ } else {
156
+ $ this ->assertMatchesRegularExpression ($ regex , $ command );
157
+ }
134
158
unlink ($ outFile );
135
159
}
136
160
public function testCanAddPageFromFileInstance ()
@@ -142,7 +166,13 @@ public function testCanAddPageFromFileInstance()
142
166
$ pdf ->binary = $ binary ;
143
167
$ pdf ->addPage (new File ('Some content ' , '.html ' ));
144
168
$ pdf ->saveAs ($ outFile );
145
- $ this ->assertRegexp ('/php_tmpfile_.*?\.html/ ' , $ pdf ->getCommand ()->getExecCommand ());
169
+ $ regex = "/php_tmpfile_.*?\.html/ " ;
170
+ $ command = (string ) $ pdf ->getCommand ()->getExecCommand ();
171
+ if (phpUnitVersion ('< ' , 9 )) {
172
+ $ this ->assertRegExp ($ regex , $ command );
173
+ } else {
174
+ $ this ->assertMatchesRegularExpression ($ regex , $ command );
175
+ }
146
176
unlink ($ outFile );
147
177
}
148
178
public function testCanAddPageFromXmlString ()
@@ -154,7 +184,13 @@ public function testCanAddPageFromXmlString()
154
184
$ pdf ->binary = $ binary ;
155
185
$ pdf ->addPage ('<xml>test</xml> ' );
156
186
$ pdf ->saveAs ($ outFile );
157
- $ this ->assertRegexp ('/tmp_wkhtmlto_pdf_.*?\.xml/ ' , $ pdf ->getCommand ()->getExecCommand ());
187
+ $ regex = "/tmp_wkhtmlto_pdf_.*?\.xml/ " ;
188
+ $ command = (string ) $ pdf ->getCommand ()->getExecCommand ();
189
+ if (phpUnitVersion ('< ' , 9 )) {
190
+ $ this ->assertRegExp ($ regex , $ command );
191
+ } else {
192
+ $ this ->assertMatchesRegularExpression ($ regex , $ command );
193
+ }
158
194
unlink ($ outFile );
159
195
}
160
196
public function testCanAddHtmlPageFromStringByType ()
@@ -166,7 +202,13 @@ public function testCanAddHtmlPageFromStringByType()
166
202
$ pdf ->binary = $ binary ;
167
203
$ pdf ->addPage ('Test ' , array (), Pdf::TYPE_HTML );
168
204
$ pdf ->saveAs ($ outFile );
169
- $ this ->assertRegexp ('/tmp_wkhtmlto_pdf_.*?\.html/ ' , $ pdf ->getCommand ()->getExecCommand ());
205
+ $ regex = "/tmp_wkhtmlto_pdf_.*?\.html/ " ;
206
+ $ command = (string ) $ pdf ->getCommand ()->getExecCommand ();
207
+ if (phpUnitVersion ('< ' , 9 )) {
208
+ $ this ->assertRegExp ($ regex , $ command );
209
+ } else {
210
+ $ this ->assertMatchesRegularExpression ($ regex , $ command );
211
+ }
170
212
unlink ($ outFile );
171
213
}
172
214
public function testCanAddXmlPageFromStringByType ()
@@ -178,7 +220,13 @@ public function testCanAddXmlPageFromStringByType()
178
220
$ pdf ->binary = $ binary ;
179
221
$ pdf ->addPage ('Test ' , array (), Pdf::TYPE_XML );
180
222
$ pdf ->saveAs ($ outFile );
181
- $ this ->assertRegexp ('/tmp_wkhtmlto_pdf_.*?\.xml/ ' , $ pdf ->getCommand ()->getExecCommand ());
223
+ $ regex = "/tmp_wkhtmlto_pdf_.*?\.xml/ " ;
224
+ $ command = (string ) $ pdf ->getCommand ()->getExecCommand ();
225
+ if (phpUnitVersion ('< ' , 9 )) {
226
+ $ this ->assertRegExp ($ regex , $ command );
227
+ } else {
228
+ $ this ->assertMatchesRegularExpression ($ regex , $ command );
229
+ }
182
230
unlink ($ outFile );
183
231
}
184
232
@@ -213,7 +261,13 @@ public function testCanAddCoverFromHtmlString()
213
261
$ this ->assertFileExists ($ outFile );
214
262
215
263
$ tmpFile = $ pdf ->getPdfFilename ();
216
- $ this ->assertRegExp ("# $ binary 'cover' '[^ ]+' ' $ tmpFile'# " , (string ) $ pdf ->getCommand ());
264
+ $ regex = "# $ binary 'cover' '[^ ]+' ' $ tmpFile'# " ;
265
+ $ command = (string ) $ pdf ->getCommand ();
266
+ if (phpUnitVersion ('< ' , 9 )) {
267
+ $ this ->assertRegExp ($ regex , $ command );
268
+ } else {
269
+ $ this ->assertMatchesRegularExpression ($ regex , $ command );
270
+ }
217
271
unlink ($ outFile );
218
272
}
219
273
public function testCanAddCoverFromUrl ()
@@ -246,7 +300,13 @@ public function testCanAddToc()
246
300
$ this ->assertFileExists ($ outFile );
247
301
248
302
$ tmpFile = $ pdf ->getPdfFilename ();
249
- $ this ->assertRegExp ("# $ binary '[^ ]+' 'toc' ' $ tmpFile'# " , (string ) $ pdf ->getCommand ());
303
+ $ regex = "# $ binary '[^ ]+' 'toc' ' $ tmpFile'# " ;
304
+ $ command = (string ) $ pdf ->getCommand ();
305
+ if (phpUnitVersion ('< ' , 9 )) {
306
+ $ this ->assertRegExp ($ regex , $ command );
307
+ } else {
308
+ $ this ->assertMatchesRegularExpression ($ regex , $ command );
309
+ }
250
310
unlink ($ outFile );
251
311
}
252
312
@@ -290,7 +350,13 @@ public function testCanPassGlobalOptionsInConstructor()
290
350
$ this ->assertTrue ($ pdf ->saveAs ($ outFile ));
291
351
292
352
$ this ->assertFileExists ($ outFile );
293
- $ this ->assertRegExp ("# $ binary '--header-html' ' $ tmpDir/tmp_wkhtmlto_pdf_[^ ]+\.html' '--no-outline' '--margin-top' '0' '--allow' '/tmp' '--allow' '/test' ' $ inFile' ' $ tmpDir/tmp_wkhtmlto_pdf_[^ ]+\.pdf'# " , (string ) $ pdf ->getCommand ());
353
+ $ regex = "# $ binary '--header-html' ' $ tmpDir/tmp_wkhtmlto_pdf_[^ ]+\.html' '--no-outline' '--margin-top' '0' '--allow' '/tmp' '--allow' '/test' ' $ inFile' ' $ tmpDir/tmp_wkhtmlto_pdf_[^ ]+\.pdf'# " ;
354
+ $ command = (string ) $ pdf ->getCommand ();
355
+ if (phpUnitVersion ('< ' , 9 )) {
356
+ $ this ->assertRegExp ($ regex , $ command );
357
+ } else {
358
+ $ this ->assertMatchesRegularExpression ($ regex , $ command );
359
+ }
294
360
unlink ($ outFile );
295
361
}
296
362
public function testCanSetGlobalOptions ()
@@ -366,7 +432,13 @@ public function testCanAddHeaderAndFooterAsHtml()
366
432
$ this ->assertFileExists ($ outFile );
367
433
368
434
$ tmpFile = $ pdf ->getPdfFilename ();
369
- $ this ->assertRegExp ("# $ binary '--header-html' '/tmp/[^ ]+' '--footer-html' '/tmp/[^ ]+' ' $ inFile' ' $ tmpFile'# " , (string ) $ pdf ->getCommand ());
435
+ $ regex = "# $ binary '--header-html' '/tmp/[^ ]+' '--footer-html' '/tmp/[^ ]+' ' $ inFile' ' $ tmpFile'# " ;
436
+ $ command = (string ) $ pdf ->getCommand ();
437
+ if (phpUnitVersion ('< ' , 9 )) {
438
+ $ this ->assertRegExp ($ regex , $ command );
439
+ } else {
440
+ $ this ->assertMatchesRegularExpression ($ regex , $ command );
441
+ }
370
442
unlink ($ outFile );
371
443
}
372
444
public function testCanAddHeaderAndFooterAsFile ()
@@ -385,7 +457,13 @@ public function testCanAddHeaderAndFooterAsFile()
385
457
$ this ->assertFileExists ($ outFile );
386
458
387
459
$ tmpFile = $ pdf ->getPdfFilename ();
388
- $ this ->assertRegExp ("# $ binary '--header-html' '/tmp/[^ ]+' '--footer-html' '/tmp/[^ ]+' ' $ inFile' ' $ tmpFile'# " , (string ) $ pdf ->getCommand ());
460
+ $ regex = "# $ binary '--header-html' '/tmp/[^ ]+' '--footer-html' '/tmp/[^ ]+' ' $ inFile' ' $ tmpFile'# " ;
461
+ $ command = (string ) $ pdf ->getCommand ();
462
+ if (phpUnitVersion ('< ' , 9 )) {
463
+ $ this ->assertRegExp ($ regex , $ command );
464
+ } else {
465
+ $ this ->assertMatchesRegularExpression ($ regex , $ command );
466
+ }
389
467
unlink ($ outFile );
390
468
}
391
469
public function testCanAddHeaderAndFooterAsHtmlToPagesAndCoverAndToc ()
@@ -413,7 +491,13 @@ public function testCanAddHeaderAndFooterAsHtmlToPagesAndCoverAndToc()
413
491
$ this ->assertFileExists ($ outFile );
414
492
415
493
$ tmpFile = $ pdf ->getPdfFilename ();
416
- $ this ->assertRegExp ("# $ binary '/tmp/[^ ]+\.html' '--header-html' '/tmp/[^ ]+\.html' '--footer-html' '/tmp/[^ ]+\.html' 'cover' ' $ inFile' '--header-html' '/tmp/[^ ]+\.html' '--footer-html' '/tmp/[^ ]+\.html' 'toc' '--header-html' '/tmp/[^ ]+\.html' '--footer-html' '/tmp/[^ ]+\.html' ' $ tmpFile'# " , (string ) $ pdf ->getCommand ());
494
+ $ regex = "# $ binary '/tmp/[^ ]+\.html' '--header-html' '/tmp/[^ ]+\.html' '--footer-html' '/tmp/[^ ]+\.html' 'cover' ' $ inFile' '--header-html' '/tmp/[^ ]+\.html' '--footer-html' '/tmp/[^ ]+\.html' 'toc' '--header-html' '/tmp/[^ ]+\.html' '--footer-html' '/tmp/[^ ]+\.html' ' $ tmpFile'# " ;
495
+ $ command = (string ) $ pdf ->getCommand ();
496
+ if (phpUnitVersion ('< ' , 9 )) {
497
+ $ this ->assertRegExp ($ regex , $ command );
498
+ } else {
499
+ $ this ->assertMatchesRegularExpression ($ regex , $ command );
500
+ }
417
501
unlink ($ outFile );
418
502
}
419
503
0 commit comments