Я пытаюсь использовать фреймворк для тестирования кодов с помощью cakePHP.Я установил этот плагин через composer: https://github.com/cakephp/codeception
Я смог запустить "vendor / bin / codecept bootstrap", и он создал все тестовые папки и файлы.После добавления простого теста я пытаюсь запустить «vendor / bin / codecept run», и он начинает мой тест, а затем заканчивается некоторыми фатальными ошибками, которые выглядят так:
vendor/bin/codecept run
Codeception PHP Testing Framework v2.3.9
Powered by PHPUnit 6.5.13 by Sebastian Bergmann and contributors.
App\TestSuite\Codeception.Acceptance Tests (1) ---------------------------------------------------------------------------
✔ SigninCest: Try to test (0.00s)
---------------------------------------------------------------------------------------------------------------------------
PHP Fatal error: Uncaught Error: Call to undefined function Cake\TestSuite\Fixture\loadPHPUnitAliases() in /var/www/html/vendor/cakephp/cakephp/src/TestSuite/Fixture/FixtureManager.php:17
Stack trace:
#0 /var/www/html/vendor/composer/ClassLoader.php(444): include()
#1 /var/www/html/vendor/composer/ClassLoader.php(322): Composer\Autoload\includeFile('/var/www/html/v...')
#2 [internal function]: Composer\Autoload\ClassLoader->loadClass('Cake\\TestSuite\\...')
#3 /var/www/html/vendor/cakephp/codeception/src/Helper/FixtureTrait.php(48): spl_autoload_call('Cake\\TestSuite\\...')
#4 /var/www/html/vendor/cakephp/codeception/src/Framework.php(40): Cake\Codeception\Framework->loadFixtureManager()
#5 /var/www/html/vendor/codeception/codeception/src/Codeception/SuiteManager.php(80): Cake\Codeception\Framework->_initialize()
#6 /var/www/html/vendor/codeception/codeception/src/Codeception/Codecept.php(187): Codeception\SuiteManager->initialize()
#7 /var/www/html/vendor/codeception/codeception/src/Codeception/Codecept.php(158): Codeception in /var/www/html/vendor/cakephp/cakephp/src/TestSuite/Fixture/FixtureManager.php on line 17
Я использую ddev-dockerокружение - если это метры ...
А это мой composer.json
{
"name": "cakephp/app",
"description": "CakePHP skeleton app",
"homepage": "https://cakephp.org",
"type": "project",
"license": "MIT",
"require": {
"php": ">=7.0",
"cakephp/cakephp": "3.6.*",
"cakephp/migrations": "^2.0.0",
"cakephp/plugin-installer": "^1.0",
"josegonzalez/dotenv": "3.*",
"mobiledetect/mobiledetectlib": "2.*"
},
"require-dev": {
"cakephp/bake": "^1.1",
"cakephp/cakephp-codesniffer": "^3.0",
"cakephp/codeception": "dev-master",
"cakephp/debug_kit": "^3.15.0",
"psy/psysh": "@stable"
},
"suggest": {
"markstory/asset_compress": "An asset compression plugin which provides file concatenation and a flexible filter system for preprocessing and minification.",
"dereuromark/cakephp-ide-helper": "After baking your code, this keeps your annotations in sync with the code evolving from there on for maximum IDE and PHPStan compatibility.",
"phpunit/phpunit": "Allows automated tests to be run without system-wide install."
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Test\\": "tests/",
"Cake\\Test\\": "vendor/cakephp/cakephp/tests/"
}
},
"scripts": {
"post-install-cmd": "App\\Console\\Installer::postInstall",
"post-create-project-cmd": "App\\Console\\Installer::postInstall",
"post-autoload-dump": "Cake\\Composer\\Installer\\PluginInstaller::postAutoloadDump",
"fullcheck": [
"@test",
"@cs-check"
],
"cs-check": "phpcs --colors -p --extensions=php,ctp --standard=vendor/cakephp/cakephp-codesniffer/CakePHP src/ tests/",
"cs-fix": "phpcbf --colors --extensions=php,ctp --standard=vendor/cakephp/cakephp-codesniffer/CakePHP src/ tests/",
"test": "phpunit --colors=always"
},
"prefer-stable": true,
"config": {
"sort-packages": true
}
}
Я также запускаю "composer dump-autoload", потому что я думаю, что это как-то связано с автозагрузкой... но безуспешно.Кто-нибудь может помочь с этим?
[ОБНОВЛЕНИЕ] Вот мой файл phpunit.xml.dist:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
colors="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="tests/bootstrap.php"
>
<php>
<ini name="memory_limit" value="-1"/>
<ini name="apc.enable_cli" value="1"/>
</php>
<!-- Add any additional test suites you want to run here -->
<testsuites>
<testsuite name="app">
<directory>tests/TestCase/</directory>
</testsuite>
<!-- Add plugin test suites here. -->
</testsuites>
<!-- Setup a listener for fixtures -->
<listeners>
<listener
class="\Cake\TestSuite\Fixture\FixtureInjector">
<arguments>
<object class="\Cake\TestSuite\Fixture\FixtureManager" />
</arguments>
</listener>
</listeners>
<!-- Ignore vendor tests in code coverage reports -->
<filter>
<whitelist>
<directory suffix=".php">src/</directory>
<directory suffix=".php">plugins/*/src/</directory>
</whitelist>
</filter>
</phpunit>
Файл bootstrap.php пуст.
Привет!