<?php


namespace Mage\Customer\Test\TestCase;

use Mage\Customer\Test\Fixture\CustomerGroup;
use Mage\Customer\Test\Page\Adminhtml\CustomerGroupIndex;
use Mage\Customer\Test\Page\Adminhtml\CustomerGroupNew;
use Magento\Mtf\TestCase\Injectable;

/**
 * Test Flow:
 * 1. Log in to backend as admin user.
 * 2. Navigate to Customers > Customer Groups.
 * 3. Start to create new Customer Group.
 * 4. Fill in all data according to data set.
 * 5. Click "Save Customer Group" button.
 * 6. Perform all assertions.
 *
 * @group Customer_Groups_(CS)
 * @ZephyrId MPERF-7420
 */
class CreateCustomerGroupEntityTest extends Injectable
{
    /**
     * Customer group index page.
     *
     * @var CustomerGroupIndex
     */
    protected $customerGroupIndex;

    /**
     * New customer group page.
     *
     * @var CustomerGroupNew
     */
    protected $customerGroupNew;

    /**
     * Inject data.
     *
     * @param CustomerGroupIndex $customerGroupIndex
     * @param CustomerGroupNew $customerGroupNew
     */
    public function __inject(
        CustomerGroupIndex $customerGroupIndex,
        CustomerGroupNew $customerGroupNew
    ) {
        $this->customerGroupIndex = $customerGroupIndex;
        $this->customerGroupNew = $customerGroupNew;
    }

    /**
     * Create customer group.
     *
     * @param CustomerGroup $customerGroup
     * @return void
     */
    public function test(CustomerGroup $customerGroup)
    {
        // Steps
        $this->customerGroupIndex->open();
        $this->customerGroupIndex->getGridPageActions()->addNew();
        $this->customerGroupNew->getCustomerGroupForm()->fill($customerGroup);
        $this->customerGroupNew->getPageActionsBlock()->save();
    }
}
