cakephp / codeception Goto Github PK
View Code? Open in Web Editor NEWCakePHP module for Codeception
License: Other
CakePHP module for Codeception
License: Other
There is a compatibility problem with the package symfony/browser-kit v2.8.7 resulting into the error
Declaration of Cake\Codeception\Connector::filterRequest($request) should be compatible with Symfony\Component\BrowserKit\Client::filterRequest(Symfony\Component\BrowserKit\Request $request)
to solve it is necessary to update the declaration of the method
protected function filterRequest($request)
within the file src/Connector.php
and change to
protected function filterRequest(\Symfony\Component\BrowserKit\Request $request)
Is there any interest in updating this to the 2.3 release? I don't see much activity here but now that the framework supports PHPUnit 6 this plugin is broken.
The dependency 2.0.* wihin the composer.json file is resolved into tag 2.0.0-RC of the codeception repository.
I think it could be better to specify 2.0.16 that is, at this moment, the most recent tag related to 2.0.* version.
I recently upgraded to cake 3.6 and all my tests are broken.
I use REST module. (PhpBrower module same too.
$I->haveHttpHeader('Origin', 'http://foo.example');
$I->sendOPTIONS('/api/foo');
But, Can't get 'Origin' header in cakephp application.
I installed codeception plugin via composer and created a simple Acceptance test. Then I try to run the test and get the following error
` vendor/bin/codecept run
Codeception PHP Testing Framework v2.3.9
Powered by PHPUnit 6.5.13 by Sebastian Bergmann and contributors.
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
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
FATAL ERROR. TESTS NOT FINISHED.
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:17
`
Did I missed anything?
Greetings
Legacy project with Cake 2.x
Is there a backwards compatibility option?
Is there a similar library for CakePHP 2.x?
I've tried to install cakephp/codeception to a new project, but when I run codecept bootstrap it does not generate the folders and files like it should. They are in the "normal" codeception style and not your CakePHP style, e. g. camelCase....
So I assume, theres something wrong. When I look into codecept I see:
require_once dirname(FILE).'/autoload.php';
use Symfony\Component\Console\Application;
$app = new Application('Codeception', Codeception\Codecept::VERSION);
$app->add(new Codeception\Command\Build('build'));
$app->add(new Codeception\Command\Run('run'));
$app->add(new Codeception\Command\Console('console'));
$app->add(new Codeception\Command\Bootstrap('bootstrap'));
$app->add(new Codeception\Command\GenerateCept('generate:cept'));
$app->add(new Codeception\Command\GenerateCest('generate:cest'));
$app->add(new Codeception\Command\GenerateTest('generate:test'));
$app->add(new Codeception\Command\GeneratePhpUnit('generate:phpunit'));
$app->add(new Codeception\Command\GenerateSuite('generate:suite'));
$app->add(new Codeception\Command\GenerateHelper('generate:helper'));
$app->add(new Codeception\Command\GenerateScenarios('generate:scenarios'));
$app->add(new Codeception\Command\Clean('clean'));
$app->add(new Codeception\Command\GenerateGroup('generate:group'));
$app->add(new Codeception\Command\GeneratePageObject('generate:pageobject'));
$app->add(new Codeception\Command\GenerateStepObject('generate:stepobject'));
$app->run();
When I run all suites at once (vendor/bin/codecept run), I get a PHPUnit_Framework_Exception about constant already defined.
First phpunit complainded about all constants defined in config/path.php, then I wrapped all of them inside 'conditionals definitions'. But the error keeps going through every constant.
When I run one suit at time, I have no problems.
The sample_app has namespaces like App\Controller\AppController what causes errors in IDEs like phpStorm because of multiple definitions. So sample_app should be in a different version/branch/tag to be excluded via composer.
Is there any plan to port this module to Cake 2.x?
Or is there an alternative module for Cake 2.x?
The bootstrap command created this folder structure for me
which is different from what stated in the README file. Using Windows 7, PHP 5.6
My composer.json:
"autoload": {
"psr-4": {
"App\\": "src",
"App\\Test\\": "tests"
}
},
"scripts": {
"post-install-cmd": "App\\Console\\Installer::postInstall",
"post-autoload-dump": [
"Cake\\Composer\\Installer\\PluginInstaller::postAutoloadDump",
"Cake\\Codeception\\Console\\Installer::postAutoloadDump"
]
}
I use a ddev docker for running the tests. I'm able to run UnitTests via Codeception, but when it comes to database and fixtures its confusing...
My codeception.dist.yml
namespace: App\TestSuite\Codeception
paths:
tests: tests
output: tmp/tests
data: tests/Fixture
support: src/TestSuite/Codeception
envs: tests/Envs
settings:
bootstrap: bootstrap.php
colors: true
memory_limit: 1024M
actor_suffix: Tester
extensions:
enabled:
- Codeception\Extension\RunFailed
modules:
config:
Db:
dsn: 'mysql:host=%DB_HOST_TEST%;dbname=%DB_NAME_TEST%'
user: '%DB_USER_TEST%'
password: '%DB_PASSWORD_TEST%'
dump: tests/_data/dump.sql
cleanup: true # reload dump between tests
populate: true # load dump before all tests
reconnect: true
enabled:
- Db
params:
- env
The dump.sql is imported into the test database on running my tests. Fixtures are not inserted...
Then in my Test "class HashableBehaviorTest extends \Codeception\Test\Unit" I do something like:
$user = $this->UsersTable->get(1);
This gives me the first record from my default database and not from the test database. I have no Idea what is missing here... Glad for any help!
Should'nt it be possible, that the app automatically uses the test db connection when running functional testing?
Cheers,
Sascha
The customizeCodeceptionBinary
is now added to the official app skeleton - refs cakephp/app/pull/223.
I think the doc should be somehow updated so that people are not surprised when they already see the customizeCodeceptionBinary
method there. Or since everything is just in pre-release there is no need to have those lines in the top of the README file. Possibly there could be an Fix issues
section on the bottom and this could be mentioned there.
Anyway I just wanted to let you know that there is cakephp/app/pull/223.
Executed:
composer require --dev cakephp/codeception:dev-master
Get:
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- cakephp/codeception dev-master requires codeception/codeception ~2.0.16 -> satisfiable by codeception/codeception[2.0.16].
- Installation request for cakephp/codeception dev-master -> satisfiable by cakephp/codeception[dev-master].
- Conclusion: remove symfony/console v3.1.5
- Conclusion: don't install symfony/console v3.1.5
- codeception/codeception 2.0.16 requires symfony/console ~2.4 -> satisfiable by symfony/console[v2.4.0, v2.4.0-BETA1, v2.4.0-BETA2, v2.4.0-RC1, v2.4.1, v2.4.10, v2.4.2, v2.4.3, v2.4.4, v2.4.5, v2.4.6, v2.4.7, v2.4.8, v2.4.9, v2.5.0, v2.5.0-BETA1, v2.5.0-BETA2, v2.5.0-RC1, v2.5.1, v2.5.10, v2.5.11, v2.5.12, v2.5.2, v2.5.3, v2.5.4, v2.5.5, v2.5.6, v2.5.7, v2.5.8, v2.5.9, v2.6.0, v2.6.0-BETA1, v2.6.0-BETA2, v2.6.1, v2.6.10, v2.6.11, v2.6.12, v2.6.13, v2.6.2, v2.6.3, v2.6.4, v2.6.5, v2.6.6, v2.6.7, v2.6.8, v2.6.9, v2.7.0, v2.7.0-BETA1, v2.7.0-BETA2, v2.7.1, v2.7.10, v2.7.11, v2.7.12, v2.7.13, v2.7.14, v2.7.15, v2.7.16, v2.7.17, v2.7.18, v2.7.19, v2.7.2, v2.7.3, v2.7.4, v2.7.5, v2.7.6, v2.7.7, v2.7.8, v2.7.9, v2.8.0, v2.8.0-BETA1, v2.8.1, v2.8.10, v2.8.11, v2.8.12, v2.8.2, v2.8.3, v2.8.4, v2.8.5, v2.8.6, v2.8.7, v2.8.8, v2.8.9].
- Can only install one of: symfony/console[v2.8.0, v3.1.5].
- Can only install one of: symfony/console[v2.8.0-BETA1, v3.1.5].
- Can only install one of: symfony/console[v2.8.1, v3.1.5].
- Can only install one of: symfony/console[v2.8.10, v3.1.5].
- Can only install one of: symfony/console[v2.8.11, v3.1.5].
- Can only install one of: symfony/console[v2.8.12, v3.1.5].
- Can only install one of: symfony/console[v2.8.2, v3.1.5].
- Can only install one of: symfony/console[v2.8.3, v3.1.5].
- Can only install one of: symfony/console[v2.8.4, v3.1.5].
- Can only install one of: symfony/console[v2.8.5, v3.1.5].
- Can only install one of: symfony/console[v2.8.6, v3.1.5].
- Can only install one of: symfony/console[v2.8.7, v3.1.5].
- Can only install one of: symfony/console[v2.8.8, v3.1.5].
- Can only install one of: symfony/console[v2.8.9, v3.1.5].
- Can only install one of: symfony/console[v2.4.0, v3.1.5].
- Can only install one of: symfony/console[v2.4.0-BETA1, v3.1.5].
- Can only install one of: symfony/console[v2.4.0-BETA2, v3.1.5].
- Can only install one of: symfony/console[v2.4.0-RC1, v3.1.5].
- Can only install one of: symfony/console[v2.4.1, v3.1.5].
- Can only install one of: symfony/console[v2.4.10, v3.1.5].
- Can only install one of: symfony/console[v2.4.2, v3.1.5].
- Can only install one of: symfony/console[v2.4.3, v3.1.5].
- Can only install one of: symfony/console[v2.4.4, v3.1.5].
- Can only install one of: symfony/console[v2.4.5, v3.1.5].
- Can only install one of: symfony/console[v2.4.6, v3.1.5].
- Can only install one of: symfony/console[v2.4.7, v3.1.5].
- Can only install one of: symfony/console[v2.4.8, v3.1.5].
- Can only install one of: symfony/console[v2.4.9, v3.1.5].
- Can only install one of: symfony/console[v2.5.0, v3.1.5].
- Can only install one of: symfony/console[v2.5.0-BETA1, v3.1.5].
- Can only install one of: symfony/console[v2.5.0-BETA2, v3.1.5].
- Can only install one of: symfony/console[v2.5.0-RC1, v3.1.5].
- Can only install one of: symfony/console[v2.5.1, v3.1.5].
- Can only install one of: symfony/console[v2.5.10, v3.1.5].
- Can only install one of: symfony/console[v2.5.11, v3.1.5].
- Can only install one of: symfony/console[v2.5.12, v3.1.5].
- Can only install one of: symfony/console[v2.5.2, v3.1.5].
- Can only install one of: symfony/console[v2.5.3, v3.1.5].
- Can only install one of: symfony/console[v2.5.4, v3.1.5].
- Can only install one of: symfony/console[v2.5.5, v3.1.5].
- Can only install one of: symfony/console[v2.5.6, v3.1.5].
- Can only install one of: symfony/console[v2.5.7, v3.1.5].
- Can only install one of: symfony/console[v2.5.8, v3.1.5].
- Can only install one of: symfony/console[v2.5.9, v3.1.5].
- Can only install one of: symfony/console[v2.6.0, v3.1.5].
- Can only install one of: symfony/console[v2.6.0-BETA1, v3.1.5].
- Can only install one of: symfony/console[v2.6.0-BETA2, v3.1.5].
- Can only install one of: symfony/console[v2.6.1, v3.1.5].
- Can only install one of: symfony/console[v2.6.10, v3.1.5].
- Can only install one of: symfony/console[v2.6.11, v3.1.5].
- Can only install one of: symfony/console[v2.6.12, v3.1.5].
- Can only install one of: symfony/console[v2.6.13, v3.1.5].
- Can only install one of: symfony/console[v2.6.2, v3.1.5].
- Can only install one of: symfony/console[v2.6.3, v3.1.5].
- Can only install one of: symfony/console[v2.6.4, v3.1.5].
- Can only install one of: symfony/console[v2.6.5, v3.1.5].
- Can only install one of: symfony/console[v2.6.6, v3.1.5].
- Can only install one of: symfony/console[v2.6.7, v3.1.5].
- Can only install one of: symfony/console[v2.6.8, v3.1.5].
- Can only install one of: symfony/console[v2.6.9, v3.1.5].
- Can only install one of: symfony/console[v2.7.0, v3.1.5].
- Can only install one of: symfony/console[v2.7.0-BETA1, v3.1.5].
- Can only install one of: symfony/console[v2.7.0-BETA2, v3.1.5].
- Can only install one of: symfony/console[v2.7.1, v3.1.5].
- Can only install one of: symfony/console[v2.7.10, v3.1.5].
- Can only install one of: symfony/console[v2.7.11, v3.1.5].
- Can only install one of: symfony/console[v2.7.12, v3.1.5].
- Can only install one of: symfony/console[v2.7.13, v3.1.5].
- Can only install one of: symfony/console[v2.7.14, v3.1.5].
- Can only install one of: symfony/console[v2.7.15, v3.1.5].
- Can only install one of: symfony/console[v2.7.16, v3.1.5].
- Can only install one of: symfony/console[v2.7.17, v3.1.5].
- Can only install one of: symfony/console[v2.7.18, v3.1.5].
- Can only install one of: symfony/console[v2.7.19, v3.1.5].
- Can only install one of: symfony/console[v2.7.2, v3.1.5].
- Can only install one of: symfony/console[v2.7.3, v3.1.5].
- Can only install one of: symfony/console[v2.7.4, v3.1.5].
- Can only install one of: symfony/console[v2.7.5, v3.1.5].
- Can only install one of: symfony/console[v2.7.6, v3.1.5].
- Can only install one of: symfony/console[v2.7.7, v3.1.5].
- Can only install one of: symfony/console[v2.7.8, v3.1.5].
- Can only install one of: symfony/console[v2.7.9, v3.1.5].
- Installation request for symfony/console (locked at v3.1.5) -> satisfiable by symfony/console[v3.1.5].
Installation failed, reverting ./composer.json to its original content.
composer.json:
{
"name": "cakephp/app",
"description": "CakePHP skeleton app",
"homepage": "http://cakephp.org",
"type": "project",
"license": "MIT",
"require": {
"php": ">=5.5.9",
"cakephp/cakephp": "3.3.*",
"mobiledetect/mobiledetectlib": "2.*",
"cakephp/migrations": "~1.0",
"cakephp/plugin-installer": "*",
"friendsofcake/crud": "^4.3",
"fzaninotto/faker": "^1.6",
"almasaeed2010/adminlte": "~2.0",
"friendsofcake/bootstrap-ui": "^0.5.1"
},
"require-dev": {
"psy/psysh": "@stable",
"cakephp/debug_kit": "~3.2",
"cakephp/bake": "~1.1"
},
"suggest": {
"markstory/asset_compress": "An asset compression plugin which provides file concatenation and a flexible filter system for preprocessing and minification.",
"phpunit/phpunit": "Allows automated tests to be run without system-wide install.",
"cakephp/cakephp-codesniffer": "Allows to check the code against the coding standards used in CakePHP."
},
"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",
"cp -rf vendor/almasaeed2010/adminlte webroot/"
]
},
"minimum-stability": "beta",
"prefer-stable": true
}
Could you please explain (also in documentation) how should I prepare the database?
I would like to run the tests also on third party continous integration tool like https://codeship.com
Where/how should I prepare the data and schema? Or is it connected with cake's fixtures?
In Rails I am able to load the schema bundle exec rake db:schema:load
. In cake there is no schema lock file, but in the fixtures it can be defined from scratch or copied from existing database. But on third party server this is not handy because there is no existing database.
This schema lock file could be refreshed after every migration. This is how it works in Rails if I'm correct.
What do you think and how would you solve this? Thanks alot.
Hi jadb!
I'm struggling very hard with fixtures in unit testing.
I have my Testclass extend from Cake\TestSuite\TestCase
. But when I try it with
public $fixtures = ['plugin.user_management.permissions'];
no fixtures are loaded. When I try
public function testAuthorize()
{
$this->loadFixtures('Permissions');
...
I get an Exception: [PHPUnit_Framework_ExceptionWrapper] No fixture manager to load the test fixture
So how can I use the built in fixture functionality from cake in unit testing? Any ideas?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.