/** * {@inheritDoc} */ public function dropConstraints(ConnectionInterface $db) { if (empty($this->_constraints)) { return true; } $sql = $this->_schema->dropConstraintSql($db); if (empty($sql)) { return true; } foreach ($sql as $stmt) { $db->execute($stmt)->closeCursor(); } foreach ($this->_constraints as $name => $data) { $this->_schema->dropConstraint($name); } return true; }
/** * Test the dropConstraintSql method. * * @return void */ public function testDropConstraintSql() { $driver = $this->_getMockedDriver(); $connection = $this->getMockBuilder('Cake\\Database\\Connection')->disableOriginalConstructor()->getMock(); $connection->expects($this->any())->method('driver')->will($this->returnValue($driver)); $table = new Table('posts'); $result = $table->dropConstraintSql($connection); $this->assertEmpty($result); }