Skip to content

Commit

Permalink
Allow industry classification description to be nullable (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
kielabokkie authored Aug 25, 2023
1 parent 784ff34 commit 31df6a0
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Model/IndustryClassificationsResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ final class IndustryClassificationsResponse extends AbstractResponse
public string $code;

#[SerializedName('classificationDescription')]
public string $description;
public ?string $description;
}
57 changes: 57 additions & 0 deletions tests/Model/IndustryClassificationResponseTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

declare(strict_types=1);

namespace Hyra\Tests\NzCompaniesOfficeLookup\Model;

use Hyra\NzCompaniesOfficeLookup\Model\IndustryClassificationsResponse;

final class IndustryClassificationResponseTest extends BaseModelTest
{
public function testValidModel(): void
{
$data = <<<JSON
{
"classificationCode": "C121220",
"classificationDescription": "Breweries",
"uniqueIdentifier": "140987"
}
JSON;

/** @var IndustryClassificationsResponse $parsed */
$parsed = $this->valid($data, IndustryClassificationsResponse::class);

static::assertSame('C121220', $parsed->code);
static::assertSame('Breweries', $parsed->description);
}

public function testValidModelWithoutDescription(): void
{
$data = <<<JSON
{
"classificationCode": "C121220",
"classificationDescription": null,
"uniqueIdentifier": "140987"
}
JSON;

/** @var IndustryClassificationsResponse $parsed */
$parsed = $this->valid($data, IndustryClassificationsResponse::class);

static::assertSame('C121220', $parsed->code);
static::assertNull($parsed->description);
}

public function testInvalidModel(): void
{
$data = <<<JSON
{
"classificationCode": null,
"classificationDescription": "Breweries",
"uniqueIdentifier": "140987"
}
JSON;

$this->invalid($data, IndustryClassificationsResponse::class);
}
}

0 comments on commit 31df6a0

Please sign in to comment.