public function testOnlyReplacePrefix() { $this->targets->add(new InstallTarget('local', 'symlink', 'public_html')); $binding = new EagerBinding('/path{,/**/*}', $this->resources, $this->bindingType, array(AssetPlugin::TARGET_PARAMETER => 'local', AssetPlugin::PATH_PARAMETER => '/css')); $this->discovery->expects($this->once())->method('findByPath')->with('/path/path/style.css', AssetPlugin::BINDING_TYPE)->willReturn(array($binding)); $this->assertSame('/css/path/style.css', $this->generator->generateUrl('/path/path/style.css')); }
/** * @expectedException \Puli\AssetPlugin\Api\Installation\NotInstallableException * @expectedExceptionMessage Puli\AssetPlugin\Tests\Installation\Fixtures\TestInstallerInvalid * @expectedExceptionCode 8 */ public function testFailIfInstallerClassInvalid() { $resources = new ArrayResourceCollection(array(new GenericResource('/path/css'), new GenericResource('/path/js'))); $installerDescriptor = new InstallerDescriptor('rsync', self::INSTALLER_CLASS_INVALID, null, array(new InstallerParameter('param1', InstallerParameter::REQUIRED), new InstallerParameter('param2', InstallerParameter::OPTIONAL, 'default1'), new InstallerParameter('param3', InstallerParameter::OPTIONAL, 'default2'))); $target = new InstallTarget('server', 'rsync', 'ssh://server/public_html', '/%s', array('param1' => 'custom1', 'param3' => 'custom2')); $mapping = new AssetMapping('/path/{css,js}', 'server', 'assets'); $this->targets->add($target); $this->repo->expects($this->any())->method('find')->with('/path/{css,js}')->willReturn($resources); $this->installerManager->expects($this->any())->method('hasInstallerDescriptor')->with('rsync')->willReturn(true); $this->installerManager->expects($this->any())->method('getInstallerDescriptor')->with('rsync')->willReturn($installerDescriptor); $this->manager->prepareInstallation($mapping); }
private function assertTargetsLoaded() { if (null !== $this->targets) { return; } $targetsData = $this->rootPackageFileManager->getExtraKey(AssetPlugin::INSTALL_TARGETS_KEY); if ($targetsData) { $jsonValidator = new JsonValidator(); $errors = $jsonValidator->validate($targetsData, __DIR__ . '/../../res/schema/install-targets-schema-1.0.json'); if (count($errors) > 0) { throw new ValidationFailedException(sprintf("The extra key \"%s\" is invalid:\n%s", AssetPlugin::INSTALL_TARGETS_KEY, implode("\n", $errors))); } } $this->targets = new InstallTargetCollection(); $this->targetsData = (array) $targetsData; foreach ($this->targetsData as $targetName => $targetData) { $this->targets->add($this->dataToTarget($targetName, $targetData)); if (isset($targetData->default) && $targetData->default) { $this->targets->setDefaultTarget($targetName); } } }
public function testContainsWithDefaultTarget() { $this->assertFalse($this->collection->contains(InstallTarget::DEFAULT_TARGET)); $this->collection->add($this->target1); $this->assertTrue($this->collection->contains(InstallTarget::DEFAULT_TARGET)); }