S
S
Sword_Dancer2017-08-09 13:04:25
Yii
Sword_Dancer, 2017-08-09 13:04:25

Why doesn't the autoloader work in PHPUnit tests (Class not found)?

I can't figure out why PHPUnit test throws an error Class 'app\someDir\SomeClass' not found
projectName\someDir\SomeClass.php

namespace app\someDir;
class SomeClass { }

projectName\tests\SomeTest.php
namespace app\tests;
use app\someDir\SomeClass;
class SomeTest extends \PHPUnit\Framework\TestCase
{ /* работа с классом SomeClass */ }

projectName\composer.json
"autoload": {
     "psr-4": {
         "app\\": ""
     }
}

I launch with a team
php phpunit --bootstrap projectName/vendor/autoload.php projectName\tests

Tell me, please, what could be the problem? Various fiddling with namespaces and the autoload section in the composer.json file didn't work.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
IceJOKER, 2017-08-09
@IceJOKER

in /web/test.php(well, or in another config file that was specified in the test settings) specify alias + controllerNamespace , as far as I understand, you changed the default namespace

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question