mercredi 26 septembre 2018

CakePHP 3 + Codeception

I try to use codeception testing framework with cakePHP. I installed this plugin via composer: https://github.com/cakephp/codeception

I was able to run "vendor/bin/codecept bootstrap" and it created all the tests folders and files. After adding a simple Test I try to run "vendor/bin/codecept run" and it starts running my test and then ends up in some Fatal errors looking like this:

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

I use a ddev-docker environment - if this metters...

And this is my 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
}
}

I also run "composer dump-autoload" because I think it has something to do with the autoloading... but without success. Can anyone help with that?

Greetings!

Aucun commentaire:

Enregistrer un commentaire