Skip to content

Commit

Permalink
Failing test for UK VAT numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
driesvints committed May 25, 2021
1 parent 4cee16e commit 6e674e4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Mpociot/VatCalculator/VatCalculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ public function getVATDetails($vatNumber)

$response = json_decode($result, true, 512, JSON_OBJECT_AS_ARRAY);

if (isset($response['code']) && $response['code'] === 'NOT_FOUND') {
if (isset($response['code'])) {
return false;
}

Expand Down
18 changes: 18 additions & 0 deletions tests/VatCalculatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,24 @@ public function testCanValidateValidUKVATNumber()
$this->assertTrue($result);
}

public function testCanValidateInvalidUKVATNumber()
{
$config = m::mock('Illuminate\Contracts\Config\Repository');

$config->shouldReceive('has')
->once()
->with('vat_calculator.business_country_code')
->andReturn(false);

$result = new \stdClass();
$result->valid = true;

$vatNumber = 'GB Invalid';
$vatCalculator = new VatCalculator($config);
$result = $vatCalculator->testing()->isValidVATNumber($vatNumber);
$this->assertFalse($result);
}

/**
* @link https://tools.tracemyip.org/search--country/germany
*/
Expand Down

0 comments on commit 6e674e4

Please sign in to comment.