This Codeception module can be able load CakePHP Fixutre in your test case.
You can install this plugin into your CakePHP application using composer.
The recommended way to install composer packages is:
composer require --dev elstc/codeception-cakefixture
Then enable this module in your test suite configration file (eg: acceptance.suite.yml
, functional.suite.yml
, and etc...):
modules:
enabled:
- CakeFixture
See: 06-ModulesAndHelpers - Codeception - Documentation
If you have not yet read the CakePHP bootstrap file with in the Codeception bootstrap, then load it:
<?php
// your tests/_bootstrap.php
require_once '__YOUR_CAKEPHP_CONFIG_PATH__/bootstrap.php';
In your Cest
test case, write $fixutures
property:
class AwesomeCest
{
public $fixtures = [
'app.users',
'app.posts',
];
// ...
}
You can use $autoFixtures
, $dropTables
property, and loadFixtures()
method:
class AwesomeCest
{
public $autoFixtures = false;
public $dropTables = false;
public $fixtures = [
'app.users',
'app.posts',
];
public function tryYourSenario($I)
{
// load fixtures manually
$I->loadFixtures('Users', 'Posts');
// or load all fixtures
$I->loadFixtures();
// ...
}
}
In your Cept
test case, use $I->useFixtures()
and $I->loadFixtures()
:
$I = new FunctionalTester($scenario);
// You should call `useFixtures` before `loadFixtures`
$I->useFixtures('app.users', 'app.posts');
// Then load fixtures manually
$I->loadFixtures('Users', 'Posts');
// or load all fixtures
$I->loadFixtures();
Pass to FixtureManager's debug option.
default: false
Default $autoFixtures
property.
default: true
Default $dropTables
property.
default: true