From bf9427bba5c57e5e4085829e9a63a0e5c6f8fd5a Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Mon, 30 Jun 2025 08:32:55 -0400 Subject: [PATCH 1/2] test: Add verification for protected method `beforeInsertNode` accessibility in subclasses of `NestedSetsBehavior`. --- tests/NestedSetsBehaviorTest.php | 41 ++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/tests/NestedSetsBehaviorTest.php b/tests/NestedSetsBehaviorTest.php index a675ae5..d29a256 100644 --- a/tests/NestedSetsBehaviorTest.php +++ b/tests/NestedSetsBehaviorTest.php @@ -2085,4 +2085,45 @@ public function testProtectedApplyTreeAttributeConditionRemainAccessibleToSubcla '\'Tree\' attribute condition should be applied correctly when \'treeAttribute\' is enabled.', ); } + + public function testProtectedBeforeInsertNodeRemainAccessibleToSubclasses(): void + { + $this->createDatabase(); + + $testNode = new ExtendableMultipleTree([ + 'name' => 'Extensibility Test Node', + 'tree' => 1, + ]); + + $extendableBehavior = $testNode->getBehavior('nestedSetsBehavior'); + + self::assertInstanceOf( + ExtendableNestedSetsBehavior::class, + $extendableBehavior, + '\'ExtendableMultipleTree\' should use \'ExtendableNestedSetsBehavior\'.', + ); + + $extendableBehavior->exposedBeforeInsertNode(5, 1); + + self::assertTrue( + $extendableBehavior->wasMethodCalled('beforeInsertNode'), + '\'beforeInsertNode\' method should remain protected to allow subclass customization.', + ); + + self::assertEquals( + 5, + $testNode->lft, + '\'beforeInsertNode\' should set the \'left\' attribute correctly.', + ); + self::assertEquals( + 6, + $testNode->rgt, + '\'beforeInsertNode\' should set the \'right\' attribute correctly.', + ); + self::assertEquals( + 1, + $testNode->depth, + '\'beforeInsertNode\' should set the \'depth\' attribute correctly.', + ); + } } From 79b1b73bb79b3b1f1c244d36c20dce7d36385d24 Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Mon, 30 Jun 2025 08:39:23 -0400 Subject: [PATCH 2/2] fix: Correct method names in test cases for protected accessibility in subclasses. --- tests/NestedSetsBehaviorTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/NestedSetsBehaviorTest.php b/tests/NestedSetsBehaviorTest.php index d29a256..845070d 100644 --- a/tests/NestedSetsBehaviorTest.php +++ b/tests/NestedSetsBehaviorTest.php @@ -2052,7 +2052,7 @@ public function testPrependToWithRunValidationParameterUsingStrictValidation(): ); } - public function testProtectedApplyTreeAttributeConditionRemainAccessibleToSubclasses(): void + public function testProtectedApplyTreeAttributeConditionRemainsAccessibleToSubclasses(): void { $this->createDatabase(); @@ -2086,7 +2086,7 @@ public function testProtectedApplyTreeAttributeConditionRemainAccessibleToSubcla ); } - public function testProtectedBeforeInsertNodeRemainAccessibleToSubclasses(): void + public function testProtectedBeforeInsertNodeRemainsAccessibleToSubclasses(): void { $this->createDatabase();