2016-01-02 19:13:18 +05:30
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace tests\codeception\common\_support;
|
|
|
|
|
|
|
|
use tests\codeception\common\fixtures\UserFixture;
|
|
|
|
use Codeception\Module;
|
|
|
|
use yii\test\FixtureTrait;
|
|
|
|
use yii\test\InitDbFixture;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This helper is used to populate the database with needed fixtures before any tests are run.
|
|
|
|
* In this example, the database is populated with the demo login user, which is used in acceptance
|
|
|
|
* and functional tests. All fixtures will be loaded before the suite is started and unloaded after it
|
|
|
|
* completes.
|
|
|
|
*/
|
|
|
|
class FixtureHelper extends Module
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
* to use in acceptance and functional tests.
|
|
|
|
* @param array $settings
|
|
|
|
*/
|
|
|
|
public function _beforeSuite($settings = [])
|
|
|
|
{
|
|
|
|
$this->loadFixtures();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Method is called after all suite tests run
|
|
|
|
*/
|
|
|
|
public function _afterSuite()
|
|
|
|
{
|
|
|
|
$this->unloadFixtures();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
public function globalFixtures()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
InitDbFixture::className(),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
public function fixtures()
|
|
|
|
{
|
|
|
|
return [
|
2016-01-03 05:48:37 +05:30
|
|
|
//'user' => [
|
|
|
|
// 'class' => UserFixture::className(),
|
|
|
|
// 'dataFile' => '@tests/codeception/common/fixtures/data/init_login.php',
|
|
|
|
//],
|
2016-01-02 19:13:18 +05:30
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|