44
55namespace yii2 \extensions \nestedsets \tests \base ;
66
7- use PHPForge \Support \Assert ;
87use yii \base \Behavior ;
98use yii \db \ActiveRecord ;
109use yii2 \extensions \nestedsets \NestedSetsBehavior ;
@@ -99,17 +98,17 @@ public function testAfterInsertCacheInvalidationIntegration(): void
9998 );
10099 self ::assertEquals (
101100 0 ,
102- Assert ::invokeMethod ($ behavior , 'getDepthValue ' ),
101+ self ::invokeMethod ($ behavior , 'getDepthValue ' ),
103102 "New cached depth should be '0'. " ,
104103 );
105104 self ::assertEquals (
106105 1 ,
107- Assert ::invokeMethod ($ behavior , 'getLeftValue ' ),
106+ self ::invokeMethod ($ behavior , 'getLeftValue ' ),
108107 "New cached left should be '1'. " ,
109108 );
110109 self ::assertEquals (
111110 2 ,
112- Assert ::invokeMethod ($ behavior , 'getRightValue ' ),
111+ self ::invokeMethod ($ behavior , 'getRightValue ' ),
113112 "New cached right should be '2'. " ,
114113 );
115114 }
@@ -284,17 +283,17 @@ public function testCacheInvalidationAfterInsertWithoutTreeAttribute(): void
284283
285284 self ::assertEquals (
286285 0 ,
287- Assert ::invokeMethod ($ behavior , 'getDepthValue ' ),
286+ self ::invokeMethod ($ behavior , 'getDepthValue ' ),
288287 "New cached depth value should be '0' for root. " ,
289288 );
290289 self ::assertEquals (
291290 1 ,
292- Assert ::invokeMethod ($ behavior , 'getLeftValue ' ),
291+ self ::invokeMethod ($ behavior , 'getLeftValue ' ),
293292 "New cached left value should be '1' for root. " ,
294293 );
295294 self ::assertEquals (
296295 2 ,
297- Assert ::invokeMethod ($ behavior , 'getRightValue ' ),
296+ self ::invokeMethod ($ behavior , 'getRightValue ' ),
298297 "New cached right value should be '2' for root. " ,
299298 );
300299 }
@@ -322,17 +321,17 @@ public function testCacheInvalidationAfterInsertWithTreeAttribute(): void
322321
323322 self ::assertEquals (
324323 0 ,
325- Assert ::invokeMethod ($ behavior , 'getDepthValue ' ),
324+ self ::invokeMethod ($ behavior , 'getDepthValue ' ),
326325 "New cached depth value should be '0' for root. " ,
327326 );
328327 self ::assertEquals (
329328 1 ,
330- Assert ::invokeMethod ($ behavior , 'getLeftValue ' ),
329+ self ::invokeMethod ($ behavior , 'getLeftValue ' ),
331330 "New cached left value should be '1' for root. " ,
332331 );
333332 self ::assertEquals (
334333 2 ,
335- Assert ::invokeMethod ($ behavior , 'getRightValue ' ),
334+ self ::invokeMethod ($ behavior , 'getRightValue ' ),
336335 "New cached right value should be '2' for root. " ,
337336 );
338337 self ::assertNotFalse (
@@ -375,17 +374,17 @@ public function testCacheInvalidationAfterMakeRoot(): void
375374
376375 self ::assertEquals (
377376 $ child ->getAttribute ('depth ' ),
378- Assert ::invokeMethod ($ behavior , 'getDepthValue ' ),
377+ self ::invokeMethod ($ behavior , 'getDepthValue ' ),
379378 'Initial cached depth value should match attribute. ' ,
380379 );
381380 self ::assertEquals (
382381 $ child ->getAttribute ('lft ' ),
383- Assert ::invokeMethod ($ behavior , 'getLeftValue ' ),
382+ self ::invokeMethod ($ behavior , 'getLeftValue ' ),
384383 'Initial cached left value should match attribute. ' ,
385384 );
386385 self ::assertEquals (
387386 $ child ->getAttribute ('rgt ' ),
388- Assert ::invokeMethod ($ behavior , 'getRightValue ' ),
387+ self ::invokeMethod ($ behavior , 'getRightValue ' ),
389388 'Initial cached right value should match attribute. ' ,
390389 );
391390
@@ -395,17 +394,17 @@ public function testCacheInvalidationAfterMakeRoot(): void
395394
396395 self ::assertEquals (
397396 0 ,
398- Assert ::invokeMethod ($ behavior , 'getDepthValue ' ),
397+ self ::invokeMethod ($ behavior , 'getDepthValue ' ),
399398 "New cached depth value should be '0' for root. " ,
400399 );
401400 self ::assertEquals (
402401 1 ,
403- Assert ::invokeMethod ($ behavior , 'getLeftValue ' ),
402+ self ::invokeMethod ($ behavior , 'getLeftValue ' ),
404403 "New cached left value should be '1' for root. " ,
405404 );
406405 self ::assertEquals (
407406 2 ,
408- Assert ::invokeMethod ($ behavior , 'getRightValue ' ),
407+ self ::invokeMethod ($ behavior , 'getRightValue ' ),
409408 "New cached right value should be '2' for root. " ,
410409 );
411410 }
@@ -434,15 +433,15 @@ public function testGetDepthValueMemoization(): void
434433 'Behavior should be attached to the node. ' ,
435434 );
436435
437- $ firstCall = Assert ::invokeMethod ($ behavior , 'getDepthValue ' );
436+ $ firstCall = self ::invokeMethod ($ behavior , 'getDepthValue ' );
438437
439438 self ::assertSame (
440439 42 ,
441440 $ firstCall ,
442441 'First call should return the mocked value. ' ,
443442 );
444443
445- $ secondCall = Assert ::invokeMethod ($ behavior , 'getDepthValue ' );
444+ $ secondCall = self ::invokeMethod ($ behavior , 'getDepthValue ' );
446445
447446 self ::assertSame (
448447 42 ,
@@ -451,7 +450,7 @@ public function testGetDepthValueMemoization(): void
451450 );
452451 self ::assertSame (
453452 42 ,
454- Assert ::inaccessibleProperty ($ behavior , 'depthValue ' ),
453+ self ::inaccessibleProperty ($ behavior , 'depthValue ' ),
455454 'Depth value should be cached after first access. ' ,
456455 );
457456 }
@@ -480,15 +479,15 @@ public function testGetLeftValueMemoization(): void
480479 'Behavior should be attached to the node. ' ,
481480 );
482481
483- $ firstCall = Assert ::invokeMethod ($ behavior , 'getLeftValue ' );
482+ $ firstCall = self ::invokeMethod ($ behavior , 'getLeftValue ' );
484483
485484 self ::assertSame (
486485 123 ,
487486 $ firstCall ,
488487 'First call should return the mocked value. ' ,
489488 );
490489
491- $ secondCall = Assert ::invokeMethod ($ behavior , 'getLeftValue ' );
490+ $ secondCall = self ::invokeMethod ($ behavior , 'getLeftValue ' );
492491
493492 self ::assertSame (
494493 123 ,
@@ -497,7 +496,7 @@ public function testGetLeftValueMemoization(): void
497496 );
498497 self ::assertSame (
499498 123 ,
500- Assert ::inaccessibleProperty ($ behavior , 'leftValue ' ),
499+ self ::inaccessibleProperty ($ behavior , 'leftValue ' ),
501500 'Left value should be cached after first access. ' ,
502501 );
503502 }
@@ -525,15 +524,15 @@ public function testGetRightValueMemoization(): void
525524 'Behavior should be attached to the node. ' ,
526525 );
527526
528- $ firstCall = Assert ::invokeMethod ($ behavior , 'getRightValue ' );
527+ $ firstCall = self ::invokeMethod ($ behavior , 'getRightValue ' );
529528
530529 self ::assertSame (
531530 456 ,
532531 $ firstCall ,
533532 'First call should return the mocked value. ' ,
534533 );
535534
536- $ secondCall = Assert ::invokeMethod ($ behavior , 'getRightValue ' );
535+ $ secondCall = self ::invokeMethod ($ behavior , 'getRightValue ' );
537536
538537 self ::assertSame (
539538 456 ,
@@ -542,7 +541,7 @@ public function testGetRightValueMemoization(): void
542541 );
543542 self ::assertSame (
544543 456 ,
545- Assert ::inaccessibleProperty ($ behavior , 'rightValue ' ),
544+ self ::inaccessibleProperty ($ behavior , 'rightValue ' ),
546545 'Right value should be cached after first access. ' ,
547546 );
548547 }
@@ -570,17 +569,17 @@ public function testManualCacheInvalidation(): void
570569
571570 self ::assertEquals (
572571 0 ,
573- Assert ::invokeMethod ($ behavior , 'getDepthValue ' ),
572+ self ::invokeMethod ($ behavior , 'getDepthValue ' ),
574573 'Depth value should be correctly retrieved after invalidation. ' ,
575574 );
576575 self ::assertEquals (
577576 1 ,
578- Assert ::invokeMethod ($ behavior , 'getLeftValue ' ),
577+ self ::invokeMethod ($ behavior , 'getLeftValue ' ),
579578 'Left value should be correctly retrieved after invalidation. ' ,
580579 );
581580 self ::assertEquals (
582581 2 ,
583- Assert ::invokeMethod ($ behavior , 'getRightValue ' ),
582+ self ::invokeMethod ($ behavior , 'getRightValue ' ),
584583 'Right value should be correctly retrieved after invalidation. ' ,
585584 );
586585 }
@@ -590,20 +589,20 @@ public function testManualCacheInvalidation(): void
590589 */
591590 private function populateAndVerifyCache (Behavior $ behavior ): void
592591 {
593- Assert ::invokeMethod ($ behavior , 'getDepthValue ' );
594- Assert ::invokeMethod ($ behavior , 'getLeftValue ' );
595- Assert ::invokeMethod ($ behavior , 'getRightValue ' );
592+ self ::invokeMethod ($ behavior , 'getDepthValue ' );
593+ self ::invokeMethod ($ behavior , 'getLeftValue ' );
594+ self ::invokeMethod ($ behavior , 'getRightValue ' );
596595
597596 self ::assertNotNull (
598- Assert ::inaccessibleProperty ($ behavior , 'depthValue ' ),
597+ self ::inaccessibleProperty ($ behavior , 'depthValue ' ),
599598 'Depth value cache should be populated. ' ,
600599 );
601600 self ::assertNotNull (
602- Assert ::inaccessibleProperty ($ behavior , 'leftValue ' ),
601+ self ::inaccessibleProperty ($ behavior , 'leftValue ' ),
603602 'Left value cache should be populated. ' ,
604603 );
605604 self ::assertNotNull (
606- Assert ::inaccessibleProperty ($ behavior , 'rightValue ' ),
605+ self ::inaccessibleProperty ($ behavior , 'rightValue ' ),
607606 'Right value cache should be populated. ' ,
608607 );
609608 }
@@ -614,23 +613,23 @@ private function populateAndVerifyCache(Behavior $behavior): void
614613 private function verifyCacheInvalidation (Behavior $ behavior ): void
615614 {
616615 self ::assertNull (
617- Assert ::inaccessibleProperty ($ behavior , 'depthValue ' ),
616+ self ::inaccessibleProperty ($ behavior , 'depthValue ' ),
618617 "Depth value cache should be invalidated after 'makeRoot()'/'afterInsert()'. " ,
619618 );
620619 self ::assertNull (
621- Assert ::inaccessibleProperty ($ behavior , 'leftValue ' ),
620+ self ::inaccessibleProperty ($ behavior , 'leftValue ' ),
622621 "Left value cache should be invalidated after 'makeRoot()'/'afterInsert()'. " ,
623622 );
624623 self ::assertNull (
625- Assert ::inaccessibleProperty ($ behavior , 'node ' ),
624+ self ::inaccessibleProperty ($ behavior , 'node ' ),
626625 "Node cache should be 'null' after manual invalidation. " ,
627626 );
628627 self ::assertNull (
629- Assert ::inaccessibleProperty ($ behavior , 'operation ' ),
628+ self ::inaccessibleProperty ($ behavior , 'operation ' ),
630629 "Operation cache should be 'null' after manual invalidation. " ,
631630 );
632631 self ::assertNull (
633- Assert ::inaccessibleProperty ($ behavior , 'rightValue ' ),
632+ self ::inaccessibleProperty ($ behavior , 'rightValue ' ),
634633 "Right value cache should be invalidated after 'makeRoot()'/'afterInsert()'. " ,
635634 );
636635 }
0 commit comments