@@ -44,9 +44,8 @@ public function autoClearProvider()
4444 */
4545 public function testEmailSendWithClearance ($ autoClear )
4646 {
47- $ config = config ('Email ' );
48- $ config ->validate = true ;
49- $ email = new MockEmail ($ config );
47+ $ email = $ this ->createMockEmail ();
48+
5049 $ email ->setTo ('foo@foo.com ' );
5150
5251 $ this ->assertTrue ($ email ->send ($ autoClear ));
@@ -58,9 +57,8 @@ public function testEmailSendWithClearance($autoClear)
5857
5958 public function testEmailSendStoresArchive ()
6059 {
61- $ config = config ('Email ' );
62- $ config ->validate = true ;
63- $ email = new MockEmail ($ config );
60+ $ email = $ this ->createMockEmail ();
61+
6462 $ email ->setTo ('foo@foo.com ' );
6563 $ email ->setFrom ('bar@foo.com ' );
6664 $ email ->setSubject ('Archive Test ' );
@@ -75,9 +73,8 @@ public function testEmailSendStoresArchive()
7573
7674 public function testAutoClearLeavesArchive ()
7775 {
78- $ config = config ('Email ' );
79- $ config ->validate = true ;
80- $ email = new MockEmail ($ config );
76+ $ email = $ this ->createMockEmail ();
77+
8178 $ email ->setTo ('foo@foo.com ' );
8279
8380 $ this ->assertTrue ($ email ->send (true ));
@@ -89,6 +86,7 @@ public function testEmailSendRepeatUpdatesArchive()
8986 {
9087 $ config = config ('Email ' );
9188 $ email = new MockEmail ($ config );
89+
9290 $ email ->setTo ('foo@foo.com ' );
9391 $ email ->setFrom ('bar@foo.com ' );
9492
@@ -104,9 +102,8 @@ public function testEmailSendRepeatUpdatesArchive()
104102
105103 public function testSuccessDoesTriggerEvent ()
106104 {
107- $ config = config ('Email ' );
108- $ config ->validate = true ;
109- $ email = new MockEmail ($ config );
105+ $ email = $ this ->createMockEmail ();
106+
110107 $ email ->setTo ('foo@foo.com ' );
111108
112109 $ result = null ;
@@ -123,9 +120,8 @@ public function testSuccessDoesTriggerEvent()
123120
124121 public function testFailureDoesNotTriggerEvent ()
125122 {
126- $ config = config ('Email ' );
127- $ config ->validate = true ;
128- $ email = new MockEmail ($ config );
123+ $ email = $ this ->createMockEmail ();
124+
129125 $ email ->setTo ('foo@foo.com ' );
130126 $ email ->returnValue = false ;
131127
@@ -139,4 +135,12 @@ public function testFailureDoesNotTriggerEvent()
139135
140136 $ this ->assertNull ($ result );
141137 }
138+
139+ private function createMockEmail (): MockEmail
140+ {
141+ $ config = config ('Email ' );
142+ $ config ->validate = true ;
143+
144+ return new MockEmail ($ config );
145+ }
142146}
0 commit comments