Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
MassAssignCustomerGroupTest.php
Go to the documentation of this file.
1 <?php
8 
10 use Magento\Customer\Test\Page\Adminhtml\CustomerIndex;
11 use Magento\Mtf\Fixture\FixtureFactory;
12 use Magento\Mtf\TestCase\Injectable;
13 
35 class MassAssignCustomerGroupTest extends Injectable
36 {
37  /* tags */
38  const MVP = 'yes';
39  const TEST_TYPE = 'extended_acceptance_test';
40  /* end tags */
41 
47  protected $customerIndex;
48 
54  protected $customersGridActions = 'Assign a Customer Group';
55 
62  public function __inject(CustomerIndex $customerIndex)
63  {
64  $this->customerIndex = $customerIndex;
65  }
66 
75  public function test(CustomerGroup $customerGroup, FixtureFactory $fixtureFactory, array $customers)
76  {
77  // Preconditions
78  if (!$customerGroup->hasData('customer_group_id')) {
79  $customerGroup->persist();
80  }
81 
82  $customerEmails = [];
83  foreach ($customers as &$customer) {
84  $customer = $fixtureFactory->createByCode('customer', ['dataset' => $customer]);
85  $customer->persist();
86  $customerEmails[] = ['email' => $customer->getEmail()];
87  }
88 
89  // Steps
90  $this->customerIndex->open();
91  $this->customerIndex->getCustomerGridBlock()->massaction(
92  $customerEmails,
93  [$this->customersGridActions => $customerGroup->getCustomerGroupCode()],
94  true
95  );
96  return ['customers' => $customers];
97  }
98 }
test(CustomerGroup $customerGroup, FixtureFactory $fixtureFactory, array $customers)
$customer
Definition: customers.php:11