Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
MassDeleteCustomerBackendEntityTest.php
Go to the documentation of this file.
1 <?php
8 
10 use Magento\Customer\Test\Page\Adminhtml\CustomerIndex;
11 use Magento\Customer\Test\Page\Adminhtml\CustomerIndexEdit;
12 use Magento\Mtf\Fixture\FixtureFactory;
13 use Magento\Mtf\TestCase\Injectable;
14 
33 class MassDeleteCustomerBackendEntityTest extends Injectable
34 {
35  /* tags */
36  const MVP = 'yes';
37  /* end tags */
38 
44  protected $customerIndexPage;
45 
52 
58  protected $fixtureFactory;
59 
68  public function __inject(
69  FixtureFactory $fixtureFactory,
70  CustomerIndex $customerIndexPage,
71  CustomerIndexEdit $customerIndexEditPage
72  ) {
73  $this->fixtureFactory = $fixtureFactory;
74  $this->customerIndexPage = $customerIndexPage;
75  $this->customerIndexEditPage = $customerIndexEditPage;
76  $customerIndexPage->open();
77  $customerIndexPage->getCustomerGridBlock()->massaction([], 'Delete', true, 'Select All');
78  }
79 
87  public function test($customersQty, $customersQtyToDelete)
88  {
89  // Preconditions:
90  $customers = $this->createCustomers($customersQty);
91  $deleteCustomers = [];
92  for ($i = 0; $i < $customersQtyToDelete; $i++) {
93  $deleteCustomers[] = ['email' => $customers[$i]->getEmail()];
94  }
95  // Steps:
96  $this->customerIndexPage->open();
97  $this->customerIndexPage->getCustomerGridBlock()->massaction($deleteCustomers, 'Delete', true);
98 
99  return ['customers' => $customers];
100  }
101 
108  protected function createCustomers($customersQty)
109  {
110  $customers = [];
111  for ($i = 0; $i < $customersQty; $i++) {
112  $customer = $this->fixtureFactory->createByCode('customer', ['dataset' => 'default']);
113  $customer->persist();
114  $customers[] = $customer;
115  }
116 
117  return $customers;
118  }
119 }
$customer
Definition: customers.php:11
__inject(FixtureFactory $fixtureFactory, CustomerIndex $customerIndexPage, CustomerIndexEdit $customerIndexEditPage)
$i
Definition: gallery.phtml:31