Skip to content

Commit 12d6c8a

Browse files
committed
test: add Ltree::fromString() error conditions test
1 parent a2eeba6 commit 12d6c8a

File tree

1 file changed

+16
-1
lines changed
  • tests/Unit/MartinGeorgiev/Doctrine/DBAL/Types/ValueObject

1 file changed

+16
-1
lines changed

tests/Unit/MartinGeorgiev/Doctrine/DBAL/Types/ValueObject/LtreeTest.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,22 @@ public static function badPathFromRootProvider(): iterable
3939
yield 'list with dotted string' => [['a', 'b.c', 'ds']];
4040
}
4141

42+
#[DataProvider('badRepresentationProvider')]
43+
public function test_from_string_throws_on_bad_value(string $value): void
44+
{
45+
$this->expectException(\InvalidArgumentException::class);
46+
Ltree::fromString($value);
47+
}
48+
49+
/**
50+
* @return iterable<string, string[]>
51+
*/
52+
public static function badRepresentationProvider(): iterable
53+
{
54+
yield 'string starting with dot' => ['.b'];
55+
yield 'string ending with dot' => ['a.'];
56+
}
57+
4258
/**
4359
* @param list<non-empty-string> $expected
4460
*/
@@ -95,7 +111,6 @@ public function test_json_encode(): void
95111
#[DataProvider('parentProvider')]
96112
public function test_get_parent(LtreeInterface $child, LtreeInterface $parent): void
97113
{
98-
$child->getPathFromRoot();
99114
$ltree = $child->getParent();
100115
self::assertSame((string) $parent, (string) $ltree);
101116
}

0 commit comments

Comments
 (0)