Skip to content

Commit fb7ccf7

Browse files
committed
remove event listener for testing purposes
1 parent 6224ccc commit fb7ccf7

File tree

3 files changed

+6
-31
lines changed

3 files changed

+6
-31
lines changed

src/Sender.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Illuminate\Mail\Mailer;
66
use Illuminate\Mail\Message;
7-
use Illuminate\Support\Facades\Event;
87

98
class Sender
109
{
@@ -21,10 +20,6 @@ public function send(Email $email)
2120

2221
$email->markAsSending();
2322

24-
if (app()->runningUnitTests()) {
25-
Event::dispatch('before.send');
26-
}
27-
2823
$this->getMailerInstance()->send([], [], function (Message $message) use ($email) {
2924
$this->buildMessage($message, $email);
3025
});

tests/RetryFailedEmailsCommandTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,13 @@ function setUp()
1313
parent::setUp();
1414

1515
$this->app['config']['laravel-database-emails.attempts'] = 3;
16-
17-
Event::listen('before.send', function() {
18-
throw new \Exception('Simulating some random error');
19-
});
2016
}
2117

2218
/** @test */
2319
function an_email_cannot_be_reset_if_the_max_attempt_count_has_not_been_reached()
2420
{
21+
$this->app['config']['mail.driver'] = 'does-not-exist';
22+
2523
$this->sendEmail();
2624

2725
$this->artisan('email:send');

tests/SendEmailsCommandTest.php

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -46,33 +46,17 @@ function an_email_should_not_be_sent_once_it_is_marked_as_sent()
4646
$this->assertEquals($firstSend, $email->fresh()->getSendDate());
4747
}
4848

49-
/** @test */
50-
function an_email_should_be_locked_so_overlapping_cronjobs_cannot_send_an_already_processing_email()
51-
{
52-
$email = $this->sendEmail();
53-
54-
Event::listen('before.send', function () {
55-
$this->artisan('email:send');
56-
});
57-
58-
$this->artisan('email:send');
59-
60-
$this->assertEquals(1, $email->fresh()->getAttempts());
61-
}
62-
6349
/** @test */
6450
function if_an_email_fails_to_be_sent_it_should_be_logged_in_the_database()
6551
{
66-
$email = $this->sendEmail();
52+
$this->app['config']['mail.driver'] = 'does-not-exist';
6753

68-
Event::listen('before.send', function () {
69-
throw new \Exception('Simulating some random error');
70-
});
54+
$email = $this->sendEmail();
7155

7256
$this->artisan('email:send');
7357

7458
$this->assertTrue($email->fresh()->hasFailed());
75-
$this->assertContains('Simulating some random error', $email->fresh()->getError());
59+
$this->assertContains('Driver [does-not-exist] not supported.', $email->fresh()->getError());
7660
}
7761

7862
/** @test */
@@ -109,9 +93,7 @@ function an_email_should_never_be_sent_before_its_scheduled_date()
10993
/** @test */
11094
function emails_will_be_sent_until_max_try_count_has_been_reached()
11195
{
112-
Event::listen('before.send', function () {
113-
throw new \Exception('Simulating some random error');
114-
});
96+
$this->app['config']['mail.driver'] = 'does-not-exist';
11597

11698
$this->sendEmail();
11799
$this->assertCount(1, (new Store)->getQueue());

0 commit comments

Comments
 (0)