diff --git a/codeception/_support/Page/Admin/OrderEditPage.php b/codeception/_support/Page/Admin/OrderEditPage.php index e480606c538..634ce4b68ca 100644 --- a/codeception/_support/Page/Admin/OrderEditPage.php +++ b/codeception/_support/Page/Admin/OrderEditPage.php @@ -207,4 +207,9 @@ public function お届け先の追加() return $this; } + + public function 注文番号() + { + return $this->tester->grabTextFrom(['css' => '#orderOverview > div > div > div:nth-child(1) > div:nth-child(1) > div.col']); + } } diff --git a/codeception/_support/Page/Admin/ShopSettingPage.php b/codeception/_support/Page/Admin/ShopSettingPage.php index 0aa286cbdf1..43bbee31db5 100644 --- a/codeception/_support/Page/Admin/ShopSettingPage.php +++ b/codeception/_support/Page/Admin/ShopSettingPage.php @@ -36,6 +36,17 @@ public function 入力_会社名($value) return $this; } + public function 切替_カナ必須項目($value) + { + $cssClass = $this->tester->grabAttributeFrom(['css' => 'span.shop_master_option_require_kana-on'], 'class'); + $optionOn = strpos($cssClass, 'd-none') === false; + $this->tester->scrollTo(['xpath' => '//label[@for="shop_master_option_require_kana"]'], 0, 100); + if (($optionOn && !$value) || (!$optionOn && $value)) { + $this->tester->click(['xpath' => '//label[@for="shop_master_option_require_kana"]']); + } + return $this; + } + public function 登録() { $this->tester->click('#point_form > div.c-conversionArea > div > div > div:nth-child(2) > div > div > button'); diff --git a/codeception/_support/Page/Front/CustomerAddressAddPage.php b/codeception/_support/Page/Front/CustomerAddressAddPage.php index 909d43b22a5..45ce67da539 100644 --- a/codeception/_support/Page/Front/CustomerAddressAddPage.php +++ b/codeception/_support/Page/Front/CustomerAddressAddPage.php @@ -20,6 +20,14 @@ public function __construct(\AcceptanceTester $I) parent::__construct($I); } + public static function go($I) + { + $page = new self($I); + $page->goPage('/mypage/delivery/new'); + + return $page; + } + public static function at($I) { $page = new self($I); @@ -30,69 +38,69 @@ public static function at($I) public function 入力_姓($value) { - $this->tester->fillField(['id' => 'shopping_shipping_name_name01'], $value); + $this->tester->fillField(['id' => 'customer_address_name_name01'], $value); return $this; } public function 入力_名($value) { - $this->tester->fillField(['id' => 'shopping_shipping_name_name02'], $value); + $this->tester->fillField(['id' => 'customer_address_name_name02'], $value); return $this; } public function 入力_セイ($value) { - $this->tester->fillField(['id' => 'shopping_shipping_kana_kana01'], $value); + $this->tester->fillField(['id' => 'customer_address_kana_kana02'], $value); return $this; } public function 入力_メイ($value) { - $this->tester->fillField(['id' => 'shopping_shipping_kana_kana02'], $value); + $this->tester->fillField(['id' => 'customer_address_kana_kana02'], $value); return $this; } public function 入力_郵便番号($value) { - $this->tester->fillField(['id' => 'shopping_shipping_postal_code'], $value); + $this->tester->fillField(['id' => 'customer_address_postal_code'], $value); return $this; } public function 入力_都道府県($value) { - $this->tester->selectOption(['id' => 'shopping_shipping_address_pref'], $value); + $this->tester->selectOption(['id' => 'customer_address_address_pref'], $value); return $this; } public function 入力_市区町村名($value) { - $this->tester->fillField(['id' => 'shopping_shipping_address_addr01'], $value); + $this->tester->fillField(['id' => 'customer_address_address_addr01'], $value); return $this; } public function 入力_番地_ビル名($value) { - $this->tester->fillField(['id' => 'shopping_shipping_address_addr02'], $value); + $this->tester->fillField(['id' => 'customer_address_address_addr02'], $value); return $this; } public function 入力_電話番号($value) { - $this->tester->fillField(['id' => 'shopping_shipping_phone_number'], $value); + $this->tester->fillField(['id' => 'customer_address_phone_number'], $value); return $this; } public function 登録する() { - $this->tester->click('div.ec-registerRole button.ec-blockBtn--action'); + $this->tester->click('button.ec-blockBtn--cancel'); } } diff --git a/codeception/_support/Page/Front/EntryConfirmPage.php b/codeception/_support/Page/Front/EntryConfirmPage.php new file mode 100644 index 00000000000..7f0b6bcf257 --- /dev/null +++ b/codeception/_support/Page/Front/EntryConfirmPage.php @@ -0,0 +1,78 @@ +goPage('/entry'); + + return $page; + } + + public static function at($I) + { + $page = new self($I); + $page->tester->see('新規会員登録(確認)', ['css' => 'div.ec-pageHeader > h1']); + + return $page; + } + + public function お名前() + { + return $this->tester->grabTextFrom(['css' => '.ec-registerRole form .ec-borderedDefs dl:nth-child(1) dd']); + } + + public function お名前カナ() + { + return $this->tester->grabTextFrom(['css' => '.ec-registerRole form .ec-borderedDefs dl:nth-child(2) dd']); + } + + public function 住所() + { + return $this->tester->grabTextFrom(['css' => '.ec-registerRole form .ec-borderedDefs dl:nth-child(4) dd']); + } + + public function 電話番号() + { + return $this->tester->grabTextFrom(['css' => '.ec-registerRole form .ec-borderedDefs dl:nth-child(5) dd']); + } + + public function メールアドレス() + { + return $this->tester->grabTextFrom(['css' => '.ec-registerRole form .ec-borderedDefs dl:nth-child(6) dd']); + } + + public function 職業() + { + return $this->tester->grabTextFrom(['css' => '.ec-registerRole form .ec-borderedDefs dl:nth-child(10) dd']); + } + + public function 会員登録をする() + { + $this->tester->click(['css' => 'form > div.ec-registerRole__actions button.ec-blockBtn--action']); + } + + public function 戻る() + { + $this->tester->click('.ec-registerRole form button.ec-blockBtn--cancel'); + } +} diff --git a/codeception/_support/Page/Front/EntryPage.php b/codeception/_support/Page/Front/EntryPage.php new file mode 100644 index 00000000000..b37382b1b2d --- /dev/null +++ b/codeception/_support/Page/Front/EntryPage.php @@ -0,0 +1,132 @@ +goPage('/entry'); + + return $page; + } + + public static function at($I) + { + $page = new self($I); + $page->tester->see('新規会員登録', ['css' => 'div.ec-pageHeader > h1']); + + return $page; + } + + public function 入力_姓($value) + { + $this->tester->fillField(['id' => 'entry_name_name01'], $value); + return $this; + } + + public function 入力_名($value) + { + $this->tester->fillField(['id' => 'entry_name_name02'], $value); + return $this; + } + + public function 入力_姓カナ($value) + { + $this->tester->fillField(['id' => 'entry_kana_kana01'], $value); + return $this; + } + + public function 入力_名カナ($value) + { + $this->tester->fillField(['id' => 'entry_kana_kana02'], $value); + return $this; + } + + public function 入力_郵便番号($value) + { + $this->tester->fillField(['id' => 'entry_postal_code'], $value); + return $this; + } + + public function 入力_都道府県($value) + { + $this->tester->selectOption(['id' => 'entry_address_pref'], $value); + return $this; + } + + public function 入力_市区町村($value) + { + $this->tester->fillField(['id' => 'entry_address_addr01'], $value); + return $this; + } + + public function 入力_住所($value) + { + $this->tester->fillField(['id' => 'entry_address_addr02'], $value); + return $this; + } + + public function 入力_電話番号($value) { + $this->tester->fillField(['id' => 'entry_phone_number'], $value); + return $this; + } + + public function 入力_メールアドレス($value) + { + $this->tester->fillField(['id' => 'entry_email_first'], $value); + return $this; + } + + public function 入力_メールアドレス確認($value) + { + $this->tester->fillField(['id' => 'entry_email_second'], $value); + return $this; + } + + public function 入力_パスワード($value) + { + $this->tester->fillField(['id' => 'entry_password_first'], $value); + return $this; + } + + public function 入力_パスワード確認($value) + { + $this->tester->fillField(['id' => 'entry_password_second'], $value); + return $this; + } + + public function 入力_職業($value) + { + $this->tester->selectOption(['id' => 'entry_job'], $value); + return $this; + } + + public function 入力_利用規約同意() + { + $this->tester->checkOption(['id' => 'entry_user_policy_check']); + return $this; + } + + public function 同意して登録() + { + $this->tester->click(['css' => 'form > div.ec-registerRole__actions button']); + } +} diff --git a/codeception/_support/Page/Front/ShoppingNonmemberPage.php b/codeception/_support/Page/Front/ShoppingNonmemberPage.php index c24a0f6a2c2..858934fa1db 100644 --- a/codeception/_support/Page/Front/ShoppingNonmemberPage.php +++ b/codeception/_support/Page/Front/ShoppingNonmemberPage.php @@ -54,6 +54,9 @@ public function 入力_メイ($value) public function 入力_郵便番号($value) { $this->tester->fillField(['id' => 'nonmember_postal_code'], $value); + if ($value) { + $this->tester->wait(5); + } return $this; } diff --git a/codeception/acceptance/EF04CustomerCest.php b/codeception/acceptance/EF04CustomerCest.php index 8eb682514bc..f23a5b96058 100644 --- a/codeception/acceptance/EF04CustomerCest.php +++ b/codeception/acceptance/EF04CustomerCest.php @@ -12,6 +12,8 @@ */ use Codeception\Util\Fixtures; +use Page\Front\EntryConfirmPage; +use Page\Front\EntryPage; /** * @group front @@ -23,45 +25,47 @@ class EF04CustomerCest public function customer_会員登録正常(\AcceptanceTester $I) { $I->wantTo('EF0401-UC01-T01 会員登録 正常パターン'); - $I->amOnPage('/entry'); $faker = Fixtures::get('faker'); $BaseInfo = Fixtures::get('baseinfo'); $new_email = microtime(true).'.'.$faker->safeEmail; + // 会員情報入力フォームに、会員情報を入力する // 「同意する」ボタンを押下する - $form = [ - 'entry[name][name01]' => '姓', - 'entry[name][name02]' => '名', - 'entry[kana][kana01]' => 'セイ', - 'entry[kana][kana02]' => 'メイ', - 'entry[postal_code]' => '530-0001', - 'entry[address][pref]' => ['value' => '27'], - 'entry[address][addr01]' => '大阪市北区', - 'entry[address][addr02]' => '梅田2-4-9 ブリーゼタワー13F', - 'entry[phone_number]' => '111-111-111', - 'entry[email][first]' => $new_email, - 'entry[email][second]' => $new_email, - 'entry[password][first]' => 'password', - 'entry[password][second]' => 'password', - 'entry[job]' => ['value' => '1'], - 'entry[user_policy_check]' => '1', - ]; + $EntryPage = EntryPage::go($I) + ->入力_姓('姓') + ->入力_名('名') + ->入力_姓カナ('セイ') + ->入力_名カナ('メイ') + ->入力_郵便番号('530-0001') + ->入力_都道府県(['value' => '27']) + ->入力_市区町村('大阪市北区') + ->入力_住所('梅田2-4-9 ブリーゼタワー13F') + ->入力_電話番号('111-111-111') + ->入力_メールアドレス($new_email) + ->入力_メールアドレス確認($new_email) + ->入力_パスワード('password') + ->入力_パスワード確認('password') + ->入力_職業(['value' => '1']) + ->入力_利用規約同意(); $findPluginByCode = Fixtures::get('findPluginByCode'); $Plugin = $findPluginByCode('MailMagazine'); if ($Plugin) { $I->amGoingTo('メルマガプラグインを発見したため、メルマガを購読します'); $form['entry[mailmaga_flg]'] = '1'; } - $I->submitForm(['css' => '.ec-layoutRole__main form'], $form, ['css' => 'button.ec-blockBtn--action']); + $EntryPage->同意して登録(); // 入力した会員情報を確認する。 - $I->see('姓 名', '.ec-registerRole form .ec-borderedDefs dl:nth-child(1) dd'); - $I->see('111111111', '.ec-registerRole form .ec-borderedDefs dl:nth-child(5) dd'); - $I->see($new_email, '.ec-registerRole form .ec-borderedDefs dl:nth-child(6) dd'); + $EntryConfirmPage = EntryConfirmPage::at($I); + $I->assertEquals('姓 名', $EntryConfirmPage->お名前()); + $I->assertEquals('セイ メイ', $EntryConfirmPage->お名前カナ()); + $I->assertEquals('〒5300001 大阪府 大阪市北区 梅田2-4-9 ブリーゼタワー13F', $EntryConfirmPage->住所()); + $I->assertEquals('111111111', $EntryConfirmPage->電話番号()); + $I->assertEquals($new_email, $EntryConfirmPage->メールアドレス()); + $I->assertEquals('公務員', $EntryConfirmPage->職業()); $I->resetEmails(); - // 「会員登録をする」ボタンを押下する - $I->click('.ec-registerRole form button.ec-blockBtn--action'); + $EntryConfirmPage->会員登録をする(); $I->seeEmailCount(2); foreach ([$new_email, $BaseInfo->getEmail01()] as $email) { @@ -96,28 +100,29 @@ public function customer_会員登録正常(\AcceptanceTester $I) public function customer_会員登録異常1(\AcceptanceTester $I) { $I->wantTo('EF0401-UC01-T02 会員登録 異常パターン 重複'); - $I->amOnPage('/entry'); $createCustomer = Fixtures::get('createCustomer'); $customer = $createCustomer(); // 会員情報入力フォームに、会員情報を入力する // 「同意する」ボタンを押下する - $I->submitForm(['css' => '.ec-layoutRole__main form'], [ - 'entry[name][name01]' => '姓', - 'entry[name][name02]' => '名', - 'entry[kana][kana01]' => 'セイ', - 'entry[kana][kana02]' => 'メイ', - 'entry[postal_code]' => '530-0001', - 'entry[address][pref]' => ['value' => '27'], - 'entry[address][addr01]' => '大阪市北区', - 'entry[address][addr02]' => '梅田2-4-9 ブリーゼタワー13F', - 'entry[phone_number]' => '111-111-111', - 'entry[email][first]' => $customer->getEmail(), // 会員登録済みのメールアドレスを入力する - 'entry[email][second]' => $customer->getEmail(), - 'entry[password][first]' => 'password', - 'entry[password][second]' => 'password', - ], ['css' => 'button.ec-blockBtn--action']); + EntryPage::go($I) + ->入力_姓('姓') + ->入力_名('名') + ->入力_姓カナ('セイ') + ->入力_名カナ('メイ') + ->入力_郵便番号('530-0001') + ->入力_都道府県(['value' => '27']) + ->入力_市区町村('大阪市北区') + ->入力_住所('梅田2-4-9 ブリーゼタワー13F') + ->入力_電話番号('111-111-111') + ->入力_メールアドレス($customer->getEmail()) // 会員登録済みのメールアドレスを入力する + ->入力_メールアドレス確認($customer->getEmail()) + ->入力_パスワード('password') + ->入力_パスワード確認('password') + ->入力_職業(['value' => '1']) + ->入力_利用規約同意() + ->同意して登録(); // 入力した会員情報を確認する。 $I->see('このメールアドレスは利用できません', '.ec-registerRole form .ec-borderedDefs dl:nth-child(6) dd'); @@ -126,33 +131,32 @@ public function customer_会員登録異常1(\AcceptanceTester $I) public function customer_会員登録異常2(\AcceptanceTester $I) { $I->wantTo('EF0401-UC01-T03 会員登録 異常パターン 入力ミス'); - $I->amOnPage('/entry'); $faker = Fixtures::get('faker'); $new_email = microtime(true).'.'.$faker->safeEmail; // 会員情報入力フォームに、会員情報を入力する // 「同意する」ボタンを押下する - $I->submitForm(['css' => '.ec-layoutRole__main form'], [ - 'entry[name][name01]' => '', - 'entry[name][name02]' => '名', - 'entry[kana][kana01]' => 'セイ', - 'entry[kana][kana02]' => 'メイ', - 'entry[postal_code]' => '530-0001', - 'entry[address][pref]' => ['value' => '27'], - 'entry[address][addr01]' => '大阪市北区', - 'entry[address][addr02]' => '梅田2-4-9 ブリーゼタワー13F', - 'entry[phone_number]' => '111-111-111', - 'entry[email][first]' => $new_email, - 'entry[email][second]' => $new_email, - 'entry[password][first]' => 'password', - 'entry[password][second]' => 'password', - ], ['css' => 'button.ec-blockBtn--action']); + EntryPage::go($I) + ->入力_姓('') + ->入力_名('名') + ->入力_姓カナ('セイ') + ->入力_名カナ('メイ') + ->入力_郵便番号('530-0001') + ->入力_都道府県(['value' => '27']) + ->入力_市区町村('大阪市北区') + ->入力_住所('梅田2-4-9 ブリーゼタワー13F') + ->入力_電話番号('111-111-111') + ->入力_メールアドレス($new_email) + ->入力_メールアドレス確認($new_email) + ->入力_パスワード('password') + ->入力_パスワード確認('password') + ->入力_職業(['value' => '1']) + ->入力_利用規約同意() + ->同意して登録(); // 入力した会員情報を確認する。 $I->see('新規会員登録', '.ec-pageHeader h1'); - - // TODO [fixture] 確認画面のあとでのメールアドレス重複エラー } public function customer_会員登録同意しない(\AcceptanceTester $I) @@ -174,23 +178,22 @@ public function customer_会員登録戻る(\AcceptanceTester $I) // 会員情報入力フォームに、会員情報を入力する // 「同意する」ボタンを押下する - $form = [ - 'entry[name][name01]' => '姓', - 'entry[name][name02]' => '名', - 'entry[kana][kana01]' => 'セイ', - 'entry[kana][kana02]' => 'メイ', - 'entry[postal_code]' => '530-0001', - 'entry[address][pref]' => ['value' => '27'], - 'entry[address][addr01]' => '大阪市北区', - 'entry[address][addr02]' => '梅田2-4-9 ブリーゼタワー13F', - 'entry[phone_number]' => '111-111-111', - 'entry[email][first]' => $new_email, - 'entry[email][second]' => $new_email, - 'entry[password][first]' => 'password', - 'entry[password][second]' => 'password', - 'entry[job]' => ['value' => '1'], - 'entry[user_policy_check]' => '1', - ]; + $EntryPage = EntryPage::go($I) + ->入力_姓('姓') + ->入力_名('名') + ->入力_姓カナ('セイ') + ->入力_名カナ('メイ') + ->入力_郵便番号('530-0001') + ->入力_都道府県(['value' => '27']) + ->入力_市区町村('大阪市北区') + ->入力_住所('梅田2-4-9 ブリーゼタワー13F') + ->入力_電話番号('111-111-111') + ->入力_メールアドレス($new_email) + ->入力_メールアドレス確認($new_email) + ->入力_パスワード('password') + ->入力_パスワード確認('password') + ->入力_職業(['value' => '1']) + ->入力_利用規約同意(); $findPluginByCode = Fixtures::get('findPluginByCode'); $Plugin = $findPluginByCode('MailMagazine'); @@ -198,10 +201,12 @@ public function customer_会員登録戻る(\AcceptanceTester $I) $I->amGoingTo('メルマガプラグインを発見したため、メルマガを購読します'); $form['entry[mailmaga_flg]'] = '1'; } - $I->submitForm(['css' => '.ec-layoutRole__main form'], $form, ['css' => 'button.ec-blockBtn--action']); + $EntryPage->同意して登録(); - $I->click('.ec-registerRole form button.ec-blockBtn--cancel'); - $I->see('新規会員登録', '.ec-pageHeader h1'); + EntryConfirmPage::at($I) + ->戻る(); + + EntryPage::at($I); } public function customer_会員登録利用規約(\AcceptanceTester $I) diff --git a/codeception/acceptance/EF07BasicCustomerOptionCest.php b/codeception/acceptance/EF07BasicCustomerOptionCest.php new file mode 100644 index 00000000000..9a0449e61a9 --- /dev/null +++ b/codeception/acceptance/EF07BasicCustomerOptionCest.php @@ -0,0 +1,190 @@ +loginAsAdmin(); + ShopSettingPage::go($I) + ->切替_カナ必須項目(false) + ->登録(); + } + + /** + * @group require_kana + * @before disableOptionRequireKana + */ + public function test_新規会員登録(\AcceptanceTester $I) + { + $I->wantTo('カナ入力なしで会員登録できる'); + + $faker = Fixtures::get('faker'); + $new_email = microtime(true).'.'.$faker->safeEmail; + + // 新規会員登録 + EntryPage::go($I) + ->入力_姓('姓') + ->入力_名('名') + ->入力_姓カナ('') + ->入力_名カナ('') + ->入力_郵便番号('530-0001') + ->入力_都道府県(['value' => '27']) + ->入力_市区町村('大阪市北区') + ->入力_住所('梅田2-4-9 ブリーゼタワー13F') + ->入力_電話番号('111-111-111') + ->入力_メールアドレス($new_email) + ->入力_メールアドレス確認($new_email) + ->入力_パスワード('password') + ->入力_パスワード確認('password') + ->入力_職業(['value' => '1']) + ->入力_利用規約同意() + ->同意して登録(); + + EntryConfirmPage::at($I); + } + + /** + * @group require_kana + * @before disableOptionRequireKana + */ + public function test_お届け先追加(\AcceptanceTester $I) + { + $I->wantTo('カナ入力なしでお届け先を追加できる'); + + $I->logoutAsMember(); + + $createCustomer = Fixtures::get('createCustomer'); + /** @var Customer $customer */ + $customer = $createCustomer(); + $I->loginAsMember($customer->getEmail(), 'password'); + CustomerAddressAddPage::go($I) + ->入力_姓('性') + ->入力_名('名') + ->入力_セイ('') + ->入力_メイ('') + ->入力_郵便番号('060-0000') + ->入力_都道府県(['1' => '北海道']) + ->入力_市区町村名('bbb') + ->入力_番地_ビル名('bbb') + ->入力_電話番号('111-111-111') + ->登録する(); + + CustomerAddressListPage::at($I); + } + + /** + * @group require_kana + * @before disableOptionRequireKana + */ + public function test_ゲスト購入(\AcceptanceTester $I) + { + $I->wantTo('カナ入力なしでゲスト購入できる'); + + $I->logoutAsMember(); + + $faker = Fixtures::get('faker'); + $new_email = microtime(true).'.'.$faker->safeEmail; + $BaseInfo = Fixtures::get('baseinfo'); + + ProductDetailPage::go($I, 2) + ->カートに入れる(1) + ->カートへ進む(); + + CartPage::go($I) + ->レジに進む(); + + $ShoppingLoginPage = ShoppingLoginPage::at($I)->ゲスト購入(); + $ShoppingLoginPage + ->入力_姓('姓') + ->入力_名('名') + ->入力_セイ('') + ->入力_メイ('') + ->入力_郵便番号('530-0001') + ->入力_都道府県(['value' => '27']) + ->入力_市区町村名('大阪市北区') + ->入力_番地_ビル名('梅田2-4-9 ブリーゼタワー13F') + ->入力_電話番号('111-111-111') + ->入力_Eメール($new_email) + ->入力_Eメール確認($new_email) + ->次へ(); + + ShoppingPage::at($I); + } + + /** + * @group require_kana + * @before disableOptionRequireKana + */ + public function test_受注出荷登録(\AcceptanceTester $I) + { + $I->wantTo('カナ入力なしで受注/出荷登録できる'); + + // 受注登録 + $OrderEditPage = OrderEditPage::go($I) + ->入力_支払方法(['4' => '郵便振替']) + ->入力_姓('order1') + ->入力_名('order1') + ->入力_セイ('') + ->入力_メイ('') + ->入力_郵便番号('060-0000') + ->入力_都道府県(['1' => '北海道']) + ->入力_市区町村名('bbb') + ->入力_番地_ビル名('bbb') + ->入力_Eメール('test@test.com') + ->入力_電話番号('111-111-111') + ->注文者情報をコピー() + ->入力_配送業者([1 => 'サンプル業者']) + ->商品検索('チェリーアイスサンド') + ->商品検索結果_選択(1) + ->受注情報登録(); + + $I->see('保存しました', OrderEditPage::$登録完了メッセージ); + + // 出荷登録 + $OrderEditPage->お届け先の追加(); + + ShippingEditPage::at($I) + ->入力_姓('aaa') + ->入力_セイ('') + ->入力_メイ('') + ->入力_郵便番号('060-0000') + ->入力_都道府県(['1' => '北海道']) + ->入力_市区町村名('bbb') + ->入力_番地_ビル名('bbb') + ->入力_電話番号('111-111-111') + ->入力_番地_ビル名('address 2') + ->出荷情報登録(); + + $I->see('保存しました', ShippingEditPage::$登録完了メッセージ); + } +} diff --git a/src/Eccube/Controller/NonMemberShoppingController.php b/src/Eccube/Controller/NonMemberShoppingController.php index 5daf7b093f3..cf3321dcf6c 100644 --- a/src/Eccube/Controller/NonMemberShoppingController.php +++ b/src/Eccube/Controller/NonMemberShoppingController.php @@ -13,7 +13,9 @@ namespace Eccube\Controller; +use Eccube\Entity\BaseInfo; use Eccube\Entity\Customer; +use Eccube\Repository\BaseInfoRepository; use Eccube\Event\EccubeEvents; use Eccube\Event\EventArgs; use Eccube\Form\Type\Front\NonMemberType; @@ -49,21 +51,29 @@ class NonMemberShoppingController extends AbstractShoppingController */ protected $cartService; + /** + * @var BaseInfo + */ + protected $baseInfo; + /** * NonMemberShoppingController constructor. * * @param ValidatorInterface $validator + * @param BaseInfoRepository $baseInfoRepository * @param PrefRepository $prefRepository * @param OrderHelper $orderHelper * @param CartService $cartService */ public function __construct( ValidatorInterface $validator, + BaseInfoRepository $baseInfoRepository, PrefRepository $prefRepository, OrderHelper $orderHelper, CartService $cartService ) { $this->validator = $validator; + $this->baseInfo = $baseInfoRepository->get(); $this->prefRepository = $prefRepository; $this->orderHelper = $orderHelper; $this->cartService = $cartService; @@ -269,24 +279,20 @@ protected function customerValidation(array &$data) ] ); - $data['customer_kana01'] = mb_convert_kana($data['customer_kana01'], 'CV', 'utf-8'); - $errors[] = $this->validator->validate( - $data['customer_kana01'], - [ - new Assert\NotBlank(), + $kanaValidators = [ new Assert\Length(['max' => $this->eccubeConfig['eccube_kana_len']]), new Assert\Regex(['pattern' => '/^[ァ-ヶヲ-゚ー]+$/u']), - ] - ); - $data['customer_kana02'] = mb_convert_kana($data['customer_kana02'], 'CV', 'utf-8'); - $errors[] = $this->validator->validate( - $data['customer_kana02'], - [ - new Assert\NotBlank(), - new Assert\Length(['max' => $this->eccubeConfig['eccube_kana_len']]), - new Assert\Regex(['pattern' => '/^[ァ-ヶヲ-゚ー]+$/u']), - ]); + ]; + if ($this->baseInfo->isOptionRequireKana()) { + $kanaValidators []= new Assert\NotBlank(); + } + + $data['customer_kana01'] = mb_convert_kana($data['customer_kana01'], 'CV', 'utf-8'); + $errors[] = $this->validator->validate($data['customer_kana01'], $kanaValidators); + + $data['customer_kana02'] = mb_convert_kana($data['customer_kana02'], 'CV', 'utf-8'); + $errors[] = $this->validator->validate($data['customer_kana02'], $kanaValidators); $errors[] = $this->validator->validate( $data['customer_company_name'], [ diff --git a/src/Eccube/Entity/BaseInfo.php b/src/Eccube/Entity/BaseInfo.php index 879064692ff..f522d36759f 100644 --- a/src/Eccube/Entity/BaseInfo.php +++ b/src/Eccube/Entity/BaseInfo.php @@ -219,6 +219,13 @@ class BaseInfo extends \Eccube\Entity\AbstractEntity */ private $option_remember_me = true; + /** + * @var boolean + * + * @ORM\Column(name="option_require_kana", type="boolean", options={"default":true}) + */ + private $option_require_kana = true; + /** * @var string|null * @@ -901,6 +908,20 @@ public function setOptionRememberMe($optionRememberMe) return $this; } + /** + * Set optionRequireKana + * + * @param boolean $optionRequireKana + * + * @return BaseInfo + */ + public function setOptionRequireKana($optionRequireKana) + { + $this->option_require_kana = $optionRequireKana; + + return $this; + } + /** * Get optionRememberMe. * @@ -911,6 +932,16 @@ public function isOptionRememberMe() return $this->option_remember_me; } + /** + * Get optionRequireKana + * + * @return boolean + */ + public function isOptionRequireKana() + { + return $this->option_require_kana; + } + /** * Set authenticationKey. * diff --git a/src/Eccube/Form/EventListener/ConvertKanaListener.php b/src/Eccube/Form/EventListener/ConvertKanaListener.php index 2ed4292a26d..50b246ed7c4 100644 --- a/src/Eccube/Form/EventListener/ConvertKanaListener.php +++ b/src/Eccube/Form/EventListener/ConvertKanaListener.php @@ -45,6 +45,9 @@ public static function getSubscribedEvents() public function onPreSubmit(FormEvent $event) { $data = $event->getData(); + if (is_null($data)) { + return; + } if (is_array($data)) { foreach ($data as &$value) { diff --git a/src/Eccube/Form/Type/Admin/CustomerType.php b/src/Eccube/Form/Type/Admin/CustomerType.php index d53b7fe3cd9..fce04ebaecc 100644 --- a/src/Eccube/Form/Type/Admin/CustomerType.php +++ b/src/Eccube/Form/Type/Admin/CustomerType.php @@ -64,9 +64,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) ->add('name', NameType::class, [ 'required' => true, ]) - ->add('kana', KanaType::class, [ - 'required' => true, - ]) + ->add('kana', KanaType::class) ->add('company_name', TextType::class, [ 'required' => false, 'constraints' => [ diff --git a/src/Eccube/Form/Type/Admin/OrderType.php b/src/Eccube/Form/Type/Admin/OrderType.php index 2bd20946b2a..b84e01da94f 100644 --- a/src/Eccube/Form/Type/Admin/OrderType.php +++ b/src/Eccube/Form/Type/Admin/OrderType.php @@ -99,14 +99,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) ], ], ]) - ->add('kana', KanaType::class, [ - 'required' => false, - 'options' => [ - 'constraints' => [ - new Assert\NotBlank(), - ], - ], - ]) + ->add('kana', KanaType::class) ->add('company_name', TextType::class, [ 'required' => false, 'constraints' => [ diff --git a/src/Eccube/Form/Type/Admin/ShippingType.php b/src/Eccube/Form/Type/Admin/ShippingType.php index a1c54287976..185cd88df3e 100644 --- a/src/Eccube/Form/Type/Admin/ShippingType.php +++ b/src/Eccube/Form/Type/Admin/ShippingType.php @@ -98,14 +98,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) ], ], ]) - ->add('kana', KanaType::class, [ - 'required' => false, - 'options' => [ - 'constraints' => [ - new Assert\NotBlank(), - ], - ], - ]) + ->add('kana', KanaType::class) ->add('company_name', TextType::class, [ 'required' => false, 'constraints' => [ diff --git a/src/Eccube/Form/Type/Admin/ShopMasterType.php b/src/Eccube/Form/Type/Admin/ShopMasterType.php index 5ecc10d8a9e..790892d2c8f 100644 --- a/src/Eccube/Form/Type/Admin/ShopMasterType.php +++ b/src/Eccube/Form/Type/Admin/ShopMasterType.php @@ -167,6 +167,8 @@ public function buildForm(FormBuilderInterface $builder, array $options) ->add('option_mypage_order_status_display', ToggleSwitchType::class) // 自動ログイン ->add('option_remember_me', ToggleSwitchType::class) + // カナ項目必須 + ->add('option_require_kana', ToggleSwitchType::class) // お気に入り商品設定 ->add('option_favorite_product', ToggleSwitchType::class) // 在庫切れ商品を非表示にする diff --git a/src/Eccube/Form/Type/Front/CustomerAddressType.php b/src/Eccube/Form/Type/Front/CustomerAddressType.php index e676b2139f5..a96f1313735 100644 --- a/src/Eccube/Form/Type/Front/CustomerAddressType.php +++ b/src/Eccube/Form/Type/Front/CustomerAddressType.php @@ -49,9 +49,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) ->add('name', NameType::class, [ 'required' => true, ]) - ->add('kana', KanaType::class, [ - 'required' => true, - ]) + ->add('kana', KanaType::class) ->add('company_name', TextType::class, [ 'required' => false, 'constraints' => [ diff --git a/src/Eccube/Form/Type/Front/EntryType.php b/src/Eccube/Form/Type/Front/EntryType.php index 7982f497a20..473042fdcb7 100644 --- a/src/Eccube/Form/Type/Front/EntryType.php +++ b/src/Eccube/Form/Type/Front/EntryType.php @@ -61,7 +61,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) ->add('name', NameType::class, [ 'required' => true, ]) - ->add('kana', KanaType::class, []) + ->add('kana', KanaType::class) ->add('company_name', TextType::class, [ 'required' => false, 'constraints' => [ diff --git a/src/Eccube/Form/Type/Front/NonMemberType.php b/src/Eccube/Form/Type/Front/NonMemberType.php index f4ceb1d8133..8ebe65bc4c0 100644 --- a/src/Eccube/Form/Type/Front/NonMemberType.php +++ b/src/Eccube/Form/Type/Front/NonMemberType.php @@ -14,6 +14,7 @@ namespace Eccube\Form\Type\Front; use Eccube\Common\EccubeConfig; +use Eccube\Repository\BaseInfoRepository; use Eccube\Form\Type\AddressType; use Eccube\Form\Type\KanaType; use Eccube\Form\Type\NameType; @@ -51,9 +52,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) ->add('name', NameType::class, [ 'required' => true, ]) - ->add('kana', KanaType::class, [ - 'required' => true, - ]) + ->add('kana', KanaType::class) ->add('company_name', TextType::class, [ 'required' => false, 'constraints' => [ diff --git a/src/Eccube/Form/Type/KanaType.php b/src/Eccube/Form/Type/KanaType.php index 9a5666886dd..63c69a3759e 100644 --- a/src/Eccube/Form/Type/KanaType.php +++ b/src/Eccube/Form/Type/KanaType.php @@ -14,6 +14,8 @@ namespace Eccube\Form\Type; use Eccube\Common\EccubeConfig; +use Eccube\Entity\BaseInfo; +use Eccube\Repository\BaseInfoRepository; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -22,18 +24,25 @@ class KanaType extends AbstractType { /** - * @var \Eccube\Common\EccubeConfig + * @var EccubeConfig */ protected $eccubeConfig; + /** + * @var BaseInfo + */ + protected $baseInfo; + /** * KanaType constructor. * * @param EccubeConfig $eccubeConfig + * @param BaseInfoRepository $baseInfoRepository */ - public function __construct(EccubeConfig $eccubeConfig) + public function __construct(EccubeConfig $eccubeConfig, BaseInfoRepository $baseInfoRepository) { $this->eccubeConfig = $eccubeConfig; + $this->baseInfo = $baseInfoRepository->get(); } /** @@ -52,6 +61,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ + 'required' => $this->baseInfo->isOptionRequireKana(), 'lastname_options' => [ 'attr' => [ 'placeholder' => 'common.last_name_kana', diff --git a/src/Eccube/Resource/locale/messages.en.yaml b/src/Eccube/Resource/locale/messages.en.yaml index 7ea345dc46c..11d7bb037f2 100644 --- a/src/Eccube/Resource/locale/messages.en.yaml +++ b/src/Eccube/Resource/locale/messages.en.yaml @@ -1108,6 +1108,7 @@ admin.setting.shop.shop.option_customer_activate: Temporary Customers admin.setting.shop.shop.option_mypage_order_status_display: Display order status in My Accounts admin.setting.shop.shop.option_favorite_product: Favorites admin.setting.shop.shop.option_remember_me: Auto Sign-in +admin.setting.shop.shop.option_require_kana: Require Kana Field admin.setting.shop.shop.option_product: Product Settings admin.setting.shop.shop.nostock_hidden: Hide out-of-stock products admin.setting.shop.shop.option_tax: Taxes @@ -1594,6 +1595,7 @@ tooltip.setting.shop.shop.option_delivery_fee_by_product: If turned on, you can tooltip.setting.shop.shop.option_customer_activate: This will register a customer as a temporary customer until email verification is completed, after which s/he will be registered as a regular customer. tooltip.setting.shop.shop.option_favorite_product: This allows users to save their favorite products as Favorites. tooltip.setting.shop.shop.option_remember_me: Allow customers to automatically sign in for certain period of time. +tooltip.setting.shop.shop.option_require_kana: Request customers to enter Kana names tooltip.setting.shop.shop.option_product_tax: If turned on, you can set the tax rate per product. tooltip.setting.shop.shop.option_point_enabled: If turned on, the point system is enabled. tooltip.setting.shop.shop.option_point_rate: You can change the point return rate by purchase amount. diff --git a/src/Eccube/Resource/locale/messages.ja.yaml b/src/Eccube/Resource/locale/messages.ja.yaml index 3564b375e2c..2bbcc3d300d 100644 --- a/src/Eccube/Resource/locale/messages.ja.yaml +++ b/src/Eccube/Resource/locale/messages.ja.yaml @@ -1108,6 +1108,7 @@ admin.setting.shop.shop.option_customer_activate: 仮会員機能 admin.setting.shop.shop.option_mypage_order_status_display: マイページに注文状況を表示 admin.setting.shop.shop.option_favorite_product: お気に入り商品機能 admin.setting.shop.shop.option_remember_me: 自動ログイン機能 +admin.setting.shop.shop.option_require_kana: カナを必須項目にする admin.setting.shop.shop.option_product: 商品設定 admin.setting.shop.shop.nostock_hidden: 在庫切れ商品の非表示 admin.setting.shop.shop.option_tax: 税設定 @@ -1594,6 +1595,7 @@ tooltip.setting.shop.shop.option_delivery_fee_by_product: ここをオンにす tooltip.setting.shop.shop.option_customer_activate: 顧客の会員登録直後は仮会員とし、メールアドレスの確認などを経て本会員として登録できる機能です。 tooltip.setting.shop.shop.option_favorite_product: 顧客が任意の商品をお気に入りとして登録できるようにする機能です。 tooltip.setting.shop.shop.option_remember_me: 顧客に一定期間の自動ログインを許可します。 +tooltip.setting.shop.shop.option_require_kana: 顧客登録時にカナの入力を必須にします。 tooltip.setting.shop.shop.option_product_tax: オンにすると、商品別に税率を設定することができるようになります。 tooltip.setting.shop.shop.option_point_enabled: オンにすると、ポイント機能を有効化できます。 tooltip.setting.shop.shop.option_point_rate: 購入金額に対するポイント付与率を編集できます。 diff --git a/src/Eccube/Resource/template/admin/Customer/edit.twig b/src/Eccube/Resource/template/admin/Customer/edit.twig index d5cda78bad3..384b794cc3f 100644 --- a/src/Eccube/Resource/template/admin/Customer/edit.twig +++ b/src/Eccube/Resource/template/admin/Customer/edit.twig @@ -87,7 +87,9 @@ file that was distributed with this source code.