File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -2144,7 +2144,13 @@ protected function mimeTypes($ext = '')
2144
2144
public function __destruct ()
2145
2145
{
2146
2146
if (is_resource ($ this ->SMTPConnect )) {
2147
- $ this ->sendCommand ('quit ' );
2147
+ try {
2148
+ $ this ->sendCommand ('quit ' );
2149
+ } catch (ErrorException $ e ) {
2150
+ $ protocol = $ this ->getProtocol ();
2151
+ $ method = 'sendWith ' . ucfirst ($ protocol );
2152
+ log_message ('error ' , 'Email: ' . $ method . ' throwed ' . $ e );
2153
+ }
2148
2154
}
2149
2155
}
2150
2156
Original file line number Diff line number Diff line change 14
14
use CodeIgniter \Events \Events ;
15
15
use CodeIgniter \Test \CIUnitTestCase ;
16
16
use CodeIgniter \Test \Mock \MockEmail ;
17
+ use ErrorException ;
17
18
18
19
/**
19
20
* @internal
@@ -136,6 +137,24 @@ public function testFailureDoesNotTriggerEvent()
136
137
$ this ->assertNull ($ result );
137
138
}
138
139
140
+ public function testDestructDoesNotThrowException ()
141
+ {
142
+ $ email = $ this ->getMockBuilder (Email::class)
143
+ ->disableOriginalConstructor ()
144
+ ->onlyMethods (['sendCommand ' ])
145
+ ->getMock ();
146
+ $ email ->method ('sendCommand ' )
147
+ ->will ($ this ->throwException (new ErrorException ('SMTP Error. ' )));
148
+
149
+ // Force resource to be injected into the property
150
+ $ SMTPConnect = fopen (__FILE__ , 'rb ' );
151
+ $ this ->setPrivateProperty ($ email , 'SMTPConnect ' , $ SMTPConnect );
152
+
153
+ $ email ->__destruct ();
154
+
155
+ $ this ->assertTrue (true );
156
+ }
157
+
139
158
private function createMockEmail (): MockEmail
140
159
{
141
160
$ config = config ('Email ' );
You can’t perform that action at this time.
0 commit comments