Skip to content

Commit 5370e5b

Browse files
maltehuebnerclaude
andcommitted
Adapt tests to verify array and non-string parameter conversion
Replace TypeError expectations with assertions that verify correct string conversion of arrays, integers, floats, and booleans in list converters. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 4727b26 commit 5370e5b

3 files changed

Lines changed: 43 additions & 15 deletions

File tree

tests/RequestParameterList/ArrayToListConverterTest.php

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,39 @@ public function testConvertSimpleArray(): void
2929
$this->assertSame('6', $result->get('month'));
3030
}
3131

32-
public function testConvertNonStringValueThrowsTypeError(): void
32+
public function testConvertIntegerValueToString(): void
3333
{
34-
$this->expectException(\TypeError::class);
35-
36-
ArrayToListConverter::convert([
34+
$result = ArrayToListConverter::convert([
3735
'size' => 25,
3836
]);
37+
38+
$this->assertSame('25', $result->get('size'));
39+
}
40+
41+
public function testConvertArrayValueToCommaSeparatedString(): void
42+
{
43+
$result = ArrayToListConverter::convert([
44+
'tags' => ['foo', 'bar', 'baz'],
45+
]);
46+
47+
$this->assertSame('foo,bar,baz', $result->get('tags'));
48+
}
49+
50+
public function testConvertFloatValueToString(): void
51+
{
52+
$result = ArrayToListConverter::convert([
53+
'latitude' => 52.52,
54+
]);
55+
56+
$this->assertSame('52.52', $result->get('latitude'));
57+
}
58+
59+
public function testConvertBooleanValueToString(): void
60+
{
61+
$result = ArrayToListConverter::convert([
62+
'enabled' => true,
63+
]);
64+
65+
$this->assertSame('1', $result->get('enabled'));
3966
}
4067
}

tests/RequestParameterList/QueryStringToListConverterTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,12 @@ public function testConvertQueryStringWithUrlEncodedValues(): void
4848
$this->assertSame('München', $result->get('city'));
4949
}
5050

51-
public function testConvertQueryStringWithArrayParametersThrowsTypeError(): void
51+
public function testConvertQueryStringWithArrayParameters(): void
5252
{
53-
$this->expectException(\TypeError::class);
53+
$result = QueryStringToListConverter::convert('tags[]=foo&tags[]=bar');
5454

55-
QueryStringToListConverter::convert('tags[]=foo&tags[]=bar');
55+
$this->assertTrue($result->has('tags'));
56+
$this->assertSame('foo,bar', $result->get('tags'));
5657
}
5758

5859
public function testConvertQueryStringWithMultipleParameters(): void

tests/RequestParameterList/RequestToListConverterTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,22 @@ public function testConvertEmptyRequest(): void
2929
$this->assertSame([], $result->getList());
3030
}
3131

32-
public function testConvertRequestWithArrayQueryParameterThrowsTypeError(): void
32+
public function testConvertRequestWithArrayQueryParameter(): void
3333
{
34-
$this->expectException(\TypeError::class);
35-
3634
$request = Request::create('/test', 'GET', ['tags' => ['foo', 'bar']]);
3735

38-
RequestToListConverter::convert($request);
36+
$result = RequestToListConverter::convert($request);
37+
38+
$this->assertSame('foo,bar', $result->get('tags'));
3939
}
4040

41-
public function testConvertRequestWithIntegerQueryParameterThrowsTypeError(): void
41+
public function testConvertRequestWithIntegerQueryParameter(): void
4242
{
43-
$this->expectException(\TypeError::class);
44-
4543
$request = Request::create('/test', 'GET', ['size' => 25]);
4644

47-
RequestToListConverter::convert($request);
45+
$result = RequestToListConverter::convert($request);
46+
47+
$this->assertSame('25', $result->get('size'));
4848
}
4949

5050
public function testConvertRequestWithMultipleParameters(): void

0 commit comments

Comments
 (0)