/** * Returns the methods of the target class. If no constructor exists in the target class, * it will nonetheless be added to the list of methods. * * @param string $targetClassName Name of the target class * @return array Method information with declaring class and method name pairs * @author Robert Lemke <*****@*****.**> */ protected function getMethodsFromTargetClass($targetClassName) { $methods = array(); $existingMethodNames = $this->reflectionService->getClassMethodNames($targetClassName); if (array_search('__construct', $existingMethodNames) === FALSE) { $methods[] = array(NULL, '__construct'); } foreach ($existingMethodNames as $methodName) { $methods[] = array($targetClassName, $methodName); } return $methods; }
/** * @test * @author Robert Lemke <*****@*****.**> */ public function getClassMethodNamesReturnsNamesOfAllMethodsOfAClass() { $availableClassNames = array('F3\\FLOW3\\Tests\\Reflection\\Fixture\\DummyClass', 'F3\\FLOW3\\Tests\\Reflection\\Fixture\\DummyClassWithMethods'); $reflectionService = new \F3\FLOW3\Reflection\ReflectionService(); $reflectionService->setStatusCache($this->getMock('F3\\FLOW3\\Cache\\Frontend\\StringFrontend', array(), array(), '', FALSE)); $reflectionService->setDataCache($this->getMock('F3\\FLOW3\\Cache\\Frontend\\VariableFrontend', array(), array(), '', FALSE)); $reflectionService->injectSystemLogger($this->getMock('F3\\FLOW3\\Log\\SystemLoggerInterface')); $reflectionService->initialize($availableClassNames); $expectedMethodNames = array('firstMethod', 'secondMethod'); $detectedMethodNames = $reflectionService->getClassMethodNames('F3\\FLOW3\\Tests\\Reflection\\Fixture\\DummyClassWithMethods'); $this->assertEquals($expectedMethodNames, $detectedMethodNames); }