Commit 8c1c3c59 by Alexander Makarov

Better AR connection init in tests

parent 5cf99922
...@@ -12,7 +12,6 @@ abstract class DatabaseTestCase extends TestCase ...@@ -12,7 +12,6 @@ abstract class DatabaseTestCase extends TestCase
* @var Connection * @var Connection
*/ */
protected $db; protected $db;
protected $initializeAppWithDb = false;
protected function setUp() protected function setUp()
{ {
...@@ -24,9 +23,6 @@ abstract class DatabaseTestCase extends TestCase ...@@ -24,9 +23,6 @@ abstract class DatabaseTestCase extends TestCase
if (!extension_loaded('pdo') || !extension_loaded($pdo_database)) { if (!extension_loaded('pdo') || !extension_loaded($pdo_database)) {
$this->markTestSkipped('pdo and '.$pdo_database.' extension are required.'); $this->markTestSkipped('pdo and '.$pdo_database.' extension are required.');
} }
if ($this->initializeAppWithDb === true) {
\Yii::$app->setComponent('db', $this->getConnection());
}
$this->mockApplication(); $this->mockApplication();
} }
......
...@@ -19,12 +19,7 @@ class ExistValidatorTest extends DatabaseTestCase ...@@ -19,12 +19,7 @@ class ExistValidatorTest extends DatabaseTestCase
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
ActiveRecord::$db = Yii::$app->getComponent('db'); ActiveRecord::$db = $this->getConnection();
}
public function tearDown()
{
parent::tearDown();
} }
public function testValidateValueExpectedException() public function testValidateValueExpectedException()
......
...@@ -20,7 +20,7 @@ class UniqueValidatorTest extends DatabaseTestCase ...@@ -20,7 +20,7 @@ class UniqueValidatorTest extends DatabaseTestCase
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
ActiveRecord::$db = Yii::$app->getComponent('db'); ActiveRecord::$db = $this->getConnection();
} }
public function testAssureMessageSetOnInit() public function testAssureMessageSetOnInit()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment