Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CreateCustomerAccountStep.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Checkout\Test\Page\CheckoutOnepageSuccess;
10 use Magento\Customer\Test\Page\CustomerAccountCreate;
11 use Magento\Mtf\TestStep\TestStepInterface;
12 use Magento\Mtf\Fixture\FixtureFactory;
13 
17 class CreateCustomerAccountStep implements TestStepInterface
18 {
25 
31  private $checkoutMethod;
32 
38  private $fixtureFactory;
39 
45  private $customerAccountCreate;
46 
52  private $customerPassword;
53 
62  public function __construct(
63  CheckoutOnepageSuccess $checkoutOnepageSuccess,
64  $checkoutMethod,
65  FixtureFactory $fixtureFactory,
66  CustomerAccountCreate $customerAccountCreate,
67  $customerPassword = null
68  ) {
69  $this->checkoutOnepageSuccess = $checkoutOnepageSuccess;
70  $this->checkoutMethod = $checkoutMethod;
71  $this->fixtureFactory = $fixtureFactory;
72  $this->customerAccountCreate = $customerAccountCreate;
73  $this->customerPassword = $customerPassword;
74  }
75 
81  public function run()
82  {
83  if ($this->checkoutMethod === 'register') {
84  $this->checkoutOnepageSuccess->getRegistrationBlock()->createAccount();
85 
86  $customerFixture = $this->fixtureFactory->createByCode(
87  'customer',
88  [
89  'data' => [
90  'password' => $this->customerPassword,
91  'password_confirmation' => $this->customerPassword,
92  ],
93  ]
94  );
95  $this->customerAccountCreate->getRegisterForm()->registerCustomer($customerFixture);
96  }
97  }
98 }
__construct(CheckoutOnepageSuccess $checkoutOnepageSuccess, $checkoutMethod, FixtureFactory $fixtureFactory, CustomerAccountCreate $customerAccountCreate, $customerPassword=null)