Exemple #1
0
 /**
  * {@inheritDoc}
  */
 public function createConstraints(ConnectionInterface $db)
 {
     if (empty($this->_constraints)) {
         return true;
     }
     foreach ($this->_constraints as $name => $data) {
         $this->_schema->addConstraint($name, $data);
     }
     $sql = $this->_schema->addConstraintSql($db);
     if (empty($sql)) {
         return true;
     }
     foreach ($sql as $stmt) {
         $db->execute($stmt)->closeCursor();
     }
     return true;
 }
Exemple #2
0
 /**
  * Test the addConstraintSql method.
  *
  * @return void
  */
 public function testAddConstraintSql()
 {
     $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->addConstraintSql($connection);
     $this->assertEmpty($result);
 }