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


PHP Sample::read方法代码示例

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


在下文中一共展示了Sample::read方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testBehaviorSaveCallbacks

 /**
  * testBehaviorSaveCallbacks method
  *
  * @return void
  */
 public function testBehaviorSaveCallbacks()
 {
     $Sample = new Sample();
     $record = array('Sample' => array('apple_id' => 6, 'name' => 'sample99'));
     $Sample->Behaviors->attach('Test', array('beforeSave' => 'on'));
     $Sample->create();
     $this->assertSame(false, $Sample->save($record));
     $Sample->Behaviors->attach('Test', array('beforeSave' => 'off'));
     $Sample->create();
     $result = $Sample->save($record);
     $expected = $record;
     $expected['Sample']['id'] = $Sample->id;
     $this->assertSame($expected, $result);
     $Sample->Behaviors->attach('Test', array('beforeSave' => 'test'));
     $Sample->create();
     $result = $Sample->save($record);
     $expected = $record;
     $expected['Sample']['id'] = $Sample->id;
     $this->assertSame($expected, $result);
     $Sample->Behaviors->attach('Test', array('beforeSave' => 'modify'));
     $expected = Hash::insert($record, 'Sample.name', 'sample99 modified before');
     $Sample->create();
     $result = $Sample->save($record);
     $expected['Sample']['id'] = $Sample->id;
     $this->assertSame($expected, $result);
     $Sample->Behaviors->disable('Test');
     $this->assertSame($record, $Sample->save($record));
     $Sample->Behaviors->attach('Test', array('beforeSave' => 'off', 'afterSave' => 'on'));
     $expected = Hash::merge($record, array('Sample' => array('aftersave' => 'modified after on create')));
     $Sample->create();
     $result = $Sample->save($record);
     $expected['Sample']['id'] = $Sample->id;
     $this->assertEquals($expected, $result);
     $Sample->Behaviors->attach('Test', array('beforeSave' => 'modify', 'afterSave' => 'modify'));
     $expected = Hash::merge($record, array('Sample' => array('name' => 'sample99 modified before modified after on create')));
     $Sample->create();
     $result = $Sample->save($record);
     $expected['Sample']['id'] = $Sample->id;
     $this->assertSame($expected, $result);
     $Sample->Behaviors->attach('Test', array('beforeSave' => 'off', 'afterSave' => 'test'));
     $Sample->create();
     $expected = $record;
     unset($expected['Sample']['name']);
     $result = $Sample->save($record);
     $expected['Sample']['id'] = $Sample->id;
     $this->assertSame($expected, $result);
     $Sample->Behaviors->attach('Test', array('afterSave' => 'test2'));
     $Sample->create();
     $expected = $record;
     $result = $Sample->save($record);
     $expected['Sample']['id'] = $Sample->id;
     $this->assertSame($expected, $result);
     $Sample->Behaviors->attach('Test', array('beforeFind' => 'off', 'afterFind' => 'off'));
     $Sample->recursive = -1;
     $record2 = $Sample->read(null, 1);
     $Sample->Behaviors->attach('Test', array('afterSave' => 'on'));
     $expected = Hash::merge($record2, array('Sample' => array('aftersave' => 'modified after')));
     $Sample->create();
     $this->assertSame($expected, $Sample->save($record2));
     $Sample->Behaviors->attach('Test', array('afterSave' => 'modify'));
     $expected = Hash::merge($record2, array('Sample' => array('name' => 'sample1 modified after')));
     $Sample->create();
     $this->assertSame($expected, $Sample->save($record2));
 }
开发者ID:magooemp,项目名称:eramba,代码行数:69,代码来源:BehaviorCollectionTest.php

示例2: testBehaviorSaveCallbacks

 /**
  * testBehaviorSaveCallbacks method
  *
  * @access public
  * @return void
  */
 function testBehaviorSaveCallbacks()
 {
     $Sample = new Sample();
     $record = array('Sample' => array('apple_id' => 6, 'name' => 'sample99'));
     $Sample->Behaviors->attach('Test', array('beforeSave' => 'on'));
     $Sample->create();
     $this->assertIdentical($Sample->save($record), false);
     $Sample->Behaviors->attach('Test', array('beforeSave' => 'off'));
     $Sample->create();
     $this->assertIdentical($Sample->save($record), $record);
     $Sample->Behaviors->attach('Test', array('beforeSave' => 'test'));
     $Sample->create();
     $this->assertIdentical($Sample->save($record), $record);
     $Sample->Behaviors->attach('Test', array('beforeSave' => 'modify'));
     $expected = Set::insert($record, 'Sample.name', 'sample99 modified before');
     $Sample->create();
     $this->assertIdentical($Sample->save($record), $expected);
     $Sample->Behaviors->disable('Test');
     $this->assertIdentical($Sample->save($record), $record);
     $Sample->Behaviors->attach('Test', array('beforeSave' => 'off', 'afterSave' => 'on'));
     $expected = Set::merge($record, array('Sample' => array('aftersave' => 'modified after on create')));
     $Sample->create();
     $this->assertIdentical($Sample->save($record), $expected);
     $Sample->Behaviors->attach('Test', array('beforeSave' => 'modify', 'afterSave' => 'modify'));
     $expected = Set::merge($record, array('Sample' => array('name' => 'sample99 modified before modified after on create')));
     $Sample->create();
     $this->assertIdentical($Sample->save($record), $expected);
     $Sample->Behaviors->attach('Test', array('beforeSave' => 'off', 'afterSave' => 'test'));
     $Sample->create();
     $this->assertIdentical($Sample->save($record), $record);
     $Sample->Behaviors->attach('Test', array('afterSave' => 'test2'));
     $Sample->create();
     $this->assertIdentical($Sample->save($record), $record);
     $Sample->Behaviors->attach('Test', array('beforeFind' => 'off', 'afterFind' => 'off'));
     $Sample->recursive = -1;
     $record2 = $Sample->read(null, 1);
     $Sample->Behaviors->attach('Test', array('afterSave' => 'on'));
     $expected = Set::merge($record2, array('Sample' => array('aftersave' => 'modified after')));
     $Sample->create();
     $this->assertIdentical($Sample->save($record2), $expected);
     $Sample->Behaviors->attach('Test', array('afterSave' => 'modify'));
     $expected = Set::merge($record2, array('Sample' => array('name' => 'sample1 modified after')));
     $Sample->create();
     $this->assertIdentical($Sample->save($record2), $expected);
 }
开发者ID:evrard,项目名称:cakephp2x,代码行数:51,代码来源:model_behavior.test.php


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