/** * @param string $lazyType * * @dataProvider getConfigLazyLoader */ public function testMissingAssetType($lazyType) { if (null !== $lazyType) { $lp = 'lazy' === $lazyType ? new CompletePackage($this->package->getName(), $this->package->getVersion(), $this->package->getPrettyVersion()) : false; $loader = $this->getMock('Fxp\Composer\AssetPlugin\Package\Loader\LazyLoaderInterface'); $loader ->expects($this->any()) ->method('load') ->will($this->returnValue($lp)); /* @var LazyLoaderInterface$loader */ $this->package->setLoader($loader); } $this->assertSame('library', $this->package->getType()); $this->assertSame(array(), $this->package->getTransportOptions()); $this->assertNull($this->package->getTargetDir()); $this->assertSame(array(), $this->package->getExtra()); $this->assertSame(array(), $this->package->getBinaries()); $this->assertNull($this->package->getInstallationSource()); $this->assertNull($this->package->getSourceType()); $this->assertNull($this->package->getSourceUrl()); $this->assertNull($this->package->getSourceReference()); $this->assertNull($this->package->getSourceMirrors()); $this->assertSame(array(), $this->package->getSourceUrls()); $this->assertNull($this->package->getDistType()); $this->assertNull($this->package->getDistUrl()); $this->assertNull($this->package->getDistReference()); $this->assertNull($this->package->getDistSha1Checksum()); $this->assertNull($this->package->getDistMirrors()); $this->assertSame(array(), $this->package->getDistUrls()); $this->assertNull($this->package->getReleaseDate()); $this->assertSame(array(), $this->package->getRequires()); $this->assertSame(array(), $this->package->getConflicts()); $this->assertSame(array(), $this->package->getProvides()); $this->assertSame(array(), $this->package->getReplaces()); $this->assertSame(array(), $this->package->getDevRequires()); $this->assertSame(array(), $this->package->getSuggests()); $this->assertSame(array(), $this->package->getAutoload()); $this->assertSame(array(), $this->package->getDevAutoload()); $this->assertSame(array(), $this->package->getIncludePaths()); $this->assertNull($this->package->getNotificationUrl()); $this->assertSame(array(), $this->package->getArchiveExcludes()); $this->assertSame(array(), $this->package->getScripts()); $this->assertNull($this->package->getRepositories()); $this->assertSame(array(), $this->package->getLicense()); $this->assertNull($this->package->getKeywords()); $this->assertNull($this->package->getAuthors()); $this->assertNull($this->package->getDescription()); $this->assertNull($this->package->getHomepage()); $this->assertSame(array(), $this->package->getSupport()); }
/** * @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()); }
/** * {@inheritDoc} */ public function load(LazyPackageInterface $package) { if (isset($this->cache[$package->getUniqueName()])) { return $this->cache[$package->getUniqueName()]; } $this->validateConfig(); $filename = $this->assetType->getFilename(); $msg = 'Reading ' . $filename . ' of <info>' . $package->getName() . '</info> (<comment>' . $package->getPrettyVersion() . '</comment>)'; if ($this->verbose) { $this->io->write($msg); } else { $this->io->overwrite($msg, false); } $realPackage = $this->loadRealPackage($package); $this->cache[$package->getUniqueName()] = $realPackage; if (!$this->verbose) { $this->io->overwrite('', false); } return $realPackage; }