コード例 #1
0
 /**
  * test that beforeSave returning false can abort saves.
  *
  * @return void
  */
 public function testBeforeSaveSaveAbortion()
 {
     $this->loadFixtures('Post');
     $Model = new CallbackPostTestModel();
     $Model->beforeSaveReturn = false;
     $data = array('title' => 'new article', 'body' => 'this is some text.');
     $Model->create();
     $result = $Model->save($data);
     $this->assertFalse($result);
 }
コード例 #2
0
 /**
  * test that beforeDelete returning false can abort deletion.
  *
  * @return void
  */
 public function testBeforeDeleteDeleteAbortion()
 {
     $this->loadFixtures('Post');
     $Model = new CallbackPostTestModel();
     $Model->beforeDeleteReturn = false;
     $result = $Model->delete(1);
     $this->assertFalse($result);
     $exists = $Model->findById(1);
     $this->assertTrue(is_array($exists));
 }