Skip to content

Commit 9266f83

Browse files
test: Add verification for protected method beforeInsertNode accessibility in subclasses of NestedSetsBehavior. (#32)
1 parent 29619a6 commit 9266f83

1 file changed

Lines changed: 42 additions & 1 deletion

File tree

tests/NestedSetsBehaviorTest.php

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2052,7 +2052,7 @@ public function testPrependToWithRunValidationParameterUsingStrictValidation():
20522052
);
20532053
}
20542054

2055-
public function testProtectedApplyTreeAttributeConditionRemainAccessibleToSubclasses(): void
2055+
public function testProtectedApplyTreeAttributeConditionRemainsAccessibleToSubclasses(): void
20562056
{
20572057
$this->createDatabase();
20582058

@@ -2085,4 +2085,45 @@ public function testProtectedApplyTreeAttributeConditionRemainAccessibleToSubcla
20852085
'\'Tree\' attribute condition should be applied correctly when \'treeAttribute\' is enabled.',
20862086
);
20872087
}
2088+
2089+
public function testProtectedBeforeInsertNodeRemainsAccessibleToSubclasses(): void
2090+
{
2091+
$this->createDatabase();
2092+
2093+
$testNode = new ExtendableMultipleTree([
2094+
'name' => 'Extensibility Test Node',
2095+
'tree' => 1,
2096+
]);
2097+
2098+
$extendableBehavior = $testNode->getBehavior('nestedSetsBehavior');
2099+
2100+
self::assertInstanceOf(
2101+
ExtendableNestedSetsBehavior::class,
2102+
$extendableBehavior,
2103+
'\'ExtendableMultipleTree\' should use \'ExtendableNestedSetsBehavior\'.',
2104+
);
2105+
2106+
$extendableBehavior->exposedBeforeInsertNode(5, 1);
2107+
2108+
self::assertTrue(
2109+
$extendableBehavior->wasMethodCalled('beforeInsertNode'),
2110+
'\'beforeInsertNode\' method should remain protected to allow subclass customization.',
2111+
);
2112+
2113+
self::assertEquals(
2114+
5,
2115+
$testNode->lft,
2116+
'\'beforeInsertNode\' should set the \'left\' attribute correctly.',
2117+
);
2118+
self::assertEquals(
2119+
6,
2120+
$testNode->rgt,
2121+
'\'beforeInsertNode\' should set the \'right\' attribute correctly.',
2122+
);
2123+
self::assertEquals(
2124+
1,
2125+
$testNode->depth,
2126+
'\'beforeInsertNode\' should set the \'depth\' attribute correctly.',
2127+
);
2128+
}
20882129
}

0 commit comments

Comments
 (0)