6
6
7
7
use App \DataAccess \DynamoDb \ViewerCodes ;
8
8
use App \DataAccess \Repository \KeyCollisionException ;
9
+ use App \Entity \Value \LpaUid ;
9
10
use Aws \CommandInterface ;
10
11
use Aws \DynamoDb \DynamoDbClient ;
11
12
use Aws \DynamoDb \Exception \DynamoDbException ;
@@ -113,7 +114,7 @@ public function cannot_lookup_a_missing_code(): void
113
114
#[Test]
114
115
public function can_query_by_lpa_id (): void
115
116
{
116
- $ testSiriusUid = '98765-43210 ' ;
117
+ $ testSiriusUid = new LpaUid ( '98765-43210 ' ) ;
117
118
118
119
$ this ->dynamoDbClientProphecy ->query (
119
120
Argument::that (function (array $ data ) use ($ testSiriusUid ) {
@@ -154,7 +155,7 @@ public function can_query_by_lpa_id(): void
154
155
#[Test]
155
156
public function lpa_with_no_generated_codes_returns_empty_array (): void
156
157
{
157
- $ testSiriusUid = '98765-43210 ' ;
158
+ $ testSiriusUid = new LpaUid ( '98765-43210 ' ) ;
158
159
159
160
$ this ->dynamoDbClientProphecy ->query (
160
161
Argument::that (function (array $ data ) use ($ testSiriusUid ) {
@@ -191,8 +192,7 @@ public function add_unique_code_for_Sirius_LPA(): void
191
192
{
192
193
$ testCode = 'test-code ' ;
193
194
$ testUserLpaActorToken = 'test-token ' ;
194
- $ testSiriusUid = 'test-uid ' ;
195
- $ testLpaUid = 'null ' ;
195
+ $ testLpaUid = new LpaUid ('98765-43210 ' );
196
196
$ testExpires = new DateTime ();
197
197
$ testOrganisation = 'test-organisation ' ;
198
198
$ testActorId = '123 ' ;
@@ -201,11 +201,10 @@ public function add_unique_code_for_Sirius_LPA(): void
201
201
Argument::that (function (array $ data ) use (
202
202
$ testCode ,
203
203
$ testUserLpaActorToken ,
204
- $ testSiriusUid ,
205
204
$ testLpaUid ,
206
205
$ testExpires ,
207
206
$ testOrganisation ,
208
- $ testActorId
207
+ $ testActorId,
209
208
) {
210
209
$ this ->assertArrayHasKey ('TableName ' , $ data );
211
210
$ this ->assertEquals (self ::TABLE_NAME , $ data ['TableName ' ]);
@@ -220,7 +219,7 @@ public function add_unique_code_for_Sirius_LPA(): void
220
219
221
220
$ this ->assertEquals (['S ' => $ testCode ], $ data ['Item ' ]['ViewerCode ' ]);
222
221
$ this ->assertEquals (['S ' => $ testUserLpaActorToken ], $ data ['Item ' ]['UserLpaActor ' ]);
223
- $ this ->assertEquals (['S ' => $ testSiriusUid ], $ data ['Item ' ]['SiriusUid ' ]);
222
+ $ this ->assertEquals (['S ' => $ testLpaUid ], $ data ['Item ' ]['SiriusUid ' ]);
224
223
$ this ->assertEquals (['S ' => $ testExpires ->format ('c ' )], $ data ['Item ' ]['Expires ' ]);
225
224
$ this ->assertEquals (['S ' => $ testOrganisation ], $ data ['Item ' ]['Organisation ' ]);
226
225
@@ -235,16 +234,20 @@ public function add_unique_code_for_Sirius_LPA(): void
235
234
236
235
$ repo ->add (
237
236
$ testCode ,
238
- $ testUserLpaActorToken , $ testSiriusUid , $ testLpaUid , $ testExpires , $ testOrganisation , $ testActorId );
237
+ $ testUserLpaActorToken ,
238
+ $ testLpaUid ,
239
+ $ testExpires ,
240
+ $ testOrganisation ,
241
+ $ testActorId
242
+ );
239
243
}
240
244
241
245
#[Test]
242
246
public function add_unique_code_for_data_store_LPA (): void
243
247
{
244
248
$ testCode = 'test-code ' ;
245
249
$ testUserLpaActorToken = 'test-token ' ;
246
- $ testSiriusUid = null ;
247
- $ testLpaUid = 'M-test-uid ' ;
250
+ $ testLpaUid = new LpaUid ('M-1098-7654-3210 ' );
248
251
$ testExpires = new DateTime ();
249
252
$ testOrganisation = 'test-organisation ' ;
250
253
$ testActorId = '123 ' ;
@@ -253,11 +256,10 @@ public function add_unique_code_for_data_store_LPA(): void
253
256
Argument::that (function (array $ data ) use (
254
257
$ testCode ,
255
258
$ testUserLpaActorToken ,
256
- $ testSiriusUid ,
257
259
$ testLpaUid ,
258
260
$ testExpires ,
259
261
$ testOrganisation ,
260
- $ testActorId
262
+ $ testActorId,
261
263
) {
262
264
$ this ->assertArrayHasKey ('TableName ' , $ data );
263
265
$ this ->assertEquals (self ::TABLE_NAME , $ data ['TableName ' ]);
@@ -272,7 +274,7 @@ public function add_unique_code_for_data_store_LPA(): void
272
274
273
275
$ this ->assertEquals (['S ' => $ testCode ], $ data ['Item ' ]['ViewerCode ' ]);
274
276
$ this ->assertEquals (['S ' => $ testUserLpaActorToken ], $ data ['Item ' ]['UserLpaActor ' ]);
275
- $ this ->assertEquals (['S ' => $ testLpaUid ], $ data ['Item ' ]['LpaUid ' ]);
277
+ $ this ->assertEquals (['S ' => $ testLpaUid ], $ data ['Item ' ]['SiriusUid ' ]);
276
278
$ this ->assertEquals (['S ' => $ testExpires ->format ('c ' )], $ data ['Item ' ]['Expires ' ]);
277
279
$ this ->assertEquals (['S ' => $ testOrganisation ], $ data ['Item ' ]['Organisation ' ]);
278
280
@@ -287,27 +289,12 @@ public function add_unique_code_for_data_store_LPA(): void
287
289
288
290
$ repo ->add (
289
291
$ testCode ,
290
- $ testUserLpaActorToken , $ testSiriusUid , $ testLpaUid , $ testExpires , $ testOrganisation , $ testActorId );
291
- }
292
-
293
- #[Test]
294
- public function throw_exception_when_add_unique_code_called_wih_null_uid (): void
295
- {
296
- $ testCode = 'test-code ' ;
297
- $ testUserLpaActorToken = 'test-token ' ;
298
- $ testSiriusUid = null ;
299
- $ testLpaUid = null ;
300
- $ testExpires = new DateTime ();
301
- $ testOrganisation = 'test-organisation ' ;
302
- $ testActorId = '123 ' ;
303
-
304
- $ repo = new ViewerCodes ($ this ->dynamoDbClientProphecy ->reveal (), self ::TABLE_NAME );
305
-
306
- $ this ->expectException (\Exception::class);
307
-
308
- $ repo ->add (
309
- $ testCode ,
310
- $ testUserLpaActorToken , $ testSiriusUid , $ testLpaUid , $ testExpires , $ testOrganisation , $ testActorId );
292
+ $ testUserLpaActorToken ,
293
+ $ testLpaUid ,
294
+ $ testExpires ,
295
+ $ testOrganisation ,
296
+ $ testActorId
297
+ );
311
298
}
312
299
313
300
#[Test]
@@ -333,8 +320,7 @@ public function add_conflicting_code(): void
333
320
$ repo ->add (
334
321
'test-val ' ,
335
322
'test-val ' ,
336
- 'test-val ' ,
337
- 'test-val ' ,
323
+ new LpaUid ('M-1098-7654-3210 ' ),
338
324
new DateTime (),
339
325
'test-val ' ,
340
326
'123 '
@@ -358,8 +344,7 @@ public function test_unknown_exception_when_adding_code(): void
358
344
$ repo ->add (
359
345
'test-val ' ,
360
346
'test-val ' ,
361
- 'test-val ' ,
362
- 'test-val ' ,
347
+ new LpaUid ('M-1098-7654-3210 ' ),
363
348
new DateTime (),
364
349
'test-val ' ,
365
350
'123 '
0 commit comments