customer_review.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. require __DIR__ . '/../../../Magento/Customer/_files/customer.php';
  7. require __DIR__ . '/../../../Magento/Catalog/_files/product_simple.php';
  8. \Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea(
  9. \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE
  10. );
  11. $review = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
  12. \Magento\Review\Model\Review::class,
  13. ['data' => [
  14. 'customer_id' => $customer->getId(),
  15. 'title' => 'Review Summary',
  16. 'detail' => 'Review text',
  17. 'nickname' => 'Nickname',
  18. ]]
  19. );
  20. $review
  21. ->setEntityId($review->getEntityIdByCode(\Magento\Review\Model\Review::ENTITY_PRODUCT_CODE))
  22. ->setEntityPkValue($product->getId())
  23. ->setStatusId(\Magento\Review\Model\Review::STATUS_PENDING)
  24. ->setStoreId(
  25. \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
  26. \Magento\Store\Model\StoreManagerInterface::class
  27. )->getStore()->getId()
  28. )
  29. ->setStores([
  30. \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
  31. \Magento\Store\Model\StoreManagerInterface::class
  32. )->getStore()->getId()
  33. ])
  34. ->save();
  35. \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(\Magento\Framework\Registry::class)->register(
  36. 'review_data',
  37. $review
  38. );