|
@@ -10,7 +10,7 @@ use App\Repository\Access\AccessRepository;
|
|
|
use App\Repository\Organization\OrganizationRepository;
|
|
use App\Repository\Organization\OrganizationRepository;
|
|
|
use App\Repository\Organization\SubdomainRepository;
|
|
use App\Repository\Organization\SubdomainRepository;
|
|
|
use App\Service\Access\Utils as AccessUtils;
|
|
use App\Service\Access\Utils as AccessUtils;
|
|
|
-use App\Service\Mailer\Builder\SubDomainChangeBuilder;
|
|
|
|
|
|
|
+use App\Service\Mailer\Builder\OnSubdomainChangeMailBuilder;
|
|
|
use App\Service\Mailer\Email;
|
|
use App\Service\Mailer\Email;
|
|
|
use App\Service\Mailer\Mailer;
|
|
use App\Service\Mailer\Mailer;
|
|
|
use App\Service\Mailer\Model\SubdomainChangeModel;
|
|
use App\Service\Mailer\Model\SubdomainChangeModel;
|
|
@@ -19,9 +19,9 @@ use PHPUnit\Framework\MockObject\MockObject;
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * Classe SubDomainChangeBuilderTest qui test le service SubDomainChangeBuilder
|
|
|
|
|
|
|
+ * Classe OnSubdomainChangeMailBuilderTest qui test le service SubDomainChangeBuilder
|
|
|
*/
|
|
*/
|
|
|
-class SubDomainChangeBuilderTest extends TestCase
|
|
|
|
|
|
|
+class OnSubdomainChangeMailBuilderTest extends TestCase
|
|
|
{
|
|
{
|
|
|
private MockObject|EntityManagerInterface $entityManager;
|
|
private MockObject|EntityManagerInterface $entityManager;
|
|
|
private string $opentalentNoReplyEmailAddress = 'no-reply@opentalent.fr';
|
|
private string $opentalentNoReplyEmailAddress = 'no-reply@opentalent.fr';
|
|
@@ -38,9 +38,9 @@ class SubDomainChangeBuilderTest extends TestCase
|
|
|
* @param string $methodUnderTest
|
|
* @param string $methodUnderTest
|
|
|
* @return Mailer|MockObject
|
|
* @return Mailer|MockObject
|
|
|
*/
|
|
*/
|
|
|
- private function makeSubDomainChangeBuilderMock(string $methodUnderTest): SubDomainChangeBuilder | MockObject
|
|
|
|
|
|
|
+ private function makeSubDomainChangeBuilderMock(string $methodUnderTest): OnSubdomainChangeMailBuilder | MockObject
|
|
|
{
|
|
{
|
|
|
- $subDomainChangeBuilder = $this->getMockBuilder(SubDomainChangeBuilder::class)
|
|
|
|
|
|
|
+ return $this->getMockBuilder(OnSubdomainChangeMailBuilder::class)
|
|
|
->setConstructorArgs([
|
|
->setConstructorArgs([
|
|
|
$this->entityManager,
|
|
$this->entityManager,
|
|
|
$this->opentalentNoReplyEmailAddress,
|
|
$this->opentalentNoReplyEmailAddress,
|
|
@@ -48,15 +48,17 @@ class SubDomainChangeBuilderTest extends TestCase
|
|
|
])
|
|
])
|
|
|
->setMethodsExcept([$methodUnderTest])
|
|
->setMethodsExcept([$methodUnderTest])
|
|
|
->getMock();
|
|
->getMock();
|
|
|
-
|
|
|
|
|
- return $subDomainChangeBuilder;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @see SubDomainChangeBuilder::build()
|
|
|
|
|
|
|
+ * @see OnSubdomainChangeMailBuilder::build()
|
|
|
*/
|
|
*/
|
|
|
public function testBuild()
|
|
public function testBuild()
|
|
|
{
|
|
{
|
|
|
|
|
+ $subdomainId = 123;
|
|
|
|
|
+ $organizationId = 444;
|
|
|
|
|
+ $senderId = 333;
|
|
|
|
|
+
|
|
|
$subDomainChangeBuilder = $this->makeSubDomainChangeBuilderMock('build');
|
|
$subDomainChangeBuilder = $this->makeSubDomainChangeBuilderMock('build');
|
|
|
|
|
|
|
|
$subdomain = $this->getMockBuilder(Subdomain::class)->disableOriginalConstructor()->getMock();
|
|
$subdomain = $this->getMockBuilder(Subdomain::class)->disableOriginalConstructor()->getMock();
|
|
@@ -65,16 +67,16 @@ class SubDomainChangeBuilderTest extends TestCase
|
|
|
$access = $this->getMockBuilder(Access::class)->disableOriginalConstructor()->getMock();
|
|
$access = $this->getMockBuilder(Access::class)->disableOriginalConstructor()->getMock();
|
|
|
|
|
|
|
|
$mailerModel = $this->getMockBuilder(SubdomainChangeModel::class)->disableOriginalConstructor()->getMock();
|
|
$mailerModel = $this->getMockBuilder(SubdomainChangeModel::class)->disableOriginalConstructor()->getMock();
|
|
|
- $mailerModel->method('getSubdomainId')->willReturn(1);
|
|
|
|
|
- $mailerModel->method('getOrganizationId')->willReturn(1);
|
|
|
|
|
- $mailerModel->method('getSenderId')->willReturn(1);
|
|
|
|
|
|
|
+ $mailerModel->method('getSubdomainId')->willReturn($subdomainId);
|
|
|
|
|
+ $mailerModel->method('getOrganizationId')->willReturn($organizationId);
|
|
|
|
|
+ $mailerModel->method('getSenderId')->willReturn($senderId);
|
|
|
|
|
|
|
|
$subdomainRepository = $this->getMockBuilder(SubdomainRepository::class)->disableOriginalConstructor()->getMock();
|
|
$subdomainRepository = $this->getMockBuilder(SubdomainRepository::class)->disableOriginalConstructor()->getMock();
|
|
|
- $subdomainRepository->expects(self::once())->method('find')->with($mailerModel->getSubdomainId())->willReturn($subdomain);
|
|
|
|
|
|
|
+ $subdomainRepository->expects(self::once())->method('find')->with($subdomainId)->willReturn($subdomain);
|
|
|
$organizationRepository = $this->getMockBuilder(OrganizationRepository::class)->disableOriginalConstructor()->getMock();
|
|
$organizationRepository = $this->getMockBuilder(OrganizationRepository::class)->disableOriginalConstructor()->getMock();
|
|
|
- $organizationRepository->expects(self::once())->method('find')->with($mailerModel->getOrganizationId())->willReturn($organization);
|
|
|
|
|
|
|
+ $organizationRepository->expects(self::once())->method('find')->with($organizationId)->willReturn($organization);
|
|
|
$accessRepository = $this->getMockBuilder(AccessRepository::class)->disableOriginalConstructor()->getMock();
|
|
$accessRepository = $this->getMockBuilder(AccessRepository::class)->disableOriginalConstructor()->getMock();
|
|
|
- $accessRepository->expects(self::once())->method('find')->with($mailerModel->getSenderId())->willReturn($access);
|
|
|
|
|
|
|
+ $accessRepository->expects(self::once())->method('find')->with($senderId)->willReturn($access);
|
|
|
|
|
|
|
|
$this->entityManager
|
|
$this->entityManager
|
|
|
->expects(self::exactly(3))
|
|
->expects(self::exactly(3))
|
|
@@ -111,6 +113,6 @@ class SubDomainChangeBuilderTest extends TestCase
|
|
|
$this->assertInstanceOf(Email::class, $email);
|
|
$this->assertInstanceOf(Email::class, $email);
|
|
|
$this->assertEquals('contenu', $email->getContent());
|
|
$this->assertEquals('contenu', $email->getContent());
|
|
|
$this->assertEquals($this->opentalentNoReplyEmailAddress, $email->getFrom());
|
|
$this->assertEquals($this->opentalentNoReplyEmailAddress, $email->getFrom());
|
|
|
- $this->assertEquals($organization->getName(), $email->getNameFrom());
|
|
|
|
|
|
|
+ $this->assertEquals($organization->getName(), $email->geFromName());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|