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\UseCases\ChangeAddress\ChangeAddressRequest; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* @covers \WMDE\Fundraising\AddressChangeContext\UseCases\ChangeAddress\ChangeAddressRequest |
11
|
|
|
*/ |
12
|
|
|
class ChangeAddressRequestTest extends TestCase { |
13
|
|
|
public function testCreatesPersonalRequest(): void { |
14
|
|
|
$request = ChangeAddressRequest::newPersonalChangeAddressRequest( |
15
|
|
|
salutation: 'Herr', |
16
|
|
|
title: 'Dr.', |
17
|
|
|
firstName: 'Bruce', |
18
|
|
|
lastName: 'Wayne', |
19
|
|
|
address: 'Fledergasse 9', |
20
|
|
|
postcode: '66484', |
21
|
|
|
city: 'Battweiler', |
22
|
|
|
country: 'ZZ', |
23
|
|
|
identifier: '0caffee', |
24
|
|
|
donationReceipt: true, |
25
|
|
|
isOptOutOnly: true, |
26
|
|
|
); |
27
|
|
|
|
28
|
|
|
$this->assertSame( '', $request->company ); |
29
|
|
|
$this->assertSame( 'Herr', $request->salutation ); |
30
|
|
|
$this->assertSame( 'Dr.', $request->title ); |
31
|
|
|
$this->assertSame( 'Bruce', $request->firstName ); |
32
|
|
|
$this->assertSame( 'Wayne', $request->lastName ); |
33
|
|
|
$this->assertSame( 'Fledergasse 9', $request->address ); |
34
|
|
|
$this->assertSame( '66484', $request->postcode ); |
35
|
|
|
$this->assertSame( 'Battweiler', $request->city ); |
36
|
|
|
$this->assertSame( 'ZZ', $request->country ); |
37
|
|
|
$this->assertSame( '0caffee', $request->identifier ); |
38
|
|
|
$this->assertSame( true, $request->donationReceipt ); |
39
|
|
|
$this->assertSame( true, $request->isOptOutOnly ); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function testCreatesCompanyRequest(): void { |
43
|
|
|
$request = ChangeAddressRequest::newCompanyChangeAddressRequest( |
44
|
|
|
company: 'Wayne Enterprises', |
45
|
|
|
address: 'Fledergasse 9', |
46
|
|
|
postcode: '66484', |
47
|
|
|
city: 'Battweiler', |
48
|
|
|
country: 'ZZ', |
49
|
|
|
identifier: '0caffee', |
50
|
|
|
donationReceipt: true, |
51
|
|
|
isOptOutOnly: true, |
52
|
|
|
); |
53
|
|
|
|
54
|
|
|
$this->assertSame( 'Wayne Enterprises', $request->company ); |
55
|
|
|
$this->assertSame( '', $request->salutation ); |
56
|
|
|
$this->assertSame( '', $request->title ); |
57
|
|
|
$this->assertSame( '', $request->firstName ); |
58
|
|
|
$this->assertSame( '', $request->lastName ); |
59
|
|
|
$this->assertSame( 'Fledergasse 9', $request->address ); |
60
|
|
|
$this->assertSame( '66484', $request->postcode ); |
61
|
|
|
$this->assertSame( 'Battweiler', $request->city ); |
62
|
|
|
$this->assertSame( 'ZZ', $request->country ); |
63
|
|
|
$this->assertSame( '0caffee', $request->identifier ); |
64
|
|
|
$this->assertSame( true, $request->donationReceipt ); |
65
|
|
|
$this->assertSame( true, $request->isOptOutOnly ); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function testPersonFieldsAreTrimmed(): void { |
69
|
|
|
$request = ChangeAddressRequest::newPersonalChangeAddressRequest( |
70
|
|
|
salutation: ' Herr ', |
71
|
|
|
title: 'Dr. ', |
72
|
|
|
firstName: ' Bruce ', |
73
|
|
|
lastName: ' Wayne ', |
74
|
|
|
address: ' Fledergasse 9 ', |
75
|
|
|
postcode: ' 66484 ', |
76
|
|
|
city: ' Battweiler ', |
77
|
|
|
country: ' ZZ ', |
78
|
|
|
identifier: '0caffee ', |
79
|
|
|
donationReceipt: true, |
80
|
|
|
isOptOutOnly: true, |
81
|
|
|
); |
82
|
|
|
|
83
|
|
|
$this->assertSame( 'Herr', $request->salutation ); |
84
|
|
|
$this->assertSame( 'Dr.', $request->title ); |
85
|
|
|
$this->assertSame( 'Bruce', $request->firstName ); |
86
|
|
|
$this->assertSame( 'Wayne', $request->lastName ); |
87
|
|
|
$this->assertSame( 'Fledergasse 9', $request->address ); |
88
|
|
|
$this->assertSame( '66484', $request->postcode ); |
89
|
|
|
$this->assertSame( 'Battweiler', $request->city ); |
90
|
|
|
$this->assertSame( 'ZZ', $request->country ); |
91
|
|
|
$this->assertSame( '0caffee', $request->identifier ); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
public function testCompanyFieldsAreTrimmed(): void { |
95
|
|
|
$request = ChangeAddressRequest::newCompanyChangeAddressRequest( |
96
|
|
|
company: ' Wayne Enterprises ', |
97
|
|
|
address: ' Fledergasse 9 ', |
98
|
|
|
postcode: ' 66484 ', |
99
|
|
|
city: ' Battweiler ', |
100
|
|
|
country: ' ZZ', |
101
|
|
|
identifier: '0caffee ', |
102
|
|
|
donationReceipt: true, |
103
|
|
|
isOptOutOnly: true, |
104
|
|
|
); |
105
|
|
|
|
106
|
|
|
$this->assertSame( 'Wayne Enterprises', $request->company ); |
107
|
|
|
$this->assertSame( 'Fledergasse 9', $request->address ); |
108
|
|
|
$this->assertSame( '66484', $request->postcode ); |
109
|
|
|
$this->assertSame( 'Battweiler', $request->city ); |
110
|
|
|
$this->assertSame( 'ZZ', $request->country ); |
111
|
|
|
$this->assertSame( '0caffee', $request->identifier ); |
112
|
|
|
} |
113
|
|
|
} |
114
|
|
|
|