From f2fe4715033ad5496f0fdc49553c52f1c706a805 Mon Sep 17 00:00:00 2001 From: Tavo Nieves J Date: Sun, 8 Nov 2020 03:40:51 -0500 Subject: [PATCH] Added availability check functions --- src/Codeception/Module/Symfony.php | 39 ++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/Codeception/Module/Symfony.php b/src/Codeception/Module/Symfony.php index 37fb938a..30d86c03 100644 --- a/src/Codeception/Module/Symfony.php +++ b/src/Codeception/Module/Symfony.php @@ -475,6 +475,45 @@ public function seeInCurrentRoute($routeName) $this->assertEquals($matchedRouteName, $routeName); } + /** + * Goes to a page and check that it can be accessed. + * + * ```php + * seePageIsAvailable('/dashboard'); + * ``` + * + * @param string $url + */ + public function seePageIsAvailable($url) + { + $this->amOnPage($url); + $this->seeResponseCodeIsSuccessful(); + $this->seeInCurrentUrl($url); + } + + /** + * Goes to a page and check that it redirects to another. + * + * ```php + * seePageRedirectsTo('/admin', '/login'); + * ``` + * + * @param string $page + * @param string $redirectsTo + */ + public function seePageRedirectsTo($page, $redirectsTo) + { + $this->client->followRedirects(false); + $this->amOnPage($page); + $this->assertTrue( + $this->client->getResponse()->isRedirection() + ); + $this->client->followRedirect(); + $this->seeInCurrentUrl($redirectsTo); + } + /** * Checks if the desired number of emails was sent. * If no argument is provided then at least one email must be sent to satisfy the check.