Skip to content
Merged
Changes from all 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
43 changes: 42 additions & 1 deletion tests/NestedSetsBehaviorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2052,7 +2052,7 @@ public function testPrependToWithRunValidationParameterUsingStrictValidation():
);
}

public function testProtectedApplyTreeAttributeConditionRemainAccessibleToSubclasses(): void
public function testProtectedApplyTreeAttributeConditionRemainsAccessibleToSubclasses(): void
{
$this->createDatabase();

Expand Down Expand Up @@ -2085,4 +2085,45 @@ public function testProtectedApplyTreeAttributeConditionRemainAccessibleToSubcla
'\'Tree\' attribute condition should be applied correctly when \'treeAttribute\' is enabled.',
);
}

public function testProtectedBeforeInsertNodeRemainsAccessibleToSubclasses(): 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.',
);
}
}