2016-01-02 19:13:18 +05:30
|
|
|
<?php
|
|
|
|
namespace tests\codeception\common\_support;
|
|
|
|
|
|
|
|
use Codeception\Module;
|
2016-01-15 14:51:27 +05:30
|
|
|
use tests\codeception\common\fixtures\AccountFixture;
|
2016-01-21 02:44:29 +05:30
|
|
|
use tests\codeception\common\fixtures\EmailActivationFixture;
|
2016-01-02 19:13:18 +05:30
|
|
|
use yii\test\FixtureTrait;
|
|
|
|
use yii\test\InitDbFixture;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This helper is used to populate the database with needed fixtures before any tests are run.
|
2016-01-15 14:51:27 +05:30
|
|
|
* All fixtures will be loaded before the suite is started and unloaded after it completes.
|
2016-01-02 19:13:18 +05:30
|
|
|
*/
|
2016-01-15 14:51:27 +05:30
|
|
|
class FixtureHelper extends Module {
|
2016-01-02 19:13:18 +05:30
|
|
|
|
|
|
|
/**
|
|
|
|
* Redeclare visibility because codeception includes all public methods that do not start with "_"
|
|
|
|
* and are not excluded by module settings, in actor class.
|
|
|
|
*/
|
|
|
|
use FixtureTrait {
|
|
|
|
loadFixtures as protected;
|
|
|
|
fixtures as protected;
|
|
|
|
globalFixtures as protected;
|
|
|
|
unloadFixtures as protected;
|
|
|
|
getFixtures as protected;
|
|
|
|
getFixture as protected;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Method called before any suite tests run. Loads User fixture login user
|
2016-01-15 14:51:27 +05:30
|
|
|
* to use in functional tests.
|
|
|
|
*
|
2016-01-02 19:13:18 +05:30
|
|
|
* @param array $settings
|
|
|
|
*/
|
2016-01-15 14:51:27 +05:30
|
|
|
public function _beforeSuite($settings = []) {
|
2016-01-02 19:13:18 +05:30
|
|
|
$this->loadFixtures();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Method is called after all suite tests run
|
|
|
|
*/
|
2016-01-15 14:51:27 +05:30
|
|
|
public function _afterSuite() {
|
2016-01-02 19:13:18 +05:30
|
|
|
$this->unloadFixtures();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
2016-01-15 14:51:27 +05:30
|
|
|
public function globalFixtures() {
|
2016-01-02 19:13:18 +05:30
|
|
|
return [
|
|
|
|
InitDbFixture::className(),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
2016-01-15 14:51:27 +05:30
|
|
|
public function fixtures() {
|
2016-01-02 19:13:18 +05:30
|
|
|
return [
|
2016-01-15 14:51:27 +05:30
|
|
|
'accounts' => [
|
|
|
|
'class' => AccountFixture::class,
|
|
|
|
'dataFile' => '@tests/codeception/common/fixtures/data/accounts.php',
|
|
|
|
],
|
2016-01-21 02:44:29 +05:30
|
|
|
'emailActivations' => [
|
|
|
|
'class' => EmailActivationFixture::class,
|
|
|
|
'dataFile' => '@tests/codeception/common/fixtures/data/email-activations.php',
|
|
|
|
],
|
2016-01-02 19:13:18 +05:30
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|