Как воспроизвести:
-
Создаю простой класс, который буду тестировать MyClass.php:
<?php class MyClass { public function baz(){} } -
Инициализрую codeception
$ codeception bootstrap -
Создаю Unit тест
$ codeception g:test unit TestMock -
Вот такой вот тест:
<?php $rootdir = dirname(dirname(__DIR__)); include $rootdir . '/MyClass.php'; class TestMockTest extends \Codeception\TestCase\Test { public function testMe() { //$my = new MyClass(); $my = $this->getMockBuilder('MyClass') ->disableOriginalConstructor() ->getMock(); } }
(new MyClass() работает, создает инстанс MyClass)
- Запускаю тесты
$ codecept run
Codeception PHP Testing Framework v2.0.5
Powered by PHPUnit 4.2.2 by Sebastian Bergmann.
Unit Tests (1) -----------------------------------------------------------------
Trying to test me (TestMockTest::testMe) PHP Fatal error: Class ‘Instantiator\Instantiator’ not found in phar:///usr/bin/codecept/vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Generator.php on line 292
PHP Stack trace:
PHP 1. {main}() /usr/bin/codecept:0
PHP 2. require_once() /usr/bin/codecept:7
PHP 3. Symfony\Component\Console\Application->run() phar:///usr/bin/codecept/codecept:34
PHP 4. Symfony\Component\Console\Application->doRun() phar:///usr/bin/codecept/vendor/symfony/console/Symfony/Component/Console/Application.php:124
PHP 5. Symfony\Component\Console\Application->doRunCommand() phar:///usr/bin/codecept/vendor/symfony/console/Symfony/Component/Console/Application.php:193
PHP 6. Symfony\Component\Console\Command\Command->run() phar:///usr/bin/codecept/vendor/symfony/console/Symfony/Component/Console/Application.php:889
PHP 7. Codeception\Command\Run->execute() phar:///usr/bin/codecept/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:252
PHP 8. Codeception\Command\Run->runSuites() phar:///usr/bin/codecept/src/Codeception/Command/Run.php:183
PHP 9. Codeception\Codecept->run() phar:///usr/bin/codecept/src/Codeception/Command/Run.php:255
PHP 10. Codeception\Codecept->runSuite() phar:///usr/bin/codecept/src/Codeception/Codecept.php:145
PHP 11. Codeception\SuiteManager->run() phar:///usr/bin/codecept/src/Codeception/Codecept.php:162
PHP 12. Codeception\PHPUnit\Runner->doEnhancedRun() phar:///usr/bin/codecept/src/Codeception/SuiteManager.php:153
PHP 13. PHPUnit_Framework_TestSuite->run() phar:///usr/bin/codecept/src/Codeception/PHPUnit/Runner.php:100
PHP 14. PHPUnit_Framework_TestCase->run() phar:///usr/bin/codecept/vendor/phpunit/phpunit/src/Framework/TestSuite.php:703
PHP 15. PHPUnit_Framework_TestResult->run() phar:///usr/bin/codecept/vendor/phpunit/phpunit/src/Framework/TestCase.php:771
PHP 16. PHPUnit_Framework_TestCase->runBare() phar:///usr/bin/codecept/vendor/phpunit/phpunit/src/Framework/TestResult.php:643
PHP 17. PHPUnit_Framework_TestCase->runTest() phar:///usr/bin/codecept/vendor/phpunit/phpunit/src/Framework/TestCase.php:835
PHP 18. ReflectionMethod->invokeArgs() phar:///usr/bin/codecept/vendor/phpunit/phpunit/src/Framework/TestCase.php:963
PHP 19. TestMockTest->testMe() phar:///usr/bin/codecept/vendor/phpunit/phpunit/src/Framework/TestCase.php:963
PHP 20. PHPUnit_Framework_MockObject_MockBuilder->getMock() /storage/proj/zftest/tests/unit/TestMockTest.php:26
PHP 21. PHPUnit_Framework_TestCase->getMock() phar:///usr/bin/codecept/vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/MockBuilder.php:142
PHP 22. PHPUnit_Framework_MockObject_Generator->getMock() phar:///usr/bin/codecept/vendor/phpunit/phpunit/src/Framework/TestCase.php:1318
PHP 23. PHPUnit_Framework_MockObject_Generator->getObject() phar:///usr/bin/codecept/vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Generator.php:264
FATAL ERROR. TESTS NOT FINISHED.
Class ‘Instantiator\Instantiator’ not found
in phar:///usr/bin/codecept/vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Generator.php:292
Что я делаю не так?
(Вот тут чуть подребнее Get fatal error when creating stub · Issue #1385 · Codeception/Codeception · GitHub)