|
8 | 8 | use EasyCorp\Bundle\EasyAdminBundle\Tests\Functional\Apps\DefaultApp\Entity\BlogPost; |
9 | 9 | use EasyCorp\Bundle\EasyAdminBundle\Tests\Functional\Apps\DefaultApp\Entity\Category; |
10 | 10 | use EasyCorp\Bundle\EasyAdminBundle\Tests\Functional\Apps\DefaultApp\Entity\Customer; |
| 11 | +use EasyCorp\Bundle\EasyAdminBundle\Tests\Functional\Apps\DefaultApp\Entity\EntityFactory\Address; |
11 | 12 | use EasyCorp\Bundle\EasyAdminBundle\Tests\Functional\Apps\DefaultApp\Entity\Page; |
| 13 | +use EasyCorp\Bundle\EasyAdminBundle\Tests\Functional\Apps\DefaultApp\Entity\ProjectDomain\Developer; |
| 14 | +use EasyCorp\Bundle\EasyAdminBundle\Tests\Functional\Apps\DefaultApp\Entity\ProjectDomain\Money; |
| 15 | +use EasyCorp\Bundle\EasyAdminBundle\Tests\Functional\Apps\DefaultApp\Entity\ProjectDomain\Project; |
| 16 | +use EasyCorp\Bundle\EasyAdminBundle\Tests\Functional\Apps\DefaultApp\Entity\ProjectDomain\ProjectRelease; |
| 17 | +use EasyCorp\Bundle\EasyAdminBundle\Tests\Functional\Apps\DefaultApp\Entity\ProjectDomain\ProjectReleaseCategory; |
12 | 18 | use EasyCorp\Bundle\EasyAdminBundle\Tests\Functional\Apps\DefaultApp\Entity\Synthetic\ActionTestEntity; |
13 | 19 | use EasyCorp\Bundle\EasyAdminBundle\Tests\Functional\Apps\DefaultApp\Entity\Synthetic\BatchActionTestEntity; |
14 | 20 | use EasyCorp\Bundle\EasyAdminBundle\Tests\Functional\Apps\DefaultApp\Entity\Synthetic\DefaultCrudTestEntity; |
@@ -80,6 +86,8 @@ public function load(ObjectManager $manager): void |
80 | 86 |
|
81 | 87 | $this->addActionTestFixtures($manager); |
82 | 88 |
|
| 89 | + $this->addProjectDomainSearchFixtures($manager); |
| 90 | + |
83 | 91 | $manager->flush(); |
84 | 92 | } |
85 | 93 |
|
@@ -604,16 +612,17 @@ private function addSearchTestFixtures(ObjectManager $manager): void |
604 | 612 | // create authors first |
605 | 613 | $authors = []; |
606 | 614 | $authorData = [ |
607 | | - [ 'name' => 'John Smith', 'email' => '[email protected]'], |
608 | | - [ 'name' => 'Jane Doe', 'email' => '[email protected]'], |
609 | | - [ 'name' => 'Alice Johnson', 'email' => '[email protected]'], |
610 | | - [ 'name' => 'Bob Williams', 'email' => '[email protected]'], |
| 615 | + [ 'name' => 'John Smith', 'email' => '[email protected]', 'addressStreet' => 10, 'addressCity' => 'New York'], |
| 616 | + [ 'name' => 'Jane Doe', 'email' => '[email protected]', 'addressStreet' => 20, 'addressCity' => 'London'], |
| 617 | + [ 'name' => 'Alice Johnson', 'email' => '[email protected]', 'addressStreet' => 30, 'addressCity' => 'New York'], |
| 618 | + [ 'name' => 'Bob Williams', 'email' => '[email protected]', 'addressStreet' => 40, 'addressCity' => 'Paris'], |
611 | 619 | ]; |
612 | 620 |
|
613 | 621 | foreach ($authorData as $index => $data) { |
614 | 622 | $author = new SearchTestAuthor(); |
615 | 623 | $author->setName($data['name']); |
616 | 624 | $author->setEmail($data['email']); |
| 625 | + $author->setAddress((new Address())->setStreet($data['addressStreet'])->setCity($data['addressCity'])); |
617 | 626 | $manager->persist($author); |
618 | 627 | $authors[$index] = $author; |
619 | 628 | $this->addReference('searchAuthor'.$index, $author); |
@@ -721,4 +730,82 @@ private function addActionTestFixtures(ObjectManager $manager): void |
721 | 730 | $this->addReference('actionTest'.$index, $entity); |
722 | 731 | } |
723 | 732 | } |
| 733 | + |
| 734 | + private function addProjectDomainSearchFixtures(ObjectManager $manager): void |
| 735 | + { |
| 736 | + // create release categories (separate entities because ProjectRelease→category is OneToOne) |
| 737 | + $categoryNames = ['Major', 'Minor', 'Major']; |
| 738 | + $categories = []; |
| 739 | + foreach ($categoryNames as $index => $name) { |
| 740 | + $category = new ProjectReleaseCategory(); |
| 741 | + $category->setName($name); |
| 742 | + $manager->persist($category); |
| 743 | + $categories[$index] = $category; |
| 744 | + } |
| 745 | + |
| 746 | + // create releases |
| 747 | + $releaseData = [ |
| 748 | + ['name' => 'v1.0', 'categoryIndex' => 0], |
| 749 | + ['name' => 'v1.1', 'categoryIndex' => 1], |
| 750 | + ['name' => 'v2.0', 'categoryIndex' => 2], |
| 751 | + ]; |
| 752 | + $releases = []; |
| 753 | + foreach ($releaseData as $index => $data) { |
| 754 | + $release = new ProjectRelease(); |
| 755 | + $release->setName($data['name']); |
| 756 | + $release->setCategory($categories[$data['categoryIndex']]); |
| 757 | + $manager->persist($release); |
| 758 | + $releases[$index] = $release; |
| 759 | + } |
| 760 | + |
| 761 | + // create developers |
| 762 | + $developerNames = ['Alice Dev', 'Bob Dev', 'Carol Dev']; |
| 763 | + $developers = []; |
| 764 | + foreach ($developerNames as $index => $name) { |
| 765 | + $developer = new Developer(); |
| 766 | + $developer->setName($name); |
| 767 | + $manager->persist($developer); |
| 768 | + $developers[$index] = $developer; |
| 769 | + } |
| 770 | + |
| 771 | + // create projects |
| 772 | + $defaultDate = new \DateTime('2024-01-01 10:00:00'); |
| 773 | + $defaultDateImmutable = new \DateTimeImmutable('2024-01-01 10:00:00'); |
| 774 | + $defaultTime = new \DateTime('10:00:00'); |
| 775 | + $defaultTimeImmutable = new \DateTimeImmutable('10:00:00'); |
| 776 | + |
| 777 | + $projectData = [ |
| 778 | + ['name' => 'Alpha Project', 'amount' => 1000, 'currency' => 'USD', 'developerIndex' => 0, 'releaseIndex' => 0], |
| 779 | + ['name' => 'Beta Project', 'amount' => 2000, 'currency' => 'EUR', 'developerIndex' => 1, 'releaseIndex' => 1], |
| 780 | + ['name' => 'Gamma Project', 'amount' => 3000, 'currency' => 'USD', 'developerIndex' => 2, 'releaseIndex' => 2], |
| 781 | + ['name' => 'Delta Project', 'amount' => 500, 'currency' => 'GBP', 'developerIndex' => 0, 'releaseIndex' => null], |
| 782 | + ]; |
| 783 | + |
| 784 | + foreach ($projectData as $data) { |
| 785 | + $project = new Project(); |
| 786 | + $project->setName($data['name']); |
| 787 | + $project->setPrice((new Money())->setAmount($data['amount'])->setCurrency($data['currency'])); |
| 788 | + $project->setLeadDeveloper($developers[$data['developerIndex']]); |
| 789 | + $project->setDescription('Test project '.$data['name']); |
| 790 | + $project->setStartDateMutable(clone $defaultDate); |
| 791 | + $project->setStartDateImmutable($defaultDateImmutable); |
| 792 | + $project->setStartDateTimeMutable(clone $defaultDate); |
| 793 | + $project->setStartDateTimeImmutable($defaultDateImmutable); |
| 794 | + $project->setStartDateTimeTzMutable(clone $defaultDate); |
| 795 | + $project->setStartDateTimeTzImmutable($defaultDateImmutable); |
| 796 | + $project->setCountInteger(1); |
| 797 | + $project->setCountSmallint(1); |
| 798 | + $project->setPriceDecimal('100'); |
| 799 | + $project->setPriceFloat(100.0); |
| 800 | + $project->setStartTimeMutable(clone $defaultTime); |
| 801 | + $project->setStartTimeImmutable($defaultTimeImmutable); |
| 802 | + $project->setStatesSimpleArray(['active']); |
| 803 | + |
| 804 | + if (null !== $data['releaseIndex']) { |
| 805 | + $project->setLatestRelease($releases[$data['releaseIndex']]); |
| 806 | + } |
| 807 | + |
| 808 | + $manager->persist($project); |
| 809 | + } |
| 810 | + } |
724 | 811 | } |
0 commit comments