I added PHPUnit to my Symfony project as described in the documentation. Creating and running the first test which extend Symfony\Bundle\FrameworkBundle\Test\WebTestCase was no problem.
Now I would like to create a custom WebTestCase subclass which provides common features for other test classes:
// .../projectDir/tests/BaseTestCase.php
namespace My\Project\Tests;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class BaseTestCase extends WebTestCase {
protected function doSomething() {}
}
// .../projectDir/tests/SomeTest.php
namespace My\Project\Tests;
use My\Project\Tests\BaseTestCase;
class SomeTest extends BaseTestCase {
protected function testSomething() {
$this->doSomething();
...
}
}
When running php bin/phpunit I get an "Class not found" error:
$ php bin/phpunit
PHP Fatal error: Uncaught Error: Class 'My\Project\Tests\BaseTestCase' not found in /path/to/projectDir/tests/SomeTest.php:6
Stack trace:
#0 /path/to/projectDir/vendor/phpunit/phpunit/src/Util/FileLoader.php(65): include_once()
#1 /path/to/projectDir/vendor/phpunit/phpunit/src/Util/FileLoader.php(49): PHPUnit\Util\FileLoader::load('/path/to/...')
#2 /path/to/projectDir/vendor/phpunit/phpunit/src/Framework/TestSuite.php(402): PHPUnit\Util\FileLoader::checkAndLoad('/path/to/...')
#3 /path/to/projectDir/vendor/phpunit/phpunit/src/Framework/TestSuite.php(530): PHPUnit\Framework\TestSuite->addTestFile('/path/to/...')
#4 /path/to/projectDir/vendor/phpunit/phpunit/src/TextUI/TestSuiteMapper.php(67): PHPUnit\Framework\TestSuite->addTestFiles(Array)
#5 /path/to/proje in /kunden/100170_47877/webpages/pockey/webpage/dev/vendor/phpunit/phpunit/src/TextUI/Command.php on line 98
I have double checked the class name, the namespace and use statement (which should not be necessary, since both classes are in the same folder/namespace).
Do I need to register BaseTestCase in PHPUnit somehow to be a valid superclass for my tests?