예제 #1
0
 /**
  * test hasMethod returning a 'callback'
  *
  * @return void
  */
 public function testHasMethodAsCallback()
 {
     new Sample();
     $Collection = new BehaviorCollection();
     $Collection->init('Sample', array('Test', 'Test2'));
     $result = $Collection->hasMethod('testMethod', true);
     $expected = array('Test', 'testMethod');
     $this->assertEquals($expected, $result);
     $result = $Collection->hasMethod('resolveMethod', true);
     $expected = array('Test2', 'resolveMethod');
     $this->assertEquals($expected, $result);
     $result = $Collection->hasMethod('mappingRobotOnTheRoof', true);
     $expected = array('Test2', 'mapped', 'mappingRobotOnTheRoof');
     $this->assertEquals($expected, $result);
 }
예제 #2
0
 /**
  * Check that a method is callable on a model.  This will check both the model's own methods, its
  * inherited methods and methods that could be callable through behaviors.
  *
  * @param string $method The method to be called.
  * @return boolean True on method being callable.
  */
 public function hasMethod($method)
 {
     if (method_exists($this, $method)) {
         return true;
     }
     if ($this->Behaviors->hasMethod($method)) {
         return true;
     }
     return false;
 }
예제 #3
0
 /**
  * Check that a method is callable on a model. This will check both the model's own methods, its
  * inherited methods and methods that could be callable through behaviors.
  *
  * @param string $method The method to be called.
  *
  * @return bool True on method being callable.
  */
 public function hasMethod($method)
 {
     if (method_exists($this, $method)) {
         return TRUE;
     }
     return $this->Behaviors->hasMethod($method);
 }