/** * testBehaviorDeleteCallbacks method * * @return void */ public function testBehaviorDeleteCallbacks() { $Apple = new Apple(); $Apple->Behaviors->attach('Test', array('beforeFind' => 'off', 'beforeDelete' => 'off')); $this->assertSame($Apple->delete(6), true); $Apple->Behaviors->attach('Test', array('beforeDelete' => 'on')); $this->assertSame($Apple->delete(4), false); $Apple->Behaviors->attach('Test', array('beforeDelete' => 'test2')); ob_start(); $results = $Apple->delete(4); $this->assertSame(trim(ob_get_clean()), 'beforeDelete success (cascading)'); $this->assertSame($results, true); ob_start(); $results = $Apple->delete(3, false); $this->assertSame(trim(ob_get_clean()), 'beforeDelete success'); $this->assertSame($results, true); $Apple->Behaviors->attach('Test', array('beforeDelete' => 'off', 'afterDelete' => 'on')); ob_start(); $results = $Apple->delete(2, false); $this->assertSame(trim(ob_get_clean()), 'afterDelete success'); $this->assertSame($results, true); }