Ejemplo n.º 1
0
 /**
  * Implementation of __call method functionality that can be used from a test case
  *
  * @param string                     $method
  * @param array                      $args
  *
  * @throws ErrorException
  * @return bool
  */
 public static function call($method, $args)
 {
     if (TestHelper::has($method)) {
         return TestHelper::invokeArgs($method, $args);
     }
     if (version_compare(PHP_VERSION, '5.4', '>=')) {
         $backTraceCalls = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 3);
     } else {
         // We cannot limit number of arguments on php before 5.4, php rises an exception :(
         $backTraceCalls = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT);
     }
     $previousCall = $backTraceCalls[2];
     throw new ErrorException(sprintf('Call to undefined function %s%s%s()', $previousCall['class'], $previousCall['type'], $previousCall['function']), 0, E_USER_ERROR, $previousCall['file'], $previousCall['line']);
 }
Ejemplo n.º 2
0
 /**
  * Tests invoking of helper by action
  *
  */
 public function testInvokeArgs()
 {
     $this->invokeStub();
     $this->assertSame('firstName_one', Helper::invokeArgs('firstName', array('one')));
     $this->assertSame('firstName_one_two', Helper::invokeArgs('firstName', array('one', 'two')));
     $this->assertSame('firstName_one_two_three', Helper::invokeArgs('firstName', array('one', 'two', 'three')));
     $this->setExpectedException('RuntimeException', 'Cannot find a helper for action "unknownName"');
     Helper::invokeArgs('unknownName', array('argument'));
 }