diff --git a/readme.md b/readme.md index 90f3a8c..49d3bd5 100644 --- a/readme.md +++ b/readme.md @@ -198,7 +198,9 @@ PDF::assertViewHas($key, $value = null); PDF::assertViewHasAll(array $bindings); PDF::assertViewMissing($key); PDF::assertSee($value); +PDF::assertSeeInOrder($values, $escape = true); PDF::assertSeeText($value); +PDF::assertSeeTextInOrder($values, $escape = true); PDF::assertDontSee($value); PDF::assertDontSeeText($value); PDF::assertFileNameIs($value); diff --git a/src/PdfFaker.php b/src/PdfFaker.php index 2b57266..2abbb59 100644 --- a/src/PdfFaker.php +++ b/src/PdfFaker.php @@ -3,7 +3,7 @@ use Illuminate\View\View; use PHPUnit\Framework\Assert as PHPUnit; use Illuminate\Support\Facades\View as ViewFacade; - +use Illuminate\Testing\Constraints\SeeInOrder; class PdfFaker extends PdfWrapper { @@ -119,6 +119,22 @@ public function assertSee($value) return $this; } + /** + * Assert that the given strings are contained in order within the response. + * + * @param array $values + * @param bool $escape + * @return $this + */ + public function assertSeeInOrder($values, $escape = true) + { + $values = $escape ? array_map('e', ($values)) : $values; + + PHPUnit::assertThat($values, new SeeInOrder($this->html)); + + return $this; + } + /** * Assert that the given string is contained within the response text. * @@ -132,6 +148,22 @@ public function assertSeeText($value) return $this; } + /** + * Assert that the given strings are contained in order within the response text. + * + * @param array $values + * @param bool $escape + * @return $this + */ + public function assertSeeTextInOrder($values, $escape = true) + { + $values = $escape ? array_map('e', ($values)) : $values; + + PHPUnit::assertThat($values, new SeeInOrder(strip_tags($this->html))); + + return $this; + } + /** * Assert that the given string is not contained within the response. * @@ -157,7 +189,7 @@ public function assertDontSeeText($value) return $this; } - + /** * Assert that the given string is equal to the saved filename. * @@ -260,21 +292,21 @@ public function output() endobj xref 0 15 -0000000000 65535 f -0000003414 00000 n -0000000187 00000 n -0000003133 00000 n -0000000022 00000 n -0000000169 00000 n -0000000297 00000 n -0000003098 00000 n -0000000365 00000 n -0000003078 00000 n -0000003222 00000 n -0000003272 00000 n -0000003295 00000 n -0000003348 00000 n -0000003372 00000 n +0000000000 65535 f +0000003414 00000 n +0000000187 00000 n +0000003133 00000 n +0000000022 00000 n +0000000169 00000 n +0000000297 00000 n +0000003098 00000 n +0000000365 00000 n +0000003078 00000 n +0000003222 00000 n +0000003272 00000 n +0000003295 00000 n +0000003348 00000 n +0000003372 00000 n trailer << /Size 15 /Root 10 0 R /Info 1 0 R /ID [ ] >>