mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 21:34:25 +00:00
address: fix address lines in case of noAddress + add test
This commit is contained in:
parent
7d20f842a2
commit
fd40ae0198
@ -188,7 +188,7 @@ class AddressRender implements ChillEntityRenderInterface
|
|||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function renderStreetLine($addr): string
|
private function renderStreetLine($addr): ?string
|
||||||
{
|
{
|
||||||
if (!empty($addr->getStreet())) {
|
if (!empty($addr->getStreet())) {
|
||||||
$street = $addr->getStreet();
|
$street = $addr->getStreet();
|
||||||
@ -210,8 +210,8 @@ class AddressRender implements ChillEntityRenderInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (',' === $res) {
|
if ((',' === $res) || ('' === $res)) {
|
||||||
$res = '';
|
$res = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
|
@ -314,5 +314,35 @@ final class AddressRenderTest extends KernelTestCase
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function noFullAddressDataProviderBE(): Iterator
|
||||||
|
{
|
||||||
|
$addr = new Address();
|
||||||
|
$country = (new Country())
|
||||||
|
->setName(['fr' => 'Belgium'])
|
||||||
|
->setCountryCode('BE');
|
||||||
|
$postCode = new PostalCode();
|
||||||
|
$postCode->setName('Locality')
|
||||||
|
->setCode('012345')
|
||||||
|
->setCountry($country);
|
||||||
|
|
||||||
|
$addr->setPostcode($postCode)
|
||||||
|
->setIsNoAddress(true);
|
||||||
|
|
||||||
|
yield [$addr, '012345 Locality - Belgium'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider noFullAddressDataProviderBE
|
||||||
|
*/
|
||||||
|
public function testRenderNoFullAddressBE(Address $addr, string $expectedString): void
|
||||||
|
{
|
||||||
|
$engine = self::$container->get(EngineInterface::class);
|
||||||
|
$translatableStringHelper = self::$container->get(TranslatableStringHelper::class);
|
||||||
|
$renderer = new AddressRender($engine, $translatableStringHelper);
|
||||||
|
|
||||||
|
$this->assertEquals($expectedString, $renderer->renderString($addr, []));
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user