/** * testBehaviorMethodDispatching method * * @return void */ public function testBehaviorMethodDispatching() { $Apple = new Apple(); $Apple->Behaviors->attach('Test'); $expected = 'working'; $this->assertEquals($expected, $Apple->testMethod()); $this->assertEquals($expected, $Apple->Behaviors->dispatchMethod($Apple, 'testMethod')); $result = $Apple->Behaviors->dispatchMethod($Apple, 'wtf'); $this->assertEquals(array('unhandled'), $result); $result = $Apple->{'look for the remote'}('in the couch'); $expected = "Item.name = 'the remote' AND Location.name = 'the couch'"; $this->assertEquals($expected, $result); $result = $Apple->{'look for THE REMOTE'}('in the couch'); $expected = "Item.name = 'THE REMOTE' AND Location.name = 'the couch'"; $this->assertEquals($expected, $result, 'Mapped method was lowercased.'); }
/** * testBehaviorMethodDispatching method * * @access public * @return void */ function testBehaviorMethodDispatching() { $Apple = new Apple(); $Apple->Behaviors->attach('Test'); $expected = 'working'; $this->assertEqual($Apple->testMethod(), $expected); $this->assertEqual($Apple->Behaviors->dispatchMethod($Apple, 'testMethod'), $expected); $result = $Apple->Behaviors->dispatchMethod($Apple, 'wtf'); $this->assertEqual($result, array('unhandled')); $result = $Apple->{'look for the remote'}('in the couch'); $expected = "Item.name = 'the remote' AND Location.name = 'the couch'"; $this->assertEqual($result, $expected); }