2016-01-02 19:13:18 +05:30
|
|
|
<?php
|
2019-09-22 02:47:21 +05:30
|
|
|
declare(strict_types=1);
|
|
|
|
|
2019-02-21 01:28:52 +05:30
|
|
|
namespace common\tests\_support;
|
2016-01-02 19:13:18 +05:30
|
|
|
|
|
|
|
use Codeception\Module;
|
2016-09-19 04:43:17 +05:30
|
|
|
use Codeception\TestInterface;
|
2019-09-22 02:47:21 +05:30
|
|
|
use common\tests\fixtures;
|
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-10-31 04:21:45 +05:30
|
|
|
*
|
|
|
|
* TODO: try to remove
|
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;
|
|
|
|
}
|
|
|
|
|
2016-09-19 04:43:17 +05:30
|
|
|
public function _before(TestInterface $test) {
|
2016-01-02 19:13:18 +05:30
|
|
|
$this->loadFixtures();
|
|
|
|
}
|
|
|
|
|
2016-09-19 04:43:17 +05:30
|
|
|
public function _after(TestInterface $test) {
|
2016-01-02 19:13:18 +05:30
|
|
|
$this->unloadFixtures();
|
|
|
|
}
|
|
|
|
|
2016-01-15 14:51:27 +05:30
|
|
|
public function globalFixtures() {
|
2016-01-02 19:13:18 +05:30
|
|
|
return [
|
2016-09-19 04:43:17 +05:30
|
|
|
InitDbFixture::class,
|
2016-01-02 19:13:18 +05:30
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2016-01-15 14:51:27 +05:30
|
|
|
public function fixtures() {
|
2016-01-02 19:13:18 +05:30
|
|
|
return [
|
2019-09-22 02:47:21 +05:30
|
|
|
'accounts' => fixtures\AccountFixture::class,
|
|
|
|
'accountSessions' => fixtures\AccountSessionFixture::class,
|
|
|
|
'emailActivations' => fixtures\EmailActivationFixture::class,
|
|
|
|
'usernamesHistory' => fixtures\UsernameHistoryFixture::class,
|
|
|
|
'oauthClients' => fixtures\OauthClientFixture::class,
|
|
|
|
'oauthSessions' => fixtures\OauthSessionFixture::class,
|
|
|
|
'oauthRefreshTokens' => fixtures\OauthRefreshTokensFixture::class,
|
|
|
|
'minecraftAccessKeys' => fixtures\MinecraftAccessKeyFixture::class,
|
2016-01-02 19:13:18 +05:30
|
|
|
];
|
|
|
|
}
|
2016-02-14 23:20:10 +05:30
|
|
|
|
2016-01-02 19:13:18 +05:30
|
|
|
}
|