-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fa5ee1d
commit b1578eb
Showing
2 changed files
with
158 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
namespace Inspirum\Balikobot\Tests\Unit\Balikobot; | ||
|
||
use Inspirum\Balikobot\Services\Balikobot; | ||
|
||
class GetActivatedServicesTest extends AbstractBalikobotTestCase | ||
{ | ||
public function testMakeRequest() | ||
{ | ||
$requester = $this->newRequesterWithMockedRequestMethod(200, [ | ||
'status' => 200, | ||
'active_parcel' => true, | ||
'active_cargo' => false, | ||
'service_types' => [], | ||
]); | ||
|
||
$service = new Balikobot($requester); | ||
|
||
$service->getActivatedServices('cp'); | ||
|
||
$requester->shouldHaveReceived( | ||
'request', | ||
[ | ||
'https://api.balikobot.cz/cp/activatedservices', | ||
[], | ||
] | ||
); | ||
|
||
$this->assertTrue(true); | ||
} | ||
|
||
public function testResponseData() | ||
{ | ||
$requester = $this->newRequesterWithMockedRequestMethod(200, [ | ||
'status' => 200, | ||
'active_parcel' => true, | ||
'active_cargo' => false, | ||
'service_types' => [ | ||
'DR' => 'DR - Balík Do ruky', | ||
'RR' => 'RR - Doporučená zásilka', | ||
], | ||
]); | ||
|
||
$service = new Balikobot($requester); | ||
|
||
$services = $service->getActivatedServices('cp'); | ||
|
||
$this->assertEquals( | ||
[ | ||
'active_parcel' => true, | ||
'active_cargo' => false, | ||
'service_types' => [ | ||
'DR' => 'DR - Balík Do ruky', | ||
'RR' => 'RR - Doporučená zásilka', | ||
], | ||
], | ||
$services | ||
); | ||
} | ||
} |
97 changes: 97 additions & 0 deletions
97
tests/Unit/Client/Requests/ActivatedServicesRequestTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<?php | ||
|
||
namespace Inspirum\Balikobot\Tests\Unit\Client\Requests; | ||
|
||
use Inspirum\Balikobot\Exceptions\BadRequestException; | ||
use Inspirum\Balikobot\Services\Client; | ||
use Inspirum\Balikobot\Tests\Unit\Client\AbstractClientTestCase; | ||
|
||
class ActivatedServicesRequestTest extends AbstractClientTestCase | ||
{ | ||
public function testThrowsExceptionOnError() | ||
{ | ||
$this->expectException(BadRequestException::class); | ||
|
||
$requester = $this->newRequesterWithMockedRequestMethod(400, [ | ||
'status' => 200, | ||
]); | ||
|
||
$client = new Client($requester); | ||
|
||
$client->getActivatedServices('cp', 1); | ||
} | ||
|
||
public function testRequestShouldHaveStatus() | ||
{ | ||
$this->expectException(BadRequestException::class); | ||
|
||
$requester = $this->newRequesterWithMockedRequestMethod(200, [ | ||
'active_parcel' => true, | ||
'active_cargo' => false, | ||
'service_types' => [ | ||
'DR' => 'DR - Balík Do ruky', | ||
'RR' => 'RR - Doporučená zásilka', | ||
], | ||
]); | ||
|
||
$client = new Client($requester); | ||
|
||
$client->getActivatedServices('cp', 1); | ||
} | ||
|
||
public function testMakeRequest() | ||
{ | ||
$requester = $this->newRequesterWithMockedRequestMethod(200, [ | ||
'status' => 200, | ||
'active_parcel' => true, | ||
'active_cargo' => false, | ||
'service_types' => [ | ||
'DR' => 'DR - Balík Do ruky', | ||
'RR' => 'RR - Doporučená zásilka', | ||
], | ||
]); | ||
|
||
$client = new Client($requester); | ||
|
||
$client->getActivatedServices('cp', 1); | ||
|
||
$requester->shouldHaveReceived( | ||
'request', | ||
[ | ||
'https://api.balikobot.cz/cp/activatedservices', | ||
[], | ||
] | ||
); | ||
|
||
$this->assertTrue(true); | ||
} | ||
|
||
public function testOnlyPackagesDataAreReturned() | ||
{ | ||
$requester = $this->newRequesterWithMockedRequestMethod(200, [ | ||
'status' => 200, | ||
'active_parcel' => true, | ||
'active_cargo' => false, | ||
'service_types' => [ | ||
'DR' => 'DR - Balík Do ruky', | ||
'RR' => 'RR - Doporučená zásilka', | ||
], | ||
]); | ||
|
||
$client = new Client($requester); | ||
|
||
$packages = $client->getActivatedServices('cp'); | ||
|
||
$this->assertEquals( | ||
[ | ||
'active_parcel' => true, | ||
'active_cargo' => false, | ||
'service_types' => [ | ||
'DR' => 'DR - Balík Do ruky', | ||
'RR' => 'RR - Doporučená zásilka', | ||
], | ||
], | ||
$packages | ||
); | ||
} | ||
} |