/** * {@inheritDoc} */ public function drop(ConnectionInterface $db) { if (empty($this->_schema)) { return false; } try { $sql = $this->_schema->dropSql($db); foreach ($sql as $stmt) { $db->execute($stmt)->closeCursor(); } } catch (Exception $e) { return false; } return true; }
/** * Run after all tests executed, should return SQL statement to drop table for this fixture. * * @param Connection $db An instance of the database object used to create the fixture table * @return bool True on success, false on failure */ public function drop(Connection $db) { if (empty($this->_schema)) { return false; } try { $sql = $this->_schema->dropSql($db); foreach ($sql as $stmt) { $db->execute($stmt)->closeCursor(); } $this->created = array_diff($this->created, [$db->configName()]); } catch (\Exception $e) { return false; } return true; }
/** * test dropSql * * @return void */ public function testDropSql() { $driver = $this->_getMockedDriver(); $connection = $this->getMockBuilder('Cake\\Database\\Connection')->disableOriginalConstructor()->getMock(); $connection->expects($this->any())->method('driver')->will($this->returnValue($driver)); $table = new Table('schema_articles'); $result = $table->dropSql($connection); $this->assertCount(1, $result); $this->assertEquals('DROP TABLE "schema_articles" CASCADE', $result[0]); }
/** * test dropSql * * @return void */ public function testDropSql() { $driver = $this->_getMockedDriver(); $connection = $this->getMock('Cake\\Database\\Connection', [], [], '', false); $connection->expects($this->any())->method('driver')->will($this->returnValue($driver)); $table = new Table('articles'); $result = $table->dropSql($connection); $this->assertCount(1, $result); $this->assertEquals('DROP TABLE "articles"', $result[0]); }