Qiang Xue
12 years ago
35 changed files with 522 additions and 559 deletions
@ -1,37 +0,0 @@
|
||||
<?php |
||||
|
||||
namespace yiiunit; |
||||
|
||||
class MysqlTestCase extends TestCase |
||||
{ |
||||
protected function setUp() |
||||
{ |
||||
parent::setUp(); |
||||
if (!extension_loaded('pdo') || !extension_loaded('pdo_mysql')) { |
||||
$this->markTestSkipped('pdo and pdo_mysql extensions are required.'); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* @param bool $reset whether to clean up the test database |
||||
* @return \yii\db\Connection |
||||
*/ |
||||
public function getConnection($reset = true) |
||||
{ |
||||
$params = $this->getParam('mysql'); |
||||
$db = new \yii\db\Connection; |
||||
$db->dsn = $params['dsn']; |
||||
$db->username = $params['username']; |
||||
$db->password = $params['password']; |
||||
if ($reset) { |
||||
$db->open(); |
||||
$lines = explode(';', file_get_contents($params['fixture'])); |
||||
foreach ($lines as $line) { |
||||
if (trim($line) !== '') { |
||||
$db->pdo->exec($line); |
||||
} |
||||
} |
||||
} |
||||
return $db; |
||||
} |
||||
} |
@ -1,8 +1,9 @@
|
||||
<?php |
||||
namespace yiiunit\framework\db; |
||||
|
||||
namespace yiiunit; |
||||
use yiiunit\TestCase as TestCase; |
||||
|
||||
class DatabaseTestCase extends TestCase |
||||
abstract class DatabaseTestCase extends TestCase |
||||
{ |
||||
protected $database; |
||||
protected $driverName = 'mysql'; |
Loading…
Reference in new issue