PageLayoutTest.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Cms\Test\Unit\Model\Page\Source;
  7. use Magento\Cms\Model\Page\Source\PageLayout;
  8. use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
  9. use Magento\Framework\View\Model\PageLayout\Config\BuilderInterface;
  10. use Magento\Framework\View\PageLayout\Config;
  11. class PageLayoutTest extends \PHPUnit\Framework\TestCase
  12. {
  13. /**
  14. * @var BuilderInterface|\PHPUnit_Framework_MockObject_MockObject
  15. */
  16. protected $builderMock;
  17. /**
  18. * @var Config|\PHPUnit_Framework_MockObject_MockObject
  19. */
  20. protected $pageLayoutConfigMock;
  21. /**
  22. * @var ObjectManager
  23. */
  24. protected $objectManagerHelper;
  25. /**
  26. * @var PageLayout
  27. */
  28. protected $object;
  29. /**
  30. * {@inheritdoc}
  31. */
  32. protected function setUp()
  33. {
  34. $this->objectManagerHelper = new ObjectManager($this);
  35. $this->builderMock = $this->getMockBuilder(
  36. \Magento\Framework\View\Model\PageLayout\Config\BuilderInterface::class
  37. )->disableOriginalConstructor()
  38. ->setMethods(['getPageLayoutsConfig'])
  39. ->getMock();
  40. $this->pageLayoutConfigMock = $this->getMockBuilder(\Magento\Framework\View\PageLayout\Config::class)
  41. ->disableOriginalConstructor()
  42. ->setMethods(['getOptions'])
  43. ->getMock();
  44. $this->builderMock->expects($this->any())
  45. ->method('getPageLayoutsConfig')
  46. ->willReturn($this->pageLayoutConfigMock);
  47. $this->object = $this->objectManagerHelper->getObject($this->getSourceClassName(), [
  48. 'pageLayoutBuilder' => $this->builderMock,
  49. ]);
  50. }
  51. /**
  52. * @return string
  53. */
  54. protected function getSourceClassName()
  55. {
  56. return \Magento\Cms\Model\Page\Source\PageLayout::class;
  57. }
  58. /**
  59. * @param array $options
  60. * @param array $expected
  61. * @return void
  62. * @dataProvider getOptionsDataProvider
  63. */
  64. public function testToOptionArray(array $options, array $expected)
  65. {
  66. $this->pageLayoutConfigMock->expects($this->once())
  67. ->method('getOptions')
  68. ->willReturn($options);
  69. $this->assertSame($expected, $this->object->toOptionArray());
  70. }
  71. /**
  72. * @return array
  73. */
  74. public function getOptionsDataProvider()
  75. {
  76. return [
  77. [
  78. [],
  79. [],
  80. ],
  81. [
  82. ['testStatus' => 'testValue'],
  83. [['label' => 'testValue', 'value' => 'testStatus']],
  84. ],
  85. ];
  86. }
  87. }