diff --git a/tests/unit/OpenConext/EngineBlock/Metadata/Factory/AbstractEntityTest.php b/tests/unit/OpenConext/EngineBlock/Metadata/Factory/AbstractEntityTest.php index bed994f65..62e8a16be 100644 --- a/tests/unit/OpenConext/EngineBlock/Metadata/Factory/AbstractEntityTest.php +++ b/tests/unit/OpenConext/EngineBlock/Metadata/Factory/AbstractEntityTest.php @@ -33,6 +33,7 @@ use OpenConext\EngineBlock\Metadata\Service; use OpenConext\EngineBlock\Metadata\ShibMdScope; use OpenConext\EngineBlock\Metadata\X509\X509Certificate; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use ReflectionClass; use ReflectionProperty; @@ -512,6 +513,64 @@ protected function getServiceProviderMockProperties() ]; } + protected function setTranslationExpectancies(MockObject $translator) + { + $translator->expects($this->at(0)) + ->method('trans') + ->with('suite_name') + ->willReturn('test-suite'); + + $translator->expects($this->at(1)) + ->method('trans') + ->with('metadata_organization_name') + ->willReturn('configuredOrganizationName'); + + $translator->expects($this->at(2)) + ->method('trans') + ->with('metadata_organization_name', [], null, 'nl') + ->willReturn('configuredOrganizationName'); + + $translator->expects($this->at(3)) + ->method('trans') + ->with('metadata_organization_displayname', [], null, 'nl') + ->willReturn('configuredOrganizationDisplayName'); + + $translator->expects($this->at(4)) + ->method('trans') + ->with('metadata_organization_url', [], null, 'nl') + ->willReturn('configuredOrganizationUrl'); + + $translator->expects($this->at(5)) + ->method('trans') + ->with('metadata_organization_name', [], null, 'en') + ->willReturn('configuredOrganizationName'); + + $translator->expects($this->at(6)) + ->method('trans') + ->with('metadata_organization_displayname', [], null, 'en') + ->willReturn('configuredOrganizationDisplayName'); + + $translator->expects($this->at(7)) + ->method('trans') + ->with('metadata_organization_url', [], null, 'en') + ->willReturn('configuredOrganizationUrl'); + + $translator->expects($this->at(8)) + ->method('trans') + ->with('metadata_organization_name', [], null, 'pt') + ->willReturn('configuredOrganizationName'); + + $translator->expects($this->at(9)) + ->method('trans') + ->with('metadata_organization_displayname', [], null, 'pt') + ->willReturn('configuredOrganizationDisplayName'); + + $translator->expects($this->at(10)) + ->method('trans') + ->with('metadata_organization_url', [], null, 'pt') + ->willReturn('configuredOrganizationUrl'); + } + private function getParameters($className, $skipParameters = []) { $results = []; diff --git a/tests/unit/OpenConext/EngineBlock/Metadata/Factory/Decorator/EngineblockIdentityProviderInformationTest.php b/tests/unit/OpenConext/EngineBlock/Metadata/Factory/Decorator/EngineblockIdentityProviderInformationTest.php index 1bc1da73d..df3e92850 100644 --- a/tests/unit/OpenConext/EngineBlock/Metadata/Factory/Decorator/EngineblockIdentityProviderInformationTest.php +++ b/tests/unit/OpenConext/EngineBlock/Metadata/Factory/Decorator/EngineblockIdentityProviderInformationTest.php @@ -22,6 +22,7 @@ use OpenConext\EngineBlock\Metadata\Factory\ValueObject\EngineBlockConfiguration; use OpenConext\EngineBlock\Metadata\Logo; use OpenConext\EngineBlock\Metadata\Organization; +use PHPUnit\Framework\MockObject\MockObject; use Symfony\Component\Translation\TranslatorInterface; class EngineblockIdentityProviderInformationTest extends AbstractEntityTest @@ -31,30 +32,8 @@ public function test_methods() $adapter = $this->createIdentityProviderAdapter(); $translator = $this->createMock(TranslatorInterface::class); - $translator->expects($this->at(0)) - ->method('trans') - ->with('suite_name') - ->willReturn('test-suite'); - $translator->expects($this->at(1)) - ->method('trans') - ->with('metadata_organization_name') - ->willReturn('configuredOrganizationName'); - - $translator->expects($this->at(2)) - ->method('trans') - ->with('metadata_organization_name') - ->willReturn('configuredOrganizationName'); - - $translator->expects($this->at(3)) - ->method('trans') - ->with('metadata_organization_displayname') - ->willReturn('configuredOrganizationDisplayName'); - - $translator->expects($this->at(4)) - ->method('trans') - ->with('metadata_organization_url') - ->willReturn('configuredOrganizationUrl'); + $this->setTranslationExpectancies($translator); $configuration = new EngineBlockConfiguration( $translator, diff --git a/tests/unit/OpenConext/EngineBlock/Metadata/Factory/Decorator/EngineblockServiceProviderInformationTest.php b/tests/unit/OpenConext/EngineBlock/Metadata/Factory/Decorator/EngineblockServiceProviderInformationTest.php index 42176d2f8..f27e5b6a4 100644 --- a/tests/unit/OpenConext/EngineBlock/Metadata/Factory/Decorator/EngineblockServiceProviderInformationTest.php +++ b/tests/unit/OpenConext/EngineBlock/Metadata/Factory/Decorator/EngineblockServiceProviderInformationTest.php @@ -32,30 +32,8 @@ public function test_methods() $adapter = $this->createServiceProviderAdapter(); $translator = $this->createMock(TranslatorInterface::class); - $translator->expects($this->at(0)) - ->method('trans') - ->with('suite_name') - ->willReturn('test-suite'); - $translator->expects($this->at(1)) - ->method('trans') - ->with('metadata_organization_name') - ->willReturn('configuredOrganizationName'); - - $translator->expects($this->at(2)) - ->method('trans') - ->with('metadata_organization_name') - ->willReturn('configuredOrganizationName'); - - $translator->expects($this->at(3)) - ->method('trans') - ->with('metadata_organization_displayname') - ->willReturn('configuredOrganizationDisplayName'); - - $translator->expects($this->at(4)) - ->method('trans') - ->with('metadata_organization_url') - ->willReturn('configuredOrganizationUrl'); + $this->setTranslationExpectancies($translator); $configuration = new EngineBlockConfiguration( $translator, diff --git a/tests/unit/OpenConext/EngineBlock/Metadata/Factory/Factory/ServiceProviderFactoryTest.php b/tests/unit/OpenConext/EngineBlock/Metadata/Factory/Factory/ServiceProviderFactoryTest.php index 1d2d96245..932a93043 100644 --- a/tests/unit/OpenConext/EngineBlock/Metadata/Factory/Factory/ServiceProviderFactoryTest.php +++ b/tests/unit/OpenConext/EngineBlock/Metadata/Factory/Factory/ServiceProviderFactoryTest.php @@ -114,30 +114,7 @@ public function test_create_stepup_entity_from() public function test_eb_properties() { - $this->translator->expects($this->at(0)) - ->method('trans') - ->with('suite_name') - ->willReturn('test-suite'); - - $this->translator->expects($this->at(1)) - ->method('trans') - ->with('metadata_organization_name') - ->willReturn('configuredOrganizationName'); - - $this->translator->expects($this->at(2)) - ->method('trans') - ->with('metadata_organization_name') - ->willReturn('configuredOrganizationName'); - - $this->translator->expects($this->at(3)) - ->method('trans') - ->with('metadata_organization_displayname') - ->willReturn('configuredOrganizationDisplayName'); - - $this->translator->expects($this->at(4)) - ->method('trans') - ->with('metadata_organization_url') - ->willReturn('configuredOrganizationUrl'); + $this->setTranslationExpectancies($this->translator); $this->configuration = new EngineBlockConfiguration( $this->translator, diff --git a/tests/unit/OpenConext/EngineBlock/Metadata/Factory/ValueObject/EngineBlockConfigurationTest.php b/tests/unit/OpenConext/EngineBlock/Metadata/Factory/ValueObject/EngineBlockConfigurationTest.php index 53b5b63cd..8eb4c49c3 100644 --- a/tests/unit/OpenConext/EngineBlock/Metadata/Factory/ValueObject/EngineBlockConfigurationTest.php +++ b/tests/unit/OpenConext/EngineBlock/Metadata/Factory/ValueObject/EngineBlockConfigurationTest.php @@ -42,17 +42,22 @@ public function test_configuration_creation() ->shouldReceive('trans') ->with('suite_name')->once() ->andReturn($suitName); + $translator + ->shouldReceive('trans') + ->with('metadata_organization_name', [], null, 'en')->once() + ->andReturn($orgName); $translator ->shouldReceive('trans') ->with('metadata_organization_name')->once() ->andReturn($orgName); $translator ->shouldReceive('trans') - ->with('metadata_organization_displayname')->once() + ->with('metadata_organization_displayname', [], null, 'en')->once() ->andReturn($orgDisplayName); + $translator ->shouldReceive('trans') - ->with('metadata_organization_url')->once() + ->with('metadata_organization_url', [], null, 'en')->once() ->andReturn($orgUrl); $mail = 'mail@example.org';