当前位置: 首页>>代码示例>>PHP>>正文


PHP Apple::unbindModel方法代码示例

本文整理汇总了PHP中Apple::unbindModel方法的典型用法代码示例。如果您正苦于以下问题:PHP Apple::unbindModel方法的具体用法?PHP Apple::unbindModel怎么用?PHP Apple::unbindModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Apple的用法示例。


在下文中一共展示了Apple::unbindModel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 Apple();
     $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->attach('Test');
     $Apple->unbindModel(array('belongsTo' => array('Parent')));
     $this->assertSame($Apple->find('all', $conditions), $wellBehaved);
     $Apple->Parent->Behaviors->attach('Test', array('before' => 'off'));
     $this->assertSame($expected, $Apple->find('all', $conditions));
     $Apple->Parent->Behaviors->attach('Test', array('before' => 'test'));
     $this->assertSame($expected, $Apple->find('all', $conditions));
     $Apple->Parent->Behaviors->attach('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->attach('Test', array('after' => 'off'));
     $this->assertEquals($expected, $Apple->find('all', $conditions));
     $Apple->Parent->Behaviors->attach('Test', array('after' => 'test'));
     $this->assertEquals($expected, $Apple->find('all', $conditions));
     $Apple->Parent->Behaviors->attach('Test', array('after' => 'test2'));
     $this->assertEquals($expected, $Apple->find('all', $conditions));
 }
开发者ID:magooemp,项目名称:eramba,代码行数:35,代码来源:BehaviorCollectionTest.php

示例2: testBehaviorBelongsToFindCallbacks

 /**
  * testBehaviorBelongsToFindCallbacks method
  *
  * @access public
  * @return void
  */
 function testBehaviorBelongsToFindCallbacks()
 {
     $Apple = new Apple();
     $Apple->unbindModel(array('hasMany' => array('Child'), 'hasOne' => array('Sample')), false);
     $expected = $Apple->find('all');
     $Apple->unbindModel(array('belongsTo' => array('Parent')));
     $wellBehaved = $Apple->find('all');
     $Apple->Parent->Behaviors->attach('Test');
     $Apple->unbindModel(array('belongsTo' => array('Parent')));
     $this->assertIdentical($Apple->find('all'), $wellBehaved);
     $Apple->Parent->Behaviors->attach('Test', array('before' => 'off'));
     $this->assertIdentical($Apple->find('all'), $expected);
     $Apple->Parent->Behaviors->attach('Test', array('before' => 'test'));
     $this->assertIdentical($Apple->find('all'), $expected);
     $Apple->Parent->Behaviors->attach('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')));
     $result = $Apple->find('all', array('fields' => array('Apple.id', 'Parent.*'), 'conditions' => array('Apple.id <' => '4')));
     //$this->assertEqual($result, $expected2);
     $Apple->Parent->Behaviors->disable('Test');
     $result = $Apple->find('all');
     $this->assertEqual($result, $expected);
     $Apple->Parent->Behaviors->attach('Test', array('before' => 'off', 'after' => 'on'));
     //$this->assertIdentical($Apple->find('all'), array());
     $Apple->Parent->Behaviors->attach('Test', array('after' => 'off'));
     $this->assertEqual($Apple->find('all'), $expected);
     $Apple->Parent->Behaviors->attach('Test', array('after' => 'test'));
     $this->assertEqual($Apple->find('all'), $expected);
     $Apple->Parent->Behaviors->attach('Test', array('after' => 'test2'));
     $this->assertEqual($Apple->find('all'), $expected);
     $Apple->Parent->Behaviors->attach('Test', array('after' => 'modify'));
     $expected = array(array('id' => '1', 'apple_id' => '2', 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17'), array('id' => '2', 'apple_id' => '1', 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17'), array('id' => '3', 'apple_id' => '2', 'color' => 'blue green', 'name' => 'green blue', 'created' => '2006-12-25 05:13:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24', 'mytime' => '22:57:17'), array('id' => '4', 'apple_id' => '2', 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17'), array('id' => '5', 'apple_id' => '5', 'color' => 'Green', 'name' => 'Blue Green', 'created' => '2006-12-25 05:24:06', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16', 'mytime' => '22:57:17'), array('id' => '6', 'apple_id' => '4', 'color' => 'My new appleOrange', 'name' => 'My new apple', 'created' => '2006-12-25 05:29:39', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39', 'mytime' => '22:57:17'), array('id' => '7', 'apple_id' => '6', 'color' => 'Some wierd color', 'name' => 'Some odd color', 'created' => '2006-12-25 05:34:21', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:34:21', 'mytime' => '22:57:17'));
     //$this->assertEqual($Apple->find('all'), $expected);
 }
开发者ID:evrard,项目名称:cakephp2x,代码行数:39,代码来源:model_behavior.test.php


注:本文中的Apple::unbindModel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。