Skip to content

[FrameworkBundle] Allow to un-verbose all the method in BrowserKitAssertionsTrait #60788

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: 7.4
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,31 @@
*/
trait BrowserKitAssertionsTrait
{
public static function assertResponseIsSuccessful(string $message = '', bool $verbose = true): void
private static bool $defaultVerboseMode = true;

public static function setBrowserKitAssertionsAsVerbose(bool $verbose): void
{
self::$defaultVerboseMode = $verbose;
}

public static function assertResponseIsSuccessful(string $message = '', ?bool $verbose = null): void
{
self::assertThatForResponse(new ResponseConstraint\ResponseIsSuccessful($verbose), $message);
self::assertThatForResponse(new ResponseConstraint\ResponseIsSuccessful($verbose ?? self::$defaultVerboseMode), $message);
}

public static function assertResponseStatusCodeSame(int $expectedCode, string $message = '', bool $verbose = true): void
public static function assertResponseStatusCodeSame(int $expectedCode, string $message = '', ?bool $verbose = null): void
{
self::assertThatForResponse(new ResponseConstraint\ResponseStatusCodeSame($expectedCode, $verbose), $message);
self::assertThatForResponse(new ResponseConstraint\ResponseStatusCodeSame($expectedCode, $verbose ?? self::$defaultVerboseMode), $message);
}

public static function assertResponseFormatSame(?string $expectedFormat, string $message = ''): void
public static function assertResponseFormatSame(?string $expectedFormat, string $message = '', ?bool $verbose = null): void
{
self::assertThatForResponse(new ResponseConstraint\ResponseFormatSame(self::getRequest(), $expectedFormat), $message);
self::assertThatForResponse(new ResponseConstraint\ResponseFormatSame(self::getRequest(), $expectedFormat, $verbose ?? self::$defaultVerboseMode), $message);
}

public static function assertResponseRedirects(?string $expectedLocation = null, ?int $expectedCode = null, string $message = '', bool $verbose = true): void
public static function assertResponseRedirects(?string $expectedLocation = null, ?int $expectedCode = null, string $message = '', ?bool $verbose = null): void
{
$constraint = new ResponseConstraint\ResponseIsRedirected($verbose);
$constraint = new ResponseConstraint\ResponseIsRedirected($verbose ?? self::$defaultVerboseMode);
if ($expectedLocation) {
if (class_exists(ResponseConstraint\ResponseHeaderLocationSame::class)) {
$locationConstraint = new ResponseConstraint\ResponseHeaderLocationSame(self::getRequest(), $expectedLocation);
Expand Down Expand Up @@ -100,9 +107,9 @@ public static function assertResponseCookieValueSame(string $name, string $expec
), $message);
}

public static function assertResponseIsUnprocessable(string $message = '', bool $verbose = true): void
public static function assertResponseIsUnprocessable(string $message = '', ?bool $verbose = null): void
{
self::assertThatForResponse(new ResponseConstraint\ResponseIsUnprocessable($verbose), $message);
self::assertThatForResponse(new ResponseConstraint\ResponseIsUnprocessable($verbose ?? self::$defaultVerboseMode), $message);
}

public static function assertBrowserHasCookie(string $name, string $path = '/', ?string $domain = null, string $message = ''): void
Expand Down
Loading