Skip to content

[FrameworkBundle] KernelTestCase does not respect test env #1313

Open
@IndraGunawan

Description

@IndraGunawan

Symfony version(s) affected

7.0.7

Description

getting the following error while running WebTestCase tests

symfony php bin/phpunit
PHPUnit 9.6.19 by Sebastian Bergmann and contributors.

Testing
E                                                                   1 / 1 (100%)

Time: 00:00.102, Memory: 20.00 MB

There was 1 error:

1) App\Tests\WebTest::testSomething
LogicException: You cannot create the client used in functional tests if the "framework.test" config is not set to true.

/tmp/test/vendor/symfony/framework-bundle/Test/WebTestCase.php:50
/tmp/test/tests/WebTest.php:11
/tmp/test/vendor/phpunit/phpunit/phpunit:107

How to reproduce

symfony new --webapp test
cd test
symfony console make:test WebTestCase WebTest
symfony php bin/phpunit

Possible Solution

modify phpunit.xml.dist file

<php>
   ...
-    <server name="APP_ENV" value="test" force="true" />
+    <env name="APP_ENV" value="test" force="true" />
+    <env name="KERNEL_CLASS" value="App\Kernel" />
   ...
</php>

Additional Context

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions