Skip to content
This repository was archived by the owner on Apr 8, 2024. It is now read-only.

Commit 9b141cf

Browse files
authored
Merge pull request #43 from spinen/release/0.3.4
Release/0.3.4
2 parents d0531ce + dd6125e commit 9b141cf

File tree

4 files changed

+57
-2
lines changed

4 files changed

+57
-2
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.3.0
1+
0.3.4

src/MailTracking.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function setUpMailTracking()
6060
return;
6161
}
6262

63-
// For PhpUnit 6 and Laravel > 5.1, register the plugin after the app is booted
63+
// For PhpUnit 6 and Laravel > 5.2, register the plugin after the app is booted
6464
$this->afterApplicationCreated(function () use ($register_plugin) {
6565
$register_plugin();
6666
});

tests/MailTrackingTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Mockery;
77
use ReflectionClass;
88
use Spinen\MailAssertions\Stubs\MailTrackingStub as MailTracking;
9+
use Spinen\MailAssertions\Stubs\OldMailTrackingStub as OldMailTracking;
910
use Swift_Mailer;
1011
use Swift_Message;
1112

@@ -115,6 +116,33 @@ public function it_registers_MailRecorder_withMail_in_the_setup_with_before_anno
115116
$this->mail_tracking->setUpMailTracking();
116117
}
117118

119+
/**
120+
* @test
121+
* @group unit
122+
*/
123+
public function it_registers_MailRecorder_without_afterApplicationCreated_method_present()
124+
{
125+
// Use a version of the MailTrackingStub without the afterApplicationCreated method
126+
$this->mail_tracking = new OldMailTracking();
127+
128+
$swift_mock = Mockery::mock(Swift_Mailer::class);
129+
130+
$swift_mock->shouldReceive('registerPlugin')
131+
->once()
132+
->with(Mockery::on(function($closure) {
133+
return is_a($closure, MailRecorder::class);
134+
}))
135+
->andReturnNull();
136+
137+
Mail::shouldReceive('getSwiftMailer')
138+
->once()
139+
->withNoArgs()
140+
->andReturn($swift_mock);
141+
142+
// TODO: Get this method name by parsing annotations
143+
$this->mail_tracking->setUpMailTracking();
144+
}
145+
118146
/**
119147
* @test
120148
* @group unit

tests/Stubs/OldMailTrackingStub.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace Spinen\MailAssertions\Stubs;
4+
5+
use Spinen\MailAssertions\MailTracking;
6+
use Spinen\MailAssertions\TestCase;
7+
8+
/**
9+
* Class MailTrackingStub
10+
*
11+
* @package Spinen\MailAssertions\Stubs
12+
*/
13+
class OldMailTrackingStub extends TestCase
14+
{
15+
use MailTracking;
16+
17+
/**
18+
* Public method in the stub to expose the protected email collection
19+
*
20+
* This is only needed in the tests to allow access to the raw collection of messages.
21+
*
22+
* @return array
23+
*/
24+
public function exposeMessage() {
25+
return $this->emails;
26+
}
27+
}

0 commit comments

Comments
 (0)