33
44use Mockery \Adapter \Phpunit \MockeryPHPUnitIntegration ;
55use Mockery \MockInterface ;
6+ use PHPUnit \Framework \TestCase ;
67use Psr \Container \ContainerInterface ;
78use ScriptFUSION \Porter \Cache \CacheUnavailableException ;
89use ScriptFUSION \Porter \Collection \FilteredRecords ;
3031use ScriptFUSION \Retry \FailingTooHardException ;
3132use ScriptFUSIONTest \MockFactory ;
3233
33- final class PorterTest extends \PHPUnit_Framework_TestCase
34+ final class PorterTest extends TestCase
3435{
3536 use MockeryPHPUnitIntegration;
3637
@@ -133,7 +134,7 @@ public function testImportConnectorWithOptions(): void
133134 $ this ->provider ->shouldReceive ('getConnector ' )
134135 ->andReturn (\Mockery::mock (Connector::class, ConnectorOptions::class));
135136
136- $ this ->setExpectedException (\LogicException::class);
137+ $ this ->expectException (\LogicException::class);
137138 $ this ->porter ->import ($ this ->specification );
138139 }
139140
@@ -181,13 +182,14 @@ public function testImportFailure(): void
181182 {
182183 $ this ->resource ->shouldReceive ('fetch ' )->andReturn (null );
183184
184- $ this ->setExpectedException (\TypeError::class, \get_class ($ this ->resource ));
185+ $ this ->expectException (\TypeError::class);
186+ $ this ->expectExceptionMessage (\get_class ($ this ->resource ));
185187 $ this ->porter ->import ($ this ->specification );
186188 }
187189
188190 public function testImportUnregisteredProvider (): void
189191 {
190- $ this ->setExpectedException (ProviderNotFoundException::class);
192+ $ this ->expectException (ProviderNotFoundException::class);
191193
192194 $ this ->porter ->import ($ this ->specification ->setProviderName ('foo ' ));
193195 }
@@ -200,7 +202,7 @@ public function testImportForeignResource(): void
200202 // Replace existing provider with a different one.
201203 $ this ->registerProvider (MockFactory::mockProvider (), get_class ($ this ->provider ));
202204
203- $ this ->setExpectedException (ForeignResourceException::class);
205+ $ this ->expectException (ForeignResourceException::class);
204206 $ this ->porter ->import ($ this ->specification );
205207 }
206208
@@ -228,7 +230,7 @@ public function testImportOneOfMany(): void
228230 {
229231 $ this ->resource ->shouldReceive ('fetch ' )->andReturn (new \ArrayIterator ([['foo ' ], ['bar ' ]]));
230232
231- $ this ->setExpectedException (ImportException::class);
233+ $ this ->expectException (ImportException::class);
232234 $ this ->porter ->importOne ($ this ->specification );
233235 }
234236
@@ -243,7 +245,7 @@ public function testOneTry(): void
243245 {
244246 $ this ->arrangeConnectorException (new RecoverableConnectorException );
245247
246- $ this ->setExpectedException (FailingTooHardException::class, '1 ' );
248+ $ this ->expectException (FailingTooHardException::class, '1 ' );
247249 $ this ->porter ->import ($ this ->specification ->setMaxFetchAttempts (1 ));
248250 }
249251
@@ -255,7 +257,7 @@ public function testDerivedRecoverableException(): void
255257 {
256258 $ this ->arrangeConnectorException (new RecoverableConnectorException );
257259
258- $ this ->setExpectedException (FailingTooHardException::class);
260+ $ this ->expectException (FailingTooHardException::class);
259261 $ this ->porter ->import ($ this ->specification ->setMaxFetchAttempts (1 ));
260262 }
261263
@@ -267,10 +269,8 @@ public function testDefaultTries(): void
267269 {
268270 $ this ->arrangeConnectorException (new RecoverableConnectorException );
269271
270- $ this ->setExpectedException (
271- FailingTooHardException::class,
272- (string )ImportSpecification::DEFAULT_FETCH_ATTEMPTS
273- );
272+ $ this ->expectException (FailingTooHardException::class);
273+ $ this ->expectExceptionMessage ((string )ImportSpecification::DEFAULT_FETCH_ATTEMPTS );
274274 $ this ->porter ->import ($ this ->specification );
275275 }
276276
@@ -282,7 +282,7 @@ public function testUnrecoverableException(): void
282282 // Subclass Exception so it's not an ancestor of any other exception.
283283 $ this ->arrangeConnectorException ($ exception = \Mockery::mock (\Exception::class));
284284
285- $ this ->setExpectedException (get_class ($ exception ));
285+ $ this ->expectException (get_class ($ exception ));
286286 $ this ->porter ->import ($ this ->specification );
287287 }
288288
@@ -303,7 +303,7 @@ public function testCustomFetchExceptionHandler(): void
303303
304304 $ this ->arrangeConnectorException (new RecoverableConnectorException );
305305
306- $ this ->setExpectedException (FailingTooHardException::class);
306+ $ this ->expectException (FailingTooHardException::class);
307307 $ this ->porter ->import ($ this ->specification );
308308 }
309309
@@ -335,7 +335,7 @@ function (\Exception $exception) use ($connectorException) {
335335 })
336336 ;
337337
338- $ this ->setExpectedException (\RuntimeException::class);
338+ $ this ->expectException (\RuntimeException::class);
339339 $ this ->porter ->importOne ($ this ->specification );
340340 }
341341
@@ -371,7 +371,7 @@ static function () {
371371 */
372372 public function testCacheUnavailable (): void
373373 {
374- $ this ->setExpectedException (CacheUnavailableException::class);
374+ $ this ->expectException (CacheUnavailableException::class);
375375
376376 $ this ->porter ->import ($ this ->specification ->enableCache ());
377377 }
0 commit comments