49 protected function setUp()
52 $this->_themeMock = $this->createMock(\
Magento\
Theme\Model\Theme::class);
53 $this->_storeManagerMock = $this->getMockForAbstractClass(
54 \
Magento\Store\Model\StoreManagerInterface::class,
60 [
'getStores',
'isSingleStoreMode']
62 $this->_configData = $this->createPartialMock(
64 [
'getCollection',
'addFieldToFilter',
'__wakeup']
66 $this->_configCacheMock = $this->getMockForAbstractClass(\
Magento\Framework\Cache\FrontendInterface::class);
67 $this->_layoutCacheMock = $this->getMockForAbstractClass(\
Magento\Framework\Cache\FrontendInterface::class);
69 $this->_scopeConfigWriter = $this->createPartialMock(
74 $this->_model = new \Magento\Theme\Model\Config(
76 $this->_scopeConfigWriter,
77 $this->_storeManagerMock,
78 $this->createMock(\
Magento\Framework\Event\ManagerInterface::class),
79 $this->_configCacheMock,
80 $this->_layoutCacheMock
86 $this->_themeMock =
null;
87 $this->_configData =
null;
88 $this->_themeFactoryMock =
null;
89 $this->_configCacheMock =
null;
90 $this->_layoutCacheMock =
null;
99 $this->_storeManagerMock->expects($this->once())->method(
'isSingleStoreMode')->will($this->returnValue(
true));
101 $themePath =
'Magento/blank';
103 $configEntity = new \Magento\Framework\DataObject([
'value' => 6,
'scope_id' => 8]);
105 $this->_configData->expects(
110 $this->returnValue($this->_configData)
113 $this->_configData->expects(
119 \
Magento\Store\Model\ScopeInterface::SCOPE_STORES
121 $this->returnValue($this->_configData)
124 $this->_configData->expects(
130 \
Magento\Framework\View\DesignInterface::XML_PATH_THEME_ID
132 $this->returnValue([$configEntity])
135 $this->_themeMock->expects($this->any())->method(
'getId')->will($this->returnValue(6));
136 $this->_themeMock->expects($this->any())->method(
'getThemePath')->will($this->returnValue($themePath));
138 $this->_scopeConfigWriter->expects($this->once())->method(
'delete');
140 $this->_scopeConfigWriter->expects($this->once())->method(
'save');
142 $this->_model->assignToStore($this->_themeMock, [2, 3, 5]);
150 $this->_storeManagerMock->expects($this->once())->method(
'isSingleStoreMode')->will($this->returnValue(
false));
152 $themePath =
'Magento/blank';
154 $configEntity = new \Magento\Framework\DataObject([
'value' => 6,
'scope_id' => 8]);
156 $this->_configData->expects(
161 $this->returnValue($this->_configData)
164 $this->_configData->expects(
170 \
Magento\Store\Model\ScopeInterface::SCOPE_STORES
172 $this->returnValue($this->_configData)
175 $this->_configData->expects(
181 \
Magento\Framework\View\DesignInterface::XML_PATH_THEME_ID
183 $this->returnValue([$configEntity])
186 $this->_themeMock->expects($this->any())->method(
'getId')->will($this->returnValue(6));
187 $this->_themeMock->expects($this->any())->method(
'getThemePath')->will($this->returnValue($themePath));
189 $this->_scopeConfigWriter->expects($this->once())->method(
'delete');
191 $this->_scopeConfigWriter->expects($this->exactly(3))->method(
'save');
193 $this->_model->assignToStore($this->_themeMock, [2, 3, 5]);
testAssignToStoreInSingleStoreMode()
testAssignToStoreNonSingleStoreMode()