Пример #1
0
 /**
  * @dataProvider getPathUpToNameProvider
  */
 public function test_getPathUpToName_returnsValidName($expected, $path, $delim)
 {
     $actual = PathWorker::getPathUpToName($path, $delim);
     $this->assertEquals($expected, $actual);
 }
 /**
  * Saves code to a file
  *
  * Does not save if file exists and overwrites are disallowed.
  *
  * @param   string $filePath Fully qualified path to new file
  * @param   string $code     Code to write in file
  * @return  bool
  * @throws  MockMakerException
  */
 protected function writeFile($filePath, $code)
 {
     // ensure that the directory we're attempting to write to exists
     // important for recursive writes!
     $writeDir = PathWorker::getPathUpToName($filePath);
     DirectoryWorker::validateWriteDir($writeDir);
     if (!file_put_contents($filePath, $code)) {
         throw new MockMakerException(MockMakerErrors::generateMessage(MockMakerErrors::DATA_POINT_WORKER_WRITE_ERR, array('file' => $filePath)));
     }
     return true;
 }
Пример #3
0
 /**
  * Recurses over a filepath => namespace converted string in an attempt
  * to find a valid class namespace path
  *
  * @param   string $classPath File path converted to class path
  * @return  string|bool
  */
 private function getClassNamespaceFromFilePath($classPath)
 {
     if (!class_exists($classPath)) {
         if (($pos = strpos($classPath, '\\')) === false) {
             return false;
         }
         return $this->getClassNamespaceFromFilePath(substr($classPath, $pos + 1));
     }
     return PathWorker::getPathUpToName($classPath, '\\');
 }