4
4
5
5
namespace yii2 \extensions \nestedsets \tests \base ;
6
6
7
- use PHPForge \Support \Assert ;
8
7
use yii \base \Behavior ;
9
8
use yii \db \ActiveRecord ;
10
9
use yii2 \extensions \nestedsets \NestedSetsBehavior ;
@@ -99,17 +98,17 @@ public function testAfterInsertCacheInvalidationIntegration(): void
99
98
);
100
99
self ::assertEquals (
101
100
0 ,
102
- Assert ::invokeMethod ($ behavior , 'getDepthValue ' ),
101
+ self ::invokeMethod ($ behavior , 'getDepthValue ' ),
103
102
"New cached depth should be '0'. " ,
104
103
);
105
104
self ::assertEquals (
106
105
1 ,
107
- Assert ::invokeMethod ($ behavior , 'getLeftValue ' ),
106
+ self ::invokeMethod ($ behavior , 'getLeftValue ' ),
108
107
"New cached left should be '1'. " ,
109
108
);
110
109
self ::assertEquals (
111
110
2 ,
112
- Assert ::invokeMethod ($ behavior , 'getRightValue ' ),
111
+ self ::invokeMethod ($ behavior , 'getRightValue ' ),
113
112
"New cached right should be '2'. " ,
114
113
);
115
114
}
@@ -284,17 +283,17 @@ public function testCacheInvalidationAfterInsertWithoutTreeAttribute(): void
284
283
285
284
self ::assertEquals (
286
285
0 ,
287
- Assert ::invokeMethod ($ behavior , 'getDepthValue ' ),
286
+ self ::invokeMethod ($ behavior , 'getDepthValue ' ),
288
287
"New cached depth value should be '0' for root. " ,
289
288
);
290
289
self ::assertEquals (
291
290
1 ,
292
- Assert ::invokeMethod ($ behavior , 'getLeftValue ' ),
291
+ self ::invokeMethod ($ behavior , 'getLeftValue ' ),
293
292
"New cached left value should be '1' for root. " ,
294
293
);
295
294
self ::assertEquals (
296
295
2 ,
297
- Assert ::invokeMethod ($ behavior , 'getRightValue ' ),
296
+ self ::invokeMethod ($ behavior , 'getRightValue ' ),
298
297
"New cached right value should be '2' for root. " ,
299
298
);
300
299
}
@@ -322,17 +321,17 @@ public function testCacheInvalidationAfterInsertWithTreeAttribute(): void
322
321
323
322
self ::assertEquals (
324
323
0 ,
325
- Assert ::invokeMethod ($ behavior , 'getDepthValue ' ),
324
+ self ::invokeMethod ($ behavior , 'getDepthValue ' ),
326
325
"New cached depth value should be '0' for root. " ,
327
326
);
328
327
self ::assertEquals (
329
328
1 ,
330
- Assert ::invokeMethod ($ behavior , 'getLeftValue ' ),
329
+ self ::invokeMethod ($ behavior , 'getLeftValue ' ),
331
330
"New cached left value should be '1' for root. " ,
332
331
);
333
332
self ::assertEquals (
334
333
2 ,
335
- Assert ::invokeMethod ($ behavior , 'getRightValue ' ),
334
+ self ::invokeMethod ($ behavior , 'getRightValue ' ),
336
335
"New cached right value should be '2' for root. " ,
337
336
);
338
337
self ::assertNotFalse (
@@ -375,17 +374,17 @@ public function testCacheInvalidationAfterMakeRoot(): void
375
374
376
375
self ::assertEquals (
377
376
$ child ->getAttribute ('depth ' ),
378
- Assert ::invokeMethod ($ behavior , 'getDepthValue ' ),
377
+ self ::invokeMethod ($ behavior , 'getDepthValue ' ),
379
378
'Initial cached depth value should match attribute. ' ,
380
379
);
381
380
self ::assertEquals (
382
381
$ child ->getAttribute ('lft ' ),
383
- Assert ::invokeMethod ($ behavior , 'getLeftValue ' ),
382
+ self ::invokeMethod ($ behavior , 'getLeftValue ' ),
384
383
'Initial cached left value should match attribute. ' ,
385
384
);
386
385
self ::assertEquals (
387
386
$ child ->getAttribute ('rgt ' ),
388
- Assert ::invokeMethod ($ behavior , 'getRightValue ' ),
387
+ self ::invokeMethod ($ behavior , 'getRightValue ' ),
389
388
'Initial cached right value should match attribute. ' ,
390
389
);
391
390
@@ -395,17 +394,17 @@ public function testCacheInvalidationAfterMakeRoot(): void
395
394
396
395
self ::assertEquals (
397
396
0 ,
398
- Assert ::invokeMethod ($ behavior , 'getDepthValue ' ),
397
+ self ::invokeMethod ($ behavior , 'getDepthValue ' ),
399
398
"New cached depth value should be '0' for root. " ,
400
399
);
401
400
self ::assertEquals (
402
401
1 ,
403
- Assert ::invokeMethod ($ behavior , 'getLeftValue ' ),
402
+ self ::invokeMethod ($ behavior , 'getLeftValue ' ),
404
403
"New cached left value should be '1' for root. " ,
405
404
);
406
405
self ::assertEquals (
407
406
2 ,
408
- Assert ::invokeMethod ($ behavior , 'getRightValue ' ),
407
+ self ::invokeMethod ($ behavior , 'getRightValue ' ),
409
408
"New cached right value should be '2' for root. " ,
410
409
);
411
410
}
@@ -434,15 +433,15 @@ public function testGetDepthValueMemoization(): void
434
433
'Behavior should be attached to the node. ' ,
435
434
);
436
435
437
- $ firstCall = Assert ::invokeMethod ($ behavior , 'getDepthValue ' );
436
+ $ firstCall = self ::invokeMethod ($ behavior , 'getDepthValue ' );
438
437
439
438
self ::assertSame (
440
439
42 ,
441
440
$ firstCall ,
442
441
'First call should return the mocked value. ' ,
443
442
);
444
443
445
- $ secondCall = Assert ::invokeMethod ($ behavior , 'getDepthValue ' );
444
+ $ secondCall = self ::invokeMethod ($ behavior , 'getDepthValue ' );
446
445
447
446
self ::assertSame (
448
447
42 ,
@@ -451,7 +450,7 @@ public function testGetDepthValueMemoization(): void
451
450
);
452
451
self ::assertSame (
453
452
42 ,
454
- Assert ::inaccessibleProperty ($ behavior , 'depthValue ' ),
453
+ self ::inaccessibleProperty ($ behavior , 'depthValue ' ),
455
454
'Depth value should be cached after first access. ' ,
456
455
);
457
456
}
@@ -480,15 +479,15 @@ public function testGetLeftValueMemoization(): void
480
479
'Behavior should be attached to the node. ' ,
481
480
);
482
481
483
- $ firstCall = Assert ::invokeMethod ($ behavior , 'getLeftValue ' );
482
+ $ firstCall = self ::invokeMethod ($ behavior , 'getLeftValue ' );
484
483
485
484
self ::assertSame (
486
485
123 ,
487
486
$ firstCall ,
488
487
'First call should return the mocked value. ' ,
489
488
);
490
489
491
- $ secondCall = Assert ::invokeMethod ($ behavior , 'getLeftValue ' );
490
+ $ secondCall = self ::invokeMethod ($ behavior , 'getLeftValue ' );
492
491
493
492
self ::assertSame (
494
493
123 ,
@@ -497,7 +496,7 @@ public function testGetLeftValueMemoization(): void
497
496
);
498
497
self ::assertSame (
499
498
123 ,
500
- Assert ::inaccessibleProperty ($ behavior , 'leftValue ' ),
499
+ self ::inaccessibleProperty ($ behavior , 'leftValue ' ),
501
500
'Left value should be cached after first access. ' ,
502
501
);
503
502
}
@@ -525,15 +524,15 @@ public function testGetRightValueMemoization(): void
525
524
'Behavior should be attached to the node. ' ,
526
525
);
527
526
528
- $ firstCall = Assert ::invokeMethod ($ behavior , 'getRightValue ' );
527
+ $ firstCall = self ::invokeMethod ($ behavior , 'getRightValue ' );
529
528
530
529
self ::assertSame (
531
530
456 ,
532
531
$ firstCall ,
533
532
'First call should return the mocked value. ' ,
534
533
);
535
534
536
- $ secondCall = Assert ::invokeMethod ($ behavior , 'getRightValue ' );
535
+ $ secondCall = self ::invokeMethod ($ behavior , 'getRightValue ' );
537
536
538
537
self ::assertSame (
539
538
456 ,
@@ -542,7 +541,7 @@ public function testGetRightValueMemoization(): void
542
541
);
543
542
self ::assertSame (
544
543
456 ,
545
- Assert ::inaccessibleProperty ($ behavior , 'rightValue ' ),
544
+ self ::inaccessibleProperty ($ behavior , 'rightValue ' ),
546
545
'Right value should be cached after first access. ' ,
547
546
);
548
547
}
@@ -570,17 +569,17 @@ public function testManualCacheInvalidation(): void
570
569
571
570
self ::assertEquals (
572
571
0 ,
573
- Assert ::invokeMethod ($ behavior , 'getDepthValue ' ),
572
+ self ::invokeMethod ($ behavior , 'getDepthValue ' ),
574
573
'Depth value should be correctly retrieved after invalidation. ' ,
575
574
);
576
575
self ::assertEquals (
577
576
1 ,
578
- Assert ::invokeMethod ($ behavior , 'getLeftValue ' ),
577
+ self ::invokeMethod ($ behavior , 'getLeftValue ' ),
579
578
'Left value should be correctly retrieved after invalidation. ' ,
580
579
);
581
580
self ::assertEquals (
582
581
2 ,
583
- Assert ::invokeMethod ($ behavior , 'getRightValue ' ),
582
+ self ::invokeMethod ($ behavior , 'getRightValue ' ),
584
583
'Right value should be correctly retrieved after invalidation. ' ,
585
584
);
586
585
}
@@ -590,20 +589,20 @@ public function testManualCacheInvalidation(): void
590
589
*/
591
590
private function populateAndVerifyCache (Behavior $ behavior ): void
592
591
{
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 ' );
596
595
597
596
self ::assertNotNull (
598
- Assert ::inaccessibleProperty ($ behavior , 'depthValue ' ),
597
+ self ::inaccessibleProperty ($ behavior , 'depthValue ' ),
599
598
'Depth value cache should be populated. ' ,
600
599
);
601
600
self ::assertNotNull (
602
- Assert ::inaccessibleProperty ($ behavior , 'leftValue ' ),
601
+ self ::inaccessibleProperty ($ behavior , 'leftValue ' ),
603
602
'Left value cache should be populated. ' ,
604
603
);
605
604
self ::assertNotNull (
606
- Assert ::inaccessibleProperty ($ behavior , 'rightValue ' ),
605
+ self ::inaccessibleProperty ($ behavior , 'rightValue ' ),
607
606
'Right value cache should be populated. ' ,
608
607
);
609
608
}
@@ -614,23 +613,23 @@ private function populateAndVerifyCache(Behavior $behavior): void
614
613
private function verifyCacheInvalidation (Behavior $ behavior ): void
615
614
{
616
615
self ::assertNull (
617
- Assert ::inaccessibleProperty ($ behavior , 'depthValue ' ),
616
+ self ::inaccessibleProperty ($ behavior , 'depthValue ' ),
618
617
"Depth value cache should be invalidated after 'makeRoot()'/'afterInsert()'. " ,
619
618
);
620
619
self ::assertNull (
621
- Assert ::inaccessibleProperty ($ behavior , 'leftValue ' ),
620
+ self ::inaccessibleProperty ($ behavior , 'leftValue ' ),
622
621
"Left value cache should be invalidated after 'makeRoot()'/'afterInsert()'. " ,
623
622
);
624
623
self ::assertNull (
625
- Assert ::inaccessibleProperty ($ behavior , 'node ' ),
624
+ self ::inaccessibleProperty ($ behavior , 'node ' ),
626
625
"Node cache should be 'null' after manual invalidation. " ,
627
626
);
628
627
self ::assertNull (
629
- Assert ::inaccessibleProperty ($ behavior , 'operation ' ),
628
+ self ::inaccessibleProperty ($ behavior , 'operation ' ),
630
629
"Operation cache should be 'null' after manual invalidation. " ,
631
630
);
632
631
self ::assertNull (
633
- Assert ::inaccessibleProperty ($ behavior , 'rightValue ' ),
632
+ self ::inaccessibleProperty ($ behavior , 'rightValue ' ),
634
633
"Right value cache should be invalidated after 'makeRoot()'/'afterInsert()'. " ,
635
634
);
636
635
}
0 commit comments