Skip to content

Commit f4ed350

Browse files
authored
Added logging on HTTP exception (#507)
* Added logging on HTTP exception * Fixed tests * Test fix * Added name to please "composer normalize" * Dont log in constructor * Mniir * PHPStan fix
1 parent 3755cf2 commit f4ed350

11 files changed

+22
-11
lines changed

tests/Unit/Result/CreateTableOutputTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use AsyncAws\Core\Test\Http\SimpleMockedResponse;
77
use AsyncAws\Core\Test\TestCase;
88
use AsyncAws\DynamoDb\Result\CreateTableOutput;
9+
use Psr\Log\NullLogger;
910
use Symfony\Component\HttpClient\MockHttpClient;
1011

1112
class CreateTableOutputTest extends TestCase
@@ -49,7 +50,7 @@ public function testCreateTableOutput(): void
4950
}');
5051

5152
$client = new MockHttpClient($response);
52-
$result = new CreateTableOutput(new Response($client->request('POST', 'http://localhost'), $client));
53+
$result = new CreateTableOutput(new Response($client->request('POST', 'http://localhost'), $client, new NullLogger()));
5354

5455
self::assertEquals('Artist', $result->getTableDescription()->getAttributeDefinitions()[0]->getAttributeName());
5556
self::assertEquals('SongTitle', $result->getTableDescription()->getAttributeDefinitions()[1]->getAttributeName());

tests/Unit/Result/DeleteItemOutputTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use AsyncAws\Core\Test\Http\SimpleMockedResponse;
77
use AsyncAws\Core\Test\TestCase;
88
use AsyncAws\DynamoDb\Result\DeleteItemOutput;
9+
use Psr\Log\NullLogger;
910
use Symfony\Component\HttpClient\MockHttpClient;
1011

1112
class DeleteItemOutputTest extends TestCase
@@ -21,7 +22,7 @@ public function testDeleteItemOutput(): void
2122
}');
2223

2324
$client = new MockHttpClient($response);
24-
$result = new DeleteItemOutput(new Response($client->request('POST', 'http://localhost'), $client));
25+
$result = new DeleteItemOutput(new Response($client->request('POST', 'http://localhost'), $client, new NullLogger()));
2526

2627
self::assertEquals(1, $result->getConsumedCapacity()->getCapacityUnits());
2728
self::assertEquals('Music', $result->getConsumedCapacity()->getTableName());

tests/Unit/Result/DeleteTableOutputTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use AsyncAws\Core\Test\Http\SimpleMockedResponse;
77
use AsyncAws\Core\Test\TestCase;
88
use AsyncAws\DynamoDb\Result\DeleteTableOutput;
9+
use Psr\Log\NullLogger;
910
use Symfony\Component\HttpClient\MockHttpClient;
1011

1112
class DeleteTableOutputTest extends TestCase
@@ -29,7 +30,7 @@ public function testDeleteTableOutput(): void
2930
}');
3031

3132
$client = new MockHttpClient($response);
32-
$result = new DeleteTableOutput(new Response($client->request('POST', 'http://localhost'), $client));
33+
$result = new DeleteTableOutput(new Response($client->request('POST', 'http://localhost'), $client, new NullLogger()));
3334

3435
self::assertEquals(0, $result->getTableDescription()->getItemCount());
3536
self::assertEquals(1, $result->getTableDescription()->getProvisionedThroughput()->getNumberOfDecreasesToday());

tests/Unit/Result/DescribeTableOutputTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use AsyncAws\Core\Test\Http\SimpleMockedResponse;
77
use AsyncAws\Core\Test\TestCase;
88
use AsyncAws\DynamoDb\Result\DescribeTableOutput;
9+
use Psr\Log\NullLogger;
910
use Symfony\Component\HttpClient\MockHttpClient;
1011

1112
class DescribeTableOutputTest extends TestCase
@@ -49,7 +50,7 @@ public function testDescribeTableOutput(): void
4950
}');
5051

5152
$client = new MockHttpClient($response);
52-
$result = new DescribeTableOutput(new Response($client->request('POST', 'http://localhost'), $client));
53+
$result = new DescribeTableOutput(new Response($client->request('POST', 'http://localhost'), $client, new NullLogger()));
5354

5455
self::assertEquals('Artist', $result->getTable()->getAttributeDefinitions()[0]->getAttributeName());
5556
self::assertEquals('SongTitle', $result->getTable()->getAttributeDefinitions()[1]->getAttributeName());

tests/Unit/Result/GetItemOutputTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use AsyncAws\Core\Test\Http\SimpleMockedResponse;
77
use AsyncAws\Core\Test\TestCase;
88
use AsyncAws\DynamoDb\Result\GetItemOutput;
9+
use Psr\Log\NullLogger;
910
use Symfony\Component\HttpClient\MockHttpClient;
1011

1112
class GetItemOutputTest extends TestCase
@@ -28,7 +29,7 @@ public function testGetItemOutput(): void
2829
}');
2930

3031
$client = new MockHttpClient($response);
31-
$result = new GetItemOutput(new Response($client->request('POST', 'http://localhost'), $client));
32+
$result = new GetItemOutput(new Response($client->request('POST', 'http://localhost'), $client, new NullLogger()));
3233

3334
self::assertEquals('Songs About Life', $result->getItem()['AlbumTitle']->getS());
3435
self::assertEquals('Acme Band', $result->getItem()['Artist']->getS());

tests/Unit/Result/ListTablesOutputTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use AsyncAws\Core\Test\Http\SimpleMockedResponse;
77
use AsyncAws\Core\Test\TestCase;
88
use AsyncAws\DynamoDb\Result\ListTablesOutput;
9+
use Psr\Log\NullLogger;
910
use Symfony\Component\HttpClient\MockHttpClient;
1011

1112
class ListTablesOutputTest extends TestCase
@@ -24,7 +25,7 @@ public function testListTablesOutput(): void
2425
}');
2526

2627
$client = new MockHttpClient($response);
27-
$result = new ListTablesOutput(new Response($client->request('POST', 'http://localhost'), $client));
28+
$result = new ListTablesOutput(new Response($client->request('POST', 'http://localhost'), $client, new NullLogger()));
2829

2930
$tableNames = $result->getTableNames(true);
3031
foreach ($tableNames as $name) {

tests/Unit/Result/PutItemOutputTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use AsyncAws\Core\Test\Http\SimpleMockedResponse;
77
use AsyncAws\Core\Test\TestCase;
88
use AsyncAws\DynamoDb\Result\PutItemOutput;
9+
use Psr\Log\NullLogger;
910
use Symfony\Component\HttpClient\MockHttpClient;
1011

1112
class PutItemOutputTest extends TestCase
@@ -22,7 +23,7 @@ public function testPutItemOutput(): void
2223
}');
2324

2425
$client = new MockHttpClient($response);
25-
$result = new PutItemOutput(new Response($client->request('POST', 'http://localhost'), $client));
26+
$result = new PutItemOutput(new Response($client->request('POST', 'http://localhost'), $client, new NullLogger()));
2627

2728
self::assertEquals(1, $result->getConsumedCapacity()->getCapacityUnits());
2829
self::assertEquals('Music', $result->getConsumedCapacity()->getTableName());

tests/Unit/Result/QueryOutputTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use AsyncAws\Core\Test\TestCase;
88
use AsyncAws\DynamoDb\Result\QueryOutput;
99
use AsyncAws\DynamoDb\ValueObject\ConsumedCapacity;
10+
use Psr\Log\NullLogger;
1011
use Symfony\Component\HttpClient\MockHttpClient;
1112

1213
class QueryOutputTest extends TestCase
@@ -31,7 +32,7 @@ public function testQueryOutput(): void
3132
}');
3233

3334
$client = new MockHttpClient($response);
34-
$result = new QueryOutput(new Response($client->request('POST', 'http://localhost'), $client));
35+
$result = new QueryOutput(new Response($client->request('POST', 'http://localhost'), $client, new NullLogger()));
3536

3637
$items = $result->getItems(true);
3738
foreach ($items as $name => $item) {

tests/Unit/Result/ScanOutputTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use AsyncAws\Core\Test\Http\SimpleMockedResponse;
77
use AsyncAws\Core\Test\TestCase;
88
use AsyncAws\DynamoDb\Result\ScanOutput;
9+
use Psr\Log\NullLogger;
910
use Symfony\Component\HttpClient\MockHttpClient;
1011

1112
class ScanOutputTest extends TestCase
@@ -38,7 +39,7 @@ public function testScanOutput(): void
3839
}');
3940

4041
$client = new MockHttpClient($response);
41-
$result = new ScanOutput(new Response($client->request('POST', 'http://localhost'), $client));
42+
$result = new ScanOutput(new Response($client->request('POST', 'http://localhost'), $client, new NullLogger()));
4243

4344
$items = $result->getItems(true);
4445
foreach ($items as $name => $item) {

tests/Unit/Result/UpdateItemOutputTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use AsyncAws\Core\Test\Http\SimpleMockedResponse;
77
use AsyncAws\Core\Test\TestCase;
88
use AsyncAws\DynamoDb\Result\UpdateItemOutput;
9+
use Psr\Log\NullLogger;
910
use Symfony\Component\HttpClient\MockHttpClient;
1011

1112
class UpdateItemOutputTest extends TestCase
@@ -31,7 +32,7 @@ public function testUpdateItemOutput(): void
3132
}');
3233

3334
$client = new MockHttpClient($response);
34-
$result = new UpdateItemOutput(new Response($client->request('POST', 'http://localhost'), $client));
35+
$result = new UpdateItemOutput(new Response($client->request('POST', 'http://localhost'), $client, new NullLogger()));
3536

3637
$attributes = $result->getAttributes();
3738
self::assertCount(4, $attributes);

0 commit comments

Comments
 (0)