@@ -132,4 +132,35 @@ public function testUsedAndExportedAddressReturnsCorrectExportState(): void {
132132
133133 $ this ->assertEquals ( AddressChange::EXPORT_STATE_USED_EXPORTED , $ addressChange ->getExportState () );
134134 }
135+
136+ public function testNewAddressChangesAreUnused (): void {
137+ $ addressChange = new AddressChange ( AddressType::Person, AddressChange::EXTERNAL_ID_TYPE_DONATION , self ::DUMMY_DONATION_ID , $ this ->identifier );
138+
139+ $ this ->assertFalse ( $ addressChange ->hasBeenUsed () );
140+ }
141+
142+ public function testAddressChangesWithAddressesAreUsed (): void {
143+ $ addressChange = new AddressChange ( AddressType::Person, AddressChange::EXTERNAL_ID_TYPE_DONATION , self ::DUMMY_DONATION_ID , $ this ->identifier );
144+ $ addressChange ->performAddressChange ( ValidAddress::newValidPersonalAddress (), $ this ->newIdentifier );
145+
146+ $ this ->assertTrue ( $ addressChange ->hasBeenUsed () );
147+ }
148+
149+ public function testAddressChangesWithOptOutAreUsed (): void {
150+ $ addressChange = new AddressChange ( AddressType::Person, AddressChange::EXTERNAL_ID_TYPE_DONATION , self ::DUMMY_DONATION_ID , $ this ->identifier );
151+ $ addressChange ->optOutOfDonationReceipt ( $ this ->newIdentifier );
152+
153+ $ this ->assertTrue ( $ addressChange ->hasBeenUsed () );
154+ }
155+
156+ public function testMultipleModificationsWithTheSameIdentifierKeepsIdentifiers (): void {
157+ $ addressChange = $ this ->newPersonAddressChange ();
158+ $ initialIdentifier = $ addressChange ->getCurrentIdentifier ();
159+
160+ $ addressChange ->performAddressChange ( ValidAddress::newValidPersonalAddress (), $ this ->newIdentifier );
161+ $ addressChange ->optOutOfDonationReceipt ( $ this ->newIdentifier );
162+
163+ $ this ->assertEquals ( $ initialIdentifier , $ addressChange ->getPreviousIdentifier () );
164+ $ this ->assertEquals ( $ this ->newIdentifier , $ addressChange ->getCurrentIdentifier () );
165+ }
135166}
0 commit comments