Skip to content

Commit

Permalink
Increase test coverage (#3)
Browse files Browse the repository at this point in the history
Increase test coverage
  • Loading branch information
stefanius committed Mar 5, 2021
1 parent a446ce7 commit f4f0006
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
28 changes: 28 additions & 0 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace TestMonitor\Custify\Tests;

use Mockery;
use PHPUnit\Framework\TestCase;
use TestMonitor\Custify\Client;
use TestMonitor\Custify\Exceptions\UnauthorizedException;

class ClientTest extends TestCase
{
public function tearDown(): void
{
Mockery::close();
}

/** @test */
public function it_should_throw_an_exception_when_there_is_no_token_provided()
{
// Given
$custify = new Client('');

$this->expectException(UnauthorizedException::class);

// When
$custify->people();
}
}
21 changes: 20 additions & 1 deletion tests/CompaniesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,25 @@ public function it_should_return_a_company_when_using_an_id()
$this->assertEquals($this->company['id'], $company->id);
}

/** @test */
public function it_should_not_return_a_company_when_the_id_doesnt_exists()
{
// Given
$custify = new Client($this->token);

$custify->setClient($service = Mockery::mock('\GuzzleHttp\Client'));

$response = Mockery::mock('Psr\Http\Message\ResponseInterface');
$response->shouldReceive('getStatusCode')->andReturn(404);

$service->shouldReceive('request')->once()->andReturn($response);

$this->expectException(NotFoundException::class);

// When
$custify->company('12346');
}

/** @test */
public function it_should_return_a_company_when_using_a_company_id()
{
Expand Down Expand Up @@ -316,7 +335,7 @@ public function it_should_delete_a_company()
$response = $custify->deleteCompany($company);

// Then
$this->assertIsBool($response, $response);
$this->assertIsBool($response);
$this->assertTrue($response);
}
}
2 changes: 1 addition & 1 deletion tests/PeopleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ public function it_should_delete_a_person()
$response = $custify->deletePerson($person);

// Then
$this->assertIsBool($response, $response);
$this->assertIsBool($response);
$this->assertTrue($response);
}
}

0 comments on commit f4f0006

Please sign in to comment.