Skip to content

Commit 70de835

Browse files
stop using JsonVatClient in tests
1 parent ecf8316 commit 70de835

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

tests/ClientsTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ public function testClient(Client $client)
2626

2727
public function clientProvider()
2828
{
29-
yield [new JsonVatClient()];
3029
yield [new IbericodeVatRatesClient()];
3130
}
3231
}

tests/RatesTest.php

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Ibericode\Vat\Tests;
44

55
use Ibericode\Vat\Clients\ClientException;
6+
use Ibericode\Vat\Clients\IbericodeVatRatesClient;
67
use Ibericode\Vat\Clients\JsonVatClient;
78
use Ibericode\Vat\Exception;
89
use Ibericode\Vat\Period;
@@ -19,10 +20,12 @@ public function setUp() : void
1920
}
2021
}
2122

22-
private function getJsonVatMock()
23+
private function getRatesClientMock()
2324
{
24-
$client = $this->getMockBuilder(JsonVatClient::class)->getMock();
25+
$client = $this->getMockBuilder(IbericodeVatRatesClient::class)
26+
->getMock();
2527
$client
28+
->expects($this->once())
2629
->method('fetch')
2730
->willReturn([
2831
'NL' => [
@@ -41,23 +44,19 @@ private function getJsonVatMock()
4144
]
4245
]);
4346

44-
$client
45-
->expects($this->once())
46-
->method('fetch');
47-
4847
return $client;
4948
}
5049

5150
public function testGetRateForCountry()
5251
{
53-
$client = $this->getJsonVatMock();
52+
$client = $this->getRatesClientMock();
5453
$rates = new Rates('vendor/rates', 30, $client);
5554
$this->assertEquals(21.0, $rates->getRateForCountry('NL'));
5655
}
5756

5857
public function testGetRateForCountryOnDate()
5958
{
60-
$client = $this->getJsonVatMock();
59+
$client = $this->getRatesClientMock();
6160
$rates = new Rates('vendor/rates', 30, $client);
6261
$this->assertEquals(19.0, $rates->getRateForCountryOnDate('NL', new \DateTime('2011/01/01')));
6362
$this->assertEquals(6.0, $rates->getRateForCountryOnDate('NL', new \DateTime('2018/01/01'), 'reduced'));
@@ -68,15 +67,15 @@ public function testGetRateForCountryOnDate()
6867

6968
public function testGetRateForCountryWithInvalidCountryCode()
7069
{
71-
$client = $this->getJsonVatMock();
70+
$client = $this->getRatesClientMock();
7271
$rates = new Rates('vendor/rates', 30, $client);
7372
$this->expectException(Exception::class);
7473
$rates->getRateForCountry('FOO');
7574
}
7675

7776
public function testRatesAreLoadedFromFile()
7877
{
79-
$client = $this->getJsonVatMock();
78+
$client = $this->getRatesClientMock();
8079
$rates = new Rates('vendor/rates', 30, $client);
8180
$this->assertEquals(21.0, $rates->getRateForCountry('NL'));
8281

@@ -95,12 +94,12 @@ public function testRatesAreLoadedFromFile()
9594
public function testRatesAreLoadedFromFileOnClientException()
9695
{
9796
// first, populate local file
98-
$client = $this->getJsonVatMock();
97+
$client = $this->getRatesClientMock();
9998
$rates = new Rates('vendor/rates', 10, $client);
10099
$this->assertEquals(21.0, $rates->getRateForCountry('NL'));
101100

102101
// then, perform test
103-
$client = $this->getJsonVatMock();
102+
$client = $this->getRatesClientMock();
104103
$client->method('fetch')->willThrowException(new ClientException('Service is down'));
105104
$rates = new Rates('vendor/rates', -1, $client);
106105
$this->assertEquals(21.0, $rates->getRateForCountry('NL'));

0 commit comments

Comments
 (0)