예제 #1
0
 public function applyTo(Database $db)
 {
     $pdo = $db->getPdo();
     $connection = new \PHPUnit_Extensions_Database_DB_DefaultDatabaseConnection($pdo, $db->getName());
     $databasetester = new \PHPUnit_Extensions_Database_DefaultTester($connection);
     $setupoperation = \PHPUnit_Extensions_Database_Operation_Factory::CLEAN_INSERT();
     $databasetester->setSetUpOperation($setupoperation);
     $databasetester->setDataSet($this->dataset);
     $databasetester->onSetUp();
 }
 /**
  * @Then /^I should have "([^"]*)" records in the "([^"]*)" table$/
  */
 public function iShouldHaveRecordsInTheTable($count, $tablename)
 {
     if (!$this->db) {
         throw new \RuntimeException('Please connect to a database before counting records');
     }
     $pdo = $this->db->getPdo();
     $res = $pdo->query('SELECT * FROM ' . $tablename);
     if ($res->rowCount() != $count) {
         throw new \RuntimeException('Rowcount did not match. Expected: ' . $count . '. Rows in database table: ' . $res->rowCount());
     }
 }