/** * Test for processException method report * * @covers \Magento\Framework\Error\Handler::processException * @runInSeparateProcess */ public function testProcessExceptionReport() { $this->appState->expects($this->any())->method('getMode')->will($this->returnValue(\Magento\Framework\App\State::MODE_DEFAULT)); $this->filesystem->expects($this->atLeastOnce())->method('getPath')->with(\Magento\Framework\App\Filesystem::PUB_DIR)->will($this->returnValue(dirname(__DIR__) . '/../../_files')); $exception = new \Exception('TestMessage'); $this->handler->processException($exception); }
public function setup() { $this->filesystemMock = $this->getMockBuilder('Magento\\Framework\\App\\Filesystem')->disableOriginalConstructor()->getMock(); $this->themesDirectoryMock = $this->getMockBuilder('Magento\\Framework\\Filesystem\\Directory\\ReadInterface')->getMock(); $this->filesystemMock->expects($this->any())->method('getDirectoryRead')->will($this->returnValue($this->themesDirectoryMock)); $this->fileFactoryMock = $this->getMockBuilder('Magento\\Framework\\View\\File\\Factory')->disableOriginalConstructor()->getMock(); $this->themeMock = $this->getMockBuilder('Magento\\Framework\\View\\Design\\ThemeInterface')->getMock(); }
/** * Test for get method with primary scope * * @dataProvider providerGet * @param string $filename * @param array $fileList * @SuppressWarnings(PHPMD.UnusedLocalVariable) */ public function testGetPrimary($filename, $fileList) { $scope = 'primary'; $directory = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\Read', array('search', 'getRelativePath'), array(), '', false); $directory->expects($this->once())->method('search')->with(sprintf('{%1$s,*/%1$s}', $filename))->will($this->returnValue($fileList)); $this->filesystem->expects($this->once())->method('getDirectoryRead')->with(\Magento\Framework\App\Filesystem::CONFIG_DIR)->will($this->returnValue($directory)); $this->iteratorFactory->expects($this->once())->method('create')->with($directory, $fileList)->will($this->returnValue(true)); $this->assertTrue($this->model->get($filename, $scope)); }
protected function setUp() { $this->_directoryMock = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\Write', array(), array(), '', false); $this->_filesystemMock = $this->getMock('Magento\\Framework\\App\\Filesystem', array(), array(), '', false); $this->_filesystemMock->expects($this->any())->method('getPath')->with(\Magento\Framework\App\Filesystem::CONFIG_DIR)->will($this->returnValue(TESTS_TEMP_DIR)); $this->_filesystemMock->expects($this->any())->method('getDirectoryWrite')->will($this->returnValue($this->_directoryMock)); $this->_messageManager = $this->getMock('\\Magento\\Framework\\Message\\ManagerInterface', array(), array(), '', false); $this->_model = new \Magento\Install\Model\Installer\Config($this->getMock('Magento\\Install\\Model\\Installer', array(), array(), '', false), $this->getMock('Magento\\Framework\\App\\RequestInterface', array(), array(), '', false), $this->_filesystemMock, $this->getMock('Magento\\Store\\Model\\StoreManagerInterface', array(), array(), '', false), $this->_messageManager); }
protected function setUp() { $this->filesystemMock = $this->getMock('Magento\\Framework\\App\\Filesystem', array(), array(), '', false, false); $this->directoryMock = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\Read', array(), array(), '', false, false); $this->_stringMock = $this->getMock('Magento\\Framework\\Stdlib\\String', array(), array(), '', false, false); $this->_stringMock->expects($this->once())->method('upperCaseWords')->will($this->returnValue('Test/Module')); $this->filesystemMock->expects($this->once())->method('getDirectoryRead')->will($this->returnValue($this->directoryMock)); $this->_model = new \Magento\Framework\Module\Dir($this->filesystemMock, $this->_stringMock); }
protected function setUp() { $this->_filesystem = $this->getMock('Magento\\Framework\\App\\Filesystem', array(), array(), '', false); $this->_helperStorage = $this->getMock('Magento\\Theme\\Helper\\Storage', array(), array(), '', false); $this->_objectManager = $this->getMock('Magento\\Framework\\ObjectManager', array(), array(), '', false); $this->_imageFactory = $this->getMock('Magento\\Framework\\Image\\AdapterFactory', array(), array(), '', false); $this->directoryWrite = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\Write', array(), array(), '', false); $this->_filesystem->expects($this->once())->method('getDirectoryWrite')->will($this->returnValue($this->directoryWrite)); $this->_storageModel = new \Magento\Theme\Model\Wysiwyg\Storage($this->_filesystem, $this->_helperStorage, $this->_objectManager, $this->_imageFactory); $this->_storageRoot = '/root'; }
public function testConstructStream() { $this->markTestSkipped('MAGETWO-17084: Replace PHP native calls'); $stream = 'data://text/plain;base64,' . base64_encode("column1,column2\nvalue1,value2\n"); $this->_directoryMock->expects($this->any())->method('openFile')->will($this->returnValue(new \Magento\Framework\Filesystem\File\Read($stream, new \Magento\Framework\Filesystem\Driver\Http()))); $this->_filesystem->expects($this->any())->method('getDirectoryWrite')->will($this->returnValue($this->_directoryMock)); $model = new \Magento\ImportExport\Model\Import\Source\Csv($stream, $this->_filesystem); foreach ($model as $value) { $this->assertSame(array('column1' => 'value1', 'column2' => 'value2'), $value); } }
/** * test get storage data */ public function testGetStorageData() { $this->filesystemMock->expects($this->once())->method('getDirectoryRead')->with($this->equalTo(\Magento\Framework\App\Filesystem::MEDIA_DIR))->will($this->returnValue($this->directoryReadMock)); $this->directoryReadMock->expects($this->any())->method('isDirectory')->will($this->returnValueMap(array(array('/', true), array('folder_one', true), array('file_three.txt', false), array('folder_one/.svn', false), array('folder_one/file_one.txt', false), array('folder_one/folder_two', true), array('folder_one/folder_two/.htaccess', false), array('folder_one/folder_two/file_two.txt', false)))); $paths = array('folder_one', 'file_three.txt', 'folder_one/.svn', 'folder_one/file_one.txt', 'folder_one/folder_two', 'folder_one/folder_two/.htaccess', 'folder_one/folder_two/file_two.txt'); sort($paths); $this->directoryReadMock->expects($this->once())->method('readRecursively')->with($this->equalTo('/'))->will($this->returnValue($paths)); $expected = array('files' => array('file_three.txt', 'folder_one/file_one.txt', 'folder_one/folder_two/file_two.txt'), 'directories' => array(array('name' => 'folder_one', 'path' => '/'), array('name' => 'folder_two', 'path' => 'folder_one'))); $actual = $this->storageFile->getStorageData(); $this->assertEquals($expected, $actual); }
protected function setUp() { $this->appState = $this->getMock('Magento\\Framework\\App\\State', array(), array(), '', false); $this->filesystem = $this->getMock('Magento\\Framework\\App\\Filesystem', array(), array(), '', false); $this->object = new Publisher($this->appState, $this->filesystem); $this->rootDirWrite = $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(\Magento\Framework\App\Filesystem::STATIC_VIEW_DIR)->will($this->returnValue($this->staticDirRead)); $this->filesystem->expects($this->any())->method('getDirectoryWrite')->will($this->returnValueMap([[\Magento\Framework\App\Filesystem::ROOT_DIR, $this->rootDirWrite], [\Magento\Framework\App\Filesystem::STATIC_VIEW_DIR, $this->staticDirWrite]])); }
/** * Setup tests * @return void */ public function setup() { $this->fileListFactoryMock = $this->getMockBuilder('Magento\\Framework\\View\\File\\FileList\\Factory')->disableOriginalConstructor()->getMock(); $this->fileListMock = $this->getMockBuilder('Magento\\Framework\\View\\File\\FileList')->disableOriginalConstructor()->getMock(); $this->fileListFactoryMock->expects($this->any())->method('create')->will($this->returnValue($this->fileListMock)); $this->fileSystemMock = $this->getMockBuilder('Magento\\Framework\\App\\Filesystem')->disableOriginalConstructor()->getMock(); $this->libraryDirectoryMock = $this->getMockBuilder('Magento\\Framework\\Filesystem\\Directory\\ReadInterface')->getMock(); $this->themesDirectoryMock = $this->getMockBuilder('Magento\\Framework\\Filesystem\\Directory\\ReadInterface')->getMock(); $this->fileSystemMock->expects($this->any())->method('getDirectoryRead')->will($this->returnValueMap([[Filesystem::LIB_WEB, $this->libraryDirectoryMock], [Filesystem::THEMES_DIR, $this->themesDirectoryMock]])); $this->fileFactoryMock = $this->getMockBuilder('Magento\\Framework\\View\\File\\Factory')->disableOriginalConstructor()->getMock(); $this->themeMock = $this->getMockBuilder('\\Magento\\Framework\\View\\Design\\ThemeInterface')->getMock(); }
public function testSetTemplateContext() { $directoryMock = $this->getMock('\\Magento\\Framework\\Filesystem\\Directory\\Read', array(), array(), '', false); $directoryMock->expects($this->any())->method('getRelativePath')->will($this->returnArgument(0)); $this->_filesystem->expects($this->once())->method('getDirectoryRead')->will($this->returnValue($directoryMock)); $this->_filesystem->expects($this->any())->method('getPath')->will($this->returnValue('themedir')); $directoryMock->expects($this->once())->method('isFile')->with('themedir/template.phtml')->will($this->returnValue(true)); $context = new \Magento\Framework\Object(); $this->_templateEngine->expects($this->once())->method('render')->with($context); $this->_block->setTemplateContext($context); $this->_block->fetchView('themedir/template.phtml'); }
protected function setUp() { $this->_uploader = $this->getMock('Magento\\Core\\Model\\File\\Uploader', array(), array(), '', false); $this->_uploaderFactory = $this->getMock('Magento\\Core\\Model\\File\\UploaderFactory', array('create'), array(), '', false); $this->_uploaderFactory->expects($this->any())->method('create')->will($this->returnValue($this->_uploader)); $this->_directoryMock = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\Read', array(), array(), '', false); $this->_filesystemMock = $this->getMock('Magento\\Framework\\App\\Filesystem', array(), array(), '', false); $this->_filesystemMock->expects($this->any())->method('getDirectoryRead')->will($this->returnValue($this->_directoryMock)); /** @var $service \Magento\Theme\Model\Uploader\Service */ $this->_fileSizeMock = $this->getMockBuilder('Magento\\Framework\\File\\Size')->setMethods(array('getMaxFileSize'))->disableOriginalConstructor()->getMock(); $this->_fileSizeMock->expects($this->any())->method('getMaxFileSize')->will($this->returnValue(600 * self::MB_MULTIPLIER)); }
protected function setUp() { $this->readerMock = $this->getMock('Magento\\Framework\\Module\\Dir\\Reader', [], [], '', false); $this->filesystemMock = $this->getMock('Magento\\Framework\\App\\Filesystem', [], [], '', false); $this->directoryReadMock = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\ReadInterface'); $this->filesystemMock->expects($this->once())->method('getDirectoryRead')->with($this->equalTo(\Magento\Framework\App\Filesystem::ROOT_DIR))->will($this->returnValue($this->directoryReadMock)); $this->repositoryMock = $this->getMock('Magento\\Framework\\View\\Asset\\Repository', [], [], '', false); $this->fileSystemMock = $this->getMock('Magento\\Framework\\View\\FileSystem', [], [], '', false); $this->fileIteratorFactoryMock = $this->getMock('Magento\\Framework\\Config\\FileIteratorFactory'); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->config = $this->objectManagerHelper->getObject('Magento\\Framework\\View\\Config', ['moduleReader' => $this->readerMock, 'filesystem' => $this->filesystemMock, 'assetRepo' => $this->repositoryMock, 'viewFileSystem' => $this->fileSystemMock, 'fileIteratorFactory' => $this->fileIteratorFactoryMock]); }
protected function setUp() { $this->_asset = $this->getMockForAbstractClass('\\Magento\\Framework\\View\\Asset\\LocalInterface'); $this->_logger = $this->getMock('\\Magento\\Framework\\Logger', array(), array(), '', false); $this->_baseUrl = $this->getMock('\\Magento\\Framework\\Url', array(), array(), '', false); $this->_staticViewDir = $this->getMockForAbstractClass('\\Magento\\Framework\\Filesystem\\Directory\\WriteInterface'); $this->_rootDir = $this->getMockForAbstractClass('\\Magento\\Framework\\Filesystem\\Directory\\ReadInterface'); $this->_filesystem = $this->getMock('\\Magento\\Framework\\App\\Filesystem', array(), array(), '', false); $this->_filesystem->expects($this->any())->method('getDirectoryRead')->will($this->returnValueMap([[\Magento\Framework\App\Filesystem::STATIC_VIEW_DIR, $this->_staticViewDir], [\Magento\Framework\App\Filesystem::ROOT_DIR, $this->_rootDir]])); $this->_filesystem->expects($this->any())->method('getDirectoryWrite')->with(\Magento\Framework\App\Filesystem::STATIC_VIEW_DIR)->will($this->returnValue($this->_staticViewDir)); $this->_adapter = $this->getMockForAbstractClass('Magento\\Framework\\Code\\Minifier\\AdapterInterface'); $this->_model = new Minified($this->_asset, $this->_logger, $this->_filesystem, $this->_baseUrl, $this->_adapter); }
/** * @covers \Magento\Framework\View\Design\Theme\Image::removePreviewImage */ public function testRemoveEmptyPreviewImage() { $this->_themeMock->setData($this->_getThemeSampleData()); $this->_themeMock->setData('preview_image', null); $this->_filesystemMock->expects($this->never())->method('delete'); $this->_model->removePreviewImage(); $this->assertNull($this->_themeMock->getData('preview_image')); }
protected function setUp() { $this->_requestMock = $this->getMock('Magento\\Core\\Model\\File\\Storage\\Request', array(), array(), '', false); $this->_closure = function () { return true; }; $this->_objectManagerMock = $this->getMock('Magento\\Framework\\ObjectManager'); $this->_configMock = $this->getMock('Magento\\Core\\Model\\File\\Storage\\Config', array(), array(), '', false); $this->_sync = $this->getMock('Magento\\Core\\Model\\File\\Storage\\Synchronization', array(), array(), '', false); $this->_dirVerificationMock = $this->getMock('Magento\\Framework\\App\\Filesystem\\DirectoryList\\Verification', array(), array(), '', false); $this->filesystemMock = $this->getMock('Magento\\Framework\\App\\Filesystem', array(), array(), '', false); $this->directoryReadMock = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\Read', array(), array(), '', false); $this->filesystemMock->expects($this->any())->method('getDirectoryRead')->with(\Magento\Framework\App\Filesystem::MEDIA_DIR)->will($this->returnValue($this->directoryReadMock)); $this->_responseMock = $this->getMock('Magento\\Core\\Model\\File\\Storage\\Response', array(), array(), '', false); $map = array(array('Magento\\Framework\\App\\Filesystem\\DirectoryList\\Verification', $this->_dirVerificationMock), array('Magento\\Core\\Model\\File\\Storage\\Request', $this->_requestMock), array('Magento\\Core\\Model\\File\\Storage\\Synchronization', $this->_sync)); $this->_model = new \Magento\Core\App\Media($this->_objectManagerMock, $this->_requestMock, $this->_responseMock, $this->_closure, 'baseDir', 'mediaDirectory', 'var', 'params', $this->filesystemMock); $this->_objectManagerMock->expects($this->any())->method('get')->will($this->returnValueMap($map)); }
protected function initFilesystem() { $this->filesystem = $this->getMock('Magento\\Framework\\App\\Filesystem', array(), array(), '', false); $this->rootDirRead = $this->getMockForAbstractClass('Magento\\Framework\\Filesystem\\Directory\\ReadInterface'); $this->staticDirRead = $this->getMockForAbstractClass('Magento\\Framework\\Filesystem\\Directory\\ReadInterface'); $this->varDir = $this->getMockForAbstractClass('Magento\\Framework\\Filesystem\\Directory\\WriteInterface'); $readDirMap = [[\Magento\Framework\App\Filesystem::ROOT_DIR, $this->rootDirRead], [\Magento\Framework\App\Filesystem::STATIC_VIEW_DIR, $this->staticDirRead], [\Magento\Framework\App\Filesystem::VAR_DIR, $this->varDir]]; $this->filesystem->expects($this->any())->method('getDirectoryRead')->will($this->returnValueMap($readDirMap)); $this->filesystem->expects($this->any())->method('getDirectoryWrite')->with(\Magento\Framework\App\Filesystem::VAR_DIR)->will($this->returnValue($this->varDir)); }
protected function setUp() { $this->customizationPath = '/' . implode('/', array('var', 'theme')); $this->request = $this->getMock('\\Magento\\Framework\\App\\Request\\Http', array(), array(), '', false); $this->filesystem = $this->getMock('Magento\\Framework\\App\\Filesystem', array(), array(), '', false); $this->session = $this->getMock('Magento\\Backend\\Model\\Session', array(), array(), '', false); $this->contextHelper = $this->getMock('Magento\\Framework\\App\\Helper\\Context', array(), array(), '', false); $this->directoryWrite = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\Write', array(), array(), '', false); $this->themeFactory = $this->getMock('Magento\\Framework\\View\\Design\\Theme\\FlyweightFactory', array(), array(), '', false); $this->theme = $this->getMock('Magento\\Core\\Model\\Theme', array(), array(), '', false); $this->customization = $this->getMock('Magento\\Framework\\View\\Design\\Theme\\Customization', array(), array(), '', false); $this->filesystem->expects($this->once())->method('getDirectoryWrite')->will($this->returnValue($this->directoryWrite)); $this->directoryWrite->expects($this->any())->method('create')->will($this->returnValue(true)); $this->contextHelper->expects($this->once())->method('getRequest')->will($this->returnValue($this->request)); $this->themeFactory->expects($this->any())->method('create')->will($this->returnValue($this->theme)); $this->theme->expects($this->any())->method('getCustomization')->will($this->returnValue($this->customization)); $this->request->expects($this->at(0))->method('getParam')->with(\Magento\Theme\Helper\Storage::PARAM_THEME_ID)->will($this->returnValue(6)); $this->request->expects($this->at(1))->method('getParam')->with(\Magento\Theme\Helper\Storage::PARAM_CONTENT_TYPE)->will($this->returnValue(\Magento\Theme\Model\Wysiwyg\Storage::TYPE_IMAGE)); $this->helper = new \Magento\Theme\Helper\Storage($this->contextHelper, $this->filesystem, $this->session, $this->themeFactory); }
/** * Set helper mocks, create resource model mock */ protected function setUp() { $this->_helperMockCore = $this->getMock('Magento\\Core\\Helper\\Data', array(), array(), '', false, false); $this->_sitemapCategoryMock = $this->getMockBuilder('Magento\\Sitemap\\Model\\Resource\\Catalog\\Category')->disableOriginalConstructor()->getMock(); $this->_sitemapProductMock = $this->getMockBuilder('Magento\\Sitemap\\Model\\Resource\\Catalog\\Product')->disableOriginalConstructor()->getMock(); $this->_sitemapCmsPageMock = $this->getMockBuilder('Magento\\Sitemap\\Model\\Resource\\Cms\\Page')->disableOriginalConstructor()->getMock(); $this->_helperMockSitemap = $this->getMock('Magento\\Sitemap\\Helper\\Data', array('getCategoryChangefreq', 'getProductChangefreq', 'getPageChangefreq', 'getCategoryPriority', 'getProductPriority', 'getPagePriority', 'getMaximumLinesNumber', 'getMaximumFileSize', 'getEnableSubmissionRobots'), array(), '', false, false); $this->_helperMockSitemap->expects($this->any())->method('getCategoryChangefreq')->will($this->returnValue('daily')); $this->_helperMockSitemap->expects($this->any())->method('getProductChangefreq')->will($this->returnValue('monthly')); $this->_helperMockSitemap->expects($this->any())->method('getPageChangefreq')->will($this->returnValue('daily')); $this->_helperMockSitemap->expects($this->any())->method('getCategoryPriority')->will($this->returnValue('1')); $this->_helperMockSitemap->expects($this->any())->method('getProductPriority')->will($this->returnValue('0.5')); $this->_helperMockSitemap->expects($this->any())->method('getPagePriority')->will($this->returnValue('0.25')); $this->_resourceMock = $this->getMockBuilder('Magento\\Sitemap\\Model\\Resource\\Sitemap')->setMethods(array('_construct', 'beginTransaction', 'rollBack', 'save', 'addCommitCallback', 'commit', '__wakeup'))->disableOriginalConstructor()->getMock(); $this->_resourceMock->expects($this->any())->method('addCommitCallback')->will($this->returnSelf()); $this->_fileMock = $this->getMockBuilder('Magento\\Framework\\Filesystem\\File\\Write')->disableOriginalConstructor()->getMock(); $this->_directoryMock = $this->getMockBuilder('Magento\\Framework\\Filesystem\\Directory\\Write')->disableOriginalConstructor()->getMock(); $this->_directoryMock->expects($this->any())->method('openFile')->will($this->returnValue($this->_fileMock)); $this->_filesystemMock = $this->getMockBuilder('Magento\\Framework\\App\\Filesystem')->setMethods(array('getDirectoryWrite'))->disableOriginalConstructor()->getMock(); $this->_filesystemMock->expects($this->any())->method('getDirectoryWrite')->will($this->returnValue($this->_directoryMock)); }
protected function getModelMock() { $dbModelName = 'Magento\\Install\\Model\\Installer\\Db\\Mysql4'; $this->directoryMock = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\Write', [], [], '', false); $this->directoryMock->expects($this->once())->method('read')->will($this->returnValue([TESTS_TEMP_DIR])); $this->directoryMock->expects($this->any())->method('isDirectory')->will($this->returnValue(true)); $this->filesystemMock = $this->getMock('Magento\\Framework\\App\\Filesystem', [], [], '', false); $this->filesystemMock->expects($this->any())->method('getDirectoryWrite')->with()->will($this->returnValue($this->directoryMock)); /** * @var \Magento\Framework\App\State|\PHPUnit_Framework_MockObject_MockObject */ $appStateMock = $this->getMock('Magento\\Framework\\App\\State', [], [], '', false); $appStateMock->expects($this->any())->method('isInstalled')->will($this->returnValue(true)); $dbModelMock = $this->getMock($dbModelName, [], [], '', false); $dbModelMock->expects($this->any())->method('cleanUpDatabase')->will($this->returnValue($this)); /** * @var \Magento\Framework\ObjectManager|\PHPUnit_Framework_MockObject_MockObject */ $objectManagerMock = $this->getMock('Magento\\Framework\\ObjectManager', [], [], '', false); $objectManagerMock->expects($this->any())->method('get')->with($dbModelName)->will($this->returnValue($dbModelMock)); return new \Magento\Install\Model\Installer\Console($this->getMock('Magento\\Install\\Model\\Installer', [], [], '', false), $this->getMock('Magento\\Framework\\App\\Resource\\Config', [], [], '', false), $this->getMock('Magento\\Framework\\Module\\UpdaterInterface', [], [], '', false), $this->filesystemMock, $this->getMock('Magento\\Install\\Model\\Installer\\Data', [], [], '', false), $appStateMock, $this->getMock('Magento\\Framework\\Locale\\ListsInterface', [], [], '', false), $objectManagerMock); }
protected function setUp() { $this->context = $this->getMock('Magento\\Framework\\Model\\Context', [], [], '', false); $this->registry = $this->getMock('Magento\\Framework\\Registry'); $this->storeManager = $this->getMockBuilder('Magento\\Store\\Model\\StoreManager')->disableOriginalConstructor()->setMethods(array('getStore', 'getWebsite'))->getMock(); $store = $this->getMockBuilder('\\Magento\\Store\\Model\\Store')->disableOriginalConstructor()->setMethods(array('getId', '__sleep', '__wakeup', 'getBaseUrl'))->getMock(); $store->expects($this->any())->method('getId')->will($this->returnValue(1)); $store->expects($this->any())->method('getBaseUrl')->will($this->returnValue('http://magento.com/media/')); $this->storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store)); $this->config = $this->getMockBuilder('Magento\\Catalog\\Model\\Product\\Media\\Config')->setMethods(['getBaseMediaPath'])->disableOriginalConstructor()->getMock(); $this->config->expects($this->any())->method('getBaseMediaPath')->will($this->returnValue('catalog/product')); $this->coreFileHelper = $this->getMockBuilder('Magento\\Core\\Helper\\File\\Storage\\Database')->setMethods(['saveFile', 'deleteFolder'])->disableOriginalConstructor()->getMock(); $this->mediaDirectory = $this->getMockBuilder('Magento\\Framework\\Filesystem\\Directory\\Write')->disableOriginalConstructor()->setMethods(['create', 'isFile', 'isExist', 'getAbsolutePath'])->getMock(); $this->mediaDirectory->expects($this->once())->method('create')->will($this->returnValue(true)); $this->filesystem = $this->getMock('Magento\\Framework\\App\\Filesystem', [], [], '', false); $this->filesystem->expects($this->once())->method('getDirectoryWrite')->with(\Magento\Framework\App\Filesystem::MEDIA_DIR)->will($this->returnValue($this->mediaDirectory)); $this->factory = $this->getMock('Magento\\Framework\\Image\\Factory', [], [], '', false); $this->repository = $this->getMock('Magento\\Framework\\View\\Asset\\Repository', [], [], '', false); $this->fileSystem = $this->getMock('Magento\\Framework\\View\\FileSystem', [], [], '', false); $this->scopeConfigInterface = $this->getMock('Magento\\Framework\\App\\Config\\ScopeConfigInterface'); $objectManagerHelper = new ObjectManagerHelper($this); $this->image = $objectManagerHelper->getObject('Magento\\Catalog\\Model\\Product\\Image', ['registry' => $this->registry, 'storeManager' => $this->storeManager, 'catalogProductMediaConfig' => $this->config, 'coreFileStorageDatabase' => $this->coreFileHelper, 'filesystem' => $this->filesystem, 'imageFactory' => $this->factory, 'assetRepo' => $this->repository, 'viewFileSystem' => $this->fileSystem, 'scopeConfig' => $this->scopeConfigInterface]); }
protected function _setupUrlMocks($size = self::FILE_SIZE, $url = self::URL, $additionalStatData = array()) { $this->_handleMock->expects($this->any())->method('stat')->will($this->returnValue(array_merge(array('size' => $size, 'type' => self::MIME_TYPE), $additionalStatData))); $this->_filesystemMock->expects($this->once())->method('getRemoteResource')->with($url)->will($this->returnValue($this->_handleMock)); $this->_helper->setResource($url, DownloadHelper::LINK_TYPE_URL); }