This repository was archived by the owner on Apr 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathMailRecorderTest.php
87 lines (74 loc) · 2.31 KB
/
MailRecorderTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
namespace Spinen\MailAssertions;
use Mockery;
use StdClass;
use Swift_Events_SendEvent;
use TypeError;
/**
* Class MailRecorderTest
*/
class MailRecorderTest extends TestCase
{
/**
* @test
*/
public function it_can_be_constructed()
{
$mail_recorder = new MailRecorder($this);
$this->assertInstanceOf(MailRecorder::class, $mail_recorder);
}
/**
* @test
*/
public function it_cannot_be_constructed_without_a_PHPUnit_Framework_TestCase()
{
$this->markTestSkipped('Figure out what the correct exception should be');
//$this->expectException(PHPUnit_Framework_Error::class);
if (class_exists(TypeError::class)) {
try {
new MailRecorder();
} catch (TypeError $e) {
throw new PHPUnit_Framework_Error('Argument 1 passed to method must be an array, but not', 0,
$e->getFile(), $e->getLine());
}
} else {
new MailRecorder();
}
}
/**
* @test
*/
public function it_cannot_be_constructed_with_class_other_than_a_PHPUnit_Framework_TestCase()
{
if (class_exists(TypeError::class)) {
try {
new MailRecorder(new StdClass());
} catch (TypeError $e) {
throw new PHPUnit_Framework_Error('Argument 1 passed to method must be an array, but not', 0,
$e->getFile(), $e->getLine());
}
} else {
new MailRecorder(new StdClass());
}
}
/**
* @test
*
* @group
*/
public function it_records_the_message_on_the_test_by_calling_recordMail()
{
$test_mock = Mockery::mock(TestCase::class);
$test_mock->shouldReceive('recordMail')
->once()
->with('message')
->andReturnNull();
$swift_message_event_mock = Mockery::mock(Swift_Events_SendEvent::class);
$swift_message_event_mock->shouldReceive('getMessage')
->once()
->withNoArgs()
->andReturn('message');
$mail_recorder = new MailRecorder($test_mock);
$this->assertNull($mail_recorder->beforeSendPerformed($swift_message_event_mock));
}
}