Can’t create test that extends WebTestCase in Symfony

  functional-testing, phpunit, symfony, symfony5

I’m having difficulty creating functional test for my bundle. Whenever I create a test class that extends SymfonyBundleFrameworkBundleTestWebTestCase and launch bin/phpunit, I get following error:

Fatal error: Cannot declare class <MyTestClass>, because the name is already in use in <path/to/my/test/class> on line <some_line>

I’ve got some unit tests running just fine. If I extend PHPUnitFrameworkTestCase for example, I get no problems launching my tests (but obviously I’m losing the functionality I need from WebTestCase).

My test class looks as follows:

namespace SomeNamespaceMyBundleTestController;
use SymfonyBundleFrameworkBundleTestWebTestCase;
class UserControllerTest extends WebTestCase
    public function setUp()
        $client = self::createClient();

    public function testCreateUser()


By the looks of it, it’s the self::createClient(); that causes the problem. However I do need the client to send some requests

Source: Symfony Questions