We have old codeception api tests that succeed on yii 2.0.11.2. However on yii 2.0.12, they get an error when loading fixtures (integrityError due to primary key already existing).
Debugging it, I found the code that triggers the error (framework/db/Command.php line 842). If I check the contents of the db table before that line is executed, I see that the db table is already populated with the fixture.
So, it appears that yii tries to load the fixtures in different places and ends up trying to reload the same ones on top of each other.
This is on php7.
application/tests/api/fixtures/UserFixture.php
<?php
namespace tests\api\fixtures;
use yii\test\ActiveFixture;
class UserFixture extends ActiveFixture
{
public $modelClass = 'common\models\User';
public $dataFile = 'tests/api/fixtures/data/User.php';
public $depends = [
];
}
application/tests/api/BaseCest.php
<?php
use tests\api\FixtureHelper;
class BaseCest
{
/** @var tests\api\FixtureHelper */
public $fixtureHelper;
public function _inject(tests\api\FixtureHelper $fixtureHelper)
{
$this->fixtureHelper = $fixtureHelper;
}
public function _before(ApiTester $I)
{
$this->fixtureHelper->_beforeSuite();
}
public function _after(ApiTester $I)
{
$this->fixtureHelper->_afterSuite();
}
}