@@ -44,9 +44,8 @@ public function autoClearProvider()
44
44
*/
45
45
public function testEmailSendWithClearance ($ autoClear )
46
46
{
47
- $ config = config ('Email ' );
48
- $ config ->validate = true ;
49
- $ email = new MockEmail ($ config );
47
+ $ email = $ this ->createMockEmail ();
48
+
50
49
$ email->
setTo (
'[email protected] ' );
51
50
52
51
$ this ->assertTrue ($ email ->send ($ autoClear ));
@@ -58,9 +57,8 @@ public function testEmailSendWithClearance($autoClear)
58
57
59
58
public function testEmailSendStoresArchive ()
60
59
{
61
- $ config = config ('Email ' );
62
- $ config ->validate = true ;
63
- $ email = new MockEmail ($ config );
60
+ $ email = $ this ->createMockEmail ();
61
+
64
62
$ email->
setTo (
'[email protected] ' );
65
63
$ email->
setFrom (
'[email protected] ' );
66
64
$ email ->setSubject ('Archive Test ' );
@@ -75,9 +73,8 @@ public function testEmailSendStoresArchive()
75
73
76
74
public function testAutoClearLeavesArchive ()
77
75
{
78
- $ config = config ('Email ' );
79
- $ config ->validate = true ;
80
- $ email = new MockEmail ($ config );
76
+ $ email = $ this ->createMockEmail ();
77
+
81
78
$ email->
setTo (
'[email protected] ' );
82
79
83
80
$ this ->assertTrue ($ email ->send (true ));
@@ -89,6 +86,7 @@ public function testEmailSendRepeatUpdatesArchive()
89
86
{
90
87
$ config = config ('Email ' );
91
88
$ email = new MockEmail ($ config );
89
+
92
90
$ email->
setTo (
'[email protected] ' );
93
91
$ email->
setFrom (
'[email protected] ' );
94
92
@@ -104,9 +102,8 @@ public function testEmailSendRepeatUpdatesArchive()
104
102
105
103
public function testSuccessDoesTriggerEvent ()
106
104
{
107
- $ config = config ('Email ' );
108
- $ config ->validate = true ;
109
- $ email = new MockEmail ($ config );
105
+ $ email = $ this ->createMockEmail ();
106
+
110
107
$ email->
setTo (
'[email protected] ' );
111
108
112
109
$ result = null ;
@@ -123,9 +120,8 @@ public function testSuccessDoesTriggerEvent()
123
120
124
121
public function testFailureDoesNotTriggerEvent ()
125
122
{
126
- $ config = config ('Email ' );
127
- $ config ->validate = true ;
128
- $ email = new MockEmail ($ config );
123
+ $ email = $ this ->createMockEmail ();
124
+
129
125
$ email->
setTo (
'[email protected] ' );
130
126
$ email ->returnValue = false ;
131
127
@@ -139,4 +135,12 @@ public function testFailureDoesNotTriggerEvent()
139
135
140
136
$ this ->assertNull ($ result );
141
137
}
138
+
139
+ private function createMockEmail (): MockEmail
140
+ {
141
+ $ config = config ('Email ' );
142
+ $ config ->validate = true ;
143
+
144
+ return new MockEmail ($ config );
145
+ }
142
146
}
0 commit comments