Skip to content

Commit f72262d

Browse files
authored
Add assertion for exception type (ruflin#2094)
1 parent 50346d8 commit f72262d

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2323
* Changed `value` in `SetProcessor` to accept `mixed` instead of `string` by @franmomu [#2082](https://github.com/ruflin/Elastica/pull/2082)
2424
* Updated `Query::create` PHPDoc to include supported types and propagate it to callers by @franmomu [#2088](https://github.com/ruflin/Elastica/pull/2088)
2525
* Update some iterable types in PHPDoc to be more specific by @franmomu [#2092](https://github.com/ruflin/Elastica/pull/2092)
26+
* Updated `AwsAuthV4Test` adding assertions for exception type by @franmomu [#2094](https://github.com/ruflin/Elastica/pull/2094)
2627

2728
### Deprecated
2829
* Deprecated `Elastica\Reindex::WAIT_FOR_COMPLETION_FALSE`, use a boolean as parameter instead by @franmomu [#2070](https://github.com/ruflin/Elastica/pull/2070)

phpstan-baseline.neon

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,3 @@ parameters:
135135
count: 1
136136
path: tests/SnapshotTest.php
137137

138-
-
139-
message: "#^Call to an undefined method GuzzleHttp\\\\Exception\\\\TransferException\\:\\:getRequest\\(\\)\\.$#"
140-
count: 6
141-
path: tests/Transport/AwsAuthV4Test.php
142-

tests/Transport/AwsAuthV4Test.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Aws\Credentials\Credentials;
77
use Aws\Sdk;
88
use Elastica\Exception\Connection\GuzzleException;
9+
use GuzzleHttp\Exception\ConnectException;
910

1011
/**
1112
* @internal
@@ -39,6 +40,7 @@ public function testSignsWithProvidedCredentialProvider(): void
3940
$client->request('_stats');
4041
} catch (GuzzleException $e) {
4142
$guzzleException = $e->getGuzzleException();
43+
$this->assertInstanceOf(ConnectException::class, $guzzleException);
4244
$request = $guzzleException->getRequest();
4345
$expected = 'AWS4-HMAC-SHA256 Credential=foo/'
4446
.\date('Ymd').'/us-east-1/es/aws4_request, ';
@@ -76,6 +78,7 @@ public function testPrefersCredentialProviderToHardCodedCredentials(): void
7678
$client->request('_stats');
7779
} catch (GuzzleException $e) {
7880
$guzzleException = $e->getGuzzleException();
81+
$this->assertInstanceOf(ConnectException::class, $guzzleException);
7982
$request = $guzzleException->getRequest();
8083
$expected = 'AWS4-HMAC-SHA256 Credential=foo/'
8184
.\date('Ymd').'/us-east-1/es/aws4_request, ';
@@ -110,6 +113,7 @@ public function testSignsWithProvidedCredentials(): void
110113
$client->request('_stats');
111114
} catch (GuzzleException $e) {
112115
$guzzleException = $e->getGuzzleException();
116+
$this->assertInstanceOf(ConnectException::class, $guzzleException);
113117
$request = $guzzleException->getRequest();
114118
$expected = 'AWS4-HMAC-SHA256 Credential=foo/'
115119
.\date('Ymd').'/us-east-1/es/aws4_request, ';
@@ -140,6 +144,7 @@ public function testUseHttpAsDefaultProtocol(): void
140144
$client->request('_stats');
141145
} catch (GuzzleException $e) {
142146
$guzzleException = $e->getGuzzleException();
147+
$this->assertInstanceOf(ConnectException::class, $guzzleException);
143148
$request = $guzzleException->getRequest();
144149

145150
$this->assertSame('http', $request->getUri()->getScheme());
@@ -163,6 +168,7 @@ public function testSetHttpsIfItIsRequired(): void
163168
$client->request('_stats');
164169
} catch (GuzzleException $e) {
165170
$guzzleException = $e->getGuzzleException();
171+
$this->assertInstanceOf(ConnectException::class, $guzzleException);
166172
$request = $guzzleException->getRequest();
167173

168174
$this->assertSame('https', $request->getUri()->getScheme());
@@ -185,6 +191,7 @@ public function testSignsWithEnvironmentalCredentials(): void
185191
$client->request('_stats');
186192
} catch (GuzzleException $e) {
187193
$guzzleException = $e->getGuzzleException();
194+
$this->assertInstanceOf(ConnectException::class, $guzzleException);
188195
$request = $guzzleException->getRequest();
189196
$expected = 'AWS4-HMAC-SHA256 Credential=foo/'
190197
.\date('Ymd').'/us-east-1/es/aws4_request, ';

0 commit comments

Comments
 (0)