public function testGetData() { $this->filesystem->expects($this->any())->method('isExists')->will($this->returnValue(true)); $dataSerialized = 'a:1:{s:6:"object";a:1:{s:9:"integrity";b:1;}}'; $this->filesystem->expects($this->once())->method('fileGetContents')->will($this->returnValue($dataSerialized)); $data = $this->file->getData(); $this->assertEquals(['object' => ['integrity' => true]], $data); }
protected function setUp() { $this->dirList = $this->getMock('Magento\\Framework\\App\\Filesystem\\DirectoryList', [], [], '', false); $this->dirList->expects($this->any())->method('getPath')->with(DirectoryList::CONFIG)->willReturn(__DIR__ . '/_files'); $this->fileDriver = $this->getMock('\\Magento\\Framework\\Filesystem\\Driver\\File', [], [], '', false); $this->fileDriver->expects($this->any())->method('isExists')->will($this->returnValueMap([[__DIR__ . '/_files/config.php', true], [__DIR__ . '/_files/custom.php', true], [__DIR__ . '/_files/duplicateConfig.php', true], [__DIR__ . '/_files/env.php', true], [__DIR__ . '/_files/mergeOne.php', true], [__DIR__ . '/_files/mergeTwo.php', true], [__DIR__ . '/_files/nonexistent.php', false]])); $this->driverPool = $this->getMock('\\Magento\\Framework\\Filesystem\\DriverPool', [], [], '', false); $this->driverPool->expects($this->any())->method('getDriver')->willReturn($this->fileDriver); $this->configFilePool = $this->getMock('Magento\\Framework\\Config\\File\\ConfigFilePool', [], [], '', false); $this->configFilePool->expects($this->any())->method('getPaths')->willReturn(['configKeyOne' => 'config.php', 'configKeyTwo' => 'env.php']); }
public function testGetTranslationFileTimestamp() { $path = 'path'; $contextMock = $this->getMockForAbstractClass('\\Magento\\Framework\\View\\Asset\\ContextInterface', [], '', true, true, true, ['getPath']); $this->assetRepoMock->expects($this->atLeastOnce())->method('getStaticViewFileContext')->willReturn($contextMock); $contextMock->expects($this->atLeastOnce())->method('getPath')->willReturn($path); $this->directoryListMock->expects($this->atLeastOnce())->method('getPath')->willReturn($path); $this->driverFileMock->expects($this->once())->method('isExists')->with('path/path/js-translation.json')->willReturn(true); $this->driverFileMock->expects($this->once())->method('stat')->willReturn(['mtime' => 1445736974]); $this->assertEquals(1445736974, $this->model->getTranslationFileTimestamp()); }
public function setUp() { $this->composerJsonFinder = $this->getMock('Magento\\Framework\\Composer\\ComposerJsonFinder', [], [], '', false); $this->composerJsonFinder->expects($this->once())->method('findComposerJson')->willReturn('composer.json'); $this->directoryList = $this->getMock('Magento\\Framework\\App\\Filesystem\\DirectoryList', [], [], '', false); $this->directoryList->expects($this->exactly(2))->method('getPath')->willReturn('var'); $this->reqUpdDryRunCommand = $this->getMock('Magento\\Composer\\RequireUpdateDryRunCommand', [], [], '', false); $this->file = $this->getMock('Magento\\Framework\\Filesystem\\Driver\\File', [], [], '', false); $this->file->expects($this->once())->method('copy')->with('composer.json', 'var/composer.json'); $composerAppFactory = $this->getMock('Magento\\Framework\\Composer\\MagentoComposerApplicationFactory', [], [], '', false); $composerAppFactory->expects($this->once())->method('createRequireUpdateDryRunCommand')->willReturn($this->reqUpdDryRunCommand); $this->dependencyReadinessCheck = new DependencyReadinessCheck($this->composerJsonFinder, $this->directoryList, $this->file, $composerAppFactory); }
/** * @return void */ public function testHandleSuccessWithoutBubble() { $extra = ['mode' => 'application mode']; $record = ['message' => $this->message, 'level' => $this->recordLevel, 'extra' => $extra]; $this->fileHandler->setLevel($this->handlerLevel); $this->fileHandler->setBubble(false); $file = 'file/path/file.log'; $this->file->expects($this->any())->method('filePutContents')->willReturn(1); $this->file->expects($this->any())->method('getRealPath')->willReturnMap([[$file, false], ['file/path', false], ['file', '/existing_path/file']]); $this->file->expects($this->once())->method('createDirectory')->willReturn(true); $this->config->expects($this->any())->method('getOption')->with('log_file')->willReturn($file); $result = $this->fileHandler->handle($record); $this->assertTrue($result); }
public function testDbRollback() { $this->setupDbBackupRollback(); $this->database->expects($this->once())->method('rollback'); $this->file->expects($this->once())->method('isExists')->with($this->path . '/backups/12345_db.gz')->willReturn(true); $this->model->dbRollback('12345_db.gz'); }