Skip to content

Commit

Permalink
フォーム入力/同意する/会員登録に分離
Browse files Browse the repository at this point in the history
  • Loading branch information
ji-eunsoo committed Sep 28, 2023
1 parent 148fdcf commit 205f580
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 23 deletions.
29 changes: 24 additions & 5 deletions codeception/_support/Page/Front/EntryPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,20 @@

class EntryPage extends AbstractFrontPage
{

private $formData = [];

public function __construct(\AcceptanceTester $I)
{
parent::__construct($I);
}

/**
* @param $I
* @param $id
*
* @return EntryPage
*/
public static function go($I)
{
$page = new self($I);
Expand All @@ -28,11 +37,11 @@ public static function go($I)
return $page;
}

public function 新規会員登録($form = [])
public function フォーム入力($form = [])
{
$this->tester->amOnPage('/entry');
$email = uniqid().microtime(true).'@example.com';

$form += [
'entry[name][name01]' => '',
'entry[name][name02]' => '',
Expand All @@ -49,10 +58,20 @@ public function 新規会員登録($form = [])
'entry[plain_password][second]' => 'password1234',
'entry[user_policy_check]' => '1',
];
$this->tester->submitForm(['css' => '.ec-layoutRole__main form'], $form, ['css' => 'button.ec-blockBtn--action']);
$this->tester->seeInField(['id' => 'entry_email_first'], $form['entry[email][first]']);
$this->tester->click('.ec-registerRole form button.ec-blockBtn--action');
$this->formData = $form;
return $this;
}

public function 同意する()
{
$this->tester->submitForm(['css' => '.ec-layoutRole__main form'], $this->formData, ['css' => 'button.ec-blockBtn--action']);
$this->tester->seeInField(['id' => 'entry_email_first'], $this->formData['entry[email][first]']);
return $this;
}

public function 登録する()
{
$this->tester->click('.ec-registerRole form button.ec-blockBtn--action');
return $this;
}
}
22 changes: 14 additions & 8 deletions codeception/acceptance/EA07BasicinfoCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,13 @@ public function basicinfo_会員設定_仮会員機能(AcceptanceTester $I)
// 会員登録
$faker = Fixtures::get('faker');
$email = microtime(true).'.'.$faker->safeEmail;
EntryPage::go($I)->新規会員登録([
'entry[email][first]' => $email,
'entry[email][second]' => $email,
]);
EntryPage::go($I)
->フォーム入力([
'entry[email][first]' => $email,
'entry[email][second]' => $email,
])
->同意する()
->登録する();

// 会員ステータスのチェック
$page = CustomerManagePage::go($I);
Expand All @@ -119,10 +122,13 @@ public function basicinfo_会員設定_仮会員機能(AcceptanceTester $I)
// 会員登録
$I->logoutAsMember();
$email = microtime(true).'.'.$faker->safeEmail;
EntryPage::go($I)->新規会員登録([
'entry[email][first]' => $email,
'entry[email][second]' => $email,
]);
EntryPage::go($I)
->フォーム入力([
'entry[email][first]' => $email,
'entry[email][second]' => $email,
])
->同意する()
->登録する();
$I->logoutAsMember();

// 会員ステータスのチェック
Expand Down
27 changes: 17 additions & 10 deletions codeception/acceptance/EF09ThrottlingCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
use Page\Front\ShoppingLoginPage;
use Page\Front\ShoppingNonmemberPage;
use Page\Front\ShoppingPage;
use Page\Front\EntryPage;


/**
* @group throttling
Expand Down Expand Up @@ -138,14 +140,18 @@ public function 会員登録(AcceptanceTester $I)

for ($i = 0; $i < 5; $i++) {
$I->expect('会員登録を行います:'.$i);
\Page\Front\EntryPage::go($I)
->新規会員登録();
EntryPage::go($I)
->フォーム入力()
->同意する()
->登録する();
$I->see('現在、仮会員の状態です。', 'p.ec-reportDescription');
}

$I->expect('試行回数上限を超過します');
\Page\Front\EntryPage::go($I)
->新規会員登録();
EntryPage::go($I)
->フォーム入力()
->同意する()
->登録する();
$I->see('試行回数の上限を超過しました。しばらくお待ちいただき、再度お試しください。', 'p.ec-reportDescription');
}

Expand Down Expand Up @@ -753,15 +759,16 @@ public function 新規会員登録_入力(AcceptanceTester $I)
{
$I->wantTo('EF0901-UC01-T18_会員登録_入力');

\Page\Front\EntryPage::go($I);

for ($i = 0; $i < 25; $i++) {
$I->expect('会員登録を行います:'.$i);
$I->click('.ec-registerRole form button.ec-blockBtn--action');
$I->see('入力されていません。','p.ec-errorMessage');
EntryPage::go($I)
->フォーム入力()
->登録する();
}
$I->expect('試行回数上限を超過します');
$I->click('.ec-registerRole form button.ec-blockBtn--action');

EntryPage::go($I)
->フォーム入力()
->登録する();
$I->see('試行回数の上限を超過しました。しばらくお待ちいただき、再度お試しください。', 'p.ec-reportDescription');
}

Expand Down

0 comments on commit 205f580

Please sign in to comment.