Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
PhysicalTest.php
Go to the documentation of this file.
1 <?php
11 
12 class PhysicalTest extends \PHPUnit\Framework\TestCase
13 {
14  public function testCreateVirtualTheme()
15  {
16  $physicalTheme = $this->createPartialMock(\Magento\Theme\Model\Theme::class, ['__wakeup']);
17  $physicalTheme->setData(['parent_id' => 10, 'theme_title' => 'Test Theme']);
18 
19  $copyService = $this->createPartialMock(\Magento\Theme\Model\CopyService::class, ['copy']);
20  $copyService->expects($this->once())->method('copy')->will($this->returnValue($copyService));
21 
22  $virtualTheme = $this->createPartialMock(
23  \Magento\Theme\Model\Theme::class,
24  ['__wakeup', 'getThemeImage', 'createPreviewImageCopy', 'save']
25  );
26  $virtualTheme->expects($this->once())->method('getThemeImage')->will($this->returnValue($virtualTheme));
27 
28  $virtualTheme->expects(
29  $this->once()
30  )->method(
31  'createPreviewImageCopy'
32  )->will(
33  $this->returnValue($virtualTheme)
34  );
35 
36  $virtualTheme->expects($this->once())->method('save')->will($this->returnValue($virtualTheme));
37 
38  $themeFactory = $this->createPartialMock(\Magento\Theme\Model\ThemeFactory::class, ['create']);
39  $themeFactory->expects($this->once())->method('create')->will($this->returnValue($virtualTheme));
40 
41  $themeCollection = $this->createPartialMock(
42  \Magento\Theme\Model\ResourceModel\Theme\Collection::class,
43  ['addTypeFilter', 'addAreaFilter', 'addFilter', 'count']
44  );
45 
46  $themeCollection->expects($this->any())->method('addTypeFilter')->will($this->returnValue($themeCollection));
47 
48  $themeCollection->expects($this->any())->method('addAreaFilter')->will($this->returnValue($themeCollection));
49 
50  $themeCollection->expects($this->any())->method('addFilter')->will($this->returnValue($themeCollection));
51 
52  $themeCollection->expects($this->once())->method('count')->will($this->returnValue(1));
53 
54  $domainModel = new \Magento\Theme\Model\Theme\Domain\Physical(
55  $this->createMock(\Magento\Framework\View\Design\ThemeInterface::class),
56  $themeFactory,
57  $copyService,
58  $themeCollection
59  );
60  $domainModel->createVirtualTheme($physicalTheme);
61  }
62 }