From b2c32ea9fd9fcc33bf417a72cbeb1665b7ba8e4c Mon Sep 17 00:00:00 2001 From: Koen Reiniers Date: Fri, 13 Aug 2021 10:43:57 +0200 Subject: [PATCH] [FrameworkBundle] Add BrowserKitAssertionsTrait::assertThatForBrowser --- .../Test/BrowserKitAssertionsTrait.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Test/BrowserKitAssertionsTrait.php b/src/Symfony/Bundle/FrameworkBundle/Test/BrowserKitAssertionsTrait.php index 62bd1b79acc05..f0b7ec726c70d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Test/BrowserKitAssertionsTrait.php +++ b/src/Symfony/Bundle/FrameworkBundle/Test/BrowserKitAssertionsTrait.php @@ -96,17 +96,17 @@ public static function assertResponseCookieValueSame(string $name, string $expec public static function assertBrowserHasCookie(string $name, string $path = '/', string $domain = null, string $message = ''): void { - self::assertThat(self::getClient(), new BrowserKitConstraint\BrowserHasCookie($name, $path, $domain), $message); + self::assertThatForClient(new BrowserKitConstraint\BrowserHasCookie($name, $path, $domain), $message); } public static function assertBrowserNotHasCookie(string $name, string $path = '/', string $domain = null, string $message = ''): void { - self::assertThat(self::getClient(), new LogicalNot(new BrowserKitConstraint\BrowserHasCookie($name, $path, $domain)), $message); + self::assertThatForClient(new LogicalNot(new BrowserKitConstraint\BrowserHasCookie($name, $path, $domain)), $message); } public static function assertBrowserCookieValueSame(string $name, string $expectedValue, bool $raw = false, string $path = '/', string $domain = null, string $message = ''): void { - self::assertThat(self::getClient(), LogicalAnd::fromConstraints( + self::assertThatForClient(LogicalAnd::fromConstraints( new BrowserKitConstraint\BrowserHasCookie($name, $path, $domain), new BrowserKitConstraint\BrowserCookieValueSame($name, $expectedValue, $raw, $path, $domain) ), $message); @@ -146,6 +146,11 @@ public static function assertThatForResponse(Constraint $constraint, string $mes } } + public static function assertThatForClient(Constraint $constraint, string $message = ''): void + { + self::assertThat(self::getClient(), $constraint, $message); + } + private static function getClient(AbstractBrowser $newClient = null): ?AbstractBrowser { static $client;