22
33namespace NotificationChannels \Pushover \Test ;
44
5- use Illuminate \ Contracts \ Foundation \ Application ;
5+ use GuzzleHttp \ Client as HttpClient ;
66use Illuminate \Support \Facades \Config ;
77use Mockery ;
88use NotificationChannels \Pushover \Pushover ;
@@ -15,30 +15,25 @@ class PushoverServiceProviderTest extends TestCase
1515 /** @var PushoverServiceProvider */
1616 protected $ provider ;
1717
18- /** @var Application */
19- protected $ app ;
20-
2118 public function setUp (): void
2219 {
2320 parent ::setUp ();
2421
25- $ this ->app = Mockery::mock (Application::class);
2622 $ this ->provider = new PushoverServiceProvider ($ this ->app );
27-
28- $ this ->app ->shouldReceive ('flush ' );
2923 }
3024
3125 /** @test */
3226 public function it_gives_an_instantiated_pushover_object_when_the_channel_asks_for_it (): void
3327 {
3428 Config::shouldReceive ('get ' )->with ('services.pushover.token ' , null )->once ()->andReturn ('test-token ' );
3529
36- $ this ->app ->shouldReceive ('when ' )->with (PushoverChannel::class)->once ()->andReturn ($ this ->app );
37- $ this ->app ->shouldReceive ('needs ' )->with (Pushover::class)->once ()->andReturn ($ this ->app );
38- $ this ->app ->shouldReceive ('give ' )->with (Mockery::on (function ($ pushover ) {
39- return $ pushover () instanceof Pushover;
40- }))->once ();
30+ $ this ->app ->when (PushoverChannel::class)->needs (Pushover::class)->give (function () {
31+ return new Pushover (Mockery::mock (HttpClient::class), 'test-token ' );
32+ });
4133
4234 $ this ->provider ->boot ();
35+
36+ $ pushover = $ this ->app ->get (PushoverChannel::class);
37+ $ this ->assertInstanceOf (PushoverChannel::class, $ pushover );
4338 }
4439}
0 commit comments