From f11d608936705208d038ca6f4764920fb95c8de6 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Wed, 7 May 2014 01:50:58 +0400 Subject: [PATCH] Re-init application if it was destroyed during RBAC test --- tests/unit/framework/rbac/DbManagerTestCase.php | 31 +++++++++++++++---------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/tests/unit/framework/rbac/DbManagerTestCase.php b/tests/unit/framework/rbac/DbManagerTestCase.php index c93320a..831b12c 100644 --- a/tests/unit/framework/rbac/DbManagerTestCase.php +++ b/tests/unit/framework/rbac/DbManagerTestCase.php @@ -1,6 +1,7 @@ 'Migrator', + 'basePath' => '@yiiunit', + 'components' => [ + 'db' => static::getConnection(), + 'authManager' => '\yii\rbac\DbManager', + ], + ]); + } + return Yii::$app; + } + public static function setUpBeforeClass() { parent::setUpBeforeClass(); @@ -30,25 +46,16 @@ abstract class DbManagerTestCase extends ManagerTestCase static::markTestSkipped('pdo and ' . $pdo_database . ' extension are required.'); } - new Application([ - 'id' => 'Migrator', - 'basePath' => '@yiiunit', - 'components' => [ - 'db' => static::getConnection(), - 'authManager' => '\yii\rbac\DbManager', - ], - ]); - - \Yii::$app->runAction('migrate/up', ['migrationPath' => '@yii/rbac/migrations/', 'interactive' => false]); + static::getApplication()->runAction('migrate/up', ['migrationPath' => '@yii/rbac/migrations/', 'interactive' => false]); } public static function tearDownAfterClass() { - \Yii::$app->runAction('migrate/down', ['migrationPath' => '@yii/rbac/migrations/', 'interactive' => false]); + static::getApplication()->runAction('migrate/down', ['migrationPath' => '@yii/rbac/migrations/', 'interactive' => false]); if (static::$db) { static::$db->close(); } - \Yii::$app = null; + Yii::$app = null; parent::tearDownAfterClass(); }