forked from magento/magento2
/
ConfigTest.php
67 lines (59 loc) · 2.36 KB
/
ConfigTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Framework\View\Test\Unit;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
class ConfigTest extends \PHPUnit_Framework_TestCase
{
/** @var \Magento\Framework\View\Config */
protected $config;
/** @var ObjectManagerHelper */
protected $objectManagerHelper;
/** @var \Magento\Framework\View\Asset\Repository | \PHPUnit_Framework_MockObject_MockObject */
protected $repositoryMock;
/**
* @var \Magento\Framework\Config\ViewFactory | \PHPUnit_Framework_MockObject_MockObject
*/
protected $viewConfigFactoryMock;
protected function setUp()
{
$this->repositoryMock = $this->getMock('Magento\Framework\View\Asset\Repository', [], [], '', false);
$this->viewConfigFactoryMock = $this->getMock('Magento\Framework\Config\ViewFactory', [], [], '', false);
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->config = $this->objectManagerHelper->getObject(
'Magento\Framework\View\Config',
[
'assetRepo' => $this->repositoryMock,
'viewConfigFactory' => $this->viewConfigFactoryMock
]
);
}
public function testGetViewConfig()
{
$themeMock = $this->getMock(
'Magento\Theme\Model\Theme',
['getCode'],
[],
'',
false
);
$themeMock->expects($this->atLeastOnce())
->method('getCode')
->will($this->returnValue(2));
$params = ['themeModel' => $themeMock];
$this->repositoryMock->expects($this->atLeastOnce())
->method('updateDesignParams')
->with($this->equalTo($params))
->will($this->returnSelf());
$configViewMock = $this->getMock('Magento\Framework\Config\View', [], [], '', false);
$this->viewConfigFactoryMock->expects($this->once())
->method('create')
->willReturn($configViewMock);
$this->assertInstanceOf('Magento\Framework\Config\View', $this->config->getViewConfig($params));
// lazy load test
$this->assertInstanceOf('Magento\Framework\Config\View', $this->config->getViewConfig($params));
}
}