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
41 changes: 41 additions & 0 deletions tests/NestedSetsBehaviorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2445,6 +2445,47 @@ public function testCacheInvalidationAfterDeleteWithChildren(): void
$this->verifyCacheInvalidation($behavior);
}

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

$root = new Tree(['name' => 'Root']);

$root->makeRoot();

$child = new Tree(['name' => 'Child']);

$child->appendTo($root);

$grandchild = new Tree(['name' => 'Grandchild']);

$grandchild->appendTo($child);

self::assertFalse(
$child->getIsNewRecord(),
'Child node should not be marked as new record before deletion.',
);
self::assertNotEmpty(
$child->getOldAttributes(),
'Child node should have old attributes before deletion.',
);

$result = $child->deleteWithChildren();

self::assertNotFalse(
$result,
'DeleteWithChildren should return the number of deleted rows.',
);
self::assertTrue(
$child->getIsNewRecord(),
"Child node should be marked as new record after deletion ('setOldAttributes(null)' effect).",
);
self::assertEmpty(
$child->getOldAttributes(),
'Child node should have empty old attributes after deletion.',
);
}

public function testManualCacheInvalidation(): void
{
$this->createDatabase();
Expand Down
Loading