public function testGetDirectoryWrite() { /** @var \Magento\Framework\Filesystem\Directory\WriteInterface $dirWriteMock */ $dirWriteMock = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\WriteInterface'); $this->_dirWriteFactoryMock->expects($this->once())->method('create')->will($this->returnValue($dirWriteMock)); $this->assertEquals($dirWriteMock, $this->_filesystem->getDirectoryWrite(DirectoryList::ROOT)); }
protected function setUp() { $this->filesystem = $this->getMock('Magento\\Framework\\Filesystem', [], [], '', false); $this->materializationStrategyFactory = $this->getMock('Magento\\Framework\\App\\View\\Asset\\MaterializationStrategy\\Factory', [], [], '', false); $this->writeFactory = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\WriteFactory', [], [], '', false); $this->object = new Publisher($this->filesystem, $this->materializationStrategyFactory, $this->writeFactory); $this->sourceDirWrite = $this->getMockForAbstractClass('Magento\\Framework\\Filesystem\\Directory\\WriteInterface'); $this->staticDirRead = $this->getMockForAbstractClass('Magento\\Framework\\Filesystem\\Directory\\ReadInterface'); $this->staticDirWrite = $this->getMockForAbstractClass('Magento\\Framework\\Filesystem\\Directory\\WriteInterface'); $this->filesystem->expects($this->any())->method('getDirectoryRead')->with(DirectoryList::STATIC_VIEW)->will($this->returnValue($this->staticDirRead)); $this->filesystem->expects($this->any())->method('getDirectoryWrite')->will($this->returnValue($this->staticDirWrite)); $this->writeFactory->expects($this->any())->method('create')->willReturn($this->sourceDirWrite); }
public function testLaunchWithException() { $writer = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\WriteInterface'); $writer->expects($this->any())->method('isDirectory')->will($this->returnValue(false)); $writer->expects($this->any())->method('create')->will($this->returnValue(true)); $this->writeFactory->expects($this->any())->method('create')->will($this->returnValue($writer)); $shell = $this->getMock('\\Migration\\App\\Shell', ['run'], [], '', false); $shell->expects($this->any())->method('run')->willThrowException(new \Exception('error')); $this->shellFactory->expects($this->any())->method('create')->will($this->returnValue($shell)); ob_start(); $this->migration->launch(); $error = ob_get_clean(); $this->assertEquals('error', $error); }