Mayor of the Plattenbaus
Mayor of the Plattenbaus

Reputation: 1256

Am I defining KERNEL_CLASS in the right place?

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

Answers (2)

AnonymousDev
AnonymousDev

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.

  1. In Preferences, go to "Languages and Frameworks", "PHP" and then "Test Frameworks"
  2. Ensure the appropriate interpreter is selected (in my case it's a remote interpreter to a Docker container)
  3. Set the path of "Default configuration file" to your project's local phpunit.xml or phpunit.xml.dist

Upvotes: 6

Mayor of the Plattenbaus
Mayor of the Plattenbaus

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

Related Questions