public function testUrlGeneration() { $file = current($this->testPaths); $baseUrl = Shopware()->Container()->get('router')->assemble(['controller' => 'index', 'module' => 'frontend']); $mediaUrl = $baseUrl . $this->mediaService->encode($file); $this->assertEquals($mediaUrl, $this->mediaService->getUrl($file)); $this->assertNull($this->mediaService->getUrl('')); }
/** * @param MediaServiceInterface $toFileSystem * @param string $path * @param resource $contents * @return boolean */ private function writeStream(MediaServiceInterface $toFileSystem, $path, $contents) { $path = $toFileSystem->encode($path); $dirString = ''; $dirs = explode('/', dirname($path)); foreach ($dirs as $dir) { $dirString .= '/' . $dir; $toFileSystem->createDir($dirString); } $toFileSystem->writeStream($path, $contents); return $toFileSystem->has($path); }