@@ 639-694 (lines=56) @@ | ||
636 | self::assertEquals($this->fixtures[2]->address->country, $result[2][0]->country); |
|
637 | } |
|
638 | ||
639 | public function testShouldSupportMultipleNewOperatorsAndSingleScalar() |
|
640 | { |
|
641 | $dql = " |
|
642 | SELECT |
|
643 | new CmsUserDTO( |
|
644 | u.name, |
|
645 | e.email |
|
646 | ), |
|
647 | new CmsAddressDTO( |
|
648 | a.country, |
|
649 | a.city |
|
650 | ), |
|
651 | u.status |
|
652 | FROM |
|
653 | Doctrine\Tests\Models\CMS\CmsUser u |
|
654 | JOIN |
|
655 | u.email e |
|
656 | JOIN |
|
657 | u.address a |
|
658 | ORDER BY |
|
659 | u.name"; |
|
660 | ||
661 | $query = $this->em->createQuery($dql); |
|
662 | $result = $query->getResult(); |
|
663 | ||
664 | self::assertCount(3, $result); |
|
665 | ||
666 | self::assertInstanceOf(CmsUserDTO::class, $result[0][0]); |
|
667 | self::assertInstanceOf(CmsUserDTO::class, $result[1][0]); |
|
668 | self::assertInstanceOf(CmsUserDTO::class, $result[2][0]); |
|
669 | ||
670 | self::assertInstanceOf(CmsAddressDTO::class, $result[0][1]); |
|
671 | self::assertInstanceOf(CmsAddressDTO::class, $result[1][1]); |
|
672 | self::assertInstanceOf(CmsAddressDTO::class, $result[2][1]); |
|
673 | ||
674 | self::assertEquals($this->fixtures[0]->name, $result[0][0]->name); |
|
675 | self::assertEquals($this->fixtures[1]->name, $result[1][0]->name); |
|
676 | self::assertEquals($this->fixtures[2]->name, $result[2][0]->name); |
|
677 | ||
678 | self::assertEquals($this->fixtures[0]->email->email, $result[0][0]->email); |
|
679 | self::assertEquals($this->fixtures[1]->email->email, $result[1][0]->email); |
|
680 | self::assertEquals($this->fixtures[2]->email->email, $result[2][0]->email); |
|
681 | ||
682 | ||
683 | self::assertEquals($this->fixtures[0]->address->city, $result[0][1]->city); |
|
684 | self::assertEquals($this->fixtures[1]->address->city, $result[1][1]->city); |
|
685 | self::assertEquals($this->fixtures[2]->address->city, $result[2][1]->city); |
|
686 | ||
687 | self::assertEquals($this->fixtures[0]->address->country, $result[0][1]->country); |
|
688 | self::assertEquals($this->fixtures[1]->address->country, $result[1][1]->country); |
|
689 | self::assertEquals($this->fixtures[2]->address->country, $result[2][1]->country); |
|
690 | ||
691 | self::assertEquals($this->fixtures[0]->status,$result[0]['status']); |
|
692 | self::assertEquals($this->fixtures[1]->status,$result[1]['status']); |
|
693 | self::assertEquals($this->fixtures[2]->status,$result[2]['status']); |
|
694 | } |
|
695 | ||
696 | public function testShouldSupportMultipleNewOperatorsAndSingleScalarWithAliases() |
|
697 | { |
|
@@ 696-751 (lines=56) @@ | ||
693 | self::assertEquals($this->fixtures[2]->status,$result[2]['status']); |
|
694 | } |
|
695 | ||
696 | public function testShouldSupportMultipleNewOperatorsAndSingleScalarWithAliases() |
|
697 | { |
|
698 | $dql = " |
|
699 | SELECT |
|
700 | new CmsUserDTO( |
|
701 | u.name, |
|
702 | e.email |
|
703 | ) as cmsUser, |
|
704 | new CmsAddressDTO( |
|
705 | a.country, |
|
706 | a.city |
|
707 | ) as cmsAddress, |
|
708 | u.status as cmsUserStatus |
|
709 | FROM |
|
710 | Doctrine\Tests\Models\CMS\CmsUser u |
|
711 | JOIN |
|
712 | u.email e |
|
713 | JOIN |
|
714 | u.address a |
|
715 | ORDER BY |
|
716 | u.name"; |
|
717 | ||
718 | $query = $this->em->createQuery($dql); |
|
719 | $result = $query->getResult(); |
|
720 | ||
721 | self::assertCount(3, $result); |
|
722 | ||
723 | self::assertInstanceOf(CmsUserDTO::class, $result[0]['cmsUser']); |
|
724 | self::assertInstanceOf(CmsUserDTO::class, $result[1]['cmsUser']); |
|
725 | self::assertInstanceOf(CmsUserDTO::class, $result[2]['cmsUser']); |
|
726 | ||
727 | self::assertInstanceOf(CmsAddressDTO::class, $result[0]['cmsAddress']); |
|
728 | self::assertInstanceOf(CmsAddressDTO::class, $result[1]['cmsAddress']); |
|
729 | self::assertInstanceOf(CmsAddressDTO::class, $result[2]['cmsAddress']); |
|
730 | ||
731 | self::assertEquals($this->fixtures[0]->name, $result[0]['cmsUser']->name); |
|
732 | self::assertEquals($this->fixtures[1]->name, $result[1]['cmsUser']->name); |
|
733 | self::assertEquals($this->fixtures[2]->name, $result[2]['cmsUser']->name); |
|
734 | ||
735 | self::assertEquals($this->fixtures[0]->email->email, $result[0]['cmsUser']->email); |
|
736 | self::assertEquals($this->fixtures[1]->email->email, $result[1]['cmsUser']->email); |
|
737 | self::assertEquals($this->fixtures[2]->email->email, $result[2]['cmsUser']->email); |
|
738 | ||
739 | ||
740 | self::assertEquals($this->fixtures[0]->address->city, $result[0]['cmsAddress']->city); |
|
741 | self::assertEquals($this->fixtures[1]->address->city, $result[1]['cmsAddress']->city); |
|
742 | self::assertEquals($this->fixtures[2]->address->city, $result[2]['cmsAddress']->city); |
|
743 | ||
744 | self::assertEquals($this->fixtures[0]->address->country, $result[0]['cmsAddress']->country); |
|
745 | self::assertEquals($this->fixtures[1]->address->country, $result[1]['cmsAddress']->country); |
|
746 | self::assertEquals($this->fixtures[2]->address->country, $result[2]['cmsAddress']->country); |
|
747 | ||
748 | self::assertEquals($this->fixtures[0]->status,$result[0]['cmsUserStatus']); |
|
749 | self::assertEquals($this->fixtures[1]->status,$result[1]['cmsUserStatus']); |
|
750 | self::assertEquals($this->fixtures[2]->status,$result[2]['cmsUserStatus']); |
|
751 | } |
|
752 | ||
753 | public function testShouldSupportMultipleNewOperatorsAndSingleScalarWithAndWithoutAliases() |
|
754 | { |
|
@@ 753-808 (lines=56) @@ | ||
750 | self::assertEquals($this->fixtures[2]->status,$result[2]['cmsUserStatus']); |
|
751 | } |
|
752 | ||
753 | public function testShouldSupportMultipleNewOperatorsAndSingleScalarWithAndWithoutAliases() |
|
754 | { |
|
755 | $dql = " |
|
756 | SELECT |
|
757 | new CmsUserDTO( |
|
758 | u.name, |
|
759 | e.email |
|
760 | ) as cmsUser, |
|
761 | new CmsAddressDTO( |
|
762 | a.country, |
|
763 | a.city |
|
764 | ), |
|
765 | u.status |
|
766 | FROM |
|
767 | Doctrine\Tests\Models\CMS\CmsUser u |
|
768 | JOIN |
|
769 | u.email e |
|
770 | JOIN |
|
771 | u.address a |
|
772 | ORDER BY |
|
773 | u.name"; |
|
774 | ||
775 | $query = $this->em->createQuery($dql); |
|
776 | $result = $query->getResult(); |
|
777 | ||
778 | self::assertCount(3, $result); |
|
779 | ||
780 | self::assertInstanceOf(CmsUserDTO::class, $result[0]['cmsUser']); |
|
781 | self::assertInstanceOf(CmsUserDTO::class, $result[1]['cmsUser']); |
|
782 | self::assertInstanceOf(CmsUserDTO::class, $result[2]['cmsUser']); |
|
783 | ||
784 | self::assertInstanceOf(CmsAddressDTO::class, $result[0][0]); |
|
785 | self::assertInstanceOf(CmsAddressDTO::class, $result[1][0]); |
|
786 | self::assertInstanceOf(CmsAddressDTO::class, $result[2][0]); |
|
787 | ||
788 | self::assertEquals($this->fixtures[0]->name, $result[0]['cmsUser']->name); |
|
789 | self::assertEquals($this->fixtures[1]->name, $result[1]['cmsUser']->name); |
|
790 | self::assertEquals($this->fixtures[2]->name, $result[2]['cmsUser']->name); |
|
791 | ||
792 | self::assertEquals($this->fixtures[0]->email->email, $result[0]['cmsUser']->email); |
|
793 | self::assertEquals($this->fixtures[1]->email->email, $result[1]['cmsUser']->email); |
|
794 | self::assertEquals($this->fixtures[2]->email->email, $result[2]['cmsUser']->email); |
|
795 | ||
796 | ||
797 | self::assertEquals($this->fixtures[0]->address->city, $result[0][0]->city); |
|
798 | self::assertEquals($this->fixtures[1]->address->city, $result[1][0]->city); |
|
799 | self::assertEquals($this->fixtures[2]->address->city, $result[2][0]->city); |
|
800 | ||
801 | self::assertEquals($this->fixtures[0]->address->country, $result[0][0]->country); |
|
802 | self::assertEquals($this->fixtures[1]->address->country, $result[1][0]->country); |
|
803 | self::assertEquals($this->fixtures[2]->address->country, $result[2][0]->country); |
|
804 | ||
805 | self::assertEquals($this->fixtures[0]->status,$result[0]['status']); |
|
806 | self::assertEquals($this->fixtures[1]->status,$result[1]['status']); |
|
807 | self::assertEquals($this->fixtures[2]->status,$result[2]['status']); |
|
808 | } |
|
809 | ||
810 | public function testShouldSupportMultipleNewOperatorsAndMultipleScalars() |
|
811 | { |