Skip to content

Commit c4d8bf8

Browse files
committed
fix: improve type validation in LtreeTypeTest
1 parent 6b44461 commit c4d8bf8

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

tests/Integration/MartinGeorgiev/Doctrine/DBAL/Types/LtreeTypeTest.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,20 @@ public function can_handle_string_values(): void
5151
*/
5252
protected function assertTypeValueEquals(mixed $expected, mixed $actual, string $typeName): void
5353
{
54-
if (!$expected instanceof LtreeValueObject && !\is_string($expected) || !$actual instanceof LtreeValueObject) {
55-
throw new \InvalidArgumentException('LtreeTypeTest expects Ltree value objects.');
54+
if (!$actual instanceof LtreeValueObject) {
55+
throw new \InvalidArgumentException('LtreeTypeTest expects actual value to be a Ltree object');
56+
}
57+
58+
if (!$expected instanceof LtreeValueObject && !\is_string($expected)) {
59+
throw new \InvalidArgumentException('LtreeTypeTest expects expected value to be a Ltree object or string');
5660
}
5761

5862
$this->assertLtreeEquals($expected, $actual, $typeName);
5963
}
6064

6165
#[DataProvider('provideValidTransformations')]
6266
#[Test]
63-
public function can_handle_ltree_values(string $testName, LtreeValueObject $ltreeValueObject): void
67+
public function can_handle_ltree_values(LtreeValueObject $ltreeValueObject): void
6468
{
6569
$typeName = $this->getTypeName();
6670
$columnType = $this->getPostgresTypeName();
@@ -69,15 +73,15 @@ public function can_handle_ltree_values(string $testName, LtreeValueObject $ltre
6973
}
7074

7175
/**
72-
* @return array<string, array{string, ?LtreeValueObject}>
76+
* @return array<string, array{LtreeValueObject}>
7377
*/
7478
public static function provideValidTransformations(): array
7579
{
7680
return [
77-
'ltree simple string' => ['ltree simple string', new LtreeValueObject(['foo', 'bar', 'baz'])],
78-
'ltree simple numeric' => ['ltree simple numeric', new LtreeValueObject(['1', '2', '3'])],
79-
'ltree single numeric' => ['ltree single numeric', new LtreeValueObject(['1'])],
80-
'ltree empty' => ['ltree empty', new LtreeValueObject([])],
81+
'ltree simple string' => [new LtreeValueObject(['foo', 'bar', 'baz'])],
82+
'ltree simple numeric' => [new LtreeValueObject(['1', '2', '3'])],
83+
'ltree single numeric' => [new LtreeValueObject(['1'])],
84+
'ltree empty' => [new LtreeValueObject([])],
8185
];
8286
}
8387

0 commit comments

Comments
 (0)