function __call($func, $args)
 {
     if (isset(self::$aliased_methods[$func])) {
         $method = self::$aliased_methods[$func];
         return call_user_func_array(array($this, $method), $args);
     } else {
         if (self::$alias_call_parent__call) {
             parent::__call($func, $args);
         } else {
             trigger_error('No such function: ' . get_class($this) . "::{$func}");
         }
     }
 }
 /**
  * PHP magic method.
  * This method is overridden so that named fixture ActiveRecord instances can be accessed in terms of a method call.
  * @param string $name method name
  * @param string $params method parameters
  * @return mixed the property value
  */
 public function __call($name, $params)
 {
     if (is_array($this->fixtures) && isset($params[0]) && ($record = $this->getFixtureManager()->getRecord($name, $params[0])) !== false) {
         return $record;
     } elseif (method_exists($this->webdriver, $name)) {
         return call_user_func_array(array($this->webdriver, $name), $params);
     } else {
         return parent::__call($name, $params);
     }
 }
예제 #3
0
 /**
  * This overload is useful to create a stub, that need to have a specific method.
  */
 public function __call($method, $args)
 {
     if ($this->{$method} instanceof Closure) {
         return call_user_func_array($this->{$method}, $args);
     } else {
         return parent::__call($method, $args);
     }
 }
 /**
  * NOTE: Makes calling any PHPUnit assertXXX magically pass thru our controller pre-processor with the following suffixes:
  * - TemplateVar        => Looks up the variable in the page template. Pass a templateVar name as the "expected" param
  * - SharedInstance     => Looks up the SharedInstance.keyPath. Pass 2 args (SharedInstance, KeyPath) in place of the "expected" param
  *
  * @method PhocoaControllerTestCase_PHPUnit::assertEqualsFromTemplateVar($expectedVal, $actualFromTemplateVarName, $msg)
  * @method PhocoaControllerTestCase_PHPUnit::assertEqualsFromSharedInstance($expectedVal, $actualSharedInstanceName, $actualSharedInstanceKeyPath, $msg)
  * @method PhocoaControllerTestCase_PHPUnit::assertRegExpFromPageOutput($expectedVal, $regex, $msg)
  * @method PhocoaControllerTestCase_PHPUnit::assertEqualsFromResponseTemplate($expectedVal, $templateFileName, $msg)
  */
 public function __call($method, $args)
 {
     if (preg_match('/^(assert.+)From(TemplateVar|SharedInstance|PageOutput|ResponseTemplate)$/', $method, $matches)) {
         $assertComparator = $matches[1];
         $varGetterType = $matches[2];
         switch ($varGetterType) {
             case 'TemplateVar':
                 $actualFromTemplateVarName = $args[1];
                 $actual = $this->_getTemplateVar($actualFromTemplateVarName);
                 return call_user_func_array(array($this, $assertComparator), $this->_buildPHPUnitAssertArgs($assertComparator, $args, $actual));
             case 'SharedInstance':
                 $sharedInstanceName = $args[1];
                 $sharedInstanceKeyPath = isset($args[2]) ? $args[2] : NULL;
                 $actual = $this->_getSharedInstanceValue($sharedInstanceName, $sharedInstanceKeyPath);
                 return call_user_func_array(array($this, $assertComparator), $this->_buildPHPUnitAssertArgs($assertComparator, $args, $actual, 2));
             case 'PageOutput':
                 $actual = $this->pageOutput;
                 return call_user_func_array(array($this, $assertComparator), $this->_buildPHPUnitAssertArgs($assertComparator, $args, $actual));
                 break;
             case 'ResponseTemplate':
                 $actual = basename($this->module->responsePage()->template()->template());
                 return call_user_func_array(array($this, $assertComparator), $this->_buildPHPUnitAssertArgs($assertComparator, $args, $actual));
                 break;
         }
     }
     // seems a little odd, dies HERE if parent doesn't define __call, but doesn't matter b/c it dies when an unexpected method is encountered
     return parent::__call($method, $args);
 }