File tree Expand file tree Collapse file tree 3 files changed +75
-0
lines changed
Expand file tree Collapse file tree 3 files changed +75
-0
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ CHANGELOG
55---
66
77 * Add ` isFirstPage() ` and ` isLastPage() ` methods to the History class for checking navigation boundaries
8+ * Add PHPUnit constraints: ` BrowserHistoryIsOnFirstPage ` and ` BrowserHistoryIsOnLastPage `
89
9106.4
1011---
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /*
4+ * This file is part of the Symfony package.
5+ *
6+ * (c) Fabien Potencier <fabien@symfony.com>
7+ *
8+ * For the full copyright and license information, please view the LICENSE
9+ * file that was distributed with this source code.
10+ */
11+
12+ namespace Symfony \Component \BrowserKit \Test \Constraint ;
13+
14+ use PHPUnit \Framework \Constraint \Constraint ;
15+ use Symfony \Component \BrowserKit \AbstractBrowser ;
16+
17+ final class BrowserHistoryIsOnFirstPage extends Constraint
18+ {
19+ public function toString (): string
20+ {
21+ return 'is on the first page ' ;
22+ }
23+
24+ protected function matches ($ other ): bool
25+ {
26+ if (!$ other instanceof AbstractBrowser) {
27+ throw new \LogicException ('Can only test on an AbstractBrowser instance. ' );
28+ }
29+
30+ return $ other ->getHistory ()->isFirstPage ();
31+ }
32+
33+ protected function failureDescription ($ other ): string
34+ {
35+ return 'the Browser history ' .$ this ->toString ();
36+ }
37+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /*
4+ * This file is part of the Symfony package.
5+ *
6+ * (c) Fabien Potencier <fabien@symfony.com>
7+ *
8+ * For the full copyright and license information, please view the LICENSE
9+ * file that was distributed with this source code.
10+ */
11+
12+ namespace Symfony \Component \BrowserKit \Test \Constraint ;
13+
14+ use PHPUnit \Framework \Constraint \Constraint ;
15+ use Symfony \Component \BrowserKit \AbstractBrowser ;
16+
17+ final class BrowserHistoryIsOnLastPage extends Constraint
18+ {
19+ public function toString (): string
20+ {
21+ return 'is on the last page ' ;
22+ }
23+
24+ protected function matches ($ other ): bool
25+ {
26+ if (!$ other instanceof AbstractBrowser) {
27+ throw new \LogicException ('Can only test on an AbstractBrowser instance. ' );
28+ }
29+
30+ return $ other ->getHistory ()->isLastPage ();
31+ }
32+
33+ protected function failureDescription ($ other ): string
34+ {
35+ return 'the Browser history ' .$ this ->toString ();
36+ }
37+ }
You can’t perform that action at this time.
0 commit comments