Symfony webtestcase functional tests do not work

I am trying to write a functional test for my application, but I am getting the following error:

InvalidArgumentException: The option "test_case" must be set. 

I tried google search but did not find any hints.

My code is:

 class WhateverTest extends WebTestCase { public function testWhatever() { $client = static::createClient(); $crawler = $client->request('GET', '/home'); $this->assertEquals(1, 1); } 

in phpunit.xml the kernel is installed

 <php> <server name="KERNEL_DIR" value="app/" /> </php> 

My AppKernel has only two functions: registerBundles() and registerContainerConfiguration

+7
symfony testing phpunit
source share
2 answers

Check which WebTestCase class you are using. Most likely you are using

use Symfony\Bundle\FrameworkBundle\Tests\Functional\WebTestCase

and you should use

use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

So just change this line and you should be good

+33
source share

you mistakenly used

  Symfony\Bundle\SecurityBundle\Tests\Functional 

or

  Symfony\Bundle\FrameworkBundle\Tests\Functional\WebTestCase 

instead

  Symfony\Bundle\FrameworkBundle\Test\WebTestCase, 
+3
source share

All Articles