PageTest.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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\Config\Source;
  7. /**
  8. * Class PageTest
  9. */
  10. class PageTest extends \PHPUnit\Framework\TestCase
  11. {
  12. /**
  13. * @var \Magento\Cms\Model\ResourceModel\Page\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject
  14. */
  15. protected $collectionFactory;
  16. /**
  17. * @var \Magento\Cms\Model\Config\Source\Page
  18. */
  19. protected $page;
  20. /**
  21. * Set up
  22. *
  23. * @return void
  24. */
  25. protected function setUp()
  26. {
  27. $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
  28. $this->collectionFactory = $this->createPartialMock(
  29. \Magento\Cms\Model\ResourceModel\Page\CollectionFactory::class,
  30. ['create']
  31. );
  32. $this->page = $objectManager->getObject(
  33. \Magento\Cms\Model\Config\Source\Page::class,
  34. [
  35. 'collectionFactory' => $this->collectionFactory,
  36. ]
  37. );
  38. }
  39. /**
  40. * Run test toOptionArray method
  41. *
  42. * @return void
  43. */
  44. public function testToOptionArray()
  45. {
  46. $pageCollectionMock = $this->createMock(\Magento\Cms\Model\ResourceModel\Page\Collection::class);
  47. $this->collectionFactory->expects($this->once())
  48. ->method('create')
  49. ->will($this->returnValue($pageCollectionMock));
  50. $pageCollectionMock->expects($this->once())
  51. ->method('toOptionIdArray')
  52. ->will($this->returnValue('return-value'));
  53. $this->assertEquals('return-value', $this->page->toOptionArray());
  54. }
  55. }