Browse Source

Better AR connection init in tests

tags/2.0.0-beta
Alexander Makarov 11 years ago
parent
commit
8c1c3c59d9
  1. 4
      tests/unit/framework/db/DatabaseTestCase.php
  2. 7
      tests/unit/framework/validators/ExistValidatorTest.php
  3. 2
      tests/unit/framework/validators/UniqueValidatorTest.php

4
tests/unit/framework/db/DatabaseTestCase.php

@ -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
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();
} }

7
tests/unit/framework/validators/ExistValidatorTest.php

@ -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()

2
tests/unit/framework/validators/UniqueValidatorTest.php

@ -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()

Loading…
Cancel
Save