本文整理汇总了PHP中Restaurant::unbindModel方法的典型用法代码示例。如果您正苦于以下问题:PHP Restaurant::unbindModel方法的具体用法?PHP Restaurant::unbindModel怎么用?PHP Restaurant::unbindModel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Restaurant
的用法示例。
在下文中一共展示了Restaurant::unbindModel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testBehaviorBelongsToFindCallbacks
/**
* testBehaviorBelongsToFindCallbacks method
*
* @return void
*/
public function testBehaviorBelongsToFindCallbacks()
{
$this->skipIf($this->db instanceof Sqlserver, 'This test is not compatible with SQL Server.');
$conditions = array('order' => 'Apple.id ASC');
$Apple = new Restaurant();
$Apple->unbindModel(array('hasMany' => array('Child'), 'hasOne' => array('Sample')), false);
$expected = $Apple->find('all', $conditions);
$Apple->unbindModel(array('belongsTo' => array('Parent')));
$wellBehaved = $Apple->find('all', $conditions);
$Apple->Parent->Behaviors->load('Test');
$Apple->unbindModel(array('belongsTo' => array('Parent')));
$this->assertSame($Apple->find('all', $conditions), $wellBehaved);
$Apple->Parent->Behaviors->load('Test', array('before' => 'off'));
$this->assertSame($expected, $Apple->find('all', $conditions));
$Apple->Parent->Behaviors->load('Test', array('before' => 'test'));
$this->assertSame($expected, $Apple->find('all', $conditions));
$Apple->Parent->Behaviors->load('Test', array('before' => 'modify'));
$expected2 = array(array('Apple' => array('id' => 1), 'Parent' => array('id' => 2, 'name' => 'Bright Red Apple', 'mytime' => '22:57:17')), array('Apple' => array('id' => 2), 'Parent' => array('id' => 1, 'name' => 'Red Apple 1', 'mytime' => '22:57:17')), array('Apple' => array('id' => 3), 'Parent' => array('id' => 2, 'name' => 'Bright Red Apple', 'mytime' => '22:57:17')));
$result2 = $Apple->find('all', array('fields' => array('Apple.id', 'Parent.id', 'Parent.name', 'Parent.mytime'), 'conditions' => array('Apple.id <' => '4'), 'order' => 'Apple.id ASC'));
$this->assertEquals($expected2, $result2);
$Apple->Parent->Behaviors->disable('Test');
$result = $Apple->find('all', $conditions);
$this->assertEquals($expected, $result);
$Apple->Parent->Behaviors->load('Test', array('after' => 'off'));
$this->assertEquals($expected, $Apple->find('all', $conditions));
$Apple->Parent->Behaviors->load('Test', array('after' => 'test'));
$this->assertEquals($expected, $Apple->find('all', $conditions));
$Apple->Parent->Behaviors->load('Test', array('after' => 'test2'));
$this->assertEquals($expected, $Apple->find('all', $conditions));
}