LayoutTest.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Theme\Test\Unit\Model\Layout\Source;
  7. use Magento\Framework\DataObject;
  8. use Magento\Theme\Model\Layout\Source\Layout;
  9. class LayoutTest extends \PHPUnit\Framework\TestCase
  10. {
  11. /**
  12. * @var Layout
  13. */
  14. protected $_model;
  15. /**
  16. * @var \Magento\Theme\Model\Layout\Config|\PHPUnit_Framework_MockObject_MockObject
  17. */
  18. protected $config;
  19. protected function setUp()
  20. {
  21. $this->config = $this->getMockBuilder(\Magento\Theme\Model\Layout\Config::class)
  22. ->disableOriginalConstructor()
  23. ->getMock();
  24. $this->_model = new Layout($this->config);
  25. }
  26. /**
  27. * @test
  28. * @return void
  29. * @covers \Magento\Theme\Model\Layout\Source\Layout::toOptionArray
  30. * @covers \Magento\Theme\Model\Layout\Source\Layout::getOptions
  31. * @covers \Magento\Theme\Model\Layout\Source\Layout::getDefaultValue
  32. * @covers \Magento\Theme\Model\Layout\Source\Layout::__construct
  33. */
  34. public function testToOptionArray()
  35. {
  36. $data = ['code' => 'testCode', 'label' => 'testLabel', 'is_default' => true];
  37. $expectedResult = [
  38. ['value' => '', 'label' => __('-- Please Select --')],
  39. ['value' => 'testCode', 'label' => 'testLabel'],
  40. ];
  41. $this->config->expects($this->once())
  42. ->method('getPageLayouts')
  43. ->willReturn([new DataObject($data)]);
  44. $this->assertEquals($expectedResult, $this->_model->toOptionArray(true));
  45. $this->assertEquals('testCode', $this->_model->getDefaultValue());
  46. }
  47. }