From 9d67f32feec97a62aa971de1a1cb7d630300946c Mon Sep 17 00:00:00 2001 From: Santiago San Martin Date: Thu, 26 Jun 2025 10:03:01 -0300 Subject: [PATCH] [BrowserKit] Add `isFirstPage()` and `isLastPage()` methods to History --- components/browser_kit.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/components/browser_kit.rst b/components/browser_kit.rst index 8cf0772298c..7feb29096fb 100644 --- a/components/browser_kit.rst +++ b/components/browser_kit.rst @@ -329,6 +329,20 @@ history:: // go forward to documentation page $crawler = $client->forward(); + // check if the history position is on the first page + if (!$client->getHistory()->isFirstPage()) { + $crawler = $client->back(); + } + + // check if the history position is on the last page + if (!$client->getHistory()->isLastPage()) { + $crawler = $client->forward(); + } + +.. versionadded:: 7.4 + + The ``isFirstPage`` and ``isLastPage`` methods were introduced in Symfony 7.4. + You can delete the client's history with the ``restart()`` method. This will also delete all the cookies::