Skip to content

Commit 7fd3d99

Browse files
authored
Merge pull request #6 from tyamahori/feature/php-8.2
fix ${var} string
2 parents 83bbb02 + 09e73d6 commit 7fd3d99

File tree

5 files changed

+28
-11
lines changed

5 files changed

+28
-11
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
strategy:
1010
fail-fast: true
1111
matrix:
12-
php: [7.4, 8.0, 8.1]
12+
php: [7.4, 8.0, 8.1, 8.2]
1313
laravel: [6.*, 7.*, 8.*, 9.*]
1414
include:
1515
- laravel: 9.*
@@ -27,7 +27,10 @@ jobs:
2727
laravel: 7.*
2828
- php: 8.1
2929
laravel: 6.*
30-
30+
- php: 8.2
31+
laravel: 7.*
32+
- php: 8.2
33+
laravel: 6.*
3134

3235
name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }}
3336

src/ValidatesOpenApiSpec.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function getOpenApiValidatorBuilder(): ValidatorBuilder
4545
} elseif ($specType === 'yaml') {
4646
$this->openApiValidatorBuilder = (new ValidatorBuilder())->fromYaml($this->getOpenApiSpec());
4747
} else {
48-
throw new UnknownParserForFileTypeException("Unknown parser for file type ${specType}");
48+
throw new UnknownParserForFileTypeException("Unknown parser for file type {$specType}");
4949
}
5050
}
5151

@@ -153,7 +153,7 @@ protected function getResponseCodesToSkipRegex(): string
153153
$codes = $this->responseCodesToSkip ?? ['5\d\d'];
154154

155155
return '/' . implode('|', array_map(function ($code) {
156-
return "(${code})";
156+
return "({$code})";
157157
}, $codes)) . '/';
158158
}
159159

@@ -213,7 +213,7 @@ protected function getSpecFileType(): string
213213
$type = strtolower(Str::afterLast($this->getOpenApiSpecPath(), '.'));
214214

215215
if (! $type || ! in_array($type, ['json', 'yaml'])) {
216-
throw new UnknownSpecFileTypeException("Expected json or yaml type OpenAPI spec, got ${type}");
216+
throw new UnknownSpecFileTypeException("Expected json or yaml type OpenAPI spec, got {$type}");
217217
}
218218

219219
return $type;

tests/ValidatesReponsesTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function testValidatesResponses(OperationAddress $address, array $respons
3939
if (is_null($expectedException)) {
4040
$this->fail('Validation failed with unexpected exception ' . get_class($exception) . PHP_EOL . $exception->getMessage());
4141
}
42-
$this->assertInstanceOf($expectedException, $exception, "Expected an exception of class [${expectedException}] to be thrown, got " . get_class($exception));
42+
$this->assertInstanceOf($expectedException, $exception, "Expected an exception of class [{$expectedException}] to be thrown, got " . get_class($exception));
4343

4444
$this->assertFalse($expectSuccess);
4545
// End the test here

tests/ValidatesRequestsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function testValidatesRequests(array $requestData, bool $expectSuccess, ?
4040
if (is_null($expectedException)) {
4141
$this->fail('Validation failed with unexpected exception ' . get_class($exception) . PHP_EOL . $exception->getMessage());
4242
}
43-
$this->assertInstanceOf($expectedException, $exception, "Expected an exception of class [${expectedException}] to be thrown, got " . get_class($exception));
43+
$this->assertInstanceOf($expectedException, $exception, "Expected an exception of class [{$expectedException}] to be thrown, got " . get_class($exception));
4444

4545
$this->assertFalse($expectSuccess);
4646
// End the test here

tests/ValidatorBuildAndSetupTest.php

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class ValidatorBuildAndSetupTest extends TestCase
2424
*/
2525
public function testGetsOpenApiValidatorBuilder(string $extension)
2626
{
27-
$this->app['config']->set('openapi_validator.spec_path', __DIR__."/fixtures/OpenAPI.${extension}");
27+
$this->app['config']->set('openapi_validator.spec_path', __DIR__."/fixtures/OpenAPI.{$extension}");
2828
$builder = $this->getOpenApiValidatorBuilder();
2929

3030
$this->assertInstanceOf(ValidatorBuilder::class, $builder);
@@ -40,15 +40,29 @@ public function provideSpecFormats()
4040

4141
/**
4242
* @test
43+
* @dataProvider provideSpecUnknownFormats
4344
*/
44-
public function testThrowsExceptionForUnknownFormat()
45+
public function testThrowsExceptionForUnknownFormat(string $extension)
4546
{
46-
$this->app['config']->set('openapi_validator.spec_path', __DIR__.'/fixtures/OpenAPI.banana');
47+
$this->app['config']->set('openapi_validator.spec_path', __DIR__ . "/fixtures/OpenAPI.{$extension}");
4748

4849
$this->expectException(UnknownSpecFileTypeException::class);
50+
$this->expectErrorMessage("Expected json or yaml type OpenAPI spec, got {$extension}");
4951
$this->getSpecFileType();
5052
}
5153

54+
/**
55+
* @return array
56+
*/
57+
public function provideSpecUnknownFormats(): array
58+
{
59+
return [
60+
['banana'],
61+
['jsonn'],
62+
['yamll'],
63+
];
64+
}
65+
5266
/**
5367
* @test
5468
*/
@@ -105,7 +119,7 @@ public function testSkipsResponseCodes($responseCode, $codesToSkip, bool $expect
105119
public function provideResponseCodes()
106120
{
107121
for ($i = 0; $i <= 8; $i++) {
108-
yield "Skips 50${i} by default" => [500 + $i, [], true];
122+
yield "Skips 50{$i} by default" => [500 + $i, [], true];
109123
}
110124

111125
yield 'Skips other 500s by default (1)' => [

0 commit comments

Comments
 (0)