Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Symfony\Bundle\FrameworkBundle\Test\WebTestCase class not found #29215

Closed
@tomaszturkowski

Description

@tomaszturkowski

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:

  1. Create project

    composer create-project symfony/skeleton my_project

  2. 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

  3. 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());
    }
}
  1. 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions