ThemeTest.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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\Theme;
  8. use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
  9. use Magento\Framework\View\Design\Theme\Label\ListInterface;
  10. class ThemeTest extends \PHPUnit\Framework\TestCase
  11. {
  12. /**
  13. * @var ListInterface|\PHPUnit_Framework_MockObject_MockObject
  14. */
  15. protected $listMock;
  16. /**
  17. * @var ObjectManager
  18. */
  19. protected $objectManagerHelper;
  20. /**
  21. * @var Theme
  22. */
  23. protected $object;
  24. /**
  25. * {@inheritdoc}
  26. */
  27. protected function setUp()
  28. {
  29. $this->objectManagerHelper = new ObjectManager($this);
  30. $this->listMock = $this->getMockBuilder(\Magento\Framework\View\Design\Theme\Label\ListInterface::class)
  31. ->disableOriginalConstructor()
  32. ->setMethods(['getLabels'])
  33. ->getMock();
  34. $this->object = $this->objectManagerHelper->getObject($this->getClassName(), [
  35. 'themeList' => $this->listMock,
  36. ]);
  37. }
  38. /**
  39. * @return string
  40. */
  41. protected function getClassName()
  42. {
  43. return \Magento\Cms\Model\Page\Source\Theme::class;
  44. }
  45. /**
  46. * @param array $options
  47. * @param array $expected
  48. * @return void
  49. * @dataProvider getOptionsDataProvider
  50. */
  51. public function testToOptionArray(array $options, array $expected)
  52. {
  53. $this->listMock->expects($this->once())
  54. ->method('getLabels')
  55. ->willReturn($options);
  56. $this->assertEquals($expected, $this->object->toOptionArray());
  57. }
  58. /**
  59. * @return array
  60. */
  61. public function getOptionsDataProvider()
  62. {
  63. return [
  64. [
  65. [],
  66. [['label' => 'Default', 'value' => '']],
  67. ],
  68. [
  69. [['label' => 'testValue', 'value' => 'testStatus']],
  70. [['label' => 'Default', 'value' => ''], ['label' => 'testValue', 'value' => 'testStatus']],
  71. ],
  72. ];
  73. }
  74. }