Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ConfigTest.php
Go to the documentation of this file.
1 <?php
8 
10 
11 class ConfigTest extends \PHPUnit\Framework\TestCase
12 {
14  protected $config;
15 
18 
20  protected $repositoryMock;
21 
26 
27  protected function setUp()
28  {
29  $this->repositoryMock = $this->createMock(\Magento\Framework\View\Asset\Repository::class);
30  $this->viewConfigFactoryMock = $this->createMock(\Magento\Framework\Config\ViewFactory::class);
31  $this->objectManagerHelper = new ObjectManagerHelper($this);
32  $this->config = $this->objectManagerHelper->getObject(
33  \Magento\Framework\View\Config::class,
34  [
35  'assetRepo' => $this->repositoryMock,
36  'viewConfigFactory' => $this->viewConfigFactoryMock
37  ]
38  );
39  }
40 
41  public function testGetViewConfig()
42  {
43  $themeCode = 'area/theme';
44 
45  $themeMock = $this->createPartialMock(\Magento\Theme\Model\Theme::class, ['getFullPath']);
46  $themeMock->expects($this->atLeastOnce())
47  ->method('getFullPath')
48  ->will($this->returnValue($themeCode));
49  $params = [
50  'themeModel' => $themeMock,
51  'area' => 'frontend'
52  ];
53  $this->repositoryMock->expects($this->atLeastOnce())
54  ->method('updateDesignParams')
55  ->with($this->equalTo($params))
56  ->will($this->returnSelf());
57  $configViewMock = $this->createMock(\Magento\Framework\Config\View::class);
58  $this->viewConfigFactoryMock->expects($this->once())
59  ->method('create')
60  ->willReturn($configViewMock);
61  $this->assertInstanceOf(\Magento\Framework\Config\View::class, $this->config->getViewConfig($params));
62  // lazy load test
63  $this->assertInstanceOf(\Magento\Framework\Config\View::class, $this->config->getViewConfig($params));
64  }
65 }
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
Definition: website.php:18