/** * @return void */ public function testGetUrl() { $themeMock = $this->getMock('Magento\\Framework\\View\\Design\\ThemeInterface', [], [], '', false); $this->designMock->expects($this->any())->method('getDesignParams')->willReturn(['themeModel' => $themeMock, 'area' => 'area', 'locale' => 'locale']); $assetMock = $this->getMockBuilder('Magento\\Framework\\View\\Asset\\File')->disableOriginalConstructor()->getMock(); $assetMock->expects($this->any())->method('getUrl')->willReturn('some url'); $this->fileFactoryMock->expects($this->exactly(2))->method('create')->with(['source' => $this->sourceMock, 'context' => '', 'filePath' => 'test/file.js', 'module' => '', 'contentType' => ''])->willReturn($assetMock); $this->assertEquals('some url', $this->repository->getUrl('test/file.js')); $this->assertEquals('some url', $this->repository->getUrlWithParams('test/file.js', [])); }
/** * Create a file asset with an arbitrary path * * This kind of file is not subject of fallback system * Client code is responsible for ensuring that the file is in specified directory * * @param string $filePath * @param string $dirPath * @param string $baseDirType * @param string $baseUrlType * @return File */ public function createArbitrary($filePath, $dirPath, $baseDirType = DirectoryList::STATIC_VIEW, $baseUrlType = UrlInterface::URL_TYPE_STATIC) { $context = $this->getFileContext($baseDirType, $baseUrlType, $dirPath); $contentType = $this->assetSource->getContentType($filePath); return $this->fileFactory->create(['source' => $this->assetSource, 'context' => $context, 'filePath' => $filePath, 'module' => '', 'contentType' => $contentType]); }