/**
  * Create customer group
  *
  * @param CustomerGroup $customerGroup
  */
 public function testCreateCustomerGroup(CustomerGroup $customerGroup)
 {
     //Steps
     $this->customerGroupIndex->open();
     $this->customerGroupIndex->getGridPageActions()->addNew();
     $this->customerGroupNew->getPageMainForm()->fill($customerGroup);
     $this->customerGroupNew->getPageMainActions()->save();
 }
 /**
  * Assert that customer group form equals to fixture data
  *
  * @param CustomerGroupIndex $customerGroupIndex
  * @param CustomerGroupNew $customerGroupNew
  * @param CustomerGroupInjectable $customerGroup
  * @param CustomerGroupInjectable $customerGroupOriginal
  * @return void
  */
 public function processAssert(CustomerGroupIndex $customerGroupIndex, CustomerGroupNew $customerGroupNew, CustomerGroupInjectable $customerGroup, CustomerGroupInjectable $customerGroupOriginal = null)
 {
     $data = $customerGroupOriginal !== null ? array_merge($customerGroupOriginal->getData(), $customerGroup->getData()) : $customerGroup->getData();
     $filter = ['code' => $data['customer_group_code']];
     $customerGroupIndex->open();
     $customerGroupIndex->getCustomerGroupGrid()->searchAndOpen($filter);
     $formData = $customerGroupNew->getPageMainForm()->getData();
     $dataDiff = $this->verifyForm($formData, $data);
     \PHPUnit_Framework_Assert::assertTrue(empty($dataDiff), 'Customer Group form was filled incorrectly.' . "\nLog:\n" . implode(";\n", $dataDiff));
 }
 /**
  * Delete Customer Group
  *
  * @param CustomerGroupInjectable $customerGroup
  * @return void
  */
 public function test(CustomerGroupInjectable $customerGroup)
 {
     // Precondition
     $customerGroup->persist();
     // Steps
     $filter = ['code' => $customerGroup->getCustomerGroupCode()];
     $this->customerGroupIndex->open();
     $this->customerGroupIndex->getCustomerGroupGrid()->searchAndOpen($filter);
     $this->customerGroupNew->getPageMainActions()->delete();
 }
 /**
  * Update Customer Group
  *
  * @param CustomerGroupInjectable $customerGroupOriginal
  * @param CustomerGroupInjectable $customerGroup
  * @return void
  */
 public function test(CustomerGroupInjectable $customerGroupOriginal, CustomerGroupInjectable $customerGroup)
 {
     // Precondition
     $customerGroupOriginal->persist();
     $filter = ['code' => $customerGroupOriginal->getCustomerGroupCode()];
     // Steps
     $this->customerGroupIndex->open();
     $this->customerGroupIndex->getCustomerGroupGrid()->searchAndOpen($filter);
     $this->customerGroupNew->getPageMainForm()->fill($customerGroup);
     $this->customerGroupNew->getPageMainActions()->save();
 }
 /**
  * Delete Customer Group.
  *
  * @param CustomerGroup $customerGroup
  * @param Customer $customer [optional]
  * @return array
  */
 public function test(CustomerGroup $customerGroup, Customer $customer = null)
 {
     // Precondition
     if ($customer !== null) {
         $customer->persist();
         $customerGroup = $customer->getDataFieldConfig('group_id')['source']->getCustomerGroup();
     } else {
         $customerGroup->persist();
     }
     // Steps
     $filter = ['code' => $customerGroup->getCustomerGroupCode()];
     $this->customerGroupIndex->open();
     $this->customerGroupIndex->getCustomerGroupGrid()->searchAndOpen($filter);
     $this->customerGroupNew->getPageMainActions()->delete();
     $this->customerGroupNew->getModalBlock()->acceptAlert();
     return ['customer' => $customer, 'customerGroup' => $customerGroup];
 }
 /**
  * Assert that customer group already exist
  *
  * @param CustomerGroupNew $customerGroupNew
  * @return void
  */
 public function processAssert(CustomerGroupNew $customerGroupNew)
 {
     $actualMessage = $customerGroupNew->getMessagesBlock()->getErrorMessage();
     \PHPUnit_Framework_Assert::assertEquals(self::ERROR_MESSAGE, $actualMessage, 'Wrong error message is displayed.');
 }