コード例 #1
0
 public function setUp()
 {
     $sql = file_get_contents(\Codeception\Configuration::dataDir() . '/dumps/sqlite.sql');
     $sql = preg_replace('%/\\*(?:(?!\\*/).)*\\*/%s', "", $sql);
     $this->sql = explode("\n", $sql);
     $this->sqlite = Db::create($this->config['dsn'], $this->config['user'], $this->config['password']);
     $this->sqlite->cleanup();
 }
コード例 #2
0
ファイル: DbTest.php プロジェクト: hendryguna/laravel-basic
 protected function loadDump()
 {
     $sql = file_get_contents(\Codeception\Configuration::dataDir() . '/dumps/sqlite.sql');
     $sql = preg_replace('%/\*(?:(?!\*/).)*\*/%s', "", $sql);
     $sql = explode("\n", $sql);
     $sqlite = \Codeception\Util\Driver\Db::create($this->config['dsn'], $this->config['user'], $this->config['password']);
     $sqlite->load($sql);
 }
コード例 #3
0
ファイル: MysqlTest.php プロジェクト: lenninsanchez/donadores
 public function setUp()
 {
     $sql = file_get_contents(\Codeception\Configuration::dataDir() . '/dumps/mysql.sql');
     $sql = preg_replace('%/\\*(?:(?!\\*/).)*\\*/%s', "", $sql);
     $this->sql = explode("\n", $sql);
     try {
         $this->mysql = Db::create($this->config['dsn'], $this->config['user'], $this->config['password']);
     } catch (\Exception $e) {
         $this->markTestSkipped('Coudn\'t establish connection to database');
         return;
     }
     $this->mysql->cleanup();
 }
コード例 #4
0
 public function setUp()
 {
     if (!function_exists('pg_connect')) {
         return $this->markTestSkipped("Postgres extensions not loaded");
     }
     $sql = file_get_contents(\Codeception\Configuration::dataDir() . '/dumps/postgres.sql');
     $sql = preg_replace('%/\\*(?:(?!\\*/).)*\\*/%s', "", $sql);
     $this->sql = explode("\n", $sql);
     try {
         $this->postgres = Db::create($this->config['dsn'], $this->config['user'], $this->config['password']);
     } catch (\Exception $e) {
         $this->markTestSkipped('Coudn\'t establish connection to database');
         return;
     }
     $this->postgres->cleanup();
 }
コード例 #5
0
ファイル: Db.php プロジェクト: BatVane/Codeception
 protected function proceedSeeInDatabase($table, $criteria)
 {
     $query = "select count(*) from `%s` where %s";
     $params = array();
     foreach ($criteria as $k => $v) {
         $params[] = "`{$k}` = ? ";
     }
     $params = implode('AND ', $params);
     $query = sprintf($query, $table, $params);
     $this->debugSection('Query', $query, $params);
     $sth = $this->driver->getDbh()->prepare($query);
     if (!$sth) {
         \PHPUnit_Framework_Assert::fail("Query '{$query}' can't be executed.");
     }
     $sth->execute(array_values($criteria));
     return $sth->fetchColumn();
 }
コード例 #6
0
ファイル: Db.php プロジェクト: lenninsanchez/donadores
 protected function proceedSeeInDatabase($table, $column, $criteria)
 {
     $query = $this->driver->select($column, $table, $criteria);
     $this->debugSection('Query', $query, json_encode($criteria));
     $sth = $this->driver->getDbh()->prepare($query);
     if (!$sth) {
         \PHPUnit_Framework_Assert::fail("Query '{$query}' can't be executed.");
     }
     $sth->execute(array_values($criteria));
     return $sth->fetchColumn();
 }