public function testListMappingsOfNonExistingDefaultTarget() { $this->targetManager->expects($this->any())->method('hasTarget')->willReturnMap(array(array('local', false), array('remote', false), array(InstallTarget::DEFAULT_TARGET, false))); $this->targetManager->expects($this->never())->method('getTarget'); $this->assetManager->expects($this->once())->method('getAssetMappings')->willReturn(array(new AssetMapping('/app/public', 'local', '/', Uuid::fromString(self::UUID1)), new AssetMapping('/acme/blog/public', 'remote', '/blog', Uuid::fromString(self::UUID2)), new AssetMapping('/acme/profiler/public', 'local', '/profiler', Uuid::fromString(self::UUID3)), new AssetMapping('/acme/admin/public', InstallTarget::DEFAULT_TARGET, '/admin', Uuid::fromString(self::UUID4)))); $args = self::$listCommand->parseArgs(new StringArgs('')); $expected = <<<EOF The following web assets are disabled since their target does not exist. Target local e81b32 /app/public / 49cfdf /acme/profiler/public /profiler Target remote 33dbec /acme/blog/public /blog Target default 8c64be /acme/admin/public /admin Use "puli target add <target> <location>" to add a target. EOF; $this->assertSame(0, $this->handler->handleList($args, $this->io)); $this->assertSame($expected, $this->io->fetchOutput()); $this->assertEmpty($this->io->fetchErrors()); }
public function testGetDefaultTarget() { $target = new InstallTarget('local', 'symlink', 'public_html'); $this->targetManager->expects($this->once())->method('getDefaultTarget')->willReturn($target); $args = self::$getDefaultCommand->parseArgs(new StringArgs('')); $this->assertSame(0, $this->handler->handleGetDefault($args, $this->io)); $this->assertSame("local\n", $this->io->fetchOutput()); $this->assertEmpty($this->io->fetchErrors()); }
public function testAddCreateUrlGeneratorMethodWithoutTargets() { $targets = new InstallTargetCollection(array()); $this->targetManager->expects($this->any())->method('getTargets')->willReturn($targets); $class = new Clazz('Puli\\MyFactory'); $class->addImport(new Import('Puli\\Factory\\PuliFactory')); $class->addImplementedInterface('PuliFactory'); $class->setFilePath($this->tempFile); $this->generator->addCreateUrlGeneratorMethod($class); $writer = new ClassWriter(); $writer->writeClass($class); $expected = <<<EOF <?php namespace Puli; use Puli\\AssetPlugin\\Api\\Factory\\UrlGeneratorFactory; use Puli\\AssetPlugin\\Api\\Target\\InstallTargetCollection; use Puli\\AssetPlugin\\Api\\UrlGenerator\\AssetUrlGenerator; use Puli\\AssetPlugin\\UrlGenerator\\DiscoveryUrlGenerator; use Puli\\Discovery\\Api\\ResourceDiscovery; use Puli\\Factory\\PuliFactory; class MyFactory implements PuliFactory, UrlGeneratorFactory { /** * Creates the URL generator. * * @param ResourceDiscovery \$discovery The resource discovery to read from. * * @return AssetUrlGenerator The created URL generator. */ public function createUrlGenerator(ResourceDiscovery \$discovery) { \$targets = new InstallTargetCollection(); \$generator = new DiscoveryUrlGenerator(\$discovery, \$targets); return \$generator; } } EOF; $this->assertSame($expected, file_get_contents($this->tempFile)); }