public function testCleanThemeRelatedContent() { $themeMock = $this->getMockBuilder('Magento\\Framework\\View\\Design\\ThemeInterface')->getMockForAbstractClass(); $eventMock = $this->getMockBuilder('Magento\\Framework\\Event')->disableOriginalConstructor()->getMock(); $eventMock->expects($this->any())->method('getData')->with('theme')->willReturn($themeMock); $observerMock = $this->getMockBuilder('Magento\\Framework\\Event\\Observer')->disableOriginalConstructor()->getMock(); $observerMock->expects($this->any())->method('getEvent')->willReturn($eventMock); $this->themeConfig->expects($this->any())->method('isThemeAssignedToStore')->with($themeMock)->willReturn(false); $this->themeImageFactory->expects($this->once())->method('create')->with(['theme' => $themeMock])->willReturnSelf(); $this->themeImageFactory->expects($this->once())->method('removePreviewImage'); $this->updateCollection->expects($this->once())->method('addThemeFilter')->willReturnSelf(); $this->updateCollection->expects($this->once())->method('delete'); $this->themeObserver->execute($observerMock); }