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

Commit 9ee60a9

Browse files
committed
Merge branch 'release/1.3.0'
2 parents 4f56cc9 + d077235 commit 9ee60a9

File tree

6 files changed

+57
-26
lines changed

6 files changed

+57
-26
lines changed

.travis.yml

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ matrix:
1313
- php: 7.3
1414
- php: 7.3
1515
env: SETUP=lowest
16+
- php: 7.4
17+
- php: 7.4
18+
env: SETUP=lowest
1619

1720
sudo: false
1821

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.2.1
1+
1.3.0

composer.json

+11-5
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,23 @@
1313
{
1414
"name": "Jimmy Puckett",
1515
"email": "jimmy.puckett@spinen.com"
16+
},
17+
{
18+
"name": "Stephen Finney",
19+
"email": "stephen.finney@spinen.com"
1620
}
1721
],
1822
"require": {
1923
"php": ">=7.2",
20-
"illuminate/support": "~5.5|~6",
21-
"swiftmailer/swiftmailer": "~6.0",
22-
"phpunit/phpunit": "~7.0.1|~8.0"
24+
"illuminate/container": "~5.7|~6|~7",
25+
"illuminate/mail": "~5.7|~6|~7",
26+
"swiftmailer/swiftmailer": "~6.2",
27+
"phpunit/phpunit": "^8.4|^9.0"
2328
},
2429
"require-dev": {
25-
"mockery/mockery": "^1",
26-
"psy/psysh": "^0.9.9",
30+
"egulias/email-validator": "^2.1.16",
31+
"mockery/mockery": "^1.3.1",
32+
"psy/psysh": "^0.10",
2733
"symfony/thanks": "^1.1",
2834
"symfony/var-dumper": "~3.0|^4.2"
2935
},

phpunit.xml.dist

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
convertErrorsToExceptions="true"
1515
convertNoticesToExceptions="true"
1616
convertWarningsToExceptions="true"
17-
processIsolation="true"
17+
processIsolation="false"
1818
stopOnFailure="false"
1919
verbose="true">
2020

@@ -48,7 +48,6 @@
4848
showOnlySummary="true"
4949
showUncoveredFiles="false"/>
5050
<log type="coverage-clover" target="build/phpunit/logs/clover.xml"/>
51-
<log type="json" target="./build/phpunit/logs/logfile.json"/>
5251
<log type="junit" target="./build/phpunit/logs/junit.xml"/>
5352
</logging>
5453
</phpunit>

src/MailTracking.php

+29-16
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
namespace Spinen\MailAssertions;
44

5-
use Illuminate\Support\Facades\Mail;
5+
use Illuminate\Container\Container;
6+
use Illuminate\Contracts\Container\BindingResolutionException;
7+
use Illuminate\Contracts\Mail\Mailer;
68
use Swift_Message;
79

810
/**
@@ -48,15 +50,30 @@ trait MailTracking
4850
public function setUpMailTracking()
4951
{
5052
$register_plugin = function () {
51-
Mail::getSwiftMailer()
52-
->registerPlugin(new MailRecorder($this));
53+
$this->resolveMailer()
54+
->getSwiftMailer()
55+
->registerPlugin(new MailRecorder($this));
5356
};
5457

5558
$this->afterApplicationCreated(function () use ($register_plugin) {
5659
$register_plugin();
5760
});
5861
}
5962

63+
/**
64+
* Resolve the mailer from the IoC
65+
*
66+
* We are staying away from the Mail facade, so that we can support PHP 7.4 with Laravel 5.x
67+
*
68+
* @return Mailer
69+
* @throws BindingResolutionException
70+
*/
71+
protected function resolveMailer()
72+
{
73+
return Container::getInstance()
74+
->make(Mailer::class);
75+
}
76+
6077
/**
6178
* Retrieve the appropriate Swift message.
6279
*
@@ -133,8 +150,8 @@ protected function seeEmailCc($cc, Swift_Message $message = null)
133150
*/
134151
protected function seeEmailContains($excerpt, Swift_Message $message = null)
135152
{
136-
$this->assertContains($excerpt, $this->getEmail($message)
137-
->getBody(), "The last email sent did not contain the provided body.");
153+
$this->assertStringContainsString($excerpt, $this->getEmail($message)
154+
->getBody(), "The last email sent did not contain the provided body.");
138155

139156
return $this;
140157
}
@@ -167,9 +184,8 @@ protected function seeEmailContentTypeEquals($content_type, Swift_Message $messa
167184
*/
168185
protected function seeEmailDoesNotContain($excerpt, Swift_Message $message = null)
169186
{
170-
$this->assertNotContains($excerpt, $this->getEmail($message)
171-
->getBody(),
172-
"The last email sent contained the provided text in its body.");
187+
$this->assertStringNotContainsString($excerpt, $this->getEmail($message)
188+
->getBody(), "The last email sent contained the provided text in its body.");
173189

174190
return $this;
175191
}
@@ -297,9 +313,8 @@ protected function seeEmailSubject($subject, Swift_Message $message = null)
297313
*/
298314
protected function seeEmailSubjectContains($excerpt, Swift_Message $message = null)
299315
{
300-
$this->assertContains($excerpt, $this->getEmail($message)
301-
->getSubject(),
302-
"The last email sent did not contain the provided subject.");
316+
$this->assertStringContainsString($excerpt, $this->getEmail($message)
317+
->getSubject(), "The last email sent did not contain the provided subject.");
303318

304319
return $this;
305320
}
@@ -314,9 +329,8 @@ protected function seeEmailSubjectContains($excerpt, Swift_Message $message = nu
314329
*/
315330
protected function seeEmailSubjectDoesNotContain($excerpt, Swift_Message $message = null)
316331
{
317-
$this->assertNotContains($excerpt, $this->getEmail($message)
318-
->getSubject(),
319-
"The last email sent contained the provided text in its subject.");
332+
$this->assertStringNotContainsString($excerpt, $this->getEmail($message)
333+
->getSubject(), "The last email sent contained the provided text in its subject.");
320334

321335
return $this;
322336
}
@@ -332,8 +346,7 @@ protected function seeEmailSubjectDoesNotContain($excerpt, Swift_Message $messag
332346
protected function seeEmailSubjectEquals($subject, Swift_Message $message = null)
333347
{
334348
$this->assertEquals($subject, $this->getEmail($message)
335-
->getSubject(),
336-
"The last email sent did not contain a subject of $subject.");
349+
->getSubject(), "The last email sent did not contain a subject of $subject.");
337350

338351
return $this;
339352
}

tests/MailTrackingTest.php

+12-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
namespace Spinen\MailAssertions;
44

5-
use Illuminate\Support\Facades\Mail;
5+
use Illuminate\Container\Container;
6+
use Illuminate\Contracts\Mail\Mailer;
67
use Mockery;
78
use ReflectionClass;
89
use Spinen\MailAssertions\Stubs\MailTrackingStub as MailTracking;
@@ -21,12 +22,21 @@ class MailTrackingTest extends TestCase
2122
*/
2223
protected $mail_tracking;
2324

25+
/**
26+
* @var Mockery\Mock
27+
*/
28+
protected $mailer_mock;
29+
2430
/**
2531
* Make a new MailTracking (Stub) instance for each test
2632
*/
2733
protected function setUp(): void
2834
{
2935
$this->mail_tracking = new MailTracking();
36+
$this->mailer_mock = Mockery::mock(Mailer::class);
37+
38+
Container::getInstance()
39+
->instance(Mailer::class, $this->mailer_mock);
3040

3141
parent::setUp();
3242
}
@@ -104,7 +114,7 @@ public function it_registers_MailRecorder_withMail_in_the_setup_with_before_anno
104114
}))
105115
->andReturnNull();
106116

107-
Mail::shouldReceive('getSwiftMailer')
117+
$this->mailer_mock->shouldReceive('getSwiftMailer')
108118
->once()
109119
->withNoArgs()
110120
->andReturn($swift_mock);

0 commit comments

Comments
 (0)