diff --git a/tests/LaravelProwlTest.php b/tests/LaravelProwlTest.php index c183e14..4029299 100644 --- a/tests/LaravelProwlTest.php +++ b/tests/LaravelProwlTest.php @@ -18,6 +18,30 @@ public static function setUpBeforeClass() include_once 'Functions.php'; } + /** + * @test + */ + public function it_sends_message_when_created_through_prowl() + { + $mockedHttpClient = \Mockery::mock(\Http\Adapter\Guzzle6\Client::class); + + $mockedHttpClient->shouldReceive('sendRequest')->once()->andReturn($this->successResponse()); + + $prowl = $this->factoryCreateCustom($mockedHttpClient, new GuzzleMessageFactory()); + + $send = $prowl->createMessage([ + 'apiKey' => ['some-value'], + 'providerKey' => 'some-value', + 'priority' => 1, + 'url' => 'some-value', + 'application' => 'some-value', + 'event' => 'some-value', + 'description' => 'some-value', + ])->add(); + + $this->assertInstanceOf(\Midnite81\Prowl\Services\Response::class, $send); + } + /** * @return Prowl */ diff --git a/tests/Services/NotificationTest.php b/tests/Services/NotificationTest.php index 63b7bcb..6e877ac 100644 --- a/tests/Services/NotificationTest.php +++ b/tests/Services/NotificationTest.php @@ -101,6 +101,23 @@ public function it_sets_properties_to_class_via_create() $this->assertEquals('testDescription', $notification->getDescription()); } + /** + * @test + */ + public function it_can_add_more_than_one_key_to_the_class() + { + $notification = $this->factoryCreate(); + + $this->assertCount(1, explode(',', $notification->getApiKeys())); + $this->assertContains('testApi', $notification->getApiKeys()); + + $notification->setApiKeys('test123'); + + $this->assertCount(2, explode(',', $notification->getApiKeys())); + $this->assertContains('testApi', $notification->getApiKeys()); + $this->assertContains('test123', $notification->getApiKeys()); + } + /** * @test */ @@ -168,6 +185,39 @@ public function it_constructs_using_create_factory_method() $this->assertInstanceOf(Notification::class, $notification); } + /** + * @test + * @expectedException \Midnite81\Prowl\Exceptions\ProwlNotAvailableException + */ + public function it_throws_an_exception_when_sending_without_prowl() + { + $notification = $this->factoryCreate(); + + $notification->add(); + } + + /** + * @test + * @expectedException \Midnite81\Prowl\Exceptions\ProwlNotAvailableException + */ + public function it_throws_an_exception_when_sending_without_prowl_send_alias() + { + $notification = $this->factoryCreate(); + + $notification->send(); + } + + /** + * @test + * @expectedException \Midnite81\Prowl\Exceptions\ProwlNotAvailableException + */ + public function it_throws_an_exception_when_sending_without_prowl_push_alias() + { + $notification = $this->factoryCreate(); + + $notification->push(); + } + /** * @return Notification * @throws \Midnite81\Prowl\Exceptions\IncorrectPriorityValueException