I am letting autoload composer try some phpunit testing classes, and I can't get it to work. when I run phpunit from the command line, I get "PHP Fatal Error: Class ... not found".
I will give all the information about the structure and the file, I can hope that someone will find where I made a mistake.
Structure (reduction to the corresponding files):
composer.json
composer.lock
phpunit.xml
vendor/
tests/
functional/
BaseTestCase.php
HomepageTest.php
composer.json
{
"require": {
"php": ">=5.5.0",
"slim/slim": "^3.1",
"slim/php-view": "^2.0",
"monolog/monolog": "^1.17"
},
"require-dev": {
"phpunit/phpunit": ">=4.8 < 6.0"
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
}
}
phpunit.xml
<?xml version="1.0" encoding="utf-8" ?>
<phpunit colors="true" bootstrap="vendor/autoload.php">
<testsuites>
<testsuite name="Initial tests">
<directory>tests/</directory>
</testsuite>
</testsuites>
</phpunit>
Test / Functional / BaseTestCase.php
<?php
namespace Tests\Functional;
use Slim\App;
use Slim\Http\Request;
use Slim\Http\Response;
use Slim\Http\Environment;
class BaseTestCase extends \PHPUnit_Framework_TestCase
{
...
Test / functional / HomepageTest.php
<?php
namespace Tests\Functional;
class HomepageTest extends BaseTestCase
{
...
Then I started the update to update startup files
$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Writing lock file
Generating autoload files
Then I tried to run phpunit and got a class error not found:
$ vendor/bin/phpunit
PHP Fatal error: Class 'Tests\Functional\BaseTestCase' not found in <project-root>/tests/functional/HomepageTest.php on line 6
To be thorough, I tried updating the startup files in a different way, just in case:
$ composer dump-autoload
Generating autoload files
sfbagency@sfb1:~/clients/ctest/dev$
vendor/composer/autoload_psr4.php, , Test , .
...
Tests\\' => array($baseDir . '/tests'),
...
Googled , , .