elstc / codeception-cakefixture
CakePHP Fixture loader for Codeception
Installs: 4 207
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=5.6
- codeception/codeception: ^2.3
Requires (Dev)
- cakephp/cakephp: ^3.4
This package is auto-updated.
Last update: 2024-11-29 05:32:41 UTC
README
This Codeception module can be able load CakePHP Fixutre in your test case.
Installation
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';
Usage
Cest
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(); // ... } }
Cept
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();
Configuration options
debug
Pass to FixtureManager's debug option.
default: false
autoFixures
Default $autoFixtures
property.
default: true
dropTables
Default $dropTables
property.
default: true