Skip to content

Commit 97ccf5d

Browse files
authoredJan 3, 2020
Merge pull request #340 from timwsuqld/fixUnitTests
Update tests due to escaping of all arguments now
2 parents b0773f8 + 5881bf5 commit 97ccf5d

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed
 

‎tests/ImageTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public function testCanOptionsInConstructor()
139139

140140
$tmpFile = $image->getimageFilename();
141141
$this->assertFileExists($outFile);
142-
$this->assertEquals("$binary --transparent --width '800' --allow '/tmp' --allow '/test' '$inFile' '$tmpFile'", (string) $image->getCommand());
142+
$this->assertEquals("$binary '--transparent' '--width' '800' '--allow' '/tmp' '--allow' '/test' '$inFile' '$tmpFile'", (string) $image->getCommand());
143143
unlink($outFile);
144144
}
145145
public function testCanSetOptions()
@@ -164,7 +164,7 @@ public function testCanSetOptions()
164164

165165
$tmpFile = $image->getimageFilename();
166166
$this->assertFileExists($outFile);
167-
$this->assertEquals("$binary --transparent --width '800' --allow '/tmp' --allow '/test' '$inFile' '$tmpFile'", (string) $image->getCommand());
167+
$this->assertEquals("$binary '--transparent' '--width' '800' '--allow' '/tmp' '--allow' '/test' '$inFile' '$tmpFile'", (string) $image->getCommand());
168168
unlink($outFile);
169169
}
170170

‎tests/PdfTest.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public function testCanAddCoverFromFile()
195195

196196
$tmpFile = $pdf->getPdfFilename();
197197
$command = (string)$pdf->getCommand();
198-
$this->assertEquals("$binary cover '$inFile' '$tmpFile'", $command);
198+
$this->assertEquals("$binary 'cover' '$inFile' '$tmpFile'", $command);
199199
unlink($outFile);
200200
}
201201
public function testCanAddCoverFromHtmlString()
@@ -210,7 +210,7 @@ public function testCanAddCoverFromHtmlString()
210210
$this->assertFileExists($outFile);
211211

212212
$tmpFile = $pdf->getPdfFilename();
213-
$this->assertRegExp("#$binary cover '[^ ]+' '$tmpFile'#", (string) $pdf->getCommand());
213+
$this->assertRegExp("#$binary 'cover' '[^ ]+' '$tmpFile'#", (string) $pdf->getCommand());
214214
unlink($outFile);
215215
}
216216
public function testCanAddCoverFromUrl()
@@ -226,7 +226,7 @@ public function testCanAddCoverFromUrl()
226226
$this->assertFileExists($outFile);
227227

228228
$tmpFile = $pdf->getPdfFilename();
229-
$this->assertEquals("$binary cover '$url' '$tmpFile'", (string) $pdf->getCommand());
229+
$this->assertEquals("$binary 'cover' '$url' '$tmpFile'", (string) $pdf->getCommand());
230230
unlink($outFile);
231231
}
232232

@@ -243,7 +243,7 @@ public function testCanAddToc()
243243
$this->assertFileExists($outFile);
244244

245245
$tmpFile = $pdf->getPdfFilename();
246-
$this->assertRegExp("#$binary '[^ ]+' toc '$tmpFile'#", (string) $pdf->getCommand());
246+
$this->assertRegExp("#$binary '[^ ]+' 'toc' '$tmpFile'#", (string) $pdf->getCommand());
247247
unlink($outFile);
248248
}
249249

@@ -287,7 +287,7 @@ public function testCanPassGlobalOptionsInConstructor()
287287
$this->assertTrue($pdf->saveAs($outFile));
288288

289289
$this->assertFileExists($outFile);
290-
$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());
290+
$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());
291291
unlink($outFile);
292292
}
293293
public function testCanSetGlobalOptions()
@@ -307,7 +307,7 @@ public function testCanSetGlobalOptions()
307307
$this->assertFileExists($outFile);
308308

309309
$tmpFile = $pdf->getPdfFilename();
310-
$this->assertEquals("$binary --no-outline --margin-top '0' '$inFile' '$tmpFile'", (string) $pdf->getCommand());
310+
$this->assertEquals("$binary '--no-outline' '--margin-top' '0' '$inFile' '$tmpFile'", (string) $pdf->getCommand());
311311
unlink($outFile);
312312
}
313313
public function testSetPageCoverAndTocOptions()
@@ -344,7 +344,7 @@ public function testSetPageCoverAndTocOptions()
344344
$this->assertFileExists($outFile);
345345

346346
$tmpFile = $pdf->getPdfFilename();
347-
$this->assertEquals("$binary --no-outline --margin-top '0' --header-center 'test {x} {y}' '$inFile' --no-background --zoom '1.5' --cookie 'name' 'value' --replace 'x' 'v' --replace 'y' '' cover '$inFile' --replace 'x' 'a' --replace 'y' 'b' toc --disable-dotted-lines '$tmpFile'", (string) $pdf->getCommand());
347+
$this->assertEquals("$binary '--no-outline' '--margin-top' '0' '--header-center' 'test {x} {y}' '$inFile' '--no-background' '--zoom' '1.5' '--cookie' 'name' 'value' '--replace' 'x' 'v' '--replace' 'y' '' 'cover' '$inFile' '--replace' 'x' 'a' '--replace' 'y' 'b' 'toc' '--disable-dotted-lines' '$tmpFile'", (string) $pdf->getCommand());
348348
unlink($outFile);
349349
}
350350
public function testCanAddHeaderAndFooterAsHtml()
@@ -363,7 +363,7 @@ public function testCanAddHeaderAndFooterAsHtml()
363363
$this->assertFileExists($outFile);
364364

365365
$tmpFile = $pdf->getPdfFilename();
366-
$this->assertRegExp("#$binary --header-html '/tmp/[^ ]+' --footer-html '/tmp/[^ ]+' '$inFile' '$tmpFile'#", (string) $pdf->getCommand());
366+
$this->assertRegExp("#$binary '--header-html' '/tmp/[^ ]+' '--footer-html' '/tmp/[^ ]+' '$inFile' '$tmpFile'#", (string) $pdf->getCommand());
367367
unlink($outFile);
368368
}
369369
public function testCanAddHeaderAndFooterAsFile()
@@ -382,7 +382,7 @@ public function testCanAddHeaderAndFooterAsFile()
382382
$this->assertFileExists($outFile);
383383

384384
$tmpFile = $pdf->getPdfFilename();
385-
$this->assertRegExp("#$binary --header-html '/tmp/[^ ]+' --footer-html '/tmp/[^ ]+' '$inFile' '$tmpFile'#", (string) $pdf->getCommand());
385+
$this->assertRegExp("#$binary '--header-html' '/tmp/[^ ]+' '--footer-html' '/tmp/[^ ]+' '$inFile' '$tmpFile'#", (string) $pdf->getCommand());
386386
unlink($outFile);
387387
}
388388
public function testCanAddHeaderAndFooterAsHtmlToPagesAndCoverAndToc()
@@ -410,7 +410,7 @@ public function testCanAddHeaderAndFooterAsHtmlToPagesAndCoverAndToc()
410410
$this->assertFileExists($outFile);
411411

412412
$tmpFile = $pdf->getPdfFilename();
413-
$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());
413+
$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());
414414
unlink($outFile);
415415
}
416416

0 commit comments

Comments
 (0)
Please sign in to comment.