Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CreateProductReviewBackendEntityTest.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Review\Test\Fixture\Rating;
11 use Magento\Review\Test\Page\Adminhtml\RatingEdit;
12 use Magento\Review\Test\Page\Adminhtml\RatingIndex;
13 use Magento\Review\Test\Page\Adminhtml\ReviewEdit;
14 use Magento\Review\Test\Page\Adminhtml\ReviewIndex;
15 use Magento\Mtf\TestCase\Injectable;
16 
33 class CreateProductReviewBackendEntityTest extends Injectable
34 {
35  /* tags */
36  const MVP = 'no';
37  const TO_MAINTAIN = 'yes';
38  /* end tags */
39 
45  protected $reviewIndex;
46 
52  protected $reviewEdit;
53 
59  protected $ratingIndex;
60 
66  protected $ratingEdit;
67 
73  protected $productRating;
74 
80  protected $review;
81 
91  public function __inject(
92  ReviewIndex $reviewIndex,
93  ReviewEdit $reviewEdit,
94  RatingIndex $ratingIndex,
95  RatingEdit $ratingEdit
96  ) {
97  $this->reviewIndex = $reviewIndex;
98  $this->reviewEdit = $reviewEdit;
99  $this->ratingIndex = $ratingIndex;
100  $this->ratingEdit = $ratingEdit;
101  }
102 
109  public function test(Review $review)
110  {
111  // Precondition:
112  $product = $review->getDataFieldConfig('entity_id')['source']->getEntity();
113  $filter = ['sku' => $product->getSku()];
114  $this->review = $review;
115 
116  // Steps:
117  $this->reviewIndex->open();
118  $this->reviewIndex->getReviewActions()->addNew();
119  $this->reviewEdit->getProductGrid()->search($filter);
120  $this->reviewEdit->getProductGrid()->openFirstRow();
121  $this->reviewEdit->getReviewForm()->fill($this->review);
122  $this->reviewEdit->getPageActions()->save();
123 
124  return ['product' => $product];
125  }
126 
132  public function tearDown()
133  {
134  $this->ratingIndex->open();
135  if ($this->review instanceof Review) {
136  foreach ($this->review->getRatings() as $rating) {
137  $this->ratingIndex->getRatingGrid()->searchAndOpen(['rating_code' => $rating['title']]);
138  $this->ratingEdit->getPageActions()->delete();
139  $this->ratingEdit->getModalBlock()->acceptAlert();
140  }
141  }
142  }
143 }
$rating
Definition: item.phtml:18
__inject(ReviewIndex $reviewIndex, ReviewEdit $reviewEdit, RatingIndex $ratingIndex, RatingEdit $ratingEdit)