2016-01-02 19:13:18 +05:30
|
|
|
<?php
|
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-02-21 01:28:52 +05:30
|
|
|
use common\tests\fixtures\AccountFixture;
|
|
|
|
use common\tests\fixtures\AccountSessionFixture;
|
|
|
|
use common\tests\fixtures\EmailActivationFixture;
|
|
|
|
use common\tests\fixtures\MinecraftAccessKeyFixture;
|
|
|
|
use common\tests\fixtures\OauthClientFixture;
|
|
|
|
use common\tests\fixtures\OauthSessionFixture;
|
|
|
|
use common\tests\fixtures\UsernameHistoryFixture;
|
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 [
|
2016-06-05 19:31:35 +05:30
|
|
|
'accounts' => AccountFixture::class,
|
|
|
|
'accountSessions' => AccountSessionFixture::class,
|
2016-05-16 04:03:19 +05:30
|
|
|
'emailActivations' => EmailActivationFixture::class,
|
2016-07-17 23:31:15 +05:30
|
|
|
'usernamesHistory' => UsernameHistoryFixture::class,
|
2016-10-31 04:21:45 +05:30
|
|
|
'oauthClients' => OauthClientFixture::class,
|
|
|
|
'oauthSessions' => OauthSessionFixture::class,
|
2016-09-01 13:01:43 +05:30
|
|
|
'minecraftAccessKeys' => 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
|
|
|
}
|