@@ 453-508 (lines=56) @@ | ||
450 | $this->assertTrue($this->checkArrayWithManyRoots($array)); |
|
451 | } |
|
452 | ||
453 | public function testMoveBefore() |
|
454 | { |
|
455 | // single root |
|
456 | $array=NestedSet::model()->findAll(); |
|
457 | ||
458 | $nestedSet=NestedSet::model()->findByPk(6); |
|
459 | $this->assertTrue($nestedSet instanceof NestedSet); |
|
460 | $target=NestedSet::model()->findByPk(2); |
|
461 | $this->assertTrue($target instanceof NestedSet); |
|
462 | $this->assertTrue($nestedSet->moveBefore($target)); |
|
463 | $this->assertTrue($this->checkTree()); |
|
464 | ||
465 | $this->assertTrue($this->checkArray($array)); |
|
466 | ||
467 | $nestedSet=NestedSet::model()->findByPk(5); |
|
468 | $this->assertTrue($nestedSet instanceof NestedSet); |
|
469 | $this->assertTrue($nestedSet->moveBefore($target)); |
|
470 | $this->assertTrue($this->checkTree()); |
|
471 | ||
472 | $this->assertTrue($this->checkArray($array)); |
|
473 | ||
474 | // many roots |
|
475 | $array=NestedSetWithManyRoots::model()->findAll(); |
|
476 | ||
477 | $nestedSet=NestedSetWithManyRoots::model()->findByPk(6); |
|
478 | $this->assertTrue($nestedSet instanceof NestedSetWithManyRoots); |
|
479 | $target=NestedSetWithManyRoots::model()->findByPk(2); |
|
480 | $this->assertTrue($target instanceof NestedSetWithManyRoots); |
|
481 | $this->assertTrue($nestedSet->moveBefore($target)); |
|
482 | $this->assertTrue($this->checkTreeWithManyRoots()); |
|
483 | ||
484 | $this->assertTrue($this->checkArrayWithManyRoots($array)); |
|
485 | ||
486 | $nestedSet=NestedSetWithManyRoots::model()->findByPk(5); |
|
487 | $this->assertTrue($nestedSet instanceof NestedSetWithManyRoots); |
|
488 | $this->assertTrue($nestedSet->moveBefore($target)); |
|
489 | $this->assertTrue($this->checkTreeWithManyRoots()); |
|
490 | ||
491 | $this->assertTrue($this->checkArrayWithManyRoots($array)); |
|
492 | ||
493 | $nestedSet=NestedSetWithManyRoots::model()->findByPk(6); |
|
494 | $this->assertTrue($nestedSet instanceof NestedSetWithManyRoots); |
|
495 | $target=NestedSetWithManyRoots::model()->findByPk(9); |
|
496 | $this->assertTrue($target instanceof NestedSetWithManyRoots); |
|
497 | $this->assertTrue($nestedSet->moveBefore($target)); |
|
498 | $this->assertTrue($this->checkTreeWithManyRoots()); |
|
499 | ||
500 | $this->assertTrue($this->checkArrayWithManyRoots($array)); |
|
501 | ||
502 | $nestedSet=NestedSetWithManyRoots::model()->findByPk(5); |
|
503 | $this->assertTrue($nestedSet instanceof NestedSetWithManyRoots); |
|
504 | $this->assertTrue($nestedSet->moveBefore($target)); |
|
505 | $this->assertTrue($this->checkTreeWithManyRoots()); |
|
506 | ||
507 | $this->assertTrue($this->checkArrayWithManyRoots($array)); |
|
508 | } |
|
509 | ||
510 | public function testMoveAfter() |
|
511 | { |
|
@@ 510-565 (lines=56) @@ | ||
507 | $this->assertTrue($this->checkArrayWithManyRoots($array)); |
|
508 | } |
|
509 | ||
510 | public function testMoveAfter() |
|
511 | { |
|
512 | // single root |
|
513 | $array=NestedSet::model()->findAll(); |
|
514 | ||
515 | $nestedSet=NestedSet::model()->findByPk(3); |
|
516 | $this->assertTrue($nestedSet instanceof NestedSet); |
|
517 | $target=NestedSet::model()->findByPk(5); |
|
518 | $this->assertTrue($target instanceof NestedSet); |
|
519 | $this->assertTrue($nestedSet->moveAfter($target)); |
|
520 | $this->assertTrue($this->checkTree()); |
|
521 | ||
522 | $this->assertTrue($this->checkArray($array)); |
|
523 | ||
524 | $nestedSet=NestedSet::model()->findByPk(2); |
|
525 | $this->assertTrue($nestedSet instanceof NestedSet); |
|
526 | $this->assertTrue($nestedSet->moveAfter($target)); |
|
527 | $this->assertTrue($this->checkTree()); |
|
528 | ||
529 | $this->assertTrue($this->checkArray($array)); |
|
530 | ||
531 | // many roots |
|
532 | $array=NestedSetWithManyRoots::model()->findAll(); |
|
533 | ||
534 | $nestedSet=NestedSetWithManyRoots::model()->findByPk(3); |
|
535 | $this->assertTrue($nestedSet instanceof NestedSetWithManyRoots); |
|
536 | $target=NestedSetWithManyRoots::model()->findByPk(5); |
|
537 | $this->assertTrue($target instanceof NestedSetWithManyRoots); |
|
538 | $this->assertTrue($nestedSet->moveAfter($target)); |
|
539 | $this->assertTrue($this->checkTreeWithManyRoots()); |
|
540 | ||
541 | $this->assertTrue($this->checkArrayWithManyRoots($array)); |
|
542 | ||
543 | $nestedSet=NestedSetWithManyRoots::model()->findByPk(2); |
|
544 | $this->assertTrue($nestedSet instanceof NestedSetWithManyRoots); |
|
545 | $this->assertTrue($nestedSet->moveAfter($target)); |
|
546 | $this->assertTrue($this->checkTreeWithManyRoots()); |
|
547 | ||
548 | $this->assertTrue($this->checkArrayWithManyRoots($array)); |
|
549 | ||
550 | $nestedSet=NestedSetWithManyRoots::model()->findByPk(3); |
|
551 | $this->assertTrue($nestedSet instanceof NestedSetWithManyRoots); |
|
552 | $target=NestedSetWithManyRoots::model()->findByPk(12); |
|
553 | $this->assertTrue($target instanceof NestedSetWithManyRoots); |
|
554 | $this->assertTrue($nestedSet->moveAfter($target)); |
|
555 | $this->assertTrue($this->checkTreeWithManyRoots()); |
|
556 | ||
557 | $this->assertTrue($this->checkArrayWithManyRoots($array)); |
|
558 | ||
559 | $nestedSet=NestedSetWithManyRoots::model()->findByPk(2); |
|
560 | $this->assertTrue($nestedSet instanceof NestedSetWithManyRoots); |
|
561 | $this->assertTrue($nestedSet->moveAfter($target)); |
|
562 | $this->assertTrue($this->checkTreeWithManyRoots()); |
|
563 | ||
564 | $this->assertTrue($this->checkArrayWithManyRoots($array)); |
|
565 | } |
|
566 | ||
567 | public function testMoveAsFirst() |
|
568 | { |
|
@@ 567-622 (lines=56) @@ | ||
564 | $this->assertTrue($this->checkArrayWithManyRoots($array)); |
|
565 | } |
|
566 | ||
567 | public function testMoveAsFirst() |
|
568 | { |
|
569 | // single root |
|
570 | $array=NestedSet::model()->findAll(); |
|
571 | ||
572 | $nestedSet=NestedSet::model()->findByPk(6); |
|
573 | $this->assertTrue($nestedSet instanceof NestedSet); |
|
574 | $target=NestedSet::model()->findByPk(2); |
|
575 | $this->assertTrue($target instanceof NestedSet); |
|
576 | $this->assertTrue($nestedSet->moveAsFirst($target)); |
|
577 | $this->assertTrue($this->checkTree()); |
|
578 | ||
579 | $this->assertTrue($this->checkArray($array)); |
|
580 | ||
581 | $nestedSet=NestedSet::model()->findByPk(5); |
|
582 | $this->assertTrue($nestedSet instanceof NestedSet); |
|
583 | $this->assertTrue($nestedSet->moveAsFirst($target)); |
|
584 | $this->assertTrue($this->checkTree()); |
|
585 | ||
586 | $this->assertTrue($this->checkArray($array)); |
|
587 | ||
588 | // many roots |
|
589 | $array=NestedSetWithManyRoots::model()->findAll(); |
|
590 | ||
591 | $nestedSet=NestedSetWithManyRoots::model()->findByPk(6); |
|
592 | $this->assertTrue($nestedSet instanceof NestedSetWithManyRoots); |
|
593 | $target=NestedSetWithManyRoots::model()->findByPk(2); |
|
594 | $this->assertTrue($target instanceof NestedSetWithManyRoots); |
|
595 | $this->assertTrue($nestedSet->moveAsFirst($target)); |
|
596 | $this->assertTrue($this->checkTreeWithManyRoots()); |
|
597 | ||
598 | $this->assertTrue($this->checkArrayWithManyRoots($array)); |
|
599 | ||
600 | $nestedSet=NestedSetWithManyRoots::model()->findByPk(5); |
|
601 | $this->assertTrue($nestedSet instanceof NestedSetWithManyRoots); |
|
602 | $this->assertTrue($nestedSet->moveAsFirst($target)); |
|
603 | $this->assertTrue($this->checkTreeWithManyRoots()); |
|
604 | ||
605 | $this->assertTrue($this->checkArrayWithManyRoots($array)); |
|
606 | ||
607 | $nestedSet=NestedSetWithManyRoots::model()->findByPk(6); |
|
608 | $this->assertTrue($nestedSet instanceof NestedSetWithManyRoots); |
|
609 | $target=NestedSetWithManyRoots::model()->findByPk(9); |
|
610 | $this->assertTrue($target instanceof NestedSetWithManyRoots); |
|
611 | $this->assertTrue($nestedSet->moveAsFirst($target)); |
|
612 | $this->assertTrue($this->checkTreeWithManyRoots()); |
|
613 | ||
614 | $this->assertTrue($this->checkArrayWithManyRoots($array)); |
|
615 | ||
616 | $nestedSet=NestedSetWithManyRoots::model()->findByPk(5); |
|
617 | $this->assertTrue($nestedSet instanceof NestedSetWithManyRoots); |
|
618 | $this->assertTrue($nestedSet->moveAsFirst($target)); |
|
619 | $this->assertTrue($this->checkTreeWithManyRoots()); |
|
620 | ||
621 | $this->assertTrue($this->checkArrayWithManyRoots($array)); |
|
622 | } |
|
623 | ||
624 | public function testMoveAsLast() |
|
625 | { |
|
@@ 624-679 (lines=56) @@ | ||
621 | $this->assertTrue($this->checkArrayWithManyRoots($array)); |
|
622 | } |
|
623 | ||
624 | public function testMoveAsLast() |
|
625 | { |
|
626 | // single root |
|
627 | $array=NestedSet::model()->findAll(); |
|
628 | ||
629 | $nestedSet=NestedSet::model()->findByPk(3); |
|
630 | $this->assertTrue($nestedSet instanceof NestedSet); |
|
631 | $target=NestedSet::model()->findByPk(5); |
|
632 | $this->assertTrue($target instanceof NestedSet); |
|
633 | $this->assertTrue($nestedSet->moveAsLast($target)); |
|
634 | $this->assertTrue($this->checkTree()); |
|
635 | ||
636 | $this->assertTrue($this->checkArray($array)); |
|
637 | ||
638 | $nestedSet=NestedSet::model()->findByPk(2); |
|
639 | $this->assertTrue($nestedSet instanceof NestedSet); |
|
640 | $this->assertTrue($nestedSet->moveAsLast($target)); |
|
641 | $this->assertTrue($this->checkTree()); |
|
642 | ||
643 | $this->assertTrue($this->checkArray($array)); |
|
644 | ||
645 | // many roots |
|
646 | $array=NestedSetWithManyRoots::model()->findAll(); |
|
647 | ||
648 | $nestedSet=NestedSetWithManyRoots::model()->findByPk(3); |
|
649 | $this->assertTrue($nestedSet instanceof NestedSetWithManyRoots); |
|
650 | $target=NestedSetWithManyRoots::model()->findByPk(5); |
|
651 | $this->assertTrue($target instanceof NestedSetWithManyRoots); |
|
652 | $this->assertTrue($nestedSet->moveAsLast($target)); |
|
653 | $this->assertTrue($this->checkTreeWithManyRoots()); |
|
654 | ||
655 | $this->assertTrue($this->checkArrayWithManyRoots($array)); |
|
656 | ||
657 | $nestedSet=NestedSetWithManyRoots::model()->findByPk(2); |
|
658 | $this->assertTrue($nestedSet instanceof NestedSetWithManyRoots); |
|
659 | $this->assertTrue($nestedSet->moveAsLast($target)); |
|
660 | $this->assertTrue($this->checkTreeWithManyRoots()); |
|
661 | ||
662 | $this->assertTrue($this->checkArrayWithManyRoots($array)); |
|
663 | ||
664 | $nestedSet=NestedSetWithManyRoots::model()->findByPk(3); |
|
665 | $this->assertTrue($nestedSet instanceof NestedSetWithManyRoots); |
|
666 | $target=NestedSetWithManyRoots::model()->findByPk(12); |
|
667 | $this->assertTrue($target instanceof NestedSetWithManyRoots); |
|
668 | $this->assertTrue($nestedSet->moveAsLast($target)); |
|
669 | $this->assertTrue($this->checkTreeWithManyRoots()); |
|
670 | ||
671 | $this->assertTrue($this->checkArrayWithManyRoots($array)); |
|
672 | ||
673 | $nestedSet=NestedSetWithManyRoots::model()->findByPk(2); |
|
674 | $this->assertTrue($nestedSet instanceof NestedSetWithManyRoots); |
|
675 | $this->assertTrue($nestedSet->moveAsLast($target)); |
|
676 | $this->assertTrue($this->checkTreeWithManyRoots()); |
|
677 | ||
678 | $this->assertTrue($this->checkArrayWithManyRoots($array)); |
|
679 | } |
|
680 | ||
681 | public function testMoveAsRoot() |
|
682 | { |