Description
I created fresh Symfony 4.1.x project, but when I'm trying to create and execute functional test I am getting error:
PHP Fatal error: Class
'Symfony\Bundle\FrameworkBundle\Test\WebTestCase' not found in
/home/tomasz/my_project/tests/ExampleControllerTest.php on line 7
Steps to reproduce:
-
Create project
composer create-project symfony/skeleton my_project
-
Install phpunit, functional tests components and maker for generating skeleton of functional test
composer req --dev symfony/phpunit-bridge symfony/css-selector symfony/browser-kit symfony/maker-bundle
-
Create example functional test
bin/console make:functional-test ExampleControllerTest
Content of created file:
<?php
namespace App\Tests;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class ExampleControllerTest extends WebTestCase
{
public function testSomething()
{
$client = static::createClient();
$crawler = $client->request('GET', '/');
$this->assertSame(200, $client->getResponse()->getStatusCode());
$this->assertContains('Hello World', $crawler->filter('h1')->text());
}
}
-
Run tests
bin/phpunit
Output (after installing phpunit dependencies):
PHP Fatal error: Class
'Symfony\Bundle\FrameworkBundle\Test\WebTestCase' not found in
/home/tomasz/my_project/tests/ExampleControllerTest.php on line 7
I checked and class Symfony\Bundle\FrameworkBundle\Test\WebTestCase
does exist in vendor/
. Any clues?
phpunit.xml.dist: https://pastebin.com/MYjgpFbA
composer.json: https://pastebin.com/WQaYFBq1
composer.lock: https://pastebin.com/pwRsmnY8
PHP Version: 7.2.12