/** * Drop all existing tables, even those not defined in the schema. * * @param Doctrine\DBAL\Connection $connection */ function dropTables(Doctrine\DBAL\Connection $connection) { $connection->query('SET FOREIGN_KEY_CHECKS=0'); foreach ($connection->getSchemaManager()->listTableNames() as $table) { $connection->getSchemaManager()->dropTable($table); } $connection->query('SET FOREIGN_KEY_CHECKS=1'); }
/** * @Then /^there sould be not data in the "([^"]*)" table$/ */ public function thereSouldBeNotDataInTheTable($table) { $query = 'SELECT count(*) as records FROM ' . $table; $st = self::$db->query($query); $result = $st->fetch(); if ($result['records'] > 0) { throw new Exception("The {$table} table should be empty. It contains " . $result['records'] . ' records'); } }