15
15
use AsyncAws \DynamoDb \Input \DescribeTableInput ;
16
16
use AsyncAws \DynamoDb \Input \GetItemInput ;
17
17
use AsyncAws \DynamoDb \Input \ListTablesInput ;
18
+ use AsyncAws \DynamoDb \Input \PutItemInput ;
18
19
use AsyncAws \DynamoDb \Input \QueryInput ;
19
20
use AsyncAws \DynamoDb \Input \ScanInput ;
20
21
use AsyncAws \DynamoDb \Input \UpdateItemInput ;
@@ -191,7 +192,32 @@ public function testBatchGetItem(): void
191
192
192
193
public function testCreateTable (): void
193
194
{
194
- self ::markTestSkipped ('This is tested in setUp() ' );
195
+ $ client = $ this ->getClient ();
196
+
197
+ $ input = new CreateTableInput ([
198
+ 'TableName ' => 'demo ' ,
199
+ 'AttributeDefinitions ' => [
200
+ new AttributeDefinition (['AttributeName ' => 'ForumName ' , 'AttributeType ' => 'S ' ]),
201
+ ],
202
+ 'KeySchema ' => [
203
+ new KeySchemaElement (['AttributeName ' => 'ForumName ' , 'KeyType ' => KeyType::HASH ]),
204
+ ],
205
+ 'ProvisionedThroughput ' => new ProvisionedThroughput ([
206
+ 'ReadCapacityUnits ' => 5 ,
207
+ 'WriteCapacityUnits ' => 5 ,
208
+ ]),
209
+ ]);
210
+
211
+ $ result = $ client ->createTable ($ input );
212
+ $ result ->resolve ();
213
+
214
+ try {
215
+ self ::assertSame ('arn:aws:dynamodb:us-east-1:000000000000:table/demo ' , $ result ->getTableDescription ()->getTableArn ());
216
+ self ::assertSame ('0 ' , $ result ->getTableDescription ()->getItemCount ());
217
+ self ::assertTrue ($ client ->tableExists (['TableName ' => 'demo ' ])->isSuccess ());
218
+ } finally {
219
+ $ this ->getClient ()->deleteTable (['TableName ' => 'demo ' ]);
220
+ }
195
221
}
196
222
197
223
public function testDeleteItem (): void
@@ -216,7 +242,28 @@ public function testDeleteItem(): void
216
242
217
243
public function testDeleteTable (): void
218
244
{
219
- self ::markTestSkipped ('This is tested in tearDown() ' );
245
+ $ client = $ this ->getClient ();
246
+
247
+ $ input = new CreateTableInput ([
248
+ 'TableName ' => 'demo ' ,
249
+ 'AttributeDefinitions ' => [
250
+ new AttributeDefinition (['AttributeName ' => 'ForumName ' , 'AttributeType ' => 'S ' ]),
251
+ ],
252
+ 'KeySchema ' => [
253
+ new KeySchemaElement (['AttributeName ' => 'ForumName ' , 'KeyType ' => KeyType::HASH ]),
254
+ ],
255
+ 'ProvisionedThroughput ' => new ProvisionedThroughput ([
256
+ 'ReadCapacityUnits ' => 5 ,
257
+ 'WriteCapacityUnits ' => 5 ,
258
+ ]),
259
+ ]);
260
+
261
+ $ client ->createTable ($ input );
262
+
263
+ $ result = $ client ->deleteTable (['TableName ' => 'demo ' ]);
264
+ $ result ->resolve ();
265
+
266
+ self ::assertFalse ($ client ->tableExists (['TableName ' => 'demo ' ])->isSuccess ());
220
267
}
221
268
222
269
public function testDescribeTable (): void
@@ -267,7 +314,22 @@ public function testListTables(): void
267
314
268
315
public function testPutItem (): void
269
316
{
270
- self ::markTestSkipped ('This is tested in setUp() ' );
317
+ $ client = $ this ->getClient ();
318
+
319
+ $ input = new PutItemInput ([
320
+ 'TableName ' => $ this ->tableName ,
321
+ 'Item ' => [
322
+ 'LastPostDateTime ' => ['S ' => '201303190422 ' ],
323
+ 'Tags ' => ['SS ' => ['Update ' , 'Multiple Items ' , 'HelpMe ' ]],
324
+ 'ForumName ' => ['S ' => 'Amazon DynamoDB ' ],
325
+ 'Message ' => ['S ' => 'I want to update multiple items in a single call. What \'s the best way to do that? ' ],
326
+ 'Subject ' => ['S ' => 'How do I update multiple items? ' ],
327
+ 'LastPostedBy ' => [
'S ' =>
'[email protected] ' ],
328
+ ],
329
+ ]);
330
+
331
+ $ result = $ client ->putItem ($ input );
332
+ self ::assertSame (1.0 , $ result ->getConsumedCapacity ()->getCapacityUnits ());
271
333
}
272
334
273
335
public function testQuery (): void
@@ -413,7 +475,7 @@ private function getClient(): DynamoDbClient
413
475
}
414
476
415
477
return $ this ->client = new DynamoDbClient ([
416
- 'endpoint ' => 'http://localhost:8000 ' ,
478
+ 'endpoint ' => 'http://localhost:4575 ' ,
417
479
], new Credentials ('aws_id ' , 'aws_secret ' ));
418
480
}
419
481
}
0 commit comments