I create a unit test. In the test method, a model is created by the command

$model = Yii::$app->get('recoveryForm'); 

then some manipulations are made, it doesn't matter further. In the config file in the recoveryForm key there is a path (namespace + name :: class) to the original class. Since I do not need to test the original RecoveryForm class, I created a duplicate with the necessary methods in the tests/_support folder. In the bootstrap after the auto-configuration of all the configs, I change the necessary key to my value (with the path to the duplicate class). When a test writes that the class is not found

Class here_newspace \ RecoveryForm does not exist

If in the original config to change the path to a duplicate - everything works, but you can not touch the original files for known reasons. In the bootstrap, in which way I did not change the key value, the class does not find it. Maybe I do not know something important?

  • require_once , not? (Either the correct folder structure in the tests/_support , or a properly configured autoloader) - Dmitriy Simushev
  • thanks, already figured it out. The auto configuration collector has been picky about the similarity of the namespace and the path to the class file. Changed the namespaces in accordance with the requirements and everything went and went. - Evgeny Golov

0