Reputation: 1256
I am trying to run a basic functional test using WebTestCase in a Symfony 4 application. When I run my test, I get this output:
1) Tests\Application\EndToEnd\AuthenticationTest::testAuthenticationMethodNotAllowed RuntimeException: Class "App\Kernel" doesn't exist or cannot be autoloaded. Check that the KERNEL_CLASS value in phpunit.xml matches the fully-qualified class name of your Kernel or override the Tests\Application\EndToEnd\AuthenticationTest::createKernel() method.
Trying to follow the advice in this answer, I edit vendor/phpunit/phpunit/phpunit.xml
and add this line:
<server name="KERNEL_CLASS" value="AppKernel" />
and here's where it gets interesting: I still get the complaint about App\Kernel
-- with the backslash -- being unavailable.
This tells me that I'm probably editing the wrong XML file, since my edited-in value doesn't contain a backslash. In which XML file should I be adding my definition?
Upvotes: 3
Views: 3565
Reputation: 1326
I got this error while running tests via PHPStorm (they were working when running them manually). I had to set the "Default configuration file" to /path/to/phpunit.xml
.
phpunit.xml
or phpunit.xml.dist
Upvotes: 6
Reputation: 1256
It turned out that I needed to create a phpunit.xml file in the root level of my project. Once the relevant XML was present there, this sorted itself out.
Upvotes: 1