| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?php
- namespace App\Test\Service\Access;
- use App\Entity\Core\AddressPostal;
- use App\Service\Core\AddressPostalUtils;
- use PHPUnit\Framework\TestCase;
- class AddressPostalUtilsTest extends TestCase
- {
- public function testGetFullStreetAddress(): void {
- $addressPostalUtils = new AddressPostalUtils(); // Cf. bug when SUT has only one method, can't be mocked
- $addressPostal = $this->getMockBuilder(AddressPostal::class)->getMock();
- $addressPostal->method('getStreetAddress')->willReturn('Abc');
- $addressPostal->method('getStreetAddressSecond')->willReturn('Def ');
- $addressPostal->method('getStreetAddressThird')->willReturn(' Ghi ');
- $this->assertEqualsCanonicalizing(
- "Abc\nDef\nGhi",
- $addressPostalUtils->getFullStreetAddress($addressPostal)
- );
- $this->assertEqualsCanonicalizing(
- "Abc Def Ghi",
- $addressPostalUtils->getFullStreetAddress($addressPostal, ' ')
- );
- }
- public function testGetFullStreetAddressWithMissing(): void {
- $addressPostalUtils = new AddressPostalUtils(); // Cf. bug when SUT has only one method, can't be mocked
- $addressPostal = $this->getMockBuilder(AddressPostal::class)->getMock();
- $addressPostal->method('getStreetAddress')->willReturn('Abc');
- $addressPostal->method('getStreetAddressSecond')->willReturn('');
- $addressPostal->method('getStreetAddressThird')->willReturn(' Def');
- $this->assertEqualsCanonicalizing(
- "Abc\nDef",
- $addressPostalUtils->getFullStreetAddress($addressPostal)
- );
- }
- }
|