/** * Loads the real package. * * @param LazyPackageInterface $package * * @return CompletePackageInterface|false */ protected function loadRealPackage(LazyPackageInterface $package) { $realPackage = false; try { $data = $this->driver->getComposerInformation($this->identifier); $valid = is_array($data); $data = $this->preProcess($this->driver, $this->validateData($data), $this->identifier); if ($this->verbose) { $this->io->write('Importing ' . ($valid ? '' : 'empty ') . $this->type . ' '.$data['version'].' ('.$data['version_normalized'].')'); } /* @var CompletePackageInterface $realPackage */ $realPackage = $this->loader->load($data); } catch (\Exception $e) { if ($this->verbose) { $filename = $this->assetType->getFilename(); $this->io->write('<'.$this->getIoTag().'>Skipped ' . $this->type . ' '.$package->getPrettyVersion().', '.($e instanceof TransportException ? 'no ' . $filename . ' file was found' : $e->getMessage()).'</'.$this->getIoTag().'>'); } } $this->driver->cleanup(); return $realPackage; }
/** * @param string $type * @param bool $verbose * @param string $exceptionClass * @param string $validTrace * * @dataProvider getConfigIoForException */ public function testTagWithTransportException($type, $verbose, $exceptionClass, $validTrace) { /* @var \PHPUnit_Framework_MockObject_MockObject $loader */ $loader = $this->loader; $loader ->expects($this->any()) ->method('load') ->will($this->throwException(new $exceptionClass('MESSAGE'))); $this->lazyLoader = $this->createLazyLoaderConfigured($type, $verbose); $package = $this->lazyLoader->load($this->lazyPackage); $this->assertFalse($package); $filename = $this->assetType->getFilename(); $validOutput = array(''); if ($verbose) { $validOutput = array( 'Reading ' . $filename . ' of <info>' . $this->lazyPackage->getName() . '</info> (<comment>' . $this->lazyPackage->getPrettyVersion() . '</comment>)', 'Importing empty ' . $type . ' ' . $this->lazyPackage->getPrettyVersion() . ' (' . $this->lazyPackage->getVersion() . ')', $validTrace, '', ); } $this->assertSame($validOutput, $this->io->getTraces()); $packageCache = $this->lazyLoader->load($this->lazyPackage); $this->assertFalse($packageCache); $this->assertSame($validOutput, $this->io->getTraces()); }