Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DumpTest.php
Go to the documentation of this file.
1 <?php
7 
12 
13 class DumpTest extends \PHPUnit\Framework\TestCase
14 {
18  private $dumpPlugin;
19 
23  private $arrayManager;
24 
30  private $themes = [
31  1 => 'adminhtml/Magento/backend',
32  2 => 'frontend/Magento/blank',
33  3 => 'frontend/Magento/luma',
34  ];
35 
39  private $themeList;
40 
41  public function setUp()
42  {
43  $this->arrayManager = new ArrayManager();
44  $this->themeList = $this->getMockBuilder(ListInterface::class)
45  ->setMethods(['getItemById', 'getThemeByFullPath'])
46  ->disableOriginalConstructor()
47  ->getMock();
48  $this->prepareThemeMock();
49 
50  $this->dumpPlugin = new Dump($this->themeList, $this->arrayManager);
51  }
52 
58  public function testAfterGet($actualResult, $expectedResult)
59  {
60  $dumpConfig = $this->getMockBuilder(DumpConfigSourceAggregated::class)
61  ->disableOriginalConstructor()
62  ->getMock();
63  $this->assertEquals($expectedResult, $this->dumpPlugin->afterGet($dumpConfig, $actualResult));
64  }
65 
71  private function prepareThemeMock()
72  {
73  $themesMap = [];
74  foreach ($this->themes as $themeId => $themeFullPath) {
75  $themeMock = $this->getMockBuilder(\Magento\Framework\View\Design\ThemeInterface::class)
76  ->getMockForAbstractClass();
77  $themeMock->expects(static::any())->method('getFullPath')->willReturn($themeFullPath);
78 
79  $themesMap[] = [$themeId, $themeMock];
80  }
81 
82  $this->themeList->expects(static::any())->method('getItemById')->willReturnMap($themesMap);
83  }
84 
88  public function getDumpConfigDataProvider()
89  {
90  return [
91  [
92  [
93  'default' => [
94  'general' => [
95  'locale' => [
96  'code' => 'en_US',
97  'timezone' => 'America/Chicago',
98  ],
99  ],
100  'design' => ['theme' => ['theme_id' => 2]],
101  ],
102  ],
103  [
104  'default' => [
105  'general' => [
106  'locale' => [
107  'code' => 'en_US',
108  'timezone' => 'America/Chicago',
109  ],
110  ],
111  'design' => ['theme' => ['theme_id' => 'frontend/Magento/blank']],
112  ],
113  ],
114  ],
115  [
116  [
117  'default' => [
118  'general' => [
119  'locale' => [
120  'code' => 'en_US',
121  'timezone' => 'America/Chicago',
122  ],
123  ],
124  ],
125  ],
126  [
127  'default' => [
128  'general' => [
129  'locale' => [
130  'code' => 'en_US',
131  'timezone' => 'America/Chicago',
132  ],
133  ],
134  ],
135  ],
136  ],
137  [
138  [],[],
139  ],
140  [
141  [
142  'stores' => [
143  'default' => [
144  'design' => ['theme' => ['theme_id' => 3]],
145  ],
146  ],
147  ],
148  [
149  'stores' => [
150  'default' => [
151  'design' => ['theme' => ['theme_id' => 'frontend/Magento/luma']],
152  ],
153  ],
154  ],
155  ],
156  [
157  [
158  'websites' => [
159  'base' => [
160  'design' => ['theme' => ['theme_id' => 3]],
161  ],
162  ],
163  ],
164  [
165  'websites' => [
166  'base' => [
167  'design' => ['theme' => ['theme_id' => 'frontend/Magento/luma']],
168  ],
169  ],
170  ],
171  ],
172  ];
173  }
174 }