elstc/codeception-cakefixture

CakePHP Fixture loader for Codeception

v1.1.0 2018-03-05 02:39 UTC

This package is auto-updated.

Last update: 2024-11-29 05:32:41 UTC


README

Software License Build Status Latest Stable Version

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