Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"require-dev": {
"ext-simplexml": "*",
"infection/infection": "^0.27|^0.29",
"infection/infection": "^0.27|^0.30",
"maglnet/composer-require-checker": "^4.1",
"php-forge/support": "^0.1",
"phpstan/extension-installer": "^1.4",
Expand Down
46 changes: 46 additions & 0 deletions tests/NestedSetsBehaviorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1388,6 +1388,52 @@ public function testReturnIsChildOfForMultipleTreeNodeUnderVariousAncestors(): v
);
}

public function testIsChildOfReturnsFalseWhenLeftValuesAreEqual(): void
{
$this->generateFixtureTree();

$parentNode = Tree::findOne(2);
$childNode = Tree::findOne(3);

self::assertNotNull($parentNode, 'Parent node should exist for boundary testing.');
self::assertNotNull($childNode, 'Child node should exist for boundary testing.');

$originalChildLeft = $childNode->getAttribute('lft');

$parentLeft = $parentNode->getAttribute('lft');
$childNode->setAttribute('lft', $parentLeft);

self::assertFalse(
$childNode->isChildOf($parentNode),
'Node should not be child when left values are equal (tests <= condition).'
);

$childNode->setAttribute('lft', $originalChildLeft);
}

public function testIsChildOfReturnsFalseWhenRightValuesAreEqual(): void
{
$this->generateFixtureTree();

$parentNode = Tree::findOne(2);
$childNode = Tree::findOne(3);

self::assertNotNull($parentNode, 'Parent node should exist for boundary testing.');
self::assertNotNull($childNode, 'Child node should exist for boundary testing.');

$originalChildRight = $childNode->getAttribute('rgt');

$parentRight = $parentNode->getAttribute('rgt');
$childNode->setAttribute('rgt', $parentRight);

self::assertFalse(
$childNode->isChildOf($parentNode),
'Node should not be child when right values are equal (tests >= condition).'
);

$childNode->setAttribute('rgt', $originalChildRight);
}

public function testIsLeafReturnsTrueForLeafAndFalseForRoot(): void
{
$this->generateFixtureTree();
Expand Down
Loading