Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

symfony functional tests webtestcase doesn't work

I try to write a functional test for my app but I am getting following error:

InvalidArgumentException: The option "test_case" must be set.

I tried googling for it but found literally no clues.

My code:

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 set

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

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

like image 331
greg Avatar asked Apr 13 '15 11:04

greg


2 Answers

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

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

and you should be using

use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

So just change this one line and you should be good

like image 61
Tomasz Madeyski Avatar answered Nov 18 '22 17:11

Tomasz Madeyski


you may have mistakenly used

    Symfony\Bundle\SecurityBundle\Tests\Functional 

or

    Symfony\Bundle\FrameworkBundle\Tests\Functional\WebTestCase 

instead of

    Symfony\Bundle\FrameworkBundle\Test\WebTestCase,
like image 38
njay Avatar answered Nov 18 '22 17:11

njay