From f4f0006a0f547b5d1b159c4eac208c40a34098bf Mon Sep 17 00:00:00 2001 From: stefanius Date: Fri, 5 Mar 2021 15:48:15 +0100 Subject: [PATCH] Increase test coverage (#3) Increase test coverage --- tests/ClientTest.php | 28 ++++++++++++++++++++++++++++ tests/CompaniesTest.php | 21 ++++++++++++++++++++- tests/PeopleTest.php | 2 +- 3 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 tests/ClientTest.php diff --git a/tests/ClientTest.php b/tests/ClientTest.php new file mode 100644 index 0000000..3122ae0 --- /dev/null +++ b/tests/ClientTest.php @@ -0,0 +1,28 @@ +expectException(UnauthorizedException::class); + + // When + $custify->people(); + } +} diff --git a/tests/CompaniesTest.php b/tests/CompaniesTest.php index ce084d4..ce85a7e 100644 --- a/tests/CompaniesTest.php +++ b/tests/CompaniesTest.php @@ -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() { @@ -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); } } diff --git a/tests/PeopleTest.php b/tests/PeopleTest.php index 654b688..19e3449 100644 --- a/tests/PeopleTest.php +++ b/tests/PeopleTest.php @@ -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); } }