33
44namespace TK \Test \Unit \Factory ;
55
6+ use TK \SDK \Exception \InvalidArgumentException ;
67use TK \SDK \ValueObject \Factory \CalculateFlightMilesParametersFactory ;
78use TK \SDK \ValueObject \CalculateFlightMilesParameters ;
89
@@ -31,6 +32,8 @@ public function shouldReturnCalculateFlightMilesParameters() : void
3132{
3233 "cabin_code": "Y",
3334 "card_type": "EP",
35+ "marketingClassCode": "TK",
36+ "marketingFlightNumber":"TK1000",
3437 "destination": "IST",
3538 "flightDate": "21.04.2017",
3639 "operatingFlightNumber": "TK1000",
@@ -42,4 +45,132 @@ public function shouldReturnCalculateFlightMilesParameters() : void
4245 $ this ->assertInstanceOf (CalculateFlightMilesParameters::class, $ parameterObject );
4346 $ this ->assertEquals (json_decode ($ json , true ), $ parameterObject ->getValue ());
4447 }
48+
49+ /**
50+ * @test
51+ * @throws \Exception
52+ */
53+ public function shouldReturnCalculateFlightMilesParametersWithClassCode () : void
54+ {
55+ $ json =<<<JSON
56+ {
57+ "cabin_code": "Y",
58+ "card_type": "EP",
59+ "class_code": "T",
60+ "marketingClassCode": "TK",
61+ "marketingFlightNumber":"TK1000",
62+ "destination": "IST",
63+ "flightDate": "21.04.2017",
64+ "operatingFlightNumber": "TK1000",
65+ "origin": "FRA"
66+ }
67+
68+ JSON ;
69+ $ parameterObject = CalculateFlightMilesParametersFactory::createFromJson ($ json );
70+ $ parameterObject ->withClassCode ();
71+ $ this ->assertInstanceOf (CalculateFlightMilesParameters::class, $ parameterObject );
72+ $ this ->assertArrayHasKey ('class_code ' , $ parameterObject ->getValue ());
73+
74+ }
75+ /**
76+ * @test
77+ * @throws \Exception
78+ * @expectedException InvalidArgumentException
79+ */
80+ public function shouldFailForInvalidCardTypesEnum () : void
81+ {
82+ $ json =<<<JSON
83+ {
84+ "cabin_code": "Y",
85+ "card_type": "TT",
86+ "class_code": "Y",
87+ "marketingClassCode": "TK",
88+ "marketingFlightNumber":"TK1000",
89+ "destination": "IST",
90+ "flightDate": "21.04.2017",
91+ "operatingFlightNumber": "TK1000",
92+ "origin": "FRA"
93+ }
94+
95+ JSON ;
96+ $ parameterObject = CalculateFlightMilesParametersFactory::createFromJson ($ json );
97+ $ this ->assertInstanceOf (CalculateFlightMilesParameters::class, $ parameterObject );
98+ $ this ->assertEquals (json_decode ($ json , true ), $ parameterObject ->getValue ());
99+ }
100+
101+
102+
103+ /**
104+ * @test
105+ * @throws \Exception
106+ * @expectedException InvalidArgumentException
107+ */
108+ public function shouldFailForInvalidOrigin () : void
109+ {
110+ $ json =<<<JSON
111+ {
112+ "cabin_code": "Y",
113+ "card_type": "TT",
114+ "class_code": "Y",
115+ "marketingClassCode": "TK",
116+ "marketingFlightNumber":"TK1000",
117+ "destination": "IST",
118+ "flightDate": "21.04.2017",
119+ "operatingFlightNumber": "TK1000",
120+ "origin": "FRAT"
121+ }
122+
123+ JSON ;
124+ CalculateFlightMilesParametersFactory::createFromJson ($ json );
125+ }
126+
127+
128+
129+ /**
130+ * @test
131+ * @throws \Exception
132+ * @expectedException InvalidArgumentException
133+ */
134+ public function shouldFailForInvalidDestination () : void
135+ {
136+ $ json =<<<JSON
137+ {
138+ "cabin_code": "Y",
139+ "card_type": "TT",
140+ "class_code": "Y",
141+ "marketingClassCode": "TK",
142+ "marketingFlightNumber":"TK1000",
143+ "destination": "ISTT",
144+ "flightDate": "21.04.2017",
145+ "operatingFlightNumber": "TK1000",
146+ "origin": "FRA"
147+ }
148+
149+ JSON ;
150+ CalculateFlightMilesParametersFactory::createFromJson ($ json );
151+ }
152+
153+
154+ /**
155+ * @test
156+ */
157+ public function shouldFailForInvalidJsony () : void
158+ {
159+ $ this ->expectException (InvalidArgumentException::class);
160+ $ json =<<<JSON
161+ {
162+ "cabin_code: "Y",
163+ "card_type": "TT",
164+ "class_code": "Y",
165+ "marketingClassCode": "TK",
166+ "marketingFlightNumber":"TK1000",
167+ "destination": "ISTT",
168+ "flightDate": "21.04.2017",
169+ "operatingFlightNumber": "TK1000",
170+ "origin": "FRA"
171+ }
172+
173+ JSON ;
174+ CalculateFlightMilesParametersFactory::createFromJson ($ json );
175+ }
45176}
0 commit comments