/** * 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']); }
/** * Tests method for checking action existence in the helper * */ public function testHas() { $helpers = $this->getHelpersForTest(1, true); // Should be used for firstName $helpers[0]->expects($this->any())->method('has')->will($this->returnValueMap(array(array('firstName', true), array('secondName', true)))); $this->assertTrue(Helper::has('firstName')); $this->assertTrue(Helper::has('secondName')); $this->assertFalse(Helper::has('unknownName')); }