review_xss.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. require __DIR__ . '/../../../Magento/Catalog/_files/product_simple_xss.php';
  7. $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
  8. $productRepository = $objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class);
  9. $product = $productRepository->get('product-with-xss');
  10. $review = $objectManager->create(\Magento\Review\Model\Review::class);
  11. $review->setEntityId(
  12. $review->getEntityIdByCode(\Magento\Review\Model\Review::ENTITY_PRODUCT_CODE)
  13. )->setEntityPkValue(
  14. $product->getId()
  15. )->setStatusId(
  16. \Magento\Review\Model\Review::STATUS_PENDING
  17. )->setStoreId(
  18. \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
  19. \Magento\Store\Model\StoreManagerInterface::class
  20. )->getStore()->getId()
  21. )->setStores(
  22. [
  23. \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
  24. \Magento\Store\Model\StoreManagerInterface::class
  25. )->getStore()->getId()
  26. ]
  27. )->setNickname(
  28. 'Nickname'
  29. )->setTitle(
  30. 'Review Summary'
  31. )->setDetail(
  32. 'Review text'
  33. )->save();