diff --git a/tests/functional/Customer/CustomerCest.php b/tests/functional/Customer/CustomerCest.php index 1c275856c..f9e5d46c5 100644 --- a/tests/functional/Customer/CustomerCest.php +++ b/tests/functional/Customer/CustomerCest.php @@ -9,13 +9,50 @@ use Webkul\Customer\Models\CustomerAddress; class CustomerCest { + /** + * Faker factory. + * + * @var Faker\Factory + */ + public $faker; + + /** + * Address Fields. + * + * @var array + */ public $fields = []; + /** + * Constructor. + * + * @return void + */ + public function __construct() + { + /** + * Instantiate a european faker factory to have the vat provider available. + */ + $this->faker = Factory::create('at_AT'); + } + + /** + * Before method. + * + * @param FunctionalTester $I + * @return void + */ public function _before(FunctionalTester $I): void { $I->useDefaultTheme(); } + /** + * Test update customer profile. + * + * @param FunctionalTester $I + * @return void + */ public function updateCustomerProfile(FunctionalTester $I): void { $customer = $I->loginAsCustomer(); @@ -36,11 +73,14 @@ class CustomerCest ]); } + /** + * Update customer address. + * + * @param FunctionalTester $I + * @return void + */ public function updateCustomerAddress(FunctionalTester $I): void { - // instantiate a european faker factory to have the vat provider available - $faker = Factory::create('at_AT'); - $formCssSelector = '#customer-address-form'; $I->loginAsCustomer(); @@ -51,22 +91,13 @@ class CustomerCest $I->click('Address'); $I->click('Add Address'); - $this->fields = [ - 'company_name' => preg_replace('/[^A-Za-z0-9 ]/', '', $faker->company), - 'first_name' => preg_replace('/[^A-Za-z0-9 ]/', '', $faker->firstName), - 'last_name' => preg_replace('/[^A-Za-z0-9 ]/', '', $faker->lastName), - 'vat_id' => 'INVALIDVAT', - 'address1[]' => preg_replace('/[^A-Za-z0-9 ]/', '', $faker->streetAddress), - 'country' => preg_replace('/[^A-Za-z0-9 ]/', '', $faker->countryCode), - 'state' => preg_replace('/[^A-Za-z0-9 ]/', '', $faker->state), - 'city' => preg_replace('/[^A-Za-z0-9 ]/', '', $faker->city), - 'postcode' => preg_replace('/[^0-9]/', '', $faker->postcode), - 'phone' => $faker->phoneNumber, - ]; + $this->setFields(); foreach ($this->fields as $key => $value) { - // the following fields are rendered via javascript so we ignore them - if (!in_array($key, [ + /** + * The following fields are rendered via javascript so we ignore them. + */ + if (! in_array($key, [ 'country', 'state', ])) { @@ -78,15 +109,15 @@ class CustomerCest $I->wantTo('Ensure that the company_name field is being displayed'); $I->seeElement('.account-table-content > div:nth-child(2) > input:nth-child(2)'); - /* - We need to use this css selector to hit the correct