Skip to content

Commit e7baba8

Browse files
committed
Updated tests
1 parent 5b5a673 commit e7baba8

32 files changed

Lines changed: 1374 additions & 912 deletions

tests/Fapi/FapiClientTests/FapiClientApiTokensTest.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ class FapiClientApiTokensTest extends TestCase
3535
);
3636

3737
$this->fapiClient = new FapiClient(
38-
'test1@slischka.cz',
39-
'pi120wrOyzNlb7p4iQwTO1vcK',
38+
'slischka@test-fapi.cz',
39+
'jIBAWlKzzB6rQVk5Y3T0VxTgn',
4040
'https://api.fapi.cz/',
4141
$this->httpClient
4242
);

tests/Fapi/FapiClientTests/FapiClientClientsTest.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ class FapiClientClientsTest extends TestCase
3333
);
3434

3535
$this->fapiClient = new FapiClient(
36-
'test1@slischka.cz',
37-
'pi120wrOyzNlb7p4iQwTO1vcK',
36+
'slischka@test-fapi.cz',
37+
'jIBAWlKzzB6rQVk5Y3T0VxTgn',
3838
'https://api.fapi.cz/',
3939
$this->httpClient
4040
);

tests/Fapi/FapiClientTests/FapiClientCountriesTest.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ class FapiClientCountriesTest extends TestCase
3232
);
3333

3434
$this->fapiClient = new FapiClient(
35-
'test1@slischka.cz',
36-
'pi120wrOyzNlb7p4iQwTO1vcK',
35+
'slischka@test-fapi.cz',
36+
'jIBAWlKzzB6rQVk5Y3T0VxTgn',
3737
'https://api.fapi.cz/',
3838
$this->httpClient
3939
);

tests/Fapi/FapiClientTests/FapiClientDiscountCodesTest.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ class FapiClientDiscountCodesTest extends TestCase
3232
);
3333

3434
$this->fapiClient = new FapiClient(
35-
'slischkaj-2019-11-26@gmail.com',
36-
'nWHypJS0XJZB6e3dWlPOULmQ4',
35+
'slischka@test-fapi.cz',
36+
'jIBAWlKzzB6rQVk5Y3T0VxTgn',
3737
'https://api.fapi.cz/',
3838
$this->httpClient
3939
);

tests/Fapi/FapiClientTests/FapiClientExchangeRatesTest.phpt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ class FapiClientExchangeRatesTest extends TestCase
3333
);
3434

3535
$this->fapiClient = new FapiClient(
36-
'test1@slischka.cz',
37-
'pi120wrOyzNlb7p4iQwTO1vcK',
36+
'slischka@test-fapi.cz',
37+
'jIBAWlKzzB6rQVk5Y3T0VxTgn',
3838
'https://api.fapi.cz/',
3939
$this->httpClient
4040
);
@@ -49,35 +49,35 @@ class FapiClientExchangeRatesTest extends TestCase
4949
{
5050
Assert::exception(function () {
5151
$this->fapiClient->getExchangeRates()->list();
52-
}, ValidationException::class, 'Parameter source is not valid.');
52+
}, ValidationException::class, 'Missing key: source');
5353

5454
Assert::exception(function () {
5555
$this->fapiClient->getExchangeRates()->list(['source' => 'EUR']);
56-
}, ValidationException::class, 'Parameter target is not valid.');
56+
}, ValidationException::class, 'Missing key: target');
5757

5858
Assert::exception(function () {
5959
$this->fapiClient->getExchangeRates()->list(['source' => 'EUR', 'target' => 'CZK']);
6060
}, ValidationException::class, 'Parameter date_from and date_to can not be null together with parameter date.');
6161

62-
$exchangeRates = $this->fapiClient->getExchangeRates()->list(['source' => 'EUR', 'target' => 'CZK', 'date' => '2019-01-01']);
62+
$exchangeRates = $this->fapiClient->getExchangeRates()->list(['source' => 'EUR', 'target' => 'CZK', 'date' => '2020-09-08']);
6363

6464
Assert::equal([
6565
[
66-
'date' => '2019-01-01',
66+
'date' => '2020-09-08',
6767
'source_currency' => 'EUR',
6868
'target_currency' => 'CZK',
69-
'exchange_rate' => 25.725,
69+
'exchange_rate' => 26.47,
7070
],
7171
], $exchangeRates);
7272

73-
$exchangeRate = $this->fapiClient->getExchangeRates()->list(['source' => 'EUR', 'target' => 'CZK', 'date' => '2019-01-01', 'single' => true]);
73+
$exchangeRate = $this->fapiClient->getExchangeRates()->list(['source' => 'EUR', 'target' => 'CZK', 'date' => '2020-09-08', 'single' => true]);
7474

7575
Assert::equal(
7676
[
77-
'date' => '2019-01-01',
77+
'date' => '2020-09-08',
7878
'source_currency' => 'EUR',
7979
'target_currency' => 'CZK',
80-
'exchange_rate' => 25.725,
80+
'exchange_rate' => 26.47,
8181
]
8282
, $exchangeRate);
8383

tests/Fapi/FapiClientTests/FapiClientFormsTest.phpt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ class FapiClientFormsTest extends TestCase
3333
);
3434

3535
$this->fapiClient = new FapiClient(
36-
'test1@slischka.cz',
37-
'pi120wrOyzNlb7p4iQwTO1vcK',
36+
'slischka@test-fapi.cz',
37+
'jIBAWlKzzB6rQVk5Y3T0VxTgn',
3838
'https://api.fapi.cz/',
3939
$this->httpClient
4040
);
@@ -49,10 +49,10 @@ class FapiClientFormsTest extends TestCase
4949
{
5050
$form = $this->fapiClient->getForms()->create([
5151
'name' => 'Sample Form',
52-
'project' => 23371,
53-
'series' => 21979,
54-
'message_template_set' => 15905,
55-
'reminder_set' => 12291,
52+
'project' => 31862,
53+
'series' => 38504,
54+
'message_template_set' => 22232,
55+
'reminder_set' => 16508,
5656
'currency' => 'by-country',
5757
'reverse_charge' => 'disabled',
5858
'thanks_content' => '',

tests/Fapi/FapiClientTests/FapiClientInvoicesTest.phpt

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ class FapiClientInvoicesTest extends TestCase
3636
);
3737

3838
$this->fapiClient = new FapiClient(
39-
'test1@slischka.cz',
40-
'pi120wrOyzNlb7p4iQwTO1vcK',
39+
'slischka@test-fapi.cz',
40+
'jIBAWlKzzB6rQVk5Y3T0VxTgn',
4141
'https://api.fapi.cz/',
4242
$this->httpClient
4343
);
@@ -51,15 +51,15 @@ class FapiClientInvoicesTest extends TestCase
5151
public function testCreateGetUpdateAndDeleteInvoices()
5252
{
5353
$createdInvoice = $this->fapiClient->getInvoices()->create([
54-
'client' => 1104658,
54+
'client' => 1808089,
5555
'items' => [
5656
[
5757
'name' => 'Sample Item',
5858
'price' => 10,
5959
],
6060
],
61-
'iban' => 'CZXX0800000000XXXXXXXXXX',
62-
'swift' => 'GIBACZPX',
61+
'iban' => 'CZ3820100000002901621321',
62+
'swift' => 'FIOBCZPPXXX',
6363
]);
6464

6565
Assert::type('array', $createdInvoice);
@@ -91,9 +91,8 @@ class FapiClientInvoicesTest extends TestCase
9191
Assert::same($invoice['id'], $updatedInvoice['id']);
9292
Assert::same('Sample footer note', $updatedInvoice['notes']);
9393

94-
$fapiClient = $this->fapiClient;
95-
Assert::exception(static function () use ($fapiClient) {
96-
$fapiClient->getInvoices()->find(1);
94+
Assert::exception(function () {
95+
$this->fapiClient->getInvoices()->find(1);
9796
}, AuthorizationException::class, 'You are not authorized for this action.');
9897

9998
$count = $this->fapiClient->getInvoices()->getCount([
@@ -126,17 +125,14 @@ class FapiClientInvoicesTest extends TestCase
126125
]);
127126
Assert::type('string', $qrCode);
128127

128+
$invoicesSequence = $this->fapiClient->getInvoices()->getInvoicesSequence((int) $invoice['id']);
129+
Assert::type('array', $invoicesSequence);
130+
Assert::equal([['id' => 185993812, 'type' => 'proforma']], $invoicesSequence);
131+
129132
$this->fapiClient->getInvoices()->delete($invoice['id']);
130133

131134
Assert::null($this->fapiClient->getInvoices()->find($invoice['id']));
132135
Assert::null($this->fapiClient->getInvoices()->getPdf($invoice['id']));
133-
134-
$invoicesSequence = $this->fapiClient->getInvoices()->getInvoicesSequence((int) $invoice['id']);
135-
Assert::type('array', $invoicesSequence);
136-
Assert::equal([
137-
['id' => 2999, 'type' => 'proforma'],
138-
['id' => 3000, 'type' => 'invoice'],
139-
], $invoicesSequence);
140136
}
141137

142138
}

tests/Fapi/FapiClientTests/FapiClientItemTemplatesTest.phpt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use Fapi\HttpClient\GuzzleHttpClient;
99
use Tester\Assert;
1010
use Tester\Environment;
1111
use Tester\TestCase;
12+
use function print_r;
1213

1314
require __DIR__ . '/../../bootstrap.php';
1415

@@ -32,8 +33,8 @@ class FapiClientItemTemplatesTest extends TestCase
3233
);
3334

3435
$this->fapiClient = new FapiClient(
35-
'test1@slischka.cz',
36-
'pi120wrOyzNlb7p4iQwTO1vcK',
36+
'slischka@test-fapi.cz',
37+
'jIBAWlKzzB6rQVk5Y3T0VxTgn',
3738
'https://api.fapi.cz/',
3839
$this->httpClient
3940
);
@@ -83,11 +84,7 @@ class FapiClientItemTemplatesTest extends TestCase
8384
$this->fapiClient->getItemTemplates()->delete($itemTemplate['id']);
8485

8586
Assert::null($this->fapiClient->getItemTemplates()->find($itemTemplate['id']));
86-
87-
$fapiClient = $this->fapiClient;
88-
Assert::exception(static function () use ($fapiClient) {
89-
$fapiClient->getItemTemplates()->find(4);
90-
}, 'Fapi\FapiClient\AuthorizationException', 'You are not authorized for this action.');
87+
Assert::null($this->fapiClient->getItemTemplates()->find(4));
9188
}
9289

9390
}

tests/Fapi/FapiClientTests/FapiClientItemsTest.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ class FapiClientItemsTest extends TestCase
3333
);
3434

3535
$this->fapiClient = new FapiClient(
36-
'test1@slischka.cz',
37-
'pi120wrOyzNlb7p4iQwTO1vcK',
36+
'slischka@test-fapi.cz',
37+
'jIBAWlKzzB6rQVk5Y3T0VxTgn',
3838
'https://api.fapi.cz/',
3939
$this->httpClient
4040
);
@@ -48,7 +48,7 @@ class FapiClientItemsTest extends TestCase
4848
public function testCreateGetUpdateAndDeleteItemTemplates()
4949
{
5050
$item = $this->fapiClient->getItems()->create([
51-
'invoice' => 183480795,
51+
'invoice' => 185993795,
5252
'name' => 'Sample Item Template',
5353
'price' => 10.0,
5454
'count' => 1,

tests/Fapi/FapiClientTests/FapiClientMessageTemplatesTest.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ class FapiClientMessageTemplatesTest extends TestCase
3232
);
3333

3434
$this->fapiClient = new FapiClient(
35-
'tester@fapi.cz',
36-
'XZRbVLPigTQpi4Kct4JAq8FZ9',
37-
'http://api.fapi.log/',
35+
'slischka@test-fapi.cz',
36+
'jIBAWlKzzB6rQVk5Y3T0VxTgn',
37+
'https://api.fapi.cz/',
3838
$this->httpClient
3939
);
4040
}

0 commit comments

Comments
 (0)