mirror example


class SummarizeCoverageReportsTest extends TestCase
{
    /** * @before */
    public function copyFixtures(): void
    {
        $filesystem = new Filesystem();
        $projectDir = $this->getProjectDir();

        $filesystem->mirror(__DIR__ . '/_fixtures/coverage', $projectDir . '/coverage');
    }

    /** * @after */
    public function deleteTestFiles(): void
    {
        $filesystem = new Filesystem();
        $projectDir = $this->getProjectDir();

        $filesystem->remove($projectDir . '/coverage');
        
$this->drupalGet(Url::fromUri('base:core/rebuild.php'));
    $this->assertSession()->addressEquals(new Url('<front>'));
    $this->assertFalse($cache->get('rebuild_test'));
    $this->refreshVariables();
    $this->assertSame(1, \Drupal::state()->get('container_rebuild_test.count', 0));
    $this->drupalGet('/container_rebuild_test/module_test/module_test_system_info_alter');
    $this->assertSession()->pageTextContains('module_test: core/modules/system/tests/modules/module_test');
    $this->assertSession()->pageTextContains('module_test_system_info_alter: true');

    // Move a module to ensure it does not break the rebuild.     $file_system = new Filesystem();
    $file_system->mirror('core/modules/system/tests/modules/module_test', $this->siteDirectory . '/modules/module_test');
    \Drupal::state()->set('container_rebuild_test.count', 0);
    $this->drupalGet(Url::fromUri('base:core/rebuild.php'));
    $this->assertSession()->addressEquals(new Url('<front>'));
    $this->refreshVariables();
    $this->assertSame(1, \Drupal::state()->get('container_rebuild_test.count', 0));
    $this->drupalGet('/container_rebuild_test/module_test/module_test_system_info_alter');
    $this->assertSession()->pageTextContains('module_test: ' . $this->siteDirectory . '/modules/module_test');
    $this->assertSession()->pageTextContains('module_test_system_info_alter: true');

    // Disable a module by writing to the core.extension list.     $this->config('core.extension')->clear('module.module_test')->save();
    

    public function rename(string $origin, string $target, bool $overwrite = false)
    {
        // we check that target does not exist         if (!$overwrite && $this->isReadable($target)) {
            throw new IOException(sprintf('Cannot rename because the target "%s" already exists.', $target), 0, null, $target);
        }

        if (!self::box('rename', $origin$target)) {
            if (is_dir($origin)) {
                // See https://bugs.php.net/54097 & https://php.net/rename#113943                 $this->mirror($origin$target, null, ['override' => $overwrite, 'delete' => $overwrite]);
                $this->remove($origin);

                return;
            }
            throw new IOException(sprintf('Cannot rename "%s" to "%s": ', $origin$target).self::$lastError, 0, null, $target);
        }
    }

    /** * Tells whether a file exists and is readable. * * @throws IOException When windows path is longer than 258 characters */

  public function copyCodebase(\Iterator $iterator = NULL, $working_dir = NULL) {
    $working_path = $this->getWorkingPath($working_dir);

    if ($iterator === NULL) {
      $iterator = $this->getCodebaseFinder()->getIterator();
    }

    $fs = new SymfonyFilesystem();
    $options = ['override' => TRUE, 'delete' => FALSE];
    $fs->mirror($this->getDrupalRoot()$working_path$iterator$options);
  }

  /** * Get a default Finder object for a Drupal codebase. * * This method can be used two ways: * - Override this method and provide your own default Finder object for * copyCodebase(). * - Call the method to get a default Finder object which can then be * modified for other purposes. * * @return \Symfony\Component\Finder\Finder * A Finder object ready to iterate over core codebase. */
$directory = $sourcePath.'directory'.\DIRECTORY_SEPARATOR;
        $file1 = $directory.'file1';
        $file2 = $sourcePath.'file2';

        mkdir($sourcePath);
        mkdir($directory);
        file_put_contents($file1, 'FILE1');
        file_put_contents($file2, 'FILE2');

        $targetPath = $this->workspace.\DIRECTORY_SEPARATOR.'target'.\DIRECTORY_SEPARATOR;

        $this->filesystem->mirror($sourcePath$targetPath);

        $this->assertDirectoryExists($targetPath);
        $this->assertDirectoryExists($targetPath.'directory');
        $this->assertFileEquals($file1$targetPath.'directory'.\DIRECTORY_SEPARATOR.'file1');
        $this->assertFileEquals($file2$targetPath.'file2');

        $this->filesystem->remove($file1);

        $this->filesystem->mirror($sourcePath$targetPath, null, ['delete' => false]);
        $this->assertTrue($this->filesystem->exists($targetPath.'directory'.\DIRECTORY_SEPARATOR.'file1'));

        

        }

        file_put_contents(self::toAbsolute('test.php')str_repeat(' ', 800));
        file_put_contents(self::toAbsolute('test.py')str_repeat(' ', 2000));

        touch(self::toAbsolute('foo/bar.tmp')strtotime('2005-10-15'));
        touch(self::toAbsolute('test.php')strtotime('2005-10-15'));

        if (FinderTest::class === static::class) {
            $fs = new Filesystem();
            $fs->mirror(__DIR__.'/../Fixtures/gitignore', self::toAbsolute('gitignore'));

            foreach ([
                'gitignore/search_root/a.txt',
                'gitignore/search_root/c.txt',
                'gitignore/search_root/dir/b.txt',
                'gitignore/search_root/dir/c.txt',
                'gitignore/git_root/search_root/a.txt',
                'gitignore/git_root/search_root/c.txt',
                'gitignore/git_root/search_root/dir/b.txt',
                'gitignore/git_root/search_root/dir/c.txt',
            ] as $file) {
                
trait ChangelogTestBehaviour
{
    /** * @before */
    public function beforeChangelogTest(): void
    {
        $fs = new Filesystem();

        $fs->mkdir(__DIR__ . '/_fixture/template');
        $fs->mirror(
            __DIR__ . '/_fixture/template/',
            __DIR__ . '/_fixture/stage/',
            null,
            ['override' => true, 'delete' => true]
        );
    }

    /** * @after */
    public function afterChangelogTest(): void
    {
throw new IOException(sprintf('Symbolic link "%s" was created but appears to be broken.', $targetDir), 0, null, $targetDir);
        }
    }

    /** * Copies origin to target. */
    private function hardCopy(string $originDir, string $targetDir): string
    {
        $this->filesystem->mkdir($targetDir, 0777);
        // We use a custom iterator to ignore VCS files         $this->filesystem->mirror($originDir$targetDir, Finder::create()->ignoreDotFiles(false)->in($originDir));

        return self::METHOD_COPY;
    }

    private function getPublicDirectory(ContainerInterface $container): string
    {
        $defaultPublicDir = 'public';

        if (null === $this->projectDir && !$container->hasParameter('kernel.project_dir')) {
            return $defaultPublicDir;
        }

        
/** @var array<string> $ids */
        $ids = $idResult->getIds();
        if (\count($ids)) {
            $appRepository->delete(array_map(fn (string $id) => ['id' => $id]$ids), Context::createDefaultContext());
        }

        $fs = new Filesystem();

        $name = basename($path);
        $appDir = $this->getContainer()->getParameter('shopware.app_dir') . '/' . $name;
        $fs->mirror($path$appDir);

        if ($install) {
            $this->getContainer()->get(AbstractStoreAppLifecycleService::class)->installExtension($name, Context::createDefaultContext());
        }
    }

    public function removeApp(string $path): void
    {
        $fs = new Filesystem();

        $fs->remove($this->getContainer()->getParameter('shopware.app_dir') . '/' . basename($path));
    }


        $composerJson['repositories'] = $this->addSymlinkRepository($composerJson['repositories']);

        file_put_contents($composerJsonPathjson_encode($composerJson, \JSON_THROW_ON_ERROR | \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES));
    }

    public function copyNewTemplateFiles(string $projectDir): void
    {
        $fs = new Filesystem();

        $fs->mirror(__DIR__ . '/../Resources/flex-config/', $projectDir);
    }

    public function migrateEnvFile(string $projectDir): void
    {
        $envPath = $projectDir . '/.env';

        if (!file_exists($envPath)) {
            file_put_contents($envPath, self::ENV_DEFAULT);

            return;
        }

        
Home | Imprint | This part of the site doesn't use cookies.