Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CreateProductRatingEntityTest.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Review\Test\Fixture\Rating;
10 use Magento\Review\Test\Page\Adminhtml\RatingEdit;
11 use Magento\Review\Test\Page\Adminhtml\RatingIndex;
12 use Magento\Review\Test\Page\Adminhtml\RatingNew;
13 use Magento\Mtf\Fixture\FixtureFactory;
14 use Magento\Mtf\TestCase\Injectable;
15 
31 class CreateProductRatingEntityTest extends Injectable
32 {
33  /* tags */
34  const MVP = 'no';
35  /* end tags */
36 
42  protected $productRating;
43 
49  protected $ratingIndex;
50 
56  protected $ratingNew;
57 
63  protected $ratingEdit;
64 
71  public function __prepare(FixtureFactory $fixtureFactory)
72  {
73  $product = $fixtureFactory->createByCode('catalogProductSimple', ['dataset' => 'default']);
74  $product->persist();
75 
76  return ['product' => $product];
77  }
78 
87  public function __inject(
88  RatingIndex $ratingIndex,
89  RatingNew $ratingNew,
90  RatingEdit $ratingEdit
91  ) {
92  $this->ratingIndex = $ratingIndex;
93  $this->ratingNew = $ratingNew;
94  $this->ratingEdit = $ratingEdit;
95  }
96 
104  {
105  // Prepare data for tear down
106  $this->productRating = $productRating;
107 
108  // Steps
109  $this->ratingIndex->open();
110  $this->ratingIndex->getGridPageActions()->addNew();
111  $this->ratingNew->getRatingForm()->fill($productRating);
112  $this->ratingNew->getPageActions()->save();
113  }
114 
120  public function tearDown()
121  {
122  if (!($this->productRating instanceof Rating)) {
123  return;
124  }
125  $filter = ['rating_code' => $this->productRating->getRatingCode()];
126  $this->ratingIndex->open();
127  $this->ratingIndex->getRatingGrid()->searchAndOpen($filter);
128  $this->ratingEdit->getPageActions()->delete();
129  $this->ratingEdit->getModalBlock()->acceptAlert();
130  }
131 }
__inject(RatingIndex $ratingIndex, RatingNew $ratingNew, RatingEdit $ratingEdit)