Browse Source

restore unit tests

Olivier Massot 3 years ago
parent
commit
993a03e9ae

+ 1 - 1
src/Entity/Organization/Organization.php

@@ -242,7 +242,7 @@ class Organization
         $this->cycles = new ArrayCollection();
         $this->educationTimings = new ArrayCollection();
         $this->educationNotationConfigs = new ArrayCollection();
-        $this->publicationDirectors = new ArrayCollection();
+        $this->subdomains = new ArrayCollection();
     }
 
     public function getId(): ?int

+ 5 - 0
src/Entity/Organization/Parameters.php

@@ -163,6 +163,11 @@ class Parameters
     #[ORM\Column(options: ['default' => false])]
     private bool $sendAttendanceSms = false;
 
+    #[Pure] public function __construct()
+    {
+        $this->publicationDirectors = new ArrayCollection();
+    }
+
     public function getId(): ?int
     {
         return $this->id;

+ 4 - 4
tests/Service/Access/AdminAccessUtilsTest.php

@@ -37,7 +37,7 @@ class AdminAccessUtilsTest extends TestCase
      */
     public function testGetAdminAccessWithoutAdministrator(){
         $this->accessUtilsMock
-            ->method('getAdminAccess')
+            ->method('findAdminFor')
             ->with($this->organization)
             ->willReturn(null);
 
@@ -51,7 +51,7 @@ class AdminAccessUtilsTest extends TestCase
         $administrator = new Access();
 
         $this->accessUtilsMock
-            ->method('getAdminAccess')
+            ->method('findAdminFor')
             ->with($this->organization)
             ->willReturn($administrator);
 
@@ -73,7 +73,7 @@ class AdminAccessUtilsTest extends TestCase
         $contactPoint = new ContactPoint();
 
         $this->accessUtilsMock
-            ->method('getAdminAccess')
+            ->method('findAdminFor')
             ->with($this->organization)
             ->willReturn($administrator);
 
@@ -84,4 +84,4 @@ class AdminAccessUtilsTest extends TestCase
 
         $this->assertInstanceOf(AdminAccess::class, $this->adminAccessUtils->getAdminAccess($this->organization));
     }
-}
+}

+ 11 - 2
tests/Service/OnChange/Organization/OnParametersChangeTest.php

@@ -11,18 +11,27 @@ use App\Enum\Education\AdvancedEducationNotationTypeEnum;
 use App\Repository\Booking\CourseRepository;
 use App\Service\OnChange\Organization\OnParametersChange;
 use PHPUnit\Framework\TestCase;
+use Symfony\Component\Messenger\MessageBusInterface;
 
 class OnParametersChangeTest extends TestCase
 {
     private Parameters $parameters;
     private OnParametersChange $onParametersChange;
     private CourseRepository $courseRepositoryMock;
+    private \App\Service\Network\Utils $networkUtils;
+    private MessageBusInterface $messageBus;
 
     public function setUp():void
     {
         $this->courseRepositoryMock = $this->getMockBuilder(CourseRepository::class)->disableOriginalConstructor()->getMock();
+        $this->networkUtils = $this->getMockBuilder(\App\Service\Network\Utils::class)->disableOriginalConstructor()->getMock();
+        $this->messageBus = $this->getMockBuilder(MessageBusInterface::class)->disableOriginalConstructor()->getMock();
         $this->parameters = new Parameters();
-        $this->onParametersChange = new OnParametersChange($this->courseRepositoryMock);
+        $this->onParametersChange = new OnParametersChange(
+            $this->courseRepositoryMock,
+            $this->networkUtils,
+            $this->messageBus
+        );
     }
 
     /**
@@ -89,4 +98,4 @@ class OnParametersChangeTest extends TestCase
         $this->assertEquals(2022, $course->getStartYear());
         $this->assertEquals(2023, $course->getEndYear());
     }
-}
+}

+ 4 - 1
tests/Service/Organization/OrganizationProfileCreatorTest.php

@@ -5,6 +5,7 @@ use App\ApiResources\Profile\OrganizationProfile;
 use App\Entity\Organization\Organization;
 use App\Entity\Organization\Parameters;
 use App\Entity\Organization\Settings;
+use App\Entity\Organization\Subdomain;
 use App\Enum\Organization\PrincipalTypeEnum;
 use App\Service\Network\Tree;
 use App\Service\Organization\OrganizationProfileCreator;
@@ -44,10 +45,12 @@ class OrganizationProfileCreatorTest extends TestCase
         $settings->setProduct('adminassos');
         $parameters = new Parameters();
         $parameters->setShowAdherentList(true);
+        $subdomain = new Subdomain();
 
         $this->organization
             ->setParameters($parameters)
             ->setSettings($settings)
+            ->addSubdomain($subdomain)
             ->setName('Foo')
         ;
     }
@@ -77,4 +80,4 @@ class OrganizationProfileCreatorTest extends TestCase
         $organizationProfile = $this->organizationProfileCreator->createCompleteOrganizationProfile($this->organization);
         $this->assertTrue($organizationProfile->getShowAdherentList());
     }
-}
+}