Browse Source

Better AR connection init in tests

tags/2.0.0-alpha
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
*/
protected $db;
protected $initializeAppWithDb = false;
protected function setUp()
{
@ -24,9 +23,6 @@ abstract class DatabaseTestCase extends TestCase
if (!extension_loaded('pdo') || !extension_loaded($pdo_database)) {
$this->markTestSkipped('pdo and '.$pdo_database.' extension are required.');
}
if ($this->initializeAppWithDb === true) {
\Yii::$app->setComponent('db', $this->getConnection());
}
$this->mockApplication();
}

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

@ -19,12 +19,7 @@ class ExistValidatorTest extends DatabaseTestCase
public function setUp()
{
parent::setUp();
ActiveRecord::$db = Yii::$app->getComponent('db');
}
public function tearDown()
{
parent::tearDown();
ActiveRecord::$db = $this->getConnection();
}
public function testValidateValueExpectedException()

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

@ -20,7 +20,7 @@ class UniqueValidatorTest extends DatabaseTestCase
public function setUp()
{
parent::setUp();
ActiveRecord::$db = Yii::$app->getComponent('db');
ActiveRecord::$db = $this->getConnection();
}
public function testAssureMessageSetOnInit()

Loading…
Cancel
Save