/** * Clear state file */ protected function tearDown() { $this->filesystem->expects($this->any())->method('getDirectoryWrite')->willReturn($this->writeInterface); $this->writeInterface->expects($this->any())->method('openFile')->willReturnSelf($this->absolutePath); $this->state->clearState(); }
public function testGenerateLessFileTree() { $originalContent = 'original content'; $expectedContent = 'updated content'; $expectedRelativePath = 'view_preprocessed/less/some/file.less'; $expectedPath = '/var/view_preprocessed/less/some/file.less'; $asset = $this->getMock('\\Magento\\Framework\\View\\Asset\\File', [], [], '', false); $asset->expects($this->once())->method('getPath')->will($this->returnValue('some/file.css')); $chain = new \Magento\Framework\View\Asset\PreProcessor\Chain($asset, $originalContent, 'less'); $this->magentoImport->expects($this->once())->method('process')->with($chain); $this->import->expects($this->once())->method('process')->with($chain); $relatedAssetOne = $this->getMock('\\Magento\\Framework\\View\\Asset\\File', [], [], '', false); $relatedAssetOne->expects($this->any())->method('getPath')->will($this->returnValue('related/file_one.css')); $relatedAssetOne->expects($this->any())->method('getContent')->will($this->returnValue("content of 'related/file_one.css'")); $relatedAssetTwo = $this->getMock('\\Magento\\Framework\\View\\Asset\\File', [], [], '', false); $relatedAssetTwo->expects($this->any())->method('getPath')->will($this->returnValue('related/file_two.css')); $relatedAssetTwo->expects($this->any())->method('getContent')->will($this->returnValue("content of 'related/file_two.css'")); $assetsMap = [['related/file_one.css', $asset, $relatedAssetOne], ['related/file_two.css', $asset, $relatedAssetTwo]]; $this->assetRepo->expects($this->any())->method('createRelated')->will($this->returnValueMap($assetsMap)); $relatedFilesOne = [['related/file_one.css', $asset]]; $this->import->expects($this->at(1))->method('getRelatedFiles')->will($this->returnValue($relatedFilesOne)); $relatedFilesTwo = [['related/file_two.css', $asset]]; $this->import->expects($this->at(3))->method('getRelatedFiles')->will($this->returnValue($relatedFilesTwo)); $this->import->expects($this->at(5))->method('getRelatedFiles')->will($this->returnValue([])); $writeMap = [[$expectedRelativePath, $expectedContent], ['related/file_one.css', "content of 'related/file_one.css'"], ['related/file_two.css', "content of 'related/file_two.css'"]]; $pathsMap = [[$expectedRelativePath, $expectedPath], ['related/file_one.css', '/var/view_preprocessed/less/related/file_one.css'], ['related/file_two.css', '/var/view_preprocessed/less/related/file_two.css']]; $this->tmpDirectory->expects($this->any())->method('writeFile')->will($this->returnValueMap($writeMap)); $this->tmpDirectory->expects($this->any())->method('getAbsolutePath')->will($this->returnValueMap($pathsMap)); $actual = $this->object->generateLessFileTree($chain); $this->assertSame($expectedPath, $actual); }
public function testPublish() { $this->appState->expects($this->once())->method('getMode')->will($this->returnValue(\Magento\Framework\App\State::MODE_PRODUCTION)); $this->staticDirRead->expects($this->once())->method('isExist')->with('some/file.ext')->will($this->returnValue(false)); $this->rootDirWrite->expects($this->once())->method('getRelativePath')->with('/root/some/file.ext')->will($this->returnValue('some/file.ext')); $this->rootDirWrite->expects($this->once())->method('copyFile')->with('some/file.ext', 'some/file.ext', $this->staticDirWrite)->will($this->returnValue(true)); $this->assertTrue($this->object->publish($this->getAsset())); }
public function testPublish() { $this->staticDirRead->expects($this->once())->method('isExist')->with('some/file.ext')->will($this->returnValue(false)); $materializationStrategy = $this->getMock('Magento\\Framework\\App\\View\\Asset\\MaterializationStrategy\\StrategyInterface', [], [], '', false); $this->rootDirWrite->expects($this->once())->method('getRelativePath')->with('/root/some/file.ext')->will($this->returnValue('some/file.ext')); $this->materializationStrategyFactory->expects($this->once())->method('create')->with($this->getAsset())->will($this->returnValue($materializationStrategy)); $materializationStrategy->expects($this->once())->method('publishFile')->with($this->rootDirWrite, $this->staticDirWrite, 'some/file.ext', 'some/file.ext')->will($this->returnValue(true)); $this->assertTrue($this->object->publish($this->getAsset())); }
public function testMergeMtimeUnchanged() { $this->targetDir->expects($this->once())->method('isExist')->with('merged/result.txt.dat')->will($this->returnValue(true)); $this->targetDir->expects($this->once())->method('readFile')->with('merged/result.txt.dat')->will($this->returnValue('11')); $assets = $this->getAssetsToMerge(); $this->mergerMock->expects($this->never())->method('merge'); $this->targetDir->expects($this->never())->method('writeFile'); $this->checksum->merge($assets, $this->resultAsset); }
protected function setUp() { $this->stream = $this->getMockForAbstractClass('\\Magento\\Framework\\Filesystem\\File\\WriteInterface'); $this->dir = $this->getMockForAbstractClass('\\Magento\\Framework\\Filesystem\\Directory\\WriteInterface'); $this->dir->expects($this->any())->method('openFile')->with(self::DEBUG_FILE, 'a')->will($this->returnValue($this->stream)); $filesystem = $this->getMock('Magento\\Framework\\Filesystem', [], [], '', false); $filesystem->expects($this->any())->method('getDirectoryWrite')->will($this->returnValue($this->dir)); $this->object = new File($filesystem, self::DEBUG_FILE); }
public function testCreateRequireJsAssetDevMode() { $this->appState->expects($this->once())->method('getMode')->will($this->returnValue(\Magento\Framework\App\State::MODE_DEVELOPER)); $this->dir->expects($this->never())->method('isExist'); $data = 'requirejs config data'; $this->config->expects($this->once())->method('getConfig')->will($this->returnValue($data)); $this->dir->expects($this->once())->method('writeFile')->with('requirejs/file.js', $data); $this->assertSame($this->asset, $this->object->createRequireJsAsset()); }
public function testMergeCss() { $this->resultAsset->expects($this->exactly(3))->method('getPath')->will($this->returnValue('foo/result')); $this->resultAsset->expects($this->any())->method('getContentType')->will($this->returnValue('css')); $assets = $this->prepareAssetsToMerge(['one', 'two']); $this->cssUrlResolver->expects($this->exactly(2))->method('relocateRelativeUrls')->will($this->onConsecutiveCalls('1', '2')); $this->cssUrlResolver->expects($this->once())->method('aggregateImportDirectives')->with('12')->will($this->returnValue('1020')); $this->writeDir->expects($this->once())->method('writeFile')->with('foo/result', '1020'); $this->object->merge($assets, $this->resultAsset); }
public function testCreateRequireJsAssetDevMode() { $this->config->expects($this->once())->method('getConfigFileRelativePath')->will($this->returnValue('requirejs/file.js')); $this->fileSystem->expects($this->once())->method('getDirectoryWrite')->with(DirectoryList::STATIC_VIEW)->will($this->returnValue($this->dir)); $this->assetRepo->expects($this->once())->method('createArbitrary')->with('requirejs/file.js', '')->will($this->returnValue($this->asset)); $this->appState->expects($this->once())->method('getMode')->will($this->returnValue(\Magento\Framework\App\State::MODE_DEVELOPER)); $this->dir->expects($this->never())->method('isExist'); $data = 'requirejs config data'; $this->config->expects($this->once())->method('getConfig')->will($this->returnValue($data)); $this->dir->expects($this->once())->method('writeFile')->with('requirejs/file.js', $data); $this->assertSame($this->asset, $this->object->createRequireJsConfigAsset()); }
public function testBeforeSave() { $value = 'filename.jpg'; $tmpMediaPath = 'tmp/design/file/' . $value; $this->fileBackend->setScope('store'); $this->fileBackend->setScopeId(1); $this->fileBackend->setValue([['url' => 'http://magento2.com/pub/media/tmp/image/' . $value, 'file' => $value, 'size' => 234234]]); $this->fileBackend->setFieldConfig(['upload_dir' => ['value' => 'value', 'config' => 'system/filesystem/media']]); $this->mediaDirectory->expects($this->once())->method('copyFile')->with($tmpMediaPath, '/' . $value)->willReturn(true); $this->mediaDirectory->expects($this->once())->method('delete')->with($tmpMediaPath); $this->fileBackend->beforeSave(); $this->assertEquals('filename.jpg', $this->fileBackend->getValue()); }
public function testBeforeSave() { $value = 'filename.jpg'; $tmpMediaPath = 'tmp/image/' . $value; $this->imageBackend->setScope('store'); $this->imageBackend->setScopeId(1); $this->imageBackend->setValue([['url' => 'http://magento2.com/pub/media/tmp/image/' . $value, 'file' => $value, 'size' => 234234]]); $this->imageConfig->expects($this->exactly(2))->method('getTmpMediaPath')->with($value)->willReturn($tmpMediaPath); $this->mediaDirectory->expects($this->once())->method('copyFile')->with($tmpMediaPath, 'image/store/1/' . $value)->willReturn(true); $this->mediaDirectory->expects($this->once())->method('delete')->with($tmpMediaPath); $this->imageBackend->beforeSave(); $this->assertEquals('store/1/filename.jpg', $this->imageBackend->getValue()); }
public function testClearBundleJsPool() { $context = $this->getMockBuilder('Magento\\Framework\\View\\Asset\\File\\FallbackContext')->disableOriginalConstructor()->getMock(); $this->fileSystem->expects($this->once())->method('getDirectoryWrite')->with(DirectoryList::STATIC_VIEW)->willReturn($this->dir); $this->assetRepoMock->expects($this->once())->method('getStaticViewFileContext')->willReturn($context); $context->expects($this->once())->method('getPath')->willReturn('/path/to/directory'); $this->dir->expects($this->once())->method('delete')->with('/path/to/directory/' . \Magento\Framework\RequireJs\Config::BUNDLE_JS_DIR)->willReturn(true); $this->assertTrue($this->object->clearBundleJsPool()); }
/** * @param string $dbCode * @param array $stat * @param string|null $stateCode * @param string|array|bool $result * @dataProvider getDbFileStatDataProvider */ public function testGetDbFileStat($dbCode, $stat, $stateCode, $result) { $this->configureDirectoryIsFileIsReadableMethods($dbCode, true, true); $dbPath = $this->getDbPathNonAbsolute($dbCode); if ($dbPath) { $this->directory->expects($this->once())->method('stat')->with($dbPath)->willReturn($stat); } $this->assertEquals($result, $this->database->getDbFileStat($dbCode, $stateCode)); }
/** * @covers \Magento\Backup\Model\Backup::output * @param bool $isFile * @param string $result * @dataProvider outputDataProvider */ public function testOutput($isFile, $result) { $path = '/path/to'; $time = 1; $name = 'test'; $type = 'db'; $extension = 'sql'; $relativePath = '/path/to/1_db_test.sql'; $contents = 'test_result'; $this->directoryMock->expects($this->atLeastOnce())->method('isFile')->with($relativePath)->willReturn($isFile); $this->directoryMock->expects($this->any())->method('getRelativePath')->with($relativePath)->willReturn($relativePath); $this->directoryMock->expects($this->any())->method('readFile')->with($relativePath)->willReturn($contents); $this->dataHelperMock->expects($this->any())->method('getExtensionByType')->with($type)->willReturn($extension); $this->backupModel->setPath($path); $this->backupModel->setName($name); $this->backupModel->setTime($time); $this->assertEquals($result, $this->backupModel->output()); }
public function testSaveFile() { $imageProcessor = $this->getMockBuilder('Magento\\Framework\\Image')->disableOriginalConstructor()->getMock(); $this->image->setImageProcessor($imageProcessor); $this->coreFileHelper->expects($this->once())->method('saveFile')->will($this->returnValue(true)); $absolutePath = dirname(dirname(__DIR__)) . '/_files/catalog/product/somefile.png'; $this->mediaDirectory->expects($this->once())->method('getAbsolutePath')->will($this->returnValue($absolutePath)); $this->image->saveFile(); }
public function testSaveToTmp() { $path = 'design/header/logo_src'; $fieldCode = 'header_logo_src'; $metadata = [$fieldCode => ['path' => $path, 'backend_model' => 'Magento\\Theme\\Model\\Design\\Backend\\File']]; $this->storeManager->expects($this->once())->method('getStore')->willReturn($this->store); $this->store->expects($this->once())->method('getBaseUrl')->with(UrlInterface::URL_TYPE_MEDIA)->willReturn('http://magento2.com/pub/media/'); $this->directoryWrite->expects($this->once())->method('getAbsolutePath')->with('tmp/' . FileProcessor::FILE_DIR)->willReturn('absolute/path/to/tmp/media'); $this->metadataProvider->expects($this->once())->method('get')->willReturn($metadata); $this->backendModelFactory->expects($this->once())->method('createByPath')->with($path)->willReturn($this->backendModel); $this->uploaderFactory->expects($this->once())->method('create')->with(['fileId' => $fieldCode])->willReturn($this->uploader); $this->uploader->expects($this->once())->method('setAllowRenameFiles')->with(true); $this->uploader->expects($this->once())->method('setFilesDispersion')->with(false); $this->backendModel->expects($this->once())->method('getAllowedExtensions')->willReturn(['png', 'jpg']); $this->uploader->expects($this->once())->method('setAllowedExtensions')->with(['png', 'jpg']); $this->uploader->expects($this->once())->method('addValidateCallback')->with('size', $this->backendModel, 'validateMaxSize'); $this->uploader->expects($this->once())->method('save')->with('absolute/path/to/tmp/media')->willReturn(['file' => 'file.jpg', 'size' => '234234']); $this->assertEquals(['file' => 'file.jpg', 'size' => '234234', 'url' => 'http://magento2.com/pub/media/tmp/' . FileProcessor::FILE_DIR . '/file.jpg'], $this->fileProcessor->saveToTmp($fieldCode)); }
public function testGenerateLessFileTree() { $lessDirectory = 'path/to/less'; $expectedContent = 'updated content'; $expectedRelativePath = 'some/file.less'; $expectedPath = $lessDirectory . '/some/file.less'; $asset = $this->getMock('Magento\\Framework\\View\\Asset\\File', [], [], '', false); $chain = $this->getMock('Magento\\Framework\\View\\Asset\\PreProcessor\\Chain', [], [], '', false); $this->config->expects($this->any())->method('getLessDirectory')->willReturn($lessDirectory); $this->tmpDirectory->expects($this->once())->method('isExist')->willReturn(true); $this->magentoImport->expects($this->once())->method('process')->with($chain); $this->import->expects($this->once())->method('process')->with($chain); $this->relatedGenerator->expects($this->once())->method('generate')->with($this->import); $asset->expects($this->once())->method('getPath')->will($this->returnValue('some/file.css')); $chain->expects($this->once())->method('getContent')->willReturn($expectedContent); $chain->expects($this->once())->method('getAsset')->willReturn($asset); $this->temporaryFile->expects($this->once())->method('createFile')->with($expectedRelativePath, $expectedContent)->willReturn($expectedPath); $this->assertSame($expectedPath, $this->object->generateFileTree($chain)); }
/** * @param string $origFile * @param string $origPath * @param string $origContent * @param bool $isMaterialization * @param bool $isExist * * @dataProvider getFileDataProvider */ public function testGetFile($origFile, $origPath, $origContent, $isMaterialization, $isExist) { $filePath = 'some/file.ext'; $read = $this->getMock('Magento\Framework\Filesystem\Directory\Read', [], [], '', false); $read->expects($this->at(0))->method('readFile')->with($origPath)->willReturn($origContent); $this->readFactory->expects($this->atLeastOnce())->method('create')->willReturn($read); $this->viewFileResolution->expects($this->once()) ->method('getFile') ->with('frontend', $this->theme, 'en_US', $filePath, 'Magento_Module') ->willReturn($origFile); $this->preProcessorPool->expects($this->once()) ->method('process') ->with($this->chain); $this->staticDirRead->expects($this->any()) ->method('isExist') ->willReturn($isExist); if ($isMaterialization || !$isExist) { $this->chain ->expects($this->once()) ->method('isChanged') ->willReturn(true); $this->chain ->expects($this->once()) ->method('getContent') ->willReturn('processed'); $this->chain ->expects($this->once()) ->method('getTargetAssetPath') ->willReturn($filePath); $this->varDir->expects($this->once()) ->method('writeFile') ->with('view_preprocessed/source/some/file.ext', 'processed'); $this->varDir->expects($this->once()) ->method('getAbsolutePath') ->willReturn('var'); $read->expects($this->once()) ->method('getAbsolutePath') ->with('view_preprocessed/source/some/file.ext') ->willReturn('result'); } else { $this->varDir->expects($this->never())->method('writeFile'); $read->expects($this->at(1)) ->method('getAbsolutePath') ->with('file.ext') ->willReturn('result'); } $this->assertSame('result', $this->object->getFile($this->getAsset())); }
/** * Cover createHistoryReport(). * * @expectedException \Magento\Framework\Exception\LocalizedException * @expectedExceptionMessage Source file coping failed */ public function testCreateHistoryReportThrowException() { $sourceFileRelative = null; $entity = ''; $extension = ''; $result = ''; $gmtTimestamp = 1234567; $this->import->expects($this->once())->method('isReportEntityType')->with($entity)->willReturn(true); $this->_varDirectory->expects($this->never())->method('getRelativePath'); $phrase = $this->getMock('\\Magento\\Framework\\Phrase', [], [], '', false); $this->_driver->expects($this->any())->method('fileGetContents')->willReturnCallback(function () use($phrase) { throw new \Magento\Framework\Exception\FileSystemException($phrase); }); $this->dateTime->expects($this->once())->method('gmtTimestamp')->willReturn($gmtTimestamp); $args = [$sourceFileRelative, $entity, $extension, $result]; $actualResult = $this->invokeMethod($this->import, 'createHistoryReport', $args); $this->assertEquals($this->import, $actualResult); }
public function testSaveWithPreviousData() { $imageContent = $this->getMockBuilder('Magento\\Framework\\Api\\Data\\ImageContentInterface')->disableOriginalConstructor()->getMock(); $imageContent->expects($this->any())->method('getBase64EncodedData')->willReturn('testImageData'); $imageContent->expects($this->any())->method('getName')->willReturn('testFileName.png'); $imageDataObject = $this->getMockBuilder('Magento\\Framework\\Api\\AttributeValue')->disableOriginalConstructor()->getMock(); $imageDataObject->expects($this->once())->method('getValue')->willReturn($imageContent); $imageData = $this->getMockForAbstractClass('Magento\\Framework\\Api\\CustomAttributesDataInterface'); $imageData->expects($this->once())->method('getCustomAttributes')->willReturn([]); $this->dataObjectHelperMock->expects($this->once())->method('getCustomAttributeValueByType')->willReturn([$imageDataObject]); $this->contentValidatorMock->expects($this->once())->method('isValid')->willReturn(true); $this->directoryWriteMock->expects($this->any())->method('getAbsolutePath')->willReturn('testPath'); $prevImageAttribute = $this->getMockForAbstractClass('Magento\\Framework\\Api\\AttributeInterface'); $prevImageAttribute->expects($this->once())->method('getValue')->willReturn('testImagePath'); $prevImageData = $this->getMockForAbstractClass('Magento\\Framework\\Api\\CustomAttributesDataInterface'); $prevImageData->expects($this->once())->method('getCustomAttribute')->willReturn($prevImageAttribute); $this->assertEquals($imageData, $this->imageProcessor->save($imageData, 'testEntityType', $prevImageData)); }
/** * @param $origFile * @param $origPath * @param $origContent * @param $isMaterialization * * @dataProvider getFileDataProvider */ public function testGetFile($origFile, $origPath, $origContent, $isMaterialization) { $filePath = 'some/file.ext'; $this->viewFileResolution->expects($this->once())->method('getFile')->with('frontend', $this->theme, 'en_US', $filePath, 'Magento_Module')->will($this->returnValue($origFile)); $this->rootDirRead->expects($this->once())->method('getRelativePath')->with($origFile)->will($this->returnValue($origPath)); $this->rootDirRead->expects($this->once())->method('readFile')->with($origPath)->will($this->returnValue($origContent)); $this->preProcessorPool->expects($this->once())->method('process')->with($this->chain); if ($isMaterialization) { $this->chain->expects($this->once())->method('isChanged')->willReturn(true); $this->chain->expects($this->once())->method('getContent')->willReturn('processed'); $this->chain->expects($this->once())->method('getTargetAssetPath')->willReturn($filePath); $this->varDir->expects($this->once())->method('writeFile')->with('view_preprocessed/source/some/file.ext', 'processed'); $this->varDir->expects($this->once())->method('getAbsolutePath')->with('view_preprocessed/source/some/file.ext')->will($this->returnValue('result')); } else { $this->varDir->expects($this->never())->method('writeFile'); $this->rootDirRead->expects($this->once())->method('getAbsolutePath')->with('source/some/file.ext')->will($this->returnValue('result')); } $this->assertSame('result', $this->object->getFile($this->getAsset())); }
public function testBeforeSaveWithoutOldValue() { $tmpFileName = ''; $value = ['delete' => 1, 'tmp_name' => $tmpFileName, 'name' => 'name']; $groupId = 1; $field = 'field'; $path = 'path'; $scope = 'scope'; $scopeCode = 'code'; $oldValue = ''; $this->model->setValue($value); $this->model->setGroupId($groupId); $this->model->setField($field); $this->model->setPath($path); $this->model->setScope($scope); $this->model->setScopeCode($scopeCode); $this->scopeConfigMock->expects($this->any())->method('getValue')->with($path, $scope, $scopeCode)->willReturn($oldValue); $this->writeMock->expects($this->never())->method('delete'); $this->assertEquals($this->model, $this->model->beforeSave()); }
/** * @param string $origFile * @param string $origPath * @param string $origContentType * @param string $origContent * @param string $isMaterialization * @dataProvider getFileDataProvider */ public function testGetFile($origFile, $origPath, $origContentType, $origContent, $isMaterialization) { $filePath = 'some/file.ext'; $cacheValue = "{$origPath}:{$filePath}"; $this->viewFileResolution->expects($this->once())->method('getFile')->with('frontend', $this->theme, 'en_US', $filePath, 'Magento_Module')->will($this->returnValue($origFile)); $this->rootDirRead->expects($this->once())->method('getRelativePath')->with($origFile)->will($this->returnValue($origPath)); $this->cache->expects($this->once())->method('load')->will($this->returnValue(false)); $this->rootDirRead->expects($this->once())->method('readFile')->with($origPath)->will($this->returnValue($origContent)); $processor = $this->getMockForAbstractClass('Magento\\Framework\\View\\Asset\\PreProcessorInterface'); $this->preProcessorPool->expects($this->once())->method('getPreProcessors')->with($origContentType, 'ext')->will($this->returnValue([$processor])); $processor->expects($this->once())->method('process')->will($this->returnCallback(array($this, 'chainTestCallback'))); if ($isMaterialization) { $this->varDir->expects($this->once())->method('writeFile')->with('view_preprocessed/source/some/file.ext', 'processed'); $this->cache->expects($this->once())->method('save')->with(serialize([\Magento\Framework\App\Filesystem::VAR_DIR, 'view_preprocessed/source/some/file.ext']), $cacheValue); $this->varDir->expects($this->once())->method('getAbsolutePath')->with('view_preprocessed/source/some/file.ext')->will($this->returnValue('result')); } else { $this->varDir->expects($this->never())->method('writeFile'); $this->cache->expects($this->once())->method('save')->with(serialize([\Magento\Framework\App\Filesystem::ROOT_DIR, 'source/some/file.ext']), $cacheValue); $this->rootDirRead->expects($this->once())->method('getAbsolutePath')->with('source/some/file.ext')->will($this->returnValue('result')); } $this->assertSame('result', $this->object->getFile($this->getAsset())); }
/** * @dataProvider getExpiredImages */ public function testDeleteExpiredImages($website, $isFile, $filename, $mTime, $timeout, $mustDelete) { $this->markTestSkipped("MAGETWO-34751: Hidden dependency"); $this->_storeManager->expects($this->once())->method('getWebsites')->will($this->returnValue(isset($website) ? [$website] : [])); if (isset($website)) { $this->_helper->expects($this->once())->method('getConfig')->with($this->equalTo('timeout'), new \PHPUnit_Framework_Constraint_IsIdentical($website->getDefaultStore()))->will($this->returnValue($timeout)); } else { $this->_helper->expects($this->never())->method('getConfig'); } $this->_adminHelper->expects($this->once())->method('getConfig')->with($this->equalTo('timeout'), new \PHPUnit_Framework_Constraint_IsNull())->will($this->returnValue($timeout)); $timesToCall = isset($website) ? 2 : 1; $this->_directory->expects($this->exactly($timesToCall))->method('read')->will($this->returnValue([$filename])); $this->_directory->expects($this->exactly($timesToCall))->method('isFile')->will($this->returnValue($isFile)); $this->_directory->expects($this->any())->method('stat')->will($this->returnValue(['mtime' => $mTime])); if ($mustDelete) { $this->_directory->expects($this->exactly($timesToCall))->method('delete')->with($filename); } else { $this->_directory->expects($this->never())->method('delete'); } $this->_deleteExpiredImages->execute(); }
public function testMergeNotExists() { $this->dirMock->expects($this->once())->method('isExist')->with('foo/file')->will($this->returnValue(false)); $this->mergerMock->expects($this->once())->method('merge')->with([], $this->resultAsset); $this->fileExists->merge([], $this->resultAsset); }
protected function configureUnpack($dbPath, $dbArchPath, $dbPathAbsolute, $dbArchPathAbsolute) { $this->directory->expects($this->exactly(2))->method('getAbsolutePath')->willReturnMap([[$dbPath, $dbPathAbsolute], [$dbArchPath, $dbArchPathAbsolute]]); $this->archive->expects($this->once())->method('unpack')->with($dbArchPathAbsolute, $dbPathAbsolute); }
public function testIsUpdateError() { $this->varReaderWriter->expects($this->once())->method('isExist')->willReturn(true); $this->assertTrue($this->status->isUpdateError()); }