From b35b5d7d1d89c39285daef784f7975db2b33e9c7 Mon Sep 17 00:00:00 2001 From: Shivendra Date: Mon, 27 Jan 2025 12:04:55 +0530 Subject: [PATCH] fixed registration testcase --- .../tests/Feature/RegistrationPageTest.php | 47 +++++++++++-------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/packages/Webkul/Shop/tests/Feature/RegistrationPageTest.php b/packages/Webkul/Shop/tests/Feature/RegistrationPageTest.php index 0feccafecc..09c6864422 100644 --- a/packages/Webkul/Shop/tests/Feature/RegistrationPageTest.php +++ b/packages/Webkul/Shop/tests/Feature/RegistrationPageTest.php @@ -52,6 +52,10 @@ }); it('successfully registers a customer', function () { + CoreConfig::where('code', 'emails.general.notifications.emails.general.notifications.verification')->update([ + 'value' => 0, + ]); + // Arrange. $requestedCustomer = [ 'first_name' => fake()->firstName(), @@ -67,16 +71,12 @@ ->assertSessionHas('success', trans('shop::app.customers.signup-form.success')); }); -it('successfully registers a customer and send mail to the customer that you have successfully registered', function () { +it('successfully registers a customer and send mail to the customer verify the account', function () { // Arrange. Mail::fake(); CoreConfig::factory()->create([ - 'code' => 'emails.general.notifications.emails.general.notifications.registration', - 'value' => 1, - ]); - - CoreConfig::where('code', 'emails.general.notifications.emails.general.notifications.customer_registration_confirmation_mail_to_admin')->update([ + 'code' => 'emails.general.notifications.emails.general.notifications.verification', 'value' => 1, ]); @@ -91,19 +91,29 @@ // Act and Assert. post(route('shop.customers.register.store'), $requestedCustomer) ->assertRedirectToRoute('shop.customer.session.index') - ->assertSessionHas('success', trans('shop::app.customers.signup-form.success')); - - Mail::assertQueued(AdminRegistrationNotification::class); + ->assertSessionHas('success', trans('shop::app.customers.signup-form.success-verify')); - Mail::assertQueued(ShopRegistrationNotification::class); + Mail::assertQueued(EmailVerificationNotification::class); - Mail::assertQueuedCount(2); + Mail::assertQueuedCount(1); }); -it('successfully registers a customer and send mail to the customer that you need to verify the mail', function () { +it('registers a customer successfully and sends a registration email to customer and admin along with a success message', function () { // Arrange. Mail::fake(); + CoreConfig::where('code', 'emails.general.notifications.emails.general.notifications.registration')->update([ + 'value' => 1, + ]); + + CoreConfig::where('code', 'emails.general.notifications.emails.general.notifications.customer_registration_confirmation_mail_to_admin')->update([ + 'value' => 1, + ]); + + CoreConfig::where('code', 'emails.general.notifications.emails.general.notifications.verification')->update([ + 'value' => 0, + ]); + $requestedCustomer = [ 'first_name' => fake()->firstName(), 'last_name' => fake()->lastName(), @@ -112,17 +122,14 @@ 'password_confirmation' => 'admin123', ]; - CoreConfig::factory()->create([ - 'code' => 'customer.settings.email.verification', - 'value' => 1, - ]); - // Act and Assert. post(route('shop.customers.register.store'), $requestedCustomer) ->assertRedirectToRoute('shop.customer.session.index') - ->assertSessionHas('success', trans('shop::app.customers.signup-form.success-verify')); + ->assertSessionHas('success', trans('shop::app.customers.signup-form.success')); - Mail::assertQueued(EmailVerificationNotification::class); + Mail::assertQueued(AdminRegistrationNotification::class); - Mail::assertQueuedCount(1); + Mail::assertQueued(ShopRegistrationNotification::class); + + Mail::assertQueuedCount(2); });