Test case for customer create
This commit is contained in:
parent
3fb2b8a5c9
commit
4e3fef5b04
|
|
@ -23,4 +23,49 @@ class CustomerCest
|
|||
$I->see($customer->id, '//script[@type="text/x-template"]');
|
||||
$I->see($customer->last_name, '//script[@type="text/x-template"]');
|
||||
}
|
||||
|
||||
public function testCreate(FunctionalTester $I): void
|
||||
{
|
||||
$I->loginAsAdmin();
|
||||
$I->amOnAdminRoute('admin.customer.index');
|
||||
|
||||
$I->click(__('admin::app.customers.customers.add-title'), '//*[contains(@class, "page-action")]');
|
||||
$I->seeCurrentRouteIs('admin.customer.create');
|
||||
|
||||
$I->click(__('admin::app.customers.customers.save-btn-title'), '//*[contains(@class, "page-action")]');
|
||||
$I->seeFormHasErrors();
|
||||
|
||||
$testData = $this->fillForm($I);
|
||||
$I->click(__('admin::app.customers.customers.save-btn-title'), '//*[contains(@class, "page-action")]');
|
||||
|
||||
$I->dontSeeFormErrors();
|
||||
$I->seeCurrentRouteIs('admin.customer.index');
|
||||
$I->seeRecord(Customer::class, $testData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FunctionalTester $I
|
||||
*
|
||||
* @return array with the test-data
|
||||
*/
|
||||
private function fillForm(FunctionalTester $I): array
|
||||
{
|
||||
$testData = [
|
||||
'first_name' => $I->fake()->firstName,
|
||||
'last_name' => $I->fake()->lastName,
|
||||
'gender' => $I->fake()->randomElement([
|
||||
'Male',
|
||||
'Female',
|
||||
'Other',
|
||||
]),
|
||||
'email' => $I->fake()->email,
|
||||
];
|
||||
|
||||
$I->fillField('first_name', $testData['first_name']);
|
||||
$I->fillField('last_name', $testData['last_name']);
|
||||
$I->selectOption('gender', $testData['gender']);
|
||||
$I->fillField('email', $testData['email']);
|
||||
|
||||
return $testData;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue