SearchResultTest.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Api\Test\Unit\Search;
  7. use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
  8. use Magento\Framework\Api\Search\SearchResult;
  9. use Magento\Framework\Api\Search\DocumentInterface;
  10. class SearchResultTest extends \PHPUnit\Framework\TestCase
  11. {
  12. /**
  13. * @var SearchResult
  14. */
  15. private $search;
  16. /**
  17. * @var DocumentInterface[]
  18. */
  19. private $items;
  20. /**
  21. * @var ObjectManager
  22. */
  23. private $objectManager;
  24. /**
  25. * Set up
  26. */
  27. protected function setUp()
  28. {
  29. $document1 = $this->createMock(DocumentInterface::class);
  30. $document2 = $this->createMock(DocumentInterface::class);
  31. $this->items = [ $document1, $document2];
  32. $document1->expects($this->any())
  33. ->method('getId')
  34. ->willReturn(1);
  35. $document2->expects($this->any())
  36. ->method('getId')
  37. ->willReturn(2);
  38. $data = [
  39. 'items' => $this->items
  40. ];
  41. $this->objectManager = new ObjectManager($this);
  42. $this->search = $this->objectManager->getObject(
  43. SearchResult::class,
  44. [
  45. 'data' => $data
  46. ]
  47. );
  48. }
  49. /**
  50. * Test getItems
  51. */
  52. public function testGetItems()
  53. {
  54. $this->assertEquals($this->items, $this->search->getItems());
  55. }
  56. }