Skip to content

Commit

Permalink
✅ Created VatZone test (#5)
Browse files Browse the repository at this point in the history
* ✅ Created VatZone test

* Fix styling

---------

Co-authored-by: mschadegg <[email protected]>
  • Loading branch information
mschadegg and mschadegg authored Jan 25, 2024
1 parent 4b1a1e3 commit 7bb9051
Showing 1 changed file with 75 additions and 0 deletions.
75 changes: 75 additions & 0 deletions tests/Unit/VatZoneTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php

use Morningtrain\Economic\Classes\EconomicCollection;
use Morningtrain\Economic\Classes\EconomicResponse;
use Morningtrain\Economic\Resources\VatZone;

it('gets all vat zones', function () {
$this->driver->expects()->get(
'https://restapi.e-conomic.com/vat-zones',
[
'pageSize' => 20,
'skipPages' => 0,
]
)
->andReturn(new EconomicResponse(200, [
'collection' => [
[
'name' => 'DK',
'vatZoneNumber' => 1,
'enabledForCustomer' => true,
'enabledForSupplier' => true,
'self' => 'https://restapi.e-conomic.com/vat-zones/1',
],
[
'name' => 'EU',
'vatZoneNumber' => 2,
'enabledForCustomer' => true,
'enabledForSupplier' => true,
'self' => 'https://restapi.e-conomic.com/vat-zones/2',
],
],
'pagination' => [
'maxPageSize' => 20,
'skipPages' => 0,
'results' => 2,
],
]));

$vatZones = VatZone::all();

expect($vatZones)->toBeInstanceOf(EconomicCollection::class);

expect($vatZones->first())
->toBeInstanceOf(VatZone::class)
->name->toBe('DK')
->vatZoneNumber->toBe(1)
->enabledForCustomer->toBe(true)
->enabledForSupplier->toBe(true)
->self->toBe('https://restapi.e-conomic.com/vat-zones/1');

expect($vatZones->all())->toHaveCount(2);
});

it('gets a specific vatZone', function () {
$this->driver->expects()->get(
'https://restapi.e-conomic.com/vat-zones/1',
[]
)
->andReturn(new EconomicResponse(200, [
'name' => 'DK',
'vatZoneNumber' => 1,
'enabledForCustomer' => true,
'enabledForSupplier' => true,
'self' => 'https://restapi.e-conomic.com/vat-zones/1',
]));

$vatZone = VatZone::find(1);

expect($vatZone)->toBeInstanceOf(VatZone::class)
->name->toBe('DK')
->vatZoneNumber->toBe(1)
->enabledForCustomer->toBe(true)
->enabledForSupplier->toBe(true)
->self->toBe('https://restapi.e-conomic.com/vat-zones/1');
});

0 comments on commit 7bb9051

Please sign in to comment.