diff --git a/tests/Unit/OccurrencesTest.php b/tests/Unit/OccurrencesTest.php index 18c0b8ca8bac1068528c6804737bd01def2ad1d4..10cbde41f384cb48d37af53b3f61e86618578fac 100644 --- a/tests/Unit/OccurrencesTest.php +++ b/tests/Unit/OccurrencesTest.php @@ -21,21 +21,21 @@ final class OccurrencesTest extends TestCase $this->occurrences = new Occurrences(); } - public function testShouldGetValidResponseFromGet() + public function testShouldGetValidResponseFromGet(): void { $response = $this->occurrences->get(1258202889); $this->assertEquals("Alfaroa Standl.", $response['scientificName']); } - public function testShouldGetValidResponseFromGetVerbatim() + public function testShouldGetValidResponseFromGetVerbatim(): void { $response = $this->occurrences->getVerbatim(1258202889); $this->assertEquals("Alfaroa Standl.", $response['http://rs.tdwg.org/dwc/terms/scientificName']); } - public function testShouldGetValidResponseFromGetFragment() + public function testShouldGetValidResponseFromGetFragment(): void { $response = $this->occurrences->getFragment(1258202889); diff --git a/tests/Unit/SpeciesTest.php b/tests/Unit/SpeciesTest.php index ef197474ccf008772dfbf2016b00114a98390627..dcc1bb01c3d3e9f63b8cbc8f439f243a6f635173 100644 --- a/tests/Unit/SpeciesTest.php +++ b/tests/Unit/SpeciesTest.php @@ -3,6 +3,7 @@ namespace ResTelae\Gbif\Tests\Unit; use PHPUnit\Framework\TestCase; +use ResTelae\Gbif\GbifException; use ResTelae\Gbif\Species; /** @@ -21,20 +22,23 @@ final class SpeciesTest extends TestCase $this->species = new Species(); } - public function testShouldThrowExceptionIfInvalidDataChoice() + public function testShouldThrowExceptionIfInvalidDataChoice(): void { + $this->expectException(GbifException::class); $this->expectExceptionMessage('Illegal choice for `data`'); $this->species->nameUsage([], 'invalid'); } - public function testShouldThrowExceptionIfNoDataKeyProvided() + public function testShouldThrowExceptionIfNoDataKeyProvided(): void { + $this->expectException(GbifException::class); $this->expectExceptionMessage('You must specify a key if `data` does not equal `all`'); $this->species->nameUsage([], 'name'); } - public function testShouldThrowExceptionOnRootDataIfNoUuidOrShortNameProvided() + public function testShouldThrowExceptionOnRootDataIfNoUuidOrShortNameProvided(): void { + $this->expectException(GbifException::class); $this->expectExceptionMessage('`uuid` and `short_name` cannot be both NULL if `data` equals "root"'); $this->species->nameUsage([], 'root', '123'); } @@ -69,7 +73,7 @@ final class SpeciesTest extends TestCase $this->assertSame($expected['canonicalName'], $response['canonicalName']); } - public function testShouldGetValidResponseFromNameUsageByKey() + public function testShouldGetValidResponseFromNameUsageByKey(): void { $response = $this->species->nameUsageByKey(5231190); @@ -78,7 +82,7 @@ final class SpeciesTest extends TestCase $this->assertEquals('Passer domesticus', $response['species']); } - public function testShouldGetValidResponseFromNameBackbone() + public function testShouldGetValidResponseFromNameBackbone(): void { $response = $this->species->nameBackbone( [ @@ -93,7 +97,7 @@ final class SpeciesTest extends TestCase $this->assertEquals('GENUS', $response['rank']); } - public function testShouldGetValidResponseFromNameLookup() + public function testShouldGetValidResponseFromNameLookup(): void { $response = $this->species->nameLookup( [ @@ -111,7 +115,7 @@ final class SpeciesTest extends TestCase $this->assertEquals('Puma', $response['results'][0]['canonicalName']); } - public function testShouldGetValidResponseFromNameSuggest() + public function testShouldGetValidResponseFromNameSuggest(): void { $response = $this->species->nameSuggest( [