41 $this->themeCustomization = $this->createMock(\
Magento\Framework\View\Design\Theme\Customization::class);
42 $themeMock = $this->createPartialMock(\
Magento\Theme\Model\Theme::class, [
'__wakeup',
'getCustomization']);
48 $this->returnValue($this->themeCustomization)
51 $designMock = $this->createMock(\
Magento\Framework\View\DesignInterface::class);
52 $designMock->expects($this->any())->method(
'getDesignTheme')->will($this->returnValue($themeMock));
54 $this->assetsMock = $this->createMock(\
Magento\Framework\View\Asset\GroupedCollection::class);
56 $this->assetRepo = $this->createMock(\
Magento\Framework\View\Asset\Repository::class);
58 $this->logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock();
60 $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
61 $this->themeObserver = $objectManagerHelper->getObject(
62 \
Magento\Theme\Observer\ApplyThemeCustomizationObserver::class,
64 'design' => $designMock,
65 'assets' => $this->assetsMock,
66 'assetRepo' => $this->assetRepo,
67 'logger' => $this->logger,
74 $asset = $this->createMock(\
Magento\Framework\View\Asset\File::class);
75 $file = $this->createMock(\
Magento\Theme\Model\Theme\File::class);
76 $fileService = $this->getMockForAbstractClass(
77 \
Magento\Framework\View\Design\Theme\Customization\FileAssetInterface::class
79 $file->expects($this->any())->method(
'getCustomizationService')->will($this->returnValue($fileService));
81 $this->assetRepo->expects($this->once())
82 ->method(
'createArbitrary')
83 ->will($this->returnValue($asset));
85 $this->themeCustomization->expects($this->once())->method(
'getFiles')->will($this->returnValue([$file]));
86 $this->assetsMock->expects($this->once())->method(
'add')->with($this->anything(), $asset);
88 $observer = new \Magento\Framework\Event\Observer();
94 $file = $this->createMock(\
Magento\Theme\Model\Theme\File::class);
95 $file->expects($this->any())
96 ->method(
'getCustomizationService')
97 ->willThrowException(
new \InvalidArgumentException());
99 $this->themeCustomization->expects($this->once())->method(
'getFiles')->will($this->returnValue([$file]));
100 $this->logger->expects($this->once())->method(
'critical');
102 $observer = new \Magento\Framework\Event\Observer();
103 $this->themeObserver->execute(
$observer);
testApplyThemeCustomization()
testApplyThemeCustomizationException()