/** * @return void */ public function testCreateArbitrary() { $contextMock = $this->getMockBuilder('Magento\\Framework\\View\\Asset\\ContextInterface')->disableOriginalConstructor()->getMock(); $this->contextFactoryMock->expects($this->once())->method('create')->with(['baseUrl' => '', 'baseDirType' => 'dirType', 'contextPath' => 'dir/path'])->willReturn($contextMock); $assetMock = $this->getMockBuilder('Magento\\Framework\\View\\Asset\\File')->disableOriginalConstructor()->getMock(); $this->fileFactoryMock->expects($this->once())->method('create')->with(['source' => $this->sourceMock, 'context' => $contextMock, 'filePath' => 'test/file.js', 'module' => '', 'contentType' => ''])->willReturn($assetMock); $this->assertEquals($assetMock, $this->repository->createArbitrary('test/file.js', 'dir/path', 'dirType', 'static')); }
/** * Get a file context value object * * Same instance per set of parameters * * @param string $baseDirType * @param string $urlType * @param string $dirPath * @return \Magento\Framework\View\Asset\File\Context */ private function getFileContext($baseDirType, $urlType, $dirPath) { $id = implode('|', [$baseDirType, $urlType, $dirPath]); if (!isset($this->fileContext[$id])) { $url = $this->baseUrl->getBaseUrl(['_type' => $urlType]); $this->fileContext[$id] = $this->contextFactory->create(['baseUrl' => $url, 'baseDirType' => $baseDirType, 'contextPath' => $dirPath]); } return $this->fileContext[$id]; }