Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfc0bc3f

Browse files
committed
feature#42526 [FrameworkBundle] Add BrowserKitAssertionsTrait::assertThatForBrowser (koenreiniers)
This PR was squashed before being merged into the 5.4 branch.Discussion----------[FrameworkBundle] Add BrowserKitAssertionsTrait::assertThatForBrowser| Q | A| ------------- | ---| Branch? | 5.4| Bug fix? | no| New feature? | yes| Deprecations? | no| Tickets | -| License | MIT| Doc PR | -I wanted to create a constraint that acts on the request and the response (an openapi schema validator constraint that needs the method and pathinfo from the request and the body from the response). But, there is currently no way to get the current client, since `BrowserKitAssertionsTrait::getClient` is private and there is no method to do an assertion on the client/browser (like `BrowserKitAssertionsTrait::assertThatForResponse` for the response).This small change will allow to do the following:```protected static function assertResponseMatchesOpenApiSchema(): void{ self::assertThatForBrowser(new ResponseMatchesOpenApiSchema(self::getOpenApiValidator()));}```Commits-------b2c32ea [FrameworkBundle] Add BrowserKitAssertionsTrait::assertThatForBrowser
2 parents42197de +b2c32ea commitfc0bc3f

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

‎src/Symfony/Bundle/FrameworkBundle/Test/BrowserKitAssertionsTrait.php‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,17 @@ public static function assertResponseCookieValueSame(string $name, string $expec
9696

9797
publicstaticfunctionassertBrowserHasCookie(string$name,string$path ='/',string$domain =null,string$message =''):void
9898
{
99-
self::assertThat(self::getClient(),newBrowserKitConstraint\BrowserHasCookie($name,$path,$domain),$message);
99+
self::assertThatForClient(newBrowserKitConstraint\BrowserHasCookie($name,$path,$domain),$message);
100100
}
101101

102102
publicstaticfunctionassertBrowserNotHasCookie(string$name,string$path ='/',string$domain =null,string$message =''):void
103103
{
104-
self::assertThat(self::getClient(),newLogicalNot(newBrowserKitConstraint\BrowserHasCookie($name,$path,$domain)),$message);
104+
self::assertThatForClient(newLogicalNot(newBrowserKitConstraint\BrowserHasCookie($name,$path,$domain)),$message);
105105
}
106106

107107
publicstaticfunctionassertBrowserCookieValueSame(string$name,string$expectedValue,bool$raw =false,string$path ='/',string$domain =null,string$message =''):void
108108
{
109-
self::assertThat(self::getClient(),LogicalAnd::fromConstraints(
109+
self::assertThatForClient(LogicalAnd::fromConstraints(
110110
newBrowserKitConstraint\BrowserHasCookie($name,$path,$domain),
111111
newBrowserKitConstraint\BrowserCookieValueSame($name,$expectedValue,$raw,$path,$domain)
112112
),$message);
@@ -146,6 +146,11 @@ public static function assertThatForResponse(Constraint $constraint, string $mes
146146
}
147147
}
148148

149+
publicstaticfunctionassertThatForClient(Constraint$constraint,string$message =''):void
150+
{
151+
self::assertThat(self::getClient(),$constraint,$message);
152+
}
153+
149154
privatestaticfunctiongetClient(AbstractBrowser$newClient =null): ?AbstractBrowser
150155
{
151156
static$client;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp