2016-01-02 16:43:18 +03:00
|
|
|
<?php
|
2019-02-20 22:58:52 +03:00
|
|
|
namespace common\tests\_support;
|
2016-01-02 16:43:18 +03:00
|
|
|
|
|
|
|
use Codeception\Module;
|
2016-09-19 02:13:17 +03:00
|
|
|
use Codeception\TestInterface;
|
2019-02-20 22:58:52 +03:00
|
|
|
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 16:43:18 +03:00
|
|
|
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 12:21:27 +03:00
|
|
|
* All fixtures will be loaded before the suite is started and unloaded after it completes.
|
2016-10-31 01:51:45 +03:00
|
|
|
*
|
|
|
|
* TODO: try to remove
|
2016-01-02 16:43:18 +03:00
|
|
|
*/
|
2016-01-15 12:21:27 +03:00
|
|
|
class FixtureHelper extends Module {
|
2016-01-02 16:43:18 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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 02:13:17 +03:00
|
|
|
public function _before(TestInterface $test) {
|
2016-01-02 16:43:18 +03:00
|
|
|
$this->loadFixtures();
|
|
|
|
}
|
|
|
|
|
2016-09-19 02:13:17 +03:00
|
|
|
public function _after(TestInterface $test) {
|
2016-01-02 16:43:18 +03:00
|
|
|
$this->unloadFixtures();
|
|
|
|
}
|
|
|
|
|
2016-01-15 12:21:27 +03:00
|
|
|
public function globalFixtures() {
|
2016-01-02 16:43:18 +03:00
|
|
|
return [
|
2016-09-19 02:13:17 +03:00
|
|
|
InitDbFixture::class,
|
2016-01-02 16:43:18 +03:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2016-01-15 12:21:27 +03:00
|
|
|
public function fixtures() {
|
2016-01-02 16:43:18 +03:00
|
|
|
return [
|
2016-06-05 17:01:35 +03:00
|
|
|
'accounts' => AccountFixture::class,
|
|
|
|
'accountSessions' => AccountSessionFixture::class,
|
2016-05-16 01:33:19 +03:00
|
|
|
'emailActivations' => EmailActivationFixture::class,
|
2016-07-17 21:01:15 +03:00
|
|
|
'usernamesHistory' => UsernameHistoryFixture::class,
|
2016-10-31 01:51:45 +03:00
|
|
|
'oauthClients' => OauthClientFixture::class,
|
|
|
|
'oauthSessions' => OauthSessionFixture::class,
|
2016-09-01 10:31:43 +03:00
|
|
|
'minecraftAccessKeys' => MinecraftAccessKeyFixture::class,
|
2016-01-02 16:43:18 +03:00
|
|
|
];
|
|
|
|
}
|
2016-02-14 20:50:10 +03:00
|
|
|
|
2016-01-02 16:43:18 +03:00
|
|
|
}
|