Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add assertSeeInOrder and assertSeeTextInOrder #499

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
66 changes: 49 additions & 17 deletions src/PdfFaker.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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.
*
Expand All @@ -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.
*
Expand All @@ -157,7 +189,7 @@ public function assertDontSeeText($value)

return $this;
}

/**
* Assert that the given string is equal to the saved filename.
*
Expand Down Expand Up @@ -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 [ <ea5d2c625a19688ce1ff05174d8a0261>
<ea5d2c625a19688ce1ff05174d8a0261> ] >>
Expand Down