Skip to content

Commit 2bd8cd1

Browse files
committed
more tests
1 parent b14c0cf commit 2bd8cd1

2 files changed

Lines changed: 68 additions & 1 deletion

File tree

tests/unit/Endpoint/CalculateAwardMilesWithTaxTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
namespace TK\Test\Unit\Endpoint;
55

66
use DateTimeImmutable;
7+
use TK\SDK\Exception\InvalidArgumentException;
78
use TK\SDK\ValueObject\CalculateAwardMilesWithTaxParameters;
89

910
class CalculateAwardMilesWithTaxTest extends EndpointAbstract
@@ -21,6 +22,29 @@ public function shouldGetResponseSuccessfully() : void
2122
->withDepartureOrigin('IST')
2223
->withDepartureDestination('JFK')
2324
->withDepartureDate(new DateTimeImmutable($departureDate));
25+
26+
$response = $this->client->calculateAwardMilesWithTax($calculateAwardMilesWithTaxParameters);
27+
$this->assertEquals(200, $response['status']);
28+
$this->assertEquals('SUCCESS', $response['response']['status']);
29+
$this->assertEquals('TK-0000', $response['response']['code']);
30+
}
31+
32+
/**
33+
* @test
34+
*/
35+
public function shouldGetResponseSuccessfullyForDifferentInputs() : void
36+
{
37+
$arrivalDate = gmdate('Y-m-d H:i:s', strtotime('+4 days'));
38+
39+
$calculateAwardMilesWithTaxParameters = (new CalculateAwardMilesWithTaxParameters(
40+
CalculateAwardMilesWithTaxParameters::AWARD_TYPE_ECONOMY
41+
))->withOneWay()
42+
->withSeatGuaranteed()
43+
->withPassengerType('FFY')
44+
->withArrivalOrigin('IST')
45+
->withArrivalDestination('JFK')
46+
->withArrivalDate(new DateTimeImmutable($arrivalDate));
47+
2448
$response = $this->client->calculateAwardMilesWithTax($calculateAwardMilesWithTaxParameters);
2549
$this->assertEquals(200, $response['status']);
2650
$this->assertEquals('SUCCESS', $response['response']['status']);

tests/unit/Factory/CalculateAwardMilesWithTaxParametersFactoryTest.php

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
namespace TK\Test\Unit\Factory;
55

6+
use TK\SDK\Exception\InvalidArgumentException;
67
use TK\SDK\ValueObject\Factory\CalculateAwardMilesWithTaxParametersFactory;
78
use TK\SDK\ValueObject\CalculateAwardMilesWithTaxParameters;
89

@@ -26,7 +27,7 @@ protected function _after()
2627
* @test
2728
* @throws \Exception
2829
*/
29-
public function shouldReturnCalculateAwardMilesWithTaxParameters() : void
30+
public function shouldReturnCalculateAwardMilesWithTaxParametersObjectSuccessfully() : void
3031
{
3132
$json =<<<JSON
3233
{
@@ -44,4 +45,46 @@ public function shouldReturnCalculateAwardMilesWithTaxParameters() : void
4445
$this->assertInstanceOf(CalculateAwardMilesWithTaxParameters::class, $parameterObject);
4546
$this->assertEquals(json_decode($json, true), $parameterObject->getValue());
4647
}
48+
49+
/**
50+
* @test
51+
*/
52+
public function shouldFailForInvalidAwardTypeSuccessfully() : void
53+
{
54+
$this->expectException(InvalidArgumentException::class);
55+
$json =<<<JSON
56+
{
57+
"awardType": "Z",
58+
"wantMoreMiles": "T",
59+
"isOneWay": "T",
60+
"departureOrigin": "IST",
61+
"departureDestination": "FRA",
62+
"departureDateDay": 12,
63+
"departureDateMonth": 11,
64+
"departureDateYear": 2017
65+
}
66+
JSON;
67+
$parameterObject = CalculateAwardMilesWithTaxParametersFactory::createFromJson($json);
68+
}
69+
70+
/**
71+
* @test
72+
*/
73+
public function shouldFailForInvalidIataCodeSuccessfully() : void
74+
{
75+
//$this->expectException(InvalidArgumentException::class);
76+
$json =<<<JSON
77+
{
78+
"awardType": "E",
79+
"wantMoreMiles": "T",
80+
"isOneWay": "T",
81+
"departureOrigin": "ICAO",
82+
"departureDestination": "FRA",
83+
"departureDateDay": 12,
84+
"departureDateMonth": 11,
85+
"departureDateYear": 2017
86+
}
87+
JSON;
88+
$parameterObject = CalculateAwardMilesWithTaxParametersFactory::createFromJson($json);
89+
}
4790
}

0 commit comments

Comments
 (0)