PHPackages                             silinternational/yii2-codeception - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. silinternational/yii2-codeception

Abandoned → [sil-org/yii2-codeception](/?search=sil-org%2Fyii2-codeception)Library[Testing &amp; Quality](/categories/testing)

silinternational/yii2-codeception
=================================

Patches to implement nice features of yii2-codeception since it was abandoned

1.2.1(8mo ago)04.3kMITPHPPHP &gt;=5.6.0

Since Jun 18Pushed 3mo ago3 watchersCompare

[ Source](https://github.com/sil-org/yii2-codeception)[ Packagist](https://packagist.org/packages/silinternational/yii2-codeception)[ RSS](/packages/silinternational-yii2-codeception/feed)WikiDiscussions main Synced 2mo ago

READMEChangelog (4)Dependencies (2)Versions (7)Used By (0)

yii2-codeception
================

[](#yii2-codeception)

Patches to implement nice features of yii2-codeception since it was abandoned

What / Why
==========

[](#what--why)

We've been developing with Yii2 for a couple years now and have several projects using the [yiisoft/yii2-codeception](https://github.com/yiisoft/yii2-codeception) library for unit tests.
This library has been deprecated in favor of using a [Codeception module](https://github.com/Codeception/Codeception/blob/2.2/docs/modules/Yii2.md).

Unfortunately this module requires quite a bit of refactoring to run tests in a simlar way as `yii2-codeception` allowed.

After a few hours of tracing and debugging we figured out that two main things had changed that we depended on and so we decided to create a standalone repo to bring in the needed features.

Loading fixtures into database
------------------------------

[](#loading-fixtures-into-database)

The first thing we found was that after reconfiguring Codeception to use the Yii2 module, to look like:

```
# Codeception Test Suite Configuration

# suite for unit (internal) tests.
class_name: UnitTester
modules:
    enabled:
      - Asserts
      - UnitHelper
      - Yii2:
          configFile: 'tests/codeception/config/unit.php'
          cleanup: true
```

Running tests it was unable to load the fixtures due to foreign key constraints. We created a new base class for our active record classes that `beforeLoad` and `afterLoad` it will disable and enable foreign key constraints respectively.

This new base class is `Sil\yii\test\ActiveFixture`. To use, simply update your fixture files to extend from it instead of the previous `yii\test\ActiveFixture` class.

### Example fixtures class

[](#example-fixtures-class)

```
