CollectionTest.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Review\Model\ResourceModel\Rating;
  7. class CollectionTest extends \PHPUnit\Framework\TestCase
  8. {
  9. /**
  10. * @var \Magento\Review\Model\ResourceModel\Rating\Collection
  11. */
  12. protected $collection;
  13. protected function setUp()
  14. {
  15. $this->collection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
  16. \Magento\Review\Model\ResourceModel\Rating\Collection::class
  17. );
  18. }
  19. /**
  20. * @magentoDataFixture Magento/Review/_files/customer_review_with_rating.php
  21. */
  22. public function testAddEntitySummaryToItem()
  23. {
  24. $ratingData = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
  25. ->get(\Magento\Framework\Registry::class)
  26. ->registry('rating_data');
  27. $result = $this->collection->addEntitySummaryToItem($ratingData->getEntityId(), $ratingData->getStoreId());
  28. $this->assertEquals($this->collection, $result);
  29. }
  30. /**
  31. * @magentoDbIsolation enabled
  32. */
  33. public function testAddEntitySummaryToItemEmpty()
  34. {
  35. foreach ($this->collection->getItems() as $item) {
  36. $item->delete();
  37. }
  38. $this->collection->clear();
  39. $result = $this->collection->addEntitySummaryToItem(1, 1);
  40. $this->assertEquals($this->collection, $result);
  41. }
  42. public function testAddStoreData()
  43. {
  44. $this->collection->addStoreData();
  45. }
  46. public function testSetStoreFilter()
  47. {
  48. $this->collection->setStoreFilter(1);
  49. }
  50. }