Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
midnite81 committed Jul 13, 2018
1 parent b4a142d commit 696f7c3
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/LaravelProwlTest.php
Expand Up @@ -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
*/
Expand Down
50 changes: 50 additions & 0 deletions tests/Services/NotificationTest.php
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 696f7c3

Please sign in to comment.