diff --git a/composer.json b/composer.json index 01b9b17..715a066 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/tests/NestedSetsBehaviorTest.php b/tests/NestedSetsBehaviorTest.php index 4e6cab8..719c9a3 100644 --- a/tests/NestedSetsBehaviorTest.php +++ b/tests/NestedSetsBehaviorTest.php @@ -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();