Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
MassActionsProductReviewEntityTest.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\ReviewIndex;
13 use Magento\Mtf\TestCase\Injectable;
14 
32 class MassActionsProductReviewEntityTest extends Injectable
33 {
34  /* tags */
35  const MVP = 'no';
36  /* end tags */
37 
43  protected $ratingIndex;
44 
50  protected $ratingEdit;
51 
57  protected $reviewIndex;
58 
64  protected $review;
65 
75  public function __inject(
76  ReviewIndex $reviewIndex,
77  RatingIndex $ratingIndex,
78  RatingEdit $ratingEdit,
79  Review $review
80  ) {
81  $this->reviewIndex = $reviewIndex;
82  $this->ratingIndex = $ratingIndex;
83  $this->ratingEdit = $ratingEdit;
84  $this->review = $review;
85  $this->review->persist();
86  $product = $review->getDataFieldConfig('entity_id')['source']->getEntity();
87 
88  return ['review' => $this->review, 'product' => $product];
89  }
90 
98  public function test($gridActions, $gridStatus)
99  {
100  // Steps
101  $this->reviewIndex->open();
102  $this->reviewIndex->getReviewGrid()->massaction(
103  [['title' => $this->review->getTitle()]],
104  [$gridActions => $gridStatus],
105  ($gridActions == 'Delete' ? true : false)
106  );
107  }
108 
114  public function tearDown()
115  {
116  $this->ratingIndex->open();
117  if ($this->review instanceof Review) {
118  foreach ($this->review->getRatings() as $rating) {
119  $this->ratingIndex->getRatingGrid()->searchAndOpen(['rating_code' => $rating['title']]);
120  $this->ratingEdit->getPageActions()->delete();
121  $this->ratingEdit->getModalBlock()->acceptAlert();
122  }
123  }
124  }
125 }
__inject(ReviewIndex $reviewIndex, RatingIndex $ratingIndex, RatingEdit $ratingEdit, Review $review)
$rating
Definition: item.phtml:18