/**
  * 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;
 }
Example #2
0
 /**
  * Sets the directory to save mock unit tests in
  *
  * @param   string $unitTestWriteDir
  */
 public function setUnitTestWriteDir($unitTestWriteDir)
 {
     DirectoryWorker::validateWriteDir($unitTestWriteDir);
     $this->unitTestWriteDir = $unitTestWriteDir;
 }
 public function test_getFilesFromReadDirs_withMultipleDirectories()
 {
     $dirsArr = array($this->entitiesDir, $this->entitiesDir . 'SubEntities');
     $actual = DirectoryWorker::getFilesFromReadDirs($dirsArr);
     $this->assertEquals(9, count($actual));
 }
 /**
  * Gathers all files found in read directories
  *
  * @param   ConfigData $config
  * @return  array
  */
 private function findAllTargetFiles(ConfigData $config)
 {
     return DirectoryWorker::getFilesFromReadDirs($config->getReadDirectories(), $config->getRecursiveRead());
 }