public function test_getClassNameFromFilePath_returnsClassName() { $expected = 'TestEntity'; $path = $this->rootDir . $expected . '.php'; $actual = PathWorker::getClassNameFromFilePath($path); $this->assertEquals($expected, $actual); }
/** * Determines a class's namespace by iterating over a filepath=>namespace conversion * * @param string $filePath Fully qualified target file path * @param string $rootPath Project root path * @return string * @throws MockMakerException */ private function determineClassNamespace($filePath, $rootPath) { $className = PathWorker::getClassNameFromFilePath($filePath); if ($result = $this->checkClassUsingValidNamespacesArray($className)) { return $result; } // not already in our array, so we have to find it the hard way $classPath = PathWorker::convertFilePathToClassPath($filePath, $rootPath); if (!($result = $this->getClassNamespaceFromFilePath($classPath))) { $args = array('class' => $className); throw new MockMakerException(MockMakerErrors::generateMessage(MockMakerErrors::INVALID_CLASS_TYPE, $args)); } $this->addValidNamespaces($result); return $result; }