File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2445,6 +2445,47 @@ public function testCacheInvalidationAfterDeleteWithChildren(): void
24452445 $ this ->verifyCacheInvalidation ($ behavior );
24462446 }
24472447
2448+ public function testNodeStateAfterDeleteWithChildren (): void
2449+ {
2450+ $ this ->createDatabase ();
2451+
2452+ $ root = new Tree (['name ' => 'Root ' ]);
2453+
2454+ $ root ->makeRoot ();
2455+
2456+ $ child = new Tree (['name ' => 'Child ' ]);
2457+
2458+ $ child ->appendTo ($ root );
2459+
2460+ $ grandchild = new Tree (['name ' => 'Grandchild ' ]);
2461+
2462+ $ grandchild ->appendTo ($ child );
2463+
2464+ self ::assertFalse (
2465+ $ child ->getIsNewRecord (),
2466+ 'Child node should not be marked as new record before deletion. ' ,
2467+ );
2468+ self ::assertNotEmpty (
2469+ $ child ->getOldAttributes (),
2470+ 'Child node should have old attributes before deletion. ' ,
2471+ );
2472+
2473+ $ result = $ child ->deleteWithChildren ();
2474+
2475+ self ::assertNotFalse (
2476+ $ result ,
2477+ 'DeleteWithChildren should return the number of deleted rows. ' ,
2478+ );
2479+ self ::assertTrue (
2480+ $ child ->getIsNewRecord (),
2481+ "Child node should be marked as new record after deletion ('setOldAttributes(null)' effect). " ,
2482+ );
2483+ self ::assertEmpty (
2484+ $ child ->getOldAttributes (),
2485+ 'Child node should have empty old attributes after deletion. ' ,
2486+ );
2487+ }
2488+
24482489 public function testManualCacheInvalidation (): void
24492490 {
24502491 $ this ->createDatabase ();
You can’t perform that action at this time.
0 commit comments