Skip to content

Commit

Permalink
Merge pull request bagisto#10506 from bagisto/mail-issue
Browse files Browse the repository at this point in the history
fixed registration testcases
  • Loading branch information
devansh-webkul authored Jan 27, 2025
2 parents bc70287 + b35b5d7 commit 731a087
Showing 1 changed file with 27 additions and 20 deletions.
47 changes: 27 additions & 20 deletions packages/Webkul/Shop/tests/Feature/RegistrationPageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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,
]);

Expand All @@ -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(),
Expand All @@ -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);
});

0 comments on commit 731a087

Please sign in to comment.