示例#1
0
    public function testRunonceCreateFiredBeforeRunonceExecuted()
    {
        RunonceManager::clearRunonces();
        $array = var_export(array('composer/vendor/unit/test/runonce1.php'), true);
        $testData = <<<EOF
<?php

\$executor = new \\ContaoCommunityAlliance\\Composer\\Plugin\\RunonceExecutor();
\$executor->run({$array});

EOF;
        file_put_contents($this->rootDir . '/system/runonce.php', $testData);
        RunonceManager::addRunonce('composer/vendor/unit/test/runonce1.php');
        RunonceManager::addRunonce('composer/vendor/unit/test/runonce2.php');
        RunonceManager::createRunonce($this->io, $this->rootDir);
        $this->assertFileExists($this->rootDir . '/system/runonce.php', 'Runonce does not exist.');
        $this->assertFileExists($this->rootDir . '/system/runonce_1.php', 'Secondary runonce does not exist.');
        $file1 = file_get_contents($this->rootDir . '/system/runonce.php');
        $file2 = file_get_contents($this->rootDir . '/system/runonce_1.php');
        $this->assertEquals($testData, $file2, 'Test runonce should have been moved to runonce_1.php');
        $this->assertContains('system/runonce_1.php', $file1, 'Previous runonce has not been added.');
        $this->assertContains('composer/vendor/unit/test/runonce2.php', $file1, 'runonce2 from module has not been added.');
        $this->assertNotContains('composer/vendor/unit/test/runonce1.php', $file1, 'runonce1 is also mentioned in new runonce.php');
    }
示例#2
0
 /**
  * Create the spec list for legacy packages.
  *
  * @param string           $installPath The installation path.
  *
  * @param string           $startPath   The destination path.
  *
  * @param string           $currentPath The current working directory.
  *
  * @param array            $sources     The sources list.
  *
  * @param PackageInterface $package     The package being examined.
  *
  * @return void
  */
 protected function createLegacySourcesSpec($installPath, $startPath, $currentPath, &$sources, PackageInterface $package)
 {
     $sourcePath = self::unprefixPath($installPath . DIRECTORY_SEPARATOR, $currentPath);
     $targetPath = self::unprefixPath($startPath . DIRECTORY_SEPARATOR, $currentPath);
     if (self::getNativePath($targetPath, '/') == 'system/runonce.php') {
         $path = self::unprefixPath($this->plugin->getContaoRoot($this->composer->getPackage()), $currentPath);
         RunonceManager::addRunonce($path);
     } elseif (is_file($currentPath) || preg_match('#^system/modules/[^/]+$#', self::getNativePath($targetPath, '/'))) {
         $sources[$sourcePath] = $targetPath;
     } elseif (is_dir($currentPath)) {
         $files = new \FilesystemIterator($currentPath, \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::UNIX_PATHS | \FilesystemIterator::CURRENT_AS_PATHNAME);
         foreach ($files as $file) {
             $this->createLegacySourcesSpec($installPath, $startPath, $file, $sources, $package);
         }
     }
 }