public function testSetBasePath() { $url = '/~/jone/assets'; $expected = trim($url, '/') . '/'; $result = $this->object->setBasePath($url); $this->assertNull($result); $this->assertEquals($expected, $this->object->getBasePath()); }
/** * Get strategy to setup assets for given $renderer. * * @param \Zend\View\Renderer\RendererInterface $renderer * @throws Exception\DomainException * @throws Exception\InvalidArgumentException * @return \AsseticBundle\View\StrategyInterface|null */ public function getStrategyForRenderer(Renderer $renderer) { if (!$this->hasStrategyForRenderer($renderer)) { return null; } $rendererName = $this->getRendererName($renderer); if (!isset($this->strategy[$rendererName])) { $strategyClass = $this->configuration->getStrategyNameForRenderer($rendererName); if (!class_exists($strategyClass, true)) { throw new Exception\InvalidArgumentException(sprintf('strategy class "%s" dosen\'t exists', $strategyClass)); } $instance = new $strategyClass(); if (!$instance instanceof StrategyInterface) { throw new Exception\DomainException(sprintf('strategy class "%s" is not instanceof "AsseticBundle\\View\\StrategyInterface"', $strategyClass)); } $this->strategy[$rendererName] = $instance; } /** @var $strategy \AsseticBundle\View\StrategyInterface */ $strategy = $this->strategy[$rendererName]; $strategy->setBaseUrl($this->configuration->getBaseUrl()); $strategy->setBasePath($this->configuration->getBasePath()); $strategy->setDebug($this->configuration->isDebug()); $strategy->setCombine($this->configuration->isCombine()); $strategy->setRenderer($renderer); return $strategy; }