/** * @expectedException \LogicException * @expectedExceptionMessage Unable to load theme by specified key: '0' */ public function testCreateDummy() { $themeId = 0; $theme = $this->getMock('Magento\\Core\\Model\\Theme', array(), array(), '', false); $theme->expects($this->once())->method('getId')->will($this->returnValue($themeId)); $this->themeProviderMock->expects($this->once())->method('getThemeById')->with($themeId)->will($this->returnValue($theme)); $this->assertNull($this->factory->create($themeId)); }
public function testValidateIsThemeInUse() { $theme = $this->getMock('Magento\\Theme\\Model\\Theme', [], [], '', false); $theme->expects($this->once())->method('getId')->willReturn(6); $defaultEntity = new \Magento\Framework\DataObject(['value' => 6, 'scope' => 'default', 'scope_id' => 8]); $websitesEntity = new \Magento\Framework\DataObject(['value' => 6, 'scope' => 'websites', 'scope_id' => 8]); $storesEntity = new \Magento\Framework\DataObject(['value' => 6, 'scope' => 'stores', 'scope_id' => 8]); $this->themeProvider->expects($this->once())->method('getThemeByFullPath')->willReturn($theme); $this->configData->expects($this->once())->method('getCollection')->willReturn($this->configData); $this->configData->expects($this->at(1))->method('addFieldToFilter')->willReturn($this->configData); $this->configData->expects($this->at(2))->method('addFieldToFilter')->willReturn([$defaultEntity, $websitesEntity, $storesEntity]); $website = $this->getMock('Magento\\Store\\Model\\Website', ['getName'], [], '', false); $website->expects($this->once())->method('getName')->willReturn('websiteA'); $store = $this->getMock('Magento\\Store\\Model\\Store', ['getName'], [], '', false); $store->expects($this->once())->method('getName')->willReturn('storeA'); $this->storeManager->expects($this->once())->method('getWebsite')->willReturn($website); $this->storeManager->expects($this->once())->method('getStore')->willReturn($store); $result = $this->themeValidator->validateIsThemeInUse(['frontend/Magento/a']); $this->assertEquals(['<error>frontend/Magento/a is in use in default config</error>', '<error>frontend/Magento/a is in use in website websiteA</error>', '<error>frontend/Magento/a is in use in store storeA</error>'], $result); }