Commit 4539661
committed
feature symfony#60895 [BrowserKit] Add
This PR was merged into the 7.4 branch.
Discussion
----------
[BrowserKit] Add `isFirstPage()` and `isLastPage()` methods to History
| Q | A
| ------------- | ---
| Branch? | 7.4
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| Issues | No
| License | MIT
This PR introduces two new utility methods
- `isFirstPage()`: Returns `true` if the current position is at the start of the history stack.
- `isLastPage()`: Returns `true` if the current position is at the end of the history stack.
These methods are particularly useful in a testing context. For example, they enable clearer and more targeted assertions, such as:
```php
$this->assertTrue($client->getHistory()->isLastPage());
$this->assertTrue($client->getHistory()->isFirstPage());
$this->assertFalse($client->getHistory()->isFirstPage());
$this->assertFalse($client->getHistory()->isLastPage());
```
These new methods also allow developers to proactively check the navigation state before calling `back()` or `forward()`, which can be useful in certain scenarios to avoid unnecessary exceptions and reduce the need for additional error handling logic.
Commits
-------
8b2045e [BrowserKit] Add `isFirstPage()` and `isLastPage()` methods to HistoryisFirstPage() and isLastPage() methods to History (santysisi)File tree
4 files changed
+57
-2
lines changed- src/Symfony/Component/BrowserKit
- Tests
4 files changed
+57
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
4 | 9 | | |
5 | 10 | | |
6 | 11 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
53 | 69 | | |
54 | 70 | | |
55 | 71 | | |
56 | 72 | | |
57 | 73 | | |
58 | 74 | | |
59 | 75 | | |
60 | | - | |
| 76 | + | |
61 | 77 | | |
62 | 78 | | |
63 | 79 | | |
| |||
71 | 87 | | |
72 | 88 | | |
73 | 89 | | |
74 | | - | |
| 90 | + | |
75 | 91 | | |
76 | 92 | | |
77 | 93 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
701 | 701 | | |
702 | 702 | | |
703 | 703 | | |
| 704 | + | |
| 705 | + | |
704 | 706 | | |
705 | 707 | | |
706 | 708 | | |
| |||
741 | 743 | | |
742 | 744 | | |
743 | 745 | | |
| 746 | + | |
| 747 | + | |
744 | 748 | | |
745 | 749 | | |
746 | 750 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
102 | 132 | | |
0 commit comments