66use OneSignal \Apps ;
77use OneSignal \Config ;
88use OneSignal \Devices ;
9+ use OneSignal \Exception \OneSignalException ;
910use OneSignal \Notifications ;
1011use OneSignal \OneSignal ;
1112use Psr \Http \Message \ResponseInterface ;
1213use PHPUnit \Framework \TestCase ;
14+ use Symfony \Bridge \PhpUnit \SetUpTearDownTrait ;
1315
1416class OneSignalTest extends TestCase
1517{
18+ use SetUpTearDownTrait;
19+
1620 /**
1721 * @var OneSignal
1822 */
1923 private $ api ;
2024
21- public function setUp ()
25+ public function doSetUp ()
2226 {
2327 $ this ->api = new OneSignal ();
2428 }
@@ -36,11 +40,10 @@ public function testIfInstanceIsCached()
3640 $ this ->assertInstanceOf (Apps::class, $ this ->api ->apps );
3741 }
3842
39- /**
40- * @expectedException \OneSignal\Exception\OneSignalException
41- */
4243 public function testBadInstance ()
4344 {
45+ $ this ->expectException (OneSignalException::class);
46+
4447 $ this ->api ->unknownInstance ;
4548 }
4649
@@ -86,23 +89,21 @@ public function testRequestParseJSONResponse()
8689 $ this ->assertEquals ($ expectedData , $ this ->api ->request ('fakeMethod ' , 'fakeURI ' ));
8790 }
8891
89- /**
90- * @expectedException \OneSignal\Exception\OneSignalException
91- */
9292 public function testRequestHandleExceptions ()
9393 {
94+ $ this ->expectException (OneSignalException::class);
95+
9496 $ client = $ this ->createMock (HttpMethodsClient::class);
9597 $ client ->method ('send ' )->will ($ this ->throwException (new \Exception ()));
9698
9799 $ this ->api ->setClient ($ client );
98100 $ this ->api ->request ('DummyMethod ' , 'DummyURI ' );
99101 }
100102
101- /**
102- * @expectedException \OneSignal\Exception\OneSignalException
103- */
104103 public function testMagicGetHandleRequest ()
105104 {
105+ $ this ->expectException (OneSignalException::class);
106+
106107 $ this ->api ->unexistingService ;
107108 }
108109}
0 commit comments