Skip to content

Commit a078993

Browse files
committed
Found unit test for normalized and non-normalized additional details
1 parent 1f96d4c commit a078993

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/ApiProblem.php

+4
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,10 @@ public function __get(string $name): mixed
187187
return $this->additionalDetails[$normalized];
188188
}
189189

190+
if (isset($this->additionalDetails[$name])) {
191+
return $this->additionalDetails[$name];
192+
}
193+
190194
throw new InvalidArgumentException(sprintf(
191195
'Invalid property name "%s"',
192196
$name

test/ApiProblemTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,9 @@ public function testMagicGetNormalizedProperties(int $code): void
303303
*/
304304
public function testMagicGetAdditionalDetails(int $code): void
305305
{
306-
$apiProblem = new ApiProblem($code, 'Testing', 'test', 'title test', ['xxmore' => 'testing']);
306+
$apiProblem = new ApiProblem($code, 'Testing', 'test', 'title test', ['MixedCase' => 'testing']);
307307

308-
$this->assertEquals('testing', $apiProblem->__get('xxmore'));
308+
$this->assertEquals('testing', $apiProblem->__get('MixedCase'));
309309
}
310310

311311
/**
@@ -314,8 +314,8 @@ public function testMagicGetAdditionalDetails(int $code): void
314314
*/
315315
public function testMagicGetAdditionalDetailsNormalized(int $code): void
316316
{
317-
$apiProblem = new ApiProblem($code, 'Testing', 'test', 'title test', ['code' => 'testing']);
317+
$apiProblem = new ApiProblem($code, 'Testing', 'test', 'title test', ['xxcode' => 'testing']);
318318

319-
$this->assertEquals('testing', $apiProblem->__get('code'));
319+
$this->assertEquals('testing', $apiProblem->__get('xxcode'));
320320
}
321321
}

0 commit comments

Comments
 (0)