Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ public function hasCompleteOrganizationData(string $locale): bool
}

/**
* @param $locale
* @param string $locale
* @return Organization
*/
public function getOrganization($locale): ?Organization
public function getOrganization(string $locale): ?Organization
{
switch (true) {
case ($locale == 'nl'):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ public function hasCompleteOrganizationData(string $locale): bool
}

/**
* @param $locale
* @param string $locale
* @return Organization
*/
public function getOrganization($locale): ?Organization
public function getOrganization(string $locale): ?Organization
{
switch (true) {
case ($locale == 'nl'):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ public function hasCompleteOrganizationData(string $locale): bool
}

/**
* @param $locale
* @param string $locale
* @return Organization|null
*/
public function getOrganization($locale): ?Organization
public function getOrganization(string $locale): ?Organization
{
return $this->entity->getOrganization($locale);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ public function hasCompleteOrganizationData(string $locale): bool
}

/**
* @param $locale
* @param string $locale
* @return Organization|null
*/
public function getOrganization($locale): ?Organization
public function getOrganization(string $locale): ?Organization
{
return $this->entity->getOrganization($locale);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ public function getLogo(): ?Logo
return $this->engineBlockConfiguration->getLogo();
}

public function getOrganization($locale): ?Organization
public function getOrganization(string $locale): ?Organization
{
return $this->engineBlockConfiguration->getOrganization();
return $this->engineBlockConfiguration->getOrganization($locale);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ public function getLogo(): ?Logo
return $this->engineBlockConfiguration->getLogo();
}

public function getOrganization($locale): ?Organization
public function getOrganization(string $locale): ?Organization
{
return $this->engineBlockConfiguration->getOrganization();
return $this->engineBlockConfiguration->getOrganization($locale);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ public function getLogo(): ?Logo;
public function hasCompleteOrganizationData(string $locale): bool;

/**
* @param $locale
* @param string $locale
* @return Organization|null
*/
public function getOrganization($locale): ?Organization;
public function getOrganization(string $locale): ?Organization;

/**
* @param $locale
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ public function getLogo(): ?Logo;
public function hasCompleteOrganizationData(string $locale): bool;

/**
* @param $locale
* @param string $locale
* @return Organization|null
*/
public function getOrganization($locale): ?Organization;
public function getOrganization(string $locale): ?Organization;

/**
* @param $locale
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
*/
class EngineBlockConfiguration
{
/**
* @var \Symfony\Component\Translation\TranslatorInterface
*/
private $translator;

/**
* @var string
*/
Expand Down Expand Up @@ -84,11 +89,12 @@ public function __construct(
int $logoWidth,
int $logoHeight
) {
$this->translator = $translator;
$this->suiteName = $translator->trans('suite_name');
$this->engineHostName = $engineHostName;
$this->organizationName = $translator->trans('metadata_organization_name');
$this->organizationDisplayName = $translator->trans('metadata_organization_displayname');
$this->organizationUrl = $translator->trans('metadata_organization_url');
$this->organizationName = 'metadata_organization_name';
$this->organizationDisplayName = 'metadata_organization_displayname';
$this->organizationUrl = 'metadata_organization_url';
$this->supportMail = $supportMail;
$this->description = $description;

Expand All @@ -101,9 +107,10 @@ public function __construct(
$this->logo->height = $logoHeight;

// Create the contact person data for the EB SP entity
$support = ContactPerson::from('support', $this->organizationName, 'Support', $this->supportMail);
$technical = ContactPerson::from('technical', $this->organizationName, 'Support', $this->supportMail);
$administrative = ContactPerson::from('administrative', $this->organizationName, 'Support', $this->supportMail);
$organizationName = $translator->trans('metadata_organization_name');
$support = ContactPerson::from('support', $organizationName, 'Support', $this->supportMail);
$technical = ContactPerson::from('technical', $organizationName, 'Support', $this->supportMail);
$administrative = ContactPerson::from('administrative', $organizationName, 'Support', $this->supportMail);

$this->contactPersons = [$support, $technical, $administrative];
}
Expand All @@ -118,9 +125,12 @@ public function getHostname(): string
return $this->engineHostName;
}

public function getOrganization() : Organization
public function getOrganization(string $locale) : Organization
{
return new Organization($this->organizationName, $this->organizationDisplayName, $this->organizationUrl);
$organizationName = $this->translator->trans($this->organizationName, [], null, $locale);
$organizationDisplayName = $this->translator->trans($this->organizationDisplayName, [], null, $locale);
$organizationUrl = $this->translator->trans($this->organizationUrl, [], null, $locale);
return new Organization($organizationName, $organizationDisplayName, $organizationUrl);
}

public function getLogo(): Logo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,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;
Expand Down Expand Up @@ -659,6 +660,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 = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -98,9 +103,10 @@ public function test_configuration_creation()
$this->assertEquals($width, $configuration->getLogo()->width);
$this->assertEquals($height, $configuration->getLogo()->height);

$this->assertInstanceOf(Organization::class, $configuration->getOrganization());
$this->assertEquals($orgUrl, $configuration->getOrganization()->url);
$this->assertEquals($orgName, $configuration->getOrganization()->name);
$this->assertEquals($orgDisplayName, $configuration->getOrganization()->displayName);
$organization = $configuration->getOrganization('en');
$this->assertInstanceOf(Organization::class, $organization);
$this->assertEquals($orgUrl, $organization->url);
$this->assertEquals($orgName, $organization->name);
$this->assertEquals($orgDisplayName, $organization->displayName);
}
}