|
| 1 | +<?php |
| 2 | +declare( strict_types=1 ); |
| 3 | + |
| 4 | +namespace WMDE\Fundraising\AddressChangeContext\Tests\Unit\UseCases; |
| 5 | + |
| 6 | +use PHPUnit\Framework\TestCase; |
| 7 | +use WMDE\Fundraising\AddressChangeContext\Domain\Model\AddressChange; |
| 8 | +use WMDE\Fundraising\AddressChangeContext\UseCases\ChangeAddress\ChangeAddressRequest; |
| 9 | + |
| 10 | +/** |
| 11 | + * @covers \WMDE\Fundraising\AddressChangeContext\UseCases\ChangeAddress\ChangeAddressRequest |
| 12 | + */ |
| 13 | +class ChangeAddressRequestTest extends TestCase { |
| 14 | + public function testAccessors(): void { |
| 15 | + $request = new ChangeAddressRequest(); |
| 16 | + $request->setSalutation( 'Herr' ); |
| 17 | + $request->setTitle( 'Dr.' ); |
| 18 | + $request->setFirstName( 'Bruce' ); |
| 19 | + $request->setLastName( 'Wayne' ); |
| 20 | + $request->setCompany( 'Wayne Enterprises' ); |
| 21 | + $request->setPostcode( '66484' ); |
| 22 | + $request->setAddress( 'Fledergasse 9' ); |
| 23 | + $request->setCity( 'Battweiler' ); |
| 24 | + $request->setCountry( 'ZZ' ); |
| 25 | + $request->setAddressType( AddressChange::ADDRESS_TYPE_PERSON ); |
| 26 | + $request->setDonationReceipt( true ); |
| 27 | + $request->setIdentifier( '0caffee' ); |
| 28 | + $request->setIsOptOutOnly( false ); |
| 29 | + $optOutRequest = new ChangeAddressRequest(); |
| 30 | + $optOutRequest->setIsOptOutOnly( true ); |
| 31 | + |
| 32 | + $this->assertSame( 'Herr', $request->getSalutation() ); |
| 33 | + $this->assertSame( 'Dr.', $request->getTitle() ); |
| 34 | + $this->assertSame( 'Bruce', $request->getFirstName() ); |
| 35 | + $this->assertSame( 'Wayne', $request->getLastName() ); |
| 36 | + $this->assertSame( 'Wayne Enterprises', $request->getCompany() ); |
| 37 | + $this->assertSame( 'Fledergasse 9', $request->getAddress() ); |
| 38 | + $this->assertSame( '66484', $request->getPostcode() ); |
| 39 | + $this->assertSame( 'Battweiler', $request->getCity() ); |
| 40 | + $this->assertSame( 'ZZ', $request->getCountry() ); |
| 41 | + $this->assertSame( AddressChange::ADDRESS_TYPE_PERSON, $request->getAddressType() ); |
| 42 | + $this->assertSame( '0caffee', $request->getIdentifier() ); |
| 43 | + $this->assertTrue( $request->isPersonal() ); |
| 44 | + $this->assertFalse( $request->isCompany() ); |
| 45 | + $this->assertFalse( $request->isOptedOutOfDonationReceipt() ); |
| 46 | + $this->assertTrue( $request->hasAddressChangeData() ); |
| 47 | + $this->assertFalse( $optOutRequest->hasAddressChangeData() ); |
| 48 | + } |
| 49 | + |
| 50 | + public function testStringFieldsAreTrimmed(): void { |
| 51 | + $request = new ChangeAddressRequest(); |
| 52 | + $request->setSalutation( ' Herr ' ); |
| 53 | + $request->setTitle( 'Dr. ' ); |
| 54 | + $request->setFirstName( ' Bruce ' ); |
| 55 | + $request->setLastName( 'Wayne ' ); |
| 56 | + $request->setCompany( ' Wayne Enterprises' ); |
| 57 | + $request->setPostcode( "66484 \n" ); |
| 58 | + $request->setAddress( "\t Fledergasse 9 " ); |
| 59 | + $request->setCity( ' Battweiler ' ); |
| 60 | + $request->setCountry( ' ZZ ' ); |
| 61 | + $request->setIdentifier( ' 0caffee ' ); |
| 62 | + |
| 63 | + $this->assertSame( 'Herr', $request->getSalutation() ); |
| 64 | + $this->assertSame( 'Dr.', $request->getTitle() ); |
| 65 | + $this->assertSame( 'Bruce', $request->getFirstName() ); |
| 66 | + $this->assertSame( 'Wayne', $request->getLastName() ); |
| 67 | + $this->assertSame( 'Wayne Enterprises', $request->getCompany() ); |
| 68 | + $this->assertSame( 'Fledergasse 9', $request->getAddress() ); |
| 69 | + $this->assertSame( '66484', $request->getPostcode() ); |
| 70 | + $this->assertSame( 'Battweiler', $request->getCity() ); |
| 71 | + $this->assertSame( 'ZZ', $request->getCountry() ); |
| 72 | + $this->assertSame( '0caffee', $request->getIdentifier() ); |
| 73 | + } |
| 74 | +} |
0 commit comments