Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
UpdateProductReviewEntityTest.php
Go to the documentation of this file.
1 <?php
8 
10 use Magento\Review\Test\Page\Adminhtml\RatingEdit;
11 use Magento\Review\Test\Page\Adminhtml\RatingIndex;
12 use Magento\Review\Test\Page\Adminhtml\ReviewEdit;
13 use Magento\Review\Test\Page\Adminhtml\ReviewIndex;
14 use Magento\Mtf\TestCase\Injectable;
15 
33 class UpdateProductReviewEntityTest extends Injectable
34 {
35  /* tags */
36  const MVP = 'no';
37  /* end tags */
38 
44  protected $reviewIndex;
45 
51  protected $reviewEdit;
52 
58  protected $ratingIndex;
59 
65  protected $ratingEdit;
66 
72  protected $review;
73 
83  public function __inject(
84  ReviewIndex $reviewIndex,
85  ReviewEdit $reviewEdit,
86  RatingIndex $ratingIndex,
87  RatingEdit $ratingEdit
88  ) {
89  $this->reviewIndex = $reviewIndex;
90  $this->reviewEdit = $reviewEdit;
91  $this->ratingIndex = $ratingIndex;
92  $this->ratingEdit = $ratingEdit;
93  }
94 
102  public function test(Review $reviewInitial, Review $review)
103  {
104  // Precondition
105  $reviewInitial->persist();
106 
107  // Prepare for tear down
108  $this->review = $reviewInitial;
109 
110  // Steps
111  $this->reviewIndex->open();
112  $this->reviewIndex->getReviewGrid()->searchAndOpen(['review_id' => $reviewInitial->getReviewId()]);
113  $this->reviewEdit->getReviewForm()->fill($review);
114  $this->reviewEdit->getPageActions()->save();
115 
116  // Prepare data for asserts
117  $product = $reviewInitial->getDataFieldConfig('entity_id')['source']->getEntity();
118 
119  return ['product' => $product];
120  }
121 
127  public function tearDown()
128  {
129  $this->ratingIndex->open();
130  if ($this->review instanceof Review) {
131  foreach ($this->review->getRatings() as $rating) {
132  $this->ratingIndex->getRatingGrid()->searchAndOpen(['rating_code' => $rating['title']]);
133  $this->ratingEdit->getPageActions()->delete();
134  $this->ratingEdit->getModalBlock()->acceptAlert();
135  }
136  }
137  }
138 }
$rating
Definition: item.phtml:18
__inject(ReviewIndex $reviewIndex, ReviewEdit $reviewEdit, RatingIndex $ratingIndex, RatingEdit $ratingEdit)