Ejemplo n.º 1
0
 /**
  * Creates and populates a EntityData object with the basic information it needs
  *
  * @param   string     $file
  * @param   ConfigData $config
  * @return  EntityData
  * @throws  MockMakerException
  */
 private function getBasicEntityInformation($file, ConfigData $config)
 {
     $obj = new EntityData();
     $obj->getFileData()->setFileName(PathWorker::getLastElementInPath($file))->setFileDirectory(PathWorker::getPathUpToName($file) . '/')->setFullFilePath($file);
     $obj->setClassName(PathWorker::getClassNameFromFilePath($file))->setClassNamespace($this->determineClassNamespace($file, $config->getProjectRootPath()))->setReflectionClass($this->createReflectionClass($obj))->setClassType($this->getClassType($obj->getReflectionClass()));
     return $obj;
 }
Ejemplo n.º 2
0
 /**
  * @dataProvider getLastElementProvider
  */
 public function test_getLastElementInPath_returnsCorrectFilename($expected, $path, $delim)
 {
     $actual = PathWorker::getLastElementInPath($path, $delim);
     $this->assertEquals($expected, $actual);
 }
Ejemplo n.º 3
0
 /**
  * Generates a valid mock file namespace using a user-supplied base
  *
  * @param   string $mockPath      Fully qualified file save path of file to be mocked
  * @param   string $baseNamespace User-supplied base namespace
  * @return  string
  */
 private function determineWithBaseNamespace($mockPath, $baseNamespace)
 {
     $modifiedNamespace = $baseNamespace;
     $lastBaseNamespaceDir = PathWorker::getLastElementInPath($baseNamespace, '\\');
     if (($strPos = strpos($mockPath, $lastBaseNamespaceDir)) !== false) {
         $subStr = substr($mockPath, $strPos + strlen($lastBaseNamespaceDir));
         $modifiedNamespace = $baseNamespace . str_replace('/', '\\', $subStr);
     }
     return rtrim($modifiedNamespace, '\\');
 }