copyAll() public méthode

Copy all files and folders between directories.
public copyAll ( string $source, string $destination, array $skip = ['.git', '.DS_Store'], boolean $override = false )
$source string
$destination string
$skip array
$override boolean
 /**
  * Test FilesystemHelper::copy().
  */
 public function testCopy()
 {
     $source = $this->tempDir(true);
     $destination = $this->tempDir();
     // Copy files.
     $this->filesystemHelper->copyAll($source, $destination);
     // Check that they have been copied.
     $this->assertFileExists($destination . '/test-file');
     $this->assertFileExists($destination . '/test-dir/test-file');
 }
 /**
  * Copy, or symlink, files from the app root to the build directory.
  *
  * @return string
  *   The absolute path to the build directory where files have been copied.
  */
 protected function copyToBuildDir()
 {
     $this->buildInPlace = true;
     $buildDir = $this->buildDir;
     if ($this->app->shouldMoveToRoot()) {
         $buildDir .= '/' . $this->documentRoot;
     }
     if (!empty($this->settings['clone'])) {
         $this->cloneToBuildDir($buildDir);
     } elseif ($this->copy) {
         $this->fsHelper->copyAll($this->appRoot, $buildDir, $this->ignoredFiles, true);
     } else {
         $this->fsHelper->symlink($this->appRoot, $buildDir);
     }
     return $buildDir;
 }
 public function testDoNotSymlinkBuildsIntoSitesDefault()
 {
     $tempDir = self::$root->getName();
     $repository = tempnam($tempDir, '');
     unlink($repository);
     mkdir($repository);
     $fsHelper = new FilesystemHelper();
     $sourceDir = 'tests/data/apps/drupal/project';
     $fsHelper->copyAll($sourceDir, $repository);
     $wwwDir = $repository . '/www';
     // Run these tests twice to check that a previous build does not affect
     // the next one.
     for ($i = 1; $i <= 2; $i++) {
         $this->assertTrue($this->builder->build($repository, $wwwDir));
         $this->assertFileExists($wwwDir . '/sites/default/settings.php');
         $this->assertFileNotExists($wwwDir . '/sites/default/builds');
         $this->assertFileNotExists($wwwDir . '/sites/default/www');
     }
 }
 /**
  * @param string $sourceDir
  *
  * @return string
  */
 protected function createDummyProject($sourceDir)
 {
     if (!is_dir($sourceDir)) {
         throw new \InvalidArgumentException("Not a directory: {$sourceDir}");
     }
     $projectRoot = $this->createTempSubDir('project');
     // Set up the project.
     $fsHelper = new FilesystemHelper();
     $fsHelper->copyAll($sourceDir, $projectRoot);
     // @todo perhaps make some of these steps unnecessary
     $local = new LocalProject();
     $cwd = getcwd();
     chdir($projectRoot);
     exec('git init');
     chdir($cwd);
     $local->ensureGitRemote($projectRoot, 'testProjectId');
     $local->writeCurrentProjectConfig(['id' => 'testProjectId'], $projectRoot);
     return $projectRoot;
 }
 /**
  * @param string $sourceDir
  *
  * @return string
  */
 protected function createDummyProject($sourceDir)
 {
     if (!is_dir($sourceDir)) {
         throw new \InvalidArgumentException("Not a directory: {$sourceDir}");
     }
     $tempDir = self::$root->getName();
     $projectRoot = tempnam($tempDir, '');
     unlink($projectRoot);
     mkdir($projectRoot);
     // Set up the project files.
     $local = new LocalProject();
     $local->createProjectFiles($projectRoot, 'testProjectId');
     // Make a dummy repository.
     $repositoryDir = $projectRoot . '/' . LocalProject::REPOSITORY_DIR;
     mkdir($repositoryDir);
     $fsHelper = new FilesystemHelper();
     $fsHelper->copyAll($sourceDir, $repositoryDir);
     return $projectRoot;
 }
 /**
  * Test with a custom source and destination.
  */
 public function testBuildCustomSourceDestination()
 {
     // Copy the 'vanilla' app to a temporary directory.
     $sourceDir = $this->createTempSubDir();
     $fsHelper = new FilesystemHelper();
     $fsHelper->copyAll('tests/data/apps/vanilla', $sourceDir);
     // Create another temporary directory.
     $destination = $this->createTempSubDir();
     // Test with symlinking.
     $builder = new LocalBuild(['abslinks' => true], null, self::$output);
     $builder->build($sourceDir, $destination);
     $this->assertFileExists($destination . '/index.html');
     // Test with copying.
     $builder = new LocalBuild(['copy' => true, 'abslinks' => true], null, self::$output);
     $builder->build($sourceDir, $destination);
     $this->assertFileExists($destination . '/index.html');
     // Remove the temporary files.
     exec('rm -R ' . escapeshellarg($destination) . ' ' . escapeshellarg($sourceDir));
 }
 public function testCreateAliasesMultiDrupal()
 {
     // Set up file structure.
     $testDir = $this->createTempSubDir();
     $fsHelper = new FilesystemHelper();
     $fsHelper->copyAll(__DIR__ . '/../data/repositories/multi-drupal', $testDir . '/project/repository');
     $projectRoot = $testDir . '/project';
     $homeDir = "{$testDir}/home";
     mkdir($homeDir);
     // Check that aliases are created.
     $this->drushHelper->setHomeDir($homeDir);
     $this->drushHelper->createAliases($this->project, $projectRoot, $this->environments);
     $this->assertFileExists("{$homeDir}/.drush/test.aliases.drushrc.php");
     // Check that aliases exist for the 'master' and local environments.
     $aliases = [];
     include_once "{$homeDir}/.drush/test.aliases.drushrc.php";
     $this->assertArrayHasKey('master--drupal1', $aliases);
     $this->assertArrayHasKey('_local--drupal1', $aliases);
     $this->assertArrayHasKey('master--drupal2', $aliases);
     $this->assertArrayHasKey('_local--drupal2', $aliases);
 }