Selaa lähdekoodia

fix unit tests

Olivier Massot 2 vuotta sitten
vanhempi
commit
a9ca184b07
1 muutettua tiedostoa jossa 7 lisäystä ja 1 poistoa
  1. 7 1
      tests/Unit/Service/Typo3/SubdomainServiceTest.php

+ 7 - 1
tests/Unit/Service/Typo3/SubdomainServiceTest.php

@@ -5,6 +5,7 @@ namespace App\Tests\Unit\Service\Typo3;
 
 use App\Entity\Access\Access;
 use App\Entity\Organization\Organization;
+use App\Entity\Organization\Parameters;
 use App\Entity\Organization\Subdomain;
 use App\Entity\Person\Person;
 use App\Message\Command\MailerCommand;
@@ -149,18 +150,23 @@ class SubdomainServiceTest extends TestCase
     public function testAddNewSubdomain(): void {
         $subdomainService = $this->makeSubdomainServiceMockFor('addNewSubdomain');
 
+        $parameters = $this->getMockBuilder(Parameters::class)->disableOriginalConstructor()->getMock();
         $organization = $this->getMockBuilder(Organization::class)->disableOriginalConstructor()->getMock();
+        $organization->method('getParameters')->willReturn($parameters);
 
         $subdomainService->expects(self::once())->method('isValidSubdomain')->with('sub')->willReturn(True);
         $subdomainService->expects(self::once())->method('canRegisterNewSubdomain')->with($organization)->willReturn(True);
         $subdomainService->expects(self::once())->method('isReservedSubdomain')->with('sub')->willReturn(false);
         $this->subdomainRepository->expects(self::once())->method('findBy')->with(['subdomain' => 'sub'])->willReturn(0);
 
-        $this->entityManager->expects(self::once())->method('persist');
+        $this->entityManager->expects(self::exactly(2))->method('persist');
         $this->entityManager->expects(self::once())->method('flush');
 
         $this->bindFileService->expects(self::once())->method('registerSubdomain')->with('sub');
 
+        $parameters->expects(self::once())->method('setSubDomain')->with('sub');
+        $parameters->expects(self::once())->method('setOtherWebsite')->with('https://sub.opentalent.fr');
+
         // Subdomain is not activated by default
         $subdomainService->expects(self::never())->method('activateSubdomain');