ConfigTest.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\View\Test\Unit;
  7. use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
  8. class ConfigTest extends \PHPUnit\Framework\TestCase
  9. {
  10. /** @var \Magento\Framework\View\Config */
  11. protected $config;
  12. /** @var ObjectManagerHelper */
  13. protected $objectManagerHelper;
  14. /** @var \Magento\Framework\View\Asset\Repository | \PHPUnit_Framework_MockObject_MockObject */
  15. protected $repositoryMock;
  16. /**
  17. * @var \Magento\Framework\Config\ViewFactory | \PHPUnit_Framework_MockObject_MockObject
  18. */
  19. protected $viewConfigFactoryMock;
  20. protected function setUp()
  21. {
  22. $this->repositoryMock = $this->createMock(\Magento\Framework\View\Asset\Repository::class);
  23. $this->viewConfigFactoryMock = $this->createMock(\Magento\Framework\Config\ViewFactory::class);
  24. $this->objectManagerHelper = new ObjectManagerHelper($this);
  25. $this->config = $this->objectManagerHelper->getObject(
  26. \Magento\Framework\View\Config::class,
  27. [
  28. 'assetRepo' => $this->repositoryMock,
  29. 'viewConfigFactory' => $this->viewConfigFactoryMock
  30. ]
  31. );
  32. }
  33. public function testGetViewConfig()
  34. {
  35. $themeCode = 'area/theme';
  36. $themeMock = $this->createPartialMock(\Magento\Theme\Model\Theme::class, ['getFullPath']);
  37. $themeMock->expects($this->atLeastOnce())
  38. ->method('getFullPath')
  39. ->will($this->returnValue($themeCode));
  40. $params = [
  41. 'themeModel' => $themeMock,
  42. 'area' => 'frontend'
  43. ];
  44. $this->repositoryMock->expects($this->atLeastOnce())
  45. ->method('updateDesignParams')
  46. ->with($this->equalTo($params))
  47. ->will($this->returnSelf());
  48. $configViewMock = $this->createMock(\Magento\Framework\Config\View::class);
  49. $this->viewConfigFactoryMock->expects($this->once())
  50. ->method('create')
  51. ->willReturn($configViewMock);
  52. $this->assertInstanceOf(\Magento\Framework\Config\View::class, $this->config->getViewConfig($params));
  53. // lazy load test
  54. $this->assertInstanceOf(\Magento\Framework\Config\View::class, $this->config->getViewConfig($params));
  55. }
  56. }