/** * Create mock objects */ protected function setUp() { $this->scopeConfigMock = $this->getMockBuilder('Magento\\Framework\\App\\Config\\ScopeConfigInterface')->getMock(); $this->contextMock = $this->getMock('Magento\\Framework\\App\\Helper\\Context', [], [], '', false); $this->contextMock->expects($this->any())->method('getScopeConfig')->willReturn($this->scopeConfigMock); $this->helper = new \Magento\ProductVideo\Helper\Media($this->contextMock); }
protected function setUp() { $this->objectManagerHelper = new ObjectManagerHelper($this); $this->context = $this->getMockBuilder('\\Magento\\Framework\\App\\Helper\\Context')->disableOriginalConstructor()->getMock(); $this->scopeConfig = $this->getMock('\\Magento\\Framework\\App\\Config\\ScopeConfigInterface'); $this->productConfig = $this->getMockBuilder('\\Magento\\Catalog\\Helper\\Product\\Configuration')->disableOriginalConstructor()->getMock(); $this->context->expects($this->once())->method('getScopeConfig')->willReturn($this->scopeConfig); $this->helper = $this->objectManagerHelper->getObject('Magento\\Downloadable\\Helper\\Catalog\\Product\\Configuration', ['context' => $this->context, 'productConfig' => $this->productConfig]); }
protected function setUp() { $this->urlBuilderMock = $this->getMock('Magento\\Framework\\UrlInterface', [], [], '', false); $this->moduleManagerMock = $this->getMock('Magento\\Framework\\Module\\Manager', [], [], '', false); $this->contextMock = $this->getMock('Magento\\Framework\\App\\Helper\\Context', [], [], '', false); $this->contextMock->expects($this->once())->method('getModuleManager')->will($this->returnValue($this->moduleManagerMock)); $this->contextMock->expects($this->once())->method('getUrlBuilder')->will($this->returnValue($this->urlBuilderMock)); $this->helper = $this->getMockForAbstractClass('Magento\\Framework\\App\\Helper\\AbstractHelper', ['context' => $this->contextMock]); }
protected function _initMock() { $scopeConfig = $this->_getConfigStub(); $this->_request = $this->getMock('\\Magento\\Framework\\App\\Request\\Http', ['getCookie'], [], '', false, false); $this->_context = $this->getMock('Magento\\Framework\\App\\Helper\\Context', ['getRequest', 'getScopeConfig'], [], '', false, false); $this->_context->expects($this->once())->method('getRequest')->will($this->returnValue($this->_request)); $this->_context->expects($this->once())->method('getScopeConfig')->will($this->returnValue($scopeConfig)); $this->_object = new \Magento\Cookie\Helper\Cookie($this->_context, $this->getMock('Magento\\Store\\Model\\StoreManager', [], [], '', false, false), ['current_store' => $this->_getStoreStub(), 'website' => $this->_getWebsiteStub()]); return $this; }
public function setUp() { $this->context = $this->getMockBuilder('Magento\\Framework\\App\\Helper\\Context')->disableOriginalConstructor()->getMock(); $this->request = $this->getMock('Magento\\Framework\\App\\RequestInterface'); $this->context->expects(static::once())->method('getRequest')->willReturn($this->request); $this->directoryHelperMock = $this->getMockBuilder('Magento\\Directory\\Helper\\Data')->disableOriginalConstructor()->getMock(); $this->backendConfig = $this->getMockBuilder('Magento\\Config\\Model\\Config')->disableOriginalConstructor()->getMock(); $this->scopeDefiner = $this->getMockBuilder('Magento\\Config\\Model\\Config\\ScopeDefiner')->disableOriginalConstructor()->getMock(); $this->helper = new Backend($this->context, $this->directoryHelperMock, $this->backendConfig, $this->scopeDefiner); }
public function setUp() { $this->_stringMock = $this->getMock('Magento\\Framework\\Stdlib\\String'); $this->_queryFactoryMock = $this->getMock('Magento\\Search\\Model\\QueryFactory', [], [], '', false); $this->_scopeConfigMock = $this->getMock('Magento\\Framework\\App\\Config\\ScopeConfigInterface'); $this->_escaperMock = $this->getMock('Magento\\Framework\\Escaper'); $this->_storeManagerMock = $this->getMock('Magento\\Store\\Model\\StoreManagerInterface'); $this->_contextMock = $this->getMock('Magento\\Framework\\App\\Helper\\Context', [], [], '', false); $this->_contextMock->expects($this->any())->method('getScopeConfig')->willReturn($this->_scopeConfigMock); $this->_model = new \Magento\CatalogSearch\Helper\Data($this->_contextMock, $this->_stringMock, $this->_queryFactoryMock, $this->_escaperMock, $this->_storeManagerMock); }
public function setUp() { $this->stringMock = $this->getMock('Magento\\Framework\\Stdlib\\StringUtils'); $this->scopeConfigMock = $this->getMock('Magento\\Framework\\App\\Config\\ScopeConfigInterface'); $this->escaperMock = $this->getMock('Magento\\Framework\\Escaper'); $this->storeManagerMock = $this->getMock('Magento\\Store\\Model\\StoreManagerInterface'); $this->requestMock = $this->getMockBuilder('\\Magento\\Framework\\App\\RequestInterface')->disableOriginalConstructor()->setMethods([])->getMock(); $this->contextMock = $this->getMock('Magento\\Framework\\App\\Helper\\Context', [], [], '', false); $this->contextMock->expects($this->any())->method('getScopeConfig')->willReturn($this->scopeConfigMock); $this->contextMock->expects($this->any())->method('getRequest')->willReturn($this->requestMock); $this->model = new \Magento\Search\Helper\Data($this->contextMock, $this->stringMock, $this->escaperMock, $this->storeManagerMock); }
protected function setUp() { $this->requestMock = $this->getMockBuilder('\\Magento\\Framework\\App\\RequestInterface')->disableOriginalConstructor()->setMethods([])->getMock(); $this->contextMock = $this->getMockBuilder('Magento\\Framework\\App\\Helper\\Context')->setMethods(['getRequest'])->disableOriginalConstructor()->getMock(); $this->contextMock->expects($this->once())->method('getRequest')->will($this->returnValue($this->requestMock)); $this->objectManagerMock = $this->getMockBuilder('Magento\\Framework\\ObjectManagerInterface')->setMethods([])->getMock(); $this->stringMock = $this->getMockBuilder('Magento\\Framework\\Stdlib\\String')->setMethods(['cleanString', 'substr'])->getMock(); $this->stringMock->expects($this->any())->method('cleanString')->will($this->returnArgument(0)); $this->scopeConfigMock = $this->getMockBuilder('Magento\\Framework\\App\\Config\\ScopeConfigInterface')->setMethods([])->getMock(); $this->queryMock = $this->getMockBuilder('\\Magento\\Search\\Model\\Query')->disableOriginalConstructor()->setMethods(['setIsQueryTextExceeded', 'getId', 'setQueryText', 'loadByQuery'])->getMock(); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->queryFactory = $this->objectManagerHelper->getObject('Magento\\Search\\Model\\QueryFactory', ['context' => $this->contextMock, 'objectManager' => $this->objectManagerMock, 'string' => $this->stringMock, 'scopeConfig' => $this->scopeConfigMock]); }
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); }
protected function setUp() { $this->path = 'PATH/'; $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->eventManagerMock = $this->getMock('Magento\\Framework\\Event\\ManagerInterface', [], [], '', false); $this->requestMock = $this->getMock('Magento\\Framework\\App\\RequestInterface', [], [], '', false); $this->urlEncoderMock = $this->getMock('Magento\\Framework\\Url\\EncoderInterface', [], [], '', false); $this->backendDataMock = $this->getMock('Magento\\Backend\\Helper\\Data', [], [], '', false); $this->contextMock = $this->getMock('Magento\\Framework\\App\\Helper\\Context', [], [], '', false); $this->contextMock->expects($this->any())->method('getEventManager')->willReturn($this->eventManagerMock); $this->contextMock->expects($this->any())->method('getRequest')->willReturn($this->requestMock); $this->contextMock->expects($this->any())->method('getUrlEncoder')->willReturn($this->urlEncoderMock); $this->directoryWriteMock = $this->getMock('\\Magento\\Framework\\Filesystem\\Directory\\Write', [], ['path' => $this->path], '', false); $this->directoryWriteMock->expects($this->any())->method('getAbsolutePath')->willReturnMap([[WysiwygConfig::IMAGE_DIRECTORY, null, $this->getAbsolutePath(WysiwygConfig::IMAGE_DIRECTORY)], [null, null, $this->getAbsolutePath(null)]]); $this->filesystemMock = $this->getMock('Magento\\Framework\\Filesystem', [], [], '', false); $this->filesystemMock->expects($this->once())->method('getDirectoryWrite')->willReturn($this->directoryWriteMock); $this->storeManagerMock = $this->getMockBuilder('Magento\\Store\\Model\\StoreManagerInterface')->setMethods(['clearWebsiteCache', 'getDefaultStoreView', 'getGroup', 'getGroups', 'getStore', 'getStores', 'getWebsite', 'getWebsites', 'hasSingleStore', 'isSingleStoreMode', 'reinitStores', 'setCurrentStore', 'setIsSingleStoreModeAllowed'])->disableOriginalConstructor()->getMock(); $this->storeMock = $this->getMock('Magento\\Store\\Model\\Store', [], [], '', false); $this->imagesHelper = $this->objectManager->getObject('Magento\\Cms\\Helper\\Wysiwyg\\Images', ['context' => $this->contextMock, 'filesystem' => $this->filesystemMock, 'storeManager' => $this->storeManagerMock, 'backendData' => $this->backendDataMock]); }
protected function mockContext() { $this->context = $this->getMockBuilder('Magento\\Framework\\App\\Helper\\Context')->disableOriginalConstructor()->getMock(); $this->scopeConfig = $this->getMockBuilder('Magento\\Framework\\App\\Config\\ScopeConfigInterface')->getMockForAbstractClass(); $this->context->expects($this->any())->method('getScopeConfig')->willReturn($this->scopeConfig); }