Ejemplo n.º 1
0
    public function testCleanPackages()
    {
        $args = self::$cleanCommand->parseArgs(new StringArgs(''));
        // The not-found package
        $this->packageManager->expects($this->once())->method('removePackage')->with('vendor/package3');
        $expected = <<<EOF
Removing vendor/package3

EOF;
        $this->assertSame(0, $this->handler->handleClean($args, $this->io));
        $this->assertSame($expected, $this->io->fetchOutput());
        $this->assertEmpty($this->io->fetchErrors());
    }
Ejemplo n.º 2
0
 protected function setUp()
 {
     $this->environment = $this->getMockBuilder('Puli\\Manager\\Api\\Environment\\ProjectEnvironment')->disableOriginalConstructor()->getMock();
     $this->dispatcher = $this->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
     $this->puli = $this->getMock('Puli\\Manager\\Api\\Puli');
     $this->rootPackageFileManager = $this->getMock('Puli\\Manager\\Api\\Package\\RootPackageFileManager');
     $this->repo = $this->getMock('Puli\\Repository\\Api\\ResourceRepository');
     $this->discovery = $this->getMock('Puli\\Discovery\\Api\\ResourceDiscovery');
     $this->discoveryManager = $this->getMock('Puli\\Manager\\Api\\Discovery\\DiscoveryManager');
     $this->packageManager = $this->getMock('Puli\\Manager\\Api\\Package\\PackageManager');
     $this->plugin = new AssetPlugin();
     $this->puli->expects($this->any())->method('getEnvironment')->willReturn($this->environment);
     $this->puli->expects($this->any())->method('getEventDispatcher')->willReturn($this->dispatcher);
     $this->puli->expects($this->any())->method('getRootPackageFileManager')->willReturn($this->rootPackageFileManager);
     $this->puli->expects($this->any())->method('getRepository')->willReturn($this->repo);
     $this->puli->expects($this->any())->method('getDiscovery')->willReturn($this->discovery);
     $this->puli->expects($this->any())->method('getDiscoveryManager')->willReturn($this->discoveryManager);
     $this->puli->expects($this->any())->method('getPackageManager')->willReturn($this->packageManager);
     $this->packageManager->expects($this->any())->method('getPackages')->willReturn(new PackageCollection());
 }
Ejemplo n.º 3
0
 /**
  * Prints not-loadable packages in a table.
  *
  * @param IO        $io       The I/O.
  * @param Package[] $packages The not-loadable packages.
  * @param bool      $indent   Whether to indent the output.
  */
 private function printNotLoadablePackages(IO $io, array $packages, $indent = false)
 {
     $rootDir = $this->packageManager->getEnvironment()->getRootDirectory();
     $table = new Table(TableStyle::borderless());
     ksort($packages);
     foreach ($packages as $package) {
         $packageName = $package->getName();
         $loadErrors = $package->getLoadErrors();
         $errorMessage = '';
         foreach ($loadErrors as $loadError) {
             $errorMessage .= StringUtil::getShortClassName(get_class($loadError)) . ': ' . $loadError->getMessage() . "\n";
         }
         $errorMessage = rtrim($errorMessage);
         if (!$errorMessage) {
             $errorMessage = 'Unknown error.';
         }
         // Remove root directory
         $errorMessage = str_replace($rootDir . '/', '', $errorMessage);
         $table->addRow(array("<bad>{$packageName}</bad>:", "<bad>{$errorMessage}</bad>"));
     }
     $table->render($io, $indent ? 4 : 0);
 }