Skip to content

feat(test): keep ApiTestCase BrowserKit assertions verbose for Symfony 8.2 - #8523

Merged
soyuka merged 1 commit into
api-platform:4.3from
ousamabenyounes:fix/issue-8450
Sep 11, 2026
Merged

feat(test): keep ApiTestCase BrowserKit assertions verbose for Symfony 8.2#8523
soyuka merged 1 commit into
api-platform:4.3from
ousamabenyounes:fix/issue-8450

Conversation

@ousamabenyounes

@ousamabenyounes ousamabenyounes commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Symfony >= 8.2 flips BrowserKit response assertions to non-verbose by default, hiding the response body on failure. ApiTestCase now re-enables verbose assertions in a #[Before] hook so failing API tests keep showing the (JSON) body; projects can still opt out via setBrowserKitAssertionsAsVerbose(false) in setUp() or per-assertion verbose: false.

Test verification (RED → GREEN)

With the fix reverted, the new test fails (RED):

PHPUnit 12.5.35 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.4.25
Configuration: /app/phpunit.xml.dist

[issue-8450] before ApiTestCase before-hook: defaultVerboseMode = false
E                                                                   1 / 1 (100%)

Time: 00:00.007, Memory: 18.00 MB

There was 1 error:

1) ApiPlatform\Tests\Symfony\Bundle\Test\ApiTestCaseTest::testBrowserKitAssertionsStayVerboseByDefault
Error: Call to undefined method ApiPlatform\Tests\Symfony\Bundle\Test\ApiTestCaseTest::keepBrowserKitAssertionsVerbose()

/app/tests/Symfony/Bundle/Test/ApiTestCaseTest.php:439

ERRORS!
Tests: 1, Assertions: 0, Errors: 1.

With the fix applied, the test passes (GREEN):

GREEN attempt 1/2 (exit 0)
PHPUnit 12.5.35 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.4.25
Configuration: /app/phpunit.xml.dist

[issue-8450] before ApiTestCase before-hook: defaultVerboseMode = false
[issue-8450] after ApiTestCase before-hook:  defaultVerboseMode = true
.                                                                   1 / 1 (100%)

Time: 00:00.006, Memory: 18.00 MB

OK (1 test, 1 assertion)

Full local suite

Command: docker run --rm -v "$PWD":/app -w /app php:8.4-cli bash -c 'php vendor/bin/phpunit --ignore-baseline && php vendor/bin/php-cs-fixer fix --dry-run --diff'

Found 0 of 2964 files that can be fixed in 36.649 seconds, 126.00 MB memory used

Fix #8450

@soyuka
soyuka changed the base branch from main to 4.3 September 11, 2026 10:46
@soyuka
soyuka merged commit 3d061e3 into api-platform:4.3 Sep 11, 2026
4 of 111 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Evaluate changes to support less verbose BrowserKit from Symfony ^8.2

2 participants