Skip to content

Commit 8ed0a2f

Browse files
committed
test: add test of ltree immutability on getParent() call
and fix @phpstan-ignore annotation position for clarity. Signed-off-by: Pierre-Yves Landuré <pierre-yves@landure.fr>
1 parent ec68aa7 commit 8ed0a2f

File tree

1 file changed

+10
-2
lines changed
  • tests/Unit/MartinGeorgiev/Doctrine/DBAL/Types/ValueObject

1 file changed

+10
-2
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,15 @@ public function test_get_parent(): void
8080
self::assertSame('a.b', (string) $parent);
8181
}
8282

83+
public function test_get_parent_respect_immutability(): void
84+
{
85+
$ltree = new Ltree(['a', 'b', 'c']);
86+
$parent = $ltree->getParent();
87+
self::assertNotSame($ltree, $parent);
88+
self::assertSame(['a', 'b', 'c'], $ltree->getBranch());
89+
self::assertSame('a.b.c', (string) $ltree);
90+
}
91+
8392
public function test_get_parent_on_root(): void
8493
{
8594
$ltree = new Ltree(['a']);
@@ -97,8 +106,7 @@ public function test_create_leaf_empty_throws(): void
97106
{
98107
$ltree = new Ltree(['a']);
99108
$this->expectException(\InvalidArgumentException::class);
100-
// @phpstan-ignore-next-line argument.type - Testing invalid type handling
101-
$ltree->createLeaf('');
109+
$ltree->createLeaf(''); // @phpstan-ignore argument.type
102110
}
103111

104112
public function test_create_leaf_with_dot_throws(): void

0 commit comments

Comments
 (0)