Completed
Push — master ( e6c518...18cdbd )
by Jeroen De
12s
created
app/RouteHandlers/AddDonationHandler.php 1 patch
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types = 1);
4 4
 
5 5
 namespace WMDE\Fundraising\Frontend\App\RouteHandlers;
6 6
 
@@ -27,47 +27,47 @@  discard block
 block discarded – undo
27 27
 	private $ffFactory;
28 28
 	private $app;
29 29
 
30
-	public function __construct( FunFunFactory $ffFactory, Application $app ) {
30
+	public function __construct(FunFunFactory $ffFactory, Application $app) {
31 31
 		$this->ffFactory = $ffFactory;
32 32
 		$this->app = $app;
33 33
 	}
34 34
 
35
-	public function handle( Request $request ): Response {
36
-		if ( !$this->isSubmissionAllowed( $request ) ) {
37
-			return new Response( $this->ffFactory->newSystemMessageResponse( 'donation_rejected_limit' ) );
35
+	public function handle(Request $request): Response {
36
+		if (!$this->isSubmissionAllowed($request)) {
37
+			return new Response($this->ffFactory->newSystemMessageResponse('donation_rejected_limit'));
38 38
 		}
39 39
 
40
-		$addDonationRequest = $this->createDonationRequest( $request );
41
-		$responseModel = $this->ffFactory->newAddDonationUseCase()->addDonation( $addDonationRequest );
40
+		$addDonationRequest = $this->createDonationRequest($request);
41
+		$responseModel = $this->ffFactory->newAddDonationUseCase()->addDonation($addDonationRequest);
42 42
 
43
-		if ( !$responseModel->isSuccessful() ) {
43
+		if (!$responseModel->isSuccessful()) {
44 44
 			return new Response(
45 45
 				$this->ffFactory->newDonationFormViolationPresenter()->present(
46 46
 					$responseModel->getValidationErrors(), $addDonationRequest,
47
-					$this->newTrackingInfoFromRequest( $request )
47
+					$this->newTrackingInfoFromRequest($request)
48 48
 				)
49 49
 			);
50 50
 		}
51 51
 
52
-		$this->sendTrackingDataIfNeeded( $request, $responseModel );
52
+		$this->sendTrackingDataIfNeeded($request, $responseModel);
53 53
 
54
-		return $this->newHttpResponse( $responseModel );
54
+		return $this->newHttpResponse($responseModel);
55 55
 	}
56 56
 
57
-	private function sendTrackingDataIfNeeded( Request $request, AddDonationResponse $responseModel ) {
58
-		if ( $request->get( 'mbt', '' ) !== '1' || $responseModel->getDonation()->getPaymentType() !== PaymentType::PAYPAL ) {
57
+	private function sendTrackingDataIfNeeded(Request $request, AddDonationResponse $responseModel) {
58
+		if ($request->get('mbt', '') !== '1' || $responseModel->getDonation()->getPaymentType() !== PaymentType::PAYPAL) {
59 59
 			return;
60 60
 		}
61 61
 
62
-		$trackingCode = explode( '/', $request->attributes->get( 'trackingCode' ) );
62
+		$trackingCode = explode('/', $request->attributes->get('trackingCode'));
63 63
 		$campaign = $trackingCode[0];
64 64
 		$keyword = $trackingCode[1] ?? '';
65 65
 
66
-		$this->ffFactory->getPageViewTracker()->trackPaypalRedirection( $campaign, $keyword, $request->getClientIp() );
66
+		$this->ffFactory->getPageViewTracker()->trackPaypalRedirection($campaign, $keyword, $request->getClientIp());
67 67
 	}
68 68
 
69
-	private function newHttpResponse( AddDonationResponse $responseModel ): Response {
70
-		switch( $responseModel->getDonation()->getPaymentType() ) {
69
+	private function newHttpResponse(AddDonationResponse $responseModel): Response {
70
+		switch ($responseModel->getDonation()->getPaymentType()) {
71 71
 			case PaymentType::DIRECT_DEBIT:
72 72
 			case PaymentType::BANK_TRANSFER:
73 73
 				$httpResponse = $this->app->redirect(
@@ -95,105 +95,105 @@  discard block
 block discarded – undo
95 95
 				break;
96 96
 			case PaymentType::CREDIT_CARD:
97 97
 				$httpResponse = new Response(
98
-					$this->ffFactory->newCreditCardPaymentHtmlPresenter()->present( $responseModel )
98
+					$this->ffFactory->newCreditCardPaymentHtmlPresenter()->present($responseModel)
99 99
 				);
100 100
 				break;
101 101
 			default:
102
-				throw new \LogicException( 'This code should not be reached' );
102
+				throw new \LogicException('This code should not be reached');
103 103
 		}
104 104
 		return $httpResponse;
105 105
 	}
106 106
 
107
-	private function createDonationRequest( Request $request ): AddDonationRequest {
107
+	private function createDonationRequest(Request $request): AddDonationRequest {
108 108
 		$donationRequest = new AddDonationRequest();
109 109
 
110
-		$donationRequest->setAmount( $this->getEuroAmountFromString( $request->get( 'betrag', '' ) ) );
111
-
112
-		$donationRequest->setPaymentType( $request->get( 'zahlweise', '' ) );
113
-		$donationRequest->setInterval( intval( $request->get( 'periode', 0 ) ) );
114
-
115
-		$donationRequest->setDonorType( $request->get( 'addressType', '' ) );
116
-		$donationRequest->setDonorSalutation( $request->get( 'salutation', '' ) );
117
-		$donationRequest->setDonorTitle( $request->get( 'title', '' ) );
118
-		$donationRequest->setDonorCompany( $request->get( 'companyName', '' ) );
119
-		$donationRequest->setDonorFirstName( $request->get( 'firstName', '' ) );
120
-		$donationRequest->setDonorLastName( $request->get( 'lastName', '' ) );
121
-		$donationRequest->setDonorStreetAddress( $this->filterAutofillCommas( $request->get( 'street', '' ) ) );
122
-		$donationRequest->setDonorPostalCode( $request->get( 'postcode', '' ) );
123
-		$donationRequest->setDonorCity( $request->get( 'city', '' ) );
124
-		$donationRequest->setDonorCountryCode( $request->get( 'country', '' ) );
125
-		$donationRequest->setDonorEmailAddress( $request->get( 'email', '' ) );
126
-
127
-		if ( $request->get( 'zahlweise', '' ) === PaymentType::DIRECT_DEBIT ) {
128
-			$donationRequest->setBankData( $this->getBankDataFromRequest( $request ) );
110
+		$donationRequest->setAmount($this->getEuroAmountFromString($request->get('betrag', '')));
111
+
112
+		$donationRequest->setPaymentType($request->get('zahlweise', ''));
113
+		$donationRequest->setInterval(intval($request->get('periode', 0)));
114
+
115
+		$donationRequest->setDonorType($request->get('addressType', ''));
116
+		$donationRequest->setDonorSalutation($request->get('salutation', ''));
117
+		$donationRequest->setDonorTitle($request->get('title', ''));
118
+		$donationRequest->setDonorCompany($request->get('companyName', ''));
119
+		$donationRequest->setDonorFirstName($request->get('firstName', ''));
120
+		$donationRequest->setDonorLastName($request->get('lastName', ''));
121
+		$donationRequest->setDonorStreetAddress($this->filterAutofillCommas($request->get('street', '')));
122
+		$donationRequest->setDonorPostalCode($request->get('postcode', ''));
123
+		$donationRequest->setDonorCity($request->get('city', ''));
124
+		$donationRequest->setDonorCountryCode($request->get('country', ''));
125
+		$donationRequest->setDonorEmailAddress($request->get('email', ''));
126
+
127
+		if ($request->get('zahlweise', '') === PaymentType::DIRECT_DEBIT) {
128
+			$donationRequest->setBankData($this->getBankDataFromRequest($request));
129 129
 		}
130 130
 
131
-		$donationRequest->setTracking( $request->attributes->get( 'trackingCode' ) );
132
-		$donationRequest->setOptIn( $request->get( 'info', '' ) );
133
-		$donationRequest->setSource( $request->attributes->get( 'trackingSource' ) );
134
-		$donationRequest->setTotalImpressionCount( intval( $request->get( 'impCount', 0 ) ) );
135
-		$donationRequest->setSingleBannerImpressionCount( intval( $request->get( 'bImpCount', 0 ) ) );
131
+		$donationRequest->setTracking($request->attributes->get('trackingCode'));
132
+		$donationRequest->setOptIn($request->get('info', ''));
133
+		$donationRequest->setSource($request->attributes->get('trackingSource'));
134
+		$donationRequest->setTotalImpressionCount(intval($request->get('impCount', 0)));
135
+		$donationRequest->setSingleBannerImpressionCount(intval($request->get('bImpCount', 0)));
136 136
 
137 137
 		return $donationRequest;
138 138
 	}
139 139
 
140
-	private function getBankDataFromRequest( Request $request ): BankData {
140
+	private function getBankDataFromRequest(Request $request): BankData {
141 141
 		$bankData = new BankData();
142
-		$bankData->setIban( new Iban( $request->get( 'iban', '' ) ) )
143
-			->setBic( $request->get( 'bic', '' ) )
144
-			->setAccount( $request->get( 'konto', '' ) )
145
-			->setBankCode( $request->get( 'blz', '' ) )
146
-			->setBankName( $request->get( 'bankname', '' ) );
147
-
148
-		if ( $bankData->hasIban() && !$bankData->hasBic() && !$bankData->hasCompleteLegacyBankData() ) {
149
-			$bankData = $this->newBankDataFromIban( $bankData->getIban() );
142
+		$bankData->setIban(new Iban($request->get('iban', '')))
143
+			->setBic($request->get('bic', ''))
144
+			->setAccount($request->get('konto', ''))
145
+			->setBankCode($request->get('blz', ''))
146
+			->setBankName($request->get('bankname', ''));
147
+
148
+		if ($bankData->hasIban() && !$bankData->hasBic() && !$bankData->hasCompleteLegacyBankData()) {
149
+			$bankData = $this->newBankDataFromIban($bankData->getIban());
150 150
 		}
151
-		if ( $bankData->hasCompleteLegacyBankData() && !$bankData->hasIban() ) {
152
-			$bankData = $this->newBankDataFromAccountAndBankCode( $bankData->getAccount(), $bankData->getBankCode() );
151
+		if ($bankData->hasCompleteLegacyBankData() && !$bankData->hasIban()) {
152
+			$bankData = $this->newBankDataFromAccountAndBankCode($bankData->getAccount(), $bankData->getBankCode());
153 153
 		}
154 154
 
155 155
 		return $bankData->freeze()->assertNoNullFields();
156 156
 	}
157 157
 
158
-	private function newBankDataFromIban( Iban $iban ): BankData {
159
-		return $this->ffFactory->newBankDataConverter()->getBankDataFromIban( $iban );
158
+	private function newBankDataFromIban(Iban $iban): BankData {
159
+		return $this->ffFactory->newBankDataConverter()->getBankDataFromIban($iban);
160 160
 	}
161 161
 
162
-	private function newBankDataFromAccountAndBankCode( string $account, string $bankCode ): BankData {
163
-		return $this->ffFactory->newBankDataConverter()->getBankDataFromAccountData( $account, $bankCode );
162
+	private function newBankDataFromAccountAndBankCode(string $account, string $bankCode): BankData {
163
+		return $this->ffFactory->newBankDataConverter()->getBankDataFromAccountData($account, $bankCode);
164 164
 	}
165 165
 
166
-	private function getEuroAmountFromString( string $amount ): Euro {
166
+	private function getEuroAmountFromString(string $amount): Euro {
167 167
 		$locale = 'de_DE'; // TODO: make this configurable for multilanguage support
168 168
 		try {
169
-			return Euro::newFromFloat( ( new AmountParser( $locale ) )->parseAsFloat( $amount ) );
170
-		} catch ( \InvalidArgumentException $ex ) {
171
-			return Euro::newFromCents( 0 );
169
+			return Euro::newFromFloat((new AmountParser($locale))->parseAsFloat($amount));
170
+		} catch (\InvalidArgumentException $ex) {
171
+			return Euro::newFromCents(0);
172 172
 		}
173 173
 
174 174
 	}
175 175
 
176
-	private function isSubmissionAllowed( Request $request ) {
177
-		$lastSubmission = $request->cookies->get( ShowDonationConfirmationHandler::SUBMISSION_COOKIE_NAME, '' );
178
-		if ( $lastSubmission === '' ) {
176
+	private function isSubmissionAllowed(Request $request) {
177
+		$lastSubmission = $request->cookies->get(ShowDonationConfirmationHandler::SUBMISSION_COOKIE_NAME, '');
178
+		if ($lastSubmission === '') {
179 179
 			return true;
180 180
 		}
181 181
 
182 182
 		$minNextTimestamp =
183
-			\DateTime::createFromFormat( ShowDonationConfirmationHandler::TIMESTAMP_FORMAT, $lastSubmission )
184
-			->add( new \DateInterval( $this->ffFactory->getDonationTimeframeLimit() ) );
183
+			\DateTime::createFromFormat(ShowDonationConfirmationHandler::TIMESTAMP_FORMAT, $lastSubmission)
184
+			->add(new \DateInterval($this->ffFactory->getDonationTimeframeLimit()));
185 185
 
186
-		if ( $minNextTimestamp > new \DateTime() ) {
186
+		if ($minNextTimestamp > new \DateTime()) {
187 187
 			return false;
188 188
 		}
189 189
 
190 190
 		return true;
191 191
 	}
192 192
 
193
-	private function newTrackingInfoFromRequest( Request $request ): DonationTrackingInfo {
193
+	private function newTrackingInfoFromRequest(Request $request): DonationTrackingInfo {
194 194
 		$tracking = new DonationTrackingInfo();
195
-		$tracking->setSingleBannerImpressionCount( intval( $request->get( 'bImpCount', 0 ) ) );
196
-		$tracking->setTotalImpressionCount( intval( $request->get( 'impCount', 0 ) ) );
195
+		$tracking->setSingleBannerImpressionCount(intval($request->get('bImpCount', 0)));
196
+		$tracking->setTotalImpressionCount(intval($request->get('impCount', 0)));
197 197
 
198 198
 		return $tracking;
199 199
 	}
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 	 * @param string $value
206 206
 	 * @return string
207 207
 	 */
208
-	private function filterAutofillCommas( string $value ): string {
209
-		return trim( preg_replace( ['/,/', '/\s{2,}/'], [' ', ' '], $value ) );
208
+	private function filterAutofillCommas(string $value): string {
209
+		return trim(preg_replace(['/,/', '/\s{2,}/'], [' ', ' '], $value));
210 210
 	}
211 211
 }
212 212
\ No newline at end of file
Please login to merge, or discard this patch.
contexts/PaymentContext/src/Domain/Model/BankData.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types = 1);
4 4
 
5 5
 namespace WMDE\Fundraising\Frontend\PaymentContext\Domain\Model;
6 6
 
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 		return $this->bic;
25 25
 	}
26 26
 
27
-	public function setBic( string $bic ) {
27
+	public function setBic(string $bic) {
28 28
 		$this->assertIsWritable();
29 29
 		$this->bic = $bic;
30 30
 		return $this;
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 		return $this->iban;
35 35
 	}
36 36
 
37
-	public function setIban( Iban $iban ) {
37
+	public function setIban(Iban $iban) {
38 38
 		$this->assertIsWritable();
39 39
 		$this->iban = $iban;
40 40
 		return $this;
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 		return $this->account;
45 45
 	}
46 46
 
47
-	public function setAccount( string $account ) {
47
+	public function setAccount(string $account) {
48 48
 		$this->assertIsWritable();
49 49
 		$this->account = $account;
50 50
 		return $this;
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 		return $this->bankCode;
55 55
 	}
56 56
 
57
-	public function setBankCode( string $bankCode ) {
57
+	public function setBankCode(string $bankCode) {
58 58
 		$this->assertIsWritable();
59 59
 		$this->bankCode = $bankCode;
60 60
 		return $this;
@@ -64,22 +64,22 @@  discard block
 block discarded – undo
64 64
 		return $this->bankName;
65 65
 	}
66 66
 
67
-	public function setBankName( string $bankName ) {
67
+	public function setBankName(string $bankName) {
68 68
 		$this->assertIsWritable();
69 69
 		$this->bankName = $bankName;
70 70
 		return $this;
71 71
 	}
72 72
 
73 73
 	public function hasIban(): bool {
74
-		return !empty( $this->getIban()->toString() );
74
+		return !empty($this->getIban()->toString());
75 75
 	}
76 76
 
77 77
 	public function hasBic(): bool {
78
-		return !empty( $this->getBic() );
78
+		return !empty($this->getBic());
79 79
 	}
80 80
 
81 81
 	public function hasCompleteLegacyBankData(): bool {
82
-		return !empty( $this->getAccount() ) || !empty( $this->getBankCode() );
82
+		return !empty($this->getAccount()) || !empty($this->getBankCode());
83 83
 	}
84 84
 
85 85
 }
Please login to merge, or discard this patch.
Unit/UseCases/ApplyForMembership/MembershipApplicationValidatorTest.php 1 patch
Spacing   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types = 1);
4 4
 
5 5
 namespace WMDE\Fundraising\Frontend\MembershipContext\Tests\Unit\UseCases\ApplyForMembership;
6 6
 
@@ -51,11 +51,11 @@  discard block
 block discarded – undo
51 51
 
52 52
 	public function testGivenValidRequest_validationSucceeds() {
53 53
 		$validRequest = $this->newValidRequest();
54
-		$response = $this->newValidator()->validate( $validRequest );
54
+		$response = $this->newValidator()->validate($validRequest);
55 55
 
56
-		$this->assertEquals( new Result(), $response );
57
-		$this->assertEmpty( $response->getViolationSources() );
58
-		$this->assertTrue( $response->isSuccessful() );
56
+		$this->assertEquals(new Result(), $response);
57
+		$this->assertEmpty($response->getViolationSources());
58
+		$this->assertTrue($response->isSuccessful());
59 59
 	}
60 60
 
61 61
 	private function newValidator() {
@@ -69,27 +69,27 @@  discard block
 block discarded – undo
69 69
 	public function testWhenFeeValidationFails_overallValidationAlsoFails() {
70 70
 		$this->feeValidator = $this->newFailingFeeValidator();
71 71
 
72
-		$response = $this->newValidator()->validate( $this->newValidRequest() );
72
+		$response = $this->newValidator()->validate($this->newValidRequest());
73 73
 
74
-		$this->assertEquals( $this->newFeeViolationResult(), $response );
74
+		$this->assertEquals($this->newFeeViolationResult(), $response);
75 75
 	}
76 76
 
77 77
 	private function newFailingFeeValidator(): MembershipFeeValidator {
78
-		$feeValidator = $this->getMockBuilder( MembershipFeeValidator::class )
78
+		$feeValidator = $this->getMockBuilder(MembershipFeeValidator::class)
79 79
 			->disableOriginalConstructor()->getMock();
80 80
 
81
-		$feeValidator->method( 'validate' )
82
-			->willReturn( $this->newFeeViolationResult() );
81
+		$feeValidator->method('validate')
82
+			->willReturn($this->newFeeViolationResult());
83 83
 
84 84
 		return $feeValidator;
85 85
 	}
86 86
 
87 87
 	private function newSucceedingFeeValidator(): MembershipFeeValidator {
88
-		$feeValidator = $this->getMockBuilder( MembershipFeeValidator::class )
88
+		$feeValidator = $this->getMockBuilder(MembershipFeeValidator::class)
89 89
 			->disableOriginalConstructor()->getMock();
90 90
 
91
-		$feeValidator->method( 'validate' )
92
-			->willReturn( new Result() );
91
+		$feeValidator->method('validate')
92
+			->willReturn(new Result());
93 93
 
94 94
 		return $feeValidator;
95 95
 	}
@@ -99,17 +99,17 @@  discard block
 block discarded – undo
99 99
 	}
100 100
 
101 101
 	private function newFeeViolationResult() {
102
-		return new Result( [
102
+		return new Result([
103 103
 			Result::SOURCE_PAYMENT_AMOUNT => Result::VIOLATION_NOT_MONEY
104
-		] );
104
+		]);
105 105
 	}
106 106
 
107 107
 	private function newSucceedingBankDataValidator(): BankDataValidator {
108
-		$feeValidator = $this->getMockBuilder( BankDataValidator::class )
108
+		$feeValidator = $this->getMockBuilder(BankDataValidator::class)
109 109
 			->disableOriginalConstructor()->getMock();
110 110
 
111
-		$feeValidator->method( 'validate' )
112
-			->willReturn( new ValidationResult() );
111
+		$feeValidator->method('validate')
112
+			->willReturn(new ValidationResult());
113 113
 
114 114
 		return $feeValidator;
115 115
 	}
@@ -118,31 +118,31 @@  discard block
 block discarded – undo
118 118
 		$this->bankDataValidator = $this->newRealBankDataValidator();
119 119
 
120 120
 		$request = $this->newValidRequest();
121
-		$request->getBankData()->setIban( new Iban( '' ) );
121
+		$request->getBankData()->setIban(new Iban(''));
122 122
 
123 123
 		$this->assertRequestValidationResultInErrors(
124 124
 			$request,
125
-			[ Result::SOURCE_IBAN => Result::VIOLATION_MISSING ]
125
+			[Result::SOURCE_IBAN => Result::VIOLATION_MISSING]
126 126
 		);
127 127
 	}
128 128
 
129
-	private function assertRequestValidationResultInErrors( ApplyForMembershipRequest $request, array $expectedErrors ) {
129
+	private function assertRequestValidationResultInErrors(ApplyForMembershipRequest $request, array $expectedErrors) {
130 130
 		$this->assertEquals(
131
-			new Result( $expectedErrors ),
132
-			$this->newValidator()->validate( $request )
131
+			new Result($expectedErrors),
132
+			$this->newValidator()->validate($request)
133 133
 		);
134 134
 	}
135 135
 
136 136
 	private function newRealBankDataValidator(): BankDataValidator {
137
-		return new BankDataValidator( $this->newSucceedingIbanValidator() );
137
+		return new BankDataValidator($this->newSucceedingIbanValidator());
138 138
 	}
139 139
 
140 140
 	private function newSucceedingIbanValidator(): IbanValidator {
141
-		$ibanValidator = $this->getMockBuilder( IbanValidator::class )
141
+		$ibanValidator = $this->getMockBuilder(IbanValidator::class)
142 142
 			->disableOriginalConstructor()->getMock();
143 143
 
144
-		$ibanValidator->method( 'validate' )
145
-			->willReturn( new ValidationResult() );
144
+		$ibanValidator->method('validate')
145
+			->willReturn(new ValidationResult());
146 146
 
147 147
 		return $ibanValidator;
148 148
 	}
@@ -151,11 +151,11 @@  discard block
 block discarded – undo
151 151
 		$this->bankDataValidator = $this->newRealBankDataValidator();
152 152
 
153 153
 		$request = $this->newValidRequest();
154
-		$request->getBankData()->setBic( '' );
154
+		$request->getBankData()->setBic('');
155 155
 
156 156
 		$this->assertRequestValidationResultInErrors(
157 157
 			$request,
158
-			[ Result::SOURCE_BIC => Result::VIOLATION_MISSING ]
158
+			[Result::SOURCE_BIC => Result::VIOLATION_MISSING]
159 159
 		);
160 160
 	}
161 161
 
@@ -163,23 +163,23 @@  discard block
 block discarded – undo
163 163
 		$this->bankDataValidator = $this->newRealBankDataValidator();
164 164
 
165 165
 		$request = $this->newValidRequest();
166
-		$request->getBankData()->setBankName( '' );
167
-		$response = $this->newValidator()->validate( $request );
166
+		$request->getBankData()->setBankName('');
167
+		$response = $this->newValidator()->validate($request);
168 168
 
169
-		$this->assertEquals( new Result(), $response );
170
-		$this->assertEmpty( $response->getViolationSources() );
171
-		$this->assertTrue( $response->isSuccessful() );
169
+		$this->assertEquals(new Result(), $response);
170
+		$this->assertEmpty($response->getViolationSources());
171
+		$this->assertTrue($response->isSuccessful());
172 172
 	}
173 173
 
174 174
 	public function testWhenBankCodeIsMissing_validationFails() {
175 175
 		$this->bankDataValidator = $this->newRealBankDataValidator();
176 176
 
177 177
 		$request = $this->newValidRequest();
178
-		$request->getBankData()->setBankCode( '' );
178
+		$request->getBankData()->setBankCode('');
179 179
 
180 180
 		$this->assertRequestValidationResultInErrors(
181 181
 			$request,
182
-			[ Result::SOURCE_BANK_CODE => Result::VIOLATION_MISSING ]
182
+			[Result::SOURCE_BANK_CODE => Result::VIOLATION_MISSING]
183 183
 		);
184 184
 	}
185 185
 
@@ -187,11 +187,11 @@  discard block
 block discarded – undo
187 187
 		$this->bankDataValidator = $this->newRealBankDataValidator();
188 188
 
189 189
 		$request = $this->newValidRequest();
190
-		$request->getBankData()->setAccount( '' );
190
+		$request->getBankData()->setAccount('');
191 191
 
192 192
 		$this->assertRequestValidationResultInErrors(
193 193
 			$request,
194
-			[ Result::SOURCE_BANK_ACCOUNT => Result::VIOLATION_MISSING ]
194
+			[Result::SOURCE_BANK_ACCOUNT => Result::VIOLATION_MISSING]
195 195
 		);
196 196
 	}
197 197
 
@@ -199,11 +199,11 @@  discard block
 block discarded – undo
199 199
 		$this->bankDataValidator = $this->newRealBankDataValidator();
200 200
 
201 201
 		$request = $this->newValidRequest();
202
-		$request->getBankData()->setAccount( '01189998819991197253' );
202
+		$request->getBankData()->setAccount('01189998819991197253');
203 203
 
204 204
 		$this->assertRequestValidationResultInErrors(
205 205
 			$request,
206
-			[ Result::SOURCE_BANK_ACCOUNT => Result::VIOLATION_WRONG_LENGTH ]
206
+			[Result::SOURCE_BANK_ACCOUNT => Result::VIOLATION_WRONG_LENGTH]
207 207
 		);
208 208
 	}
209 209
 
@@ -211,40 +211,40 @@  discard block
 block discarded – undo
211 211
 		$this->bankDataValidator = $this->newRealBankDataValidator();
212 212
 
213 213
 		$request = $this->newValidRequest();
214
-		$request->getBankData()->setBankCode( '01189998819991197253' );
214
+		$request->getBankData()->setBankCode('01189998819991197253');
215 215
 
216 216
 		$this->assertRequestValidationResultInErrors(
217 217
 			$request,
218
-			[ Result::SOURCE_BANK_CODE => Result::VIOLATION_WRONG_LENGTH ]
218
+			[Result::SOURCE_BANK_CODE => Result::VIOLATION_WRONG_LENGTH]
219 219
 		);
220 220
 	}
221 221
 
222 222
 	public function testWhenDateOfBirthIsNotDate_validationFails() {
223 223
 		$request = $this->newValidRequest();
224
-		$request->setApplicantDateOfBirth( 'this is not a valid date' );
224
+		$request->setApplicantDateOfBirth('this is not a valid date');
225 225
 
226 226
 		$this->assertRequestValidationResultInErrors(
227 227
 			$request,
228
-			[ Result::SOURCE_APPLICANT_DATE_OF_BIRTH => Result::VIOLATION_NOT_DATE ]
228
+			[Result::SOURCE_APPLICANT_DATE_OF_BIRTH => Result::VIOLATION_NOT_DATE]
229 229
 		);
230 230
 	}
231 231
 
232 232
 	/**
233 233
 	 * @dataProvider invalidPhoneNumberProvider
234 234
 	 */
235
-	public function testWhenApplicantPhoneNumberIsInvalid_validationFails( string $invalidPhoneNumber ) {
235
+	public function testWhenApplicantPhoneNumberIsInvalid_validationFails(string $invalidPhoneNumber) {
236 236
 		$request = $this->newValidRequest();
237
-		$request->setApplicantPhoneNumber( $invalidPhoneNumber );
237
+		$request->setApplicantPhoneNumber($invalidPhoneNumber);
238 238
 
239 239
 		$this->assertRequestValidationResultInErrors(
240 240
 			$request,
241
-			[ Result::SOURCE_APPLICANT_PHONE_NUMBER => Result::VIOLATION_NOT_PHONE_NUMBER ]
241
+			[Result::SOURCE_APPLICANT_PHONE_NUMBER => Result::VIOLATION_NOT_PHONE_NUMBER]
242 242
 		);
243 243
 	}
244 244
 
245 245
 	public function invalidPhoneNumberProvider() {
246 246
 		return [
247
-			'potato' => [ 'potato' ],
247
+			'potato' => ['potato'],
248 248
 
249 249
 			// TODO: we use the regex from the old app, which allows for lots of bugus. Improve when time
250 250
 //			'number plus stuff' => [ '01189998819991197253 (invalid edition)' ],
@@ -254,23 +254,23 @@  discard block
 block discarded – undo
254 254
 	/**
255 255
 	 * @dataProvider emailViolationTypeProvider
256 256
 	 */
257
-	public function testWhenApplicantEmailIsInvalid_validationFails( string $emailViolationType ) {
258
-		$this->emailValidator = $this->newFailingEmailValidator( $emailViolationType );
257
+	public function testWhenApplicantEmailIsInvalid_validationFails(string $emailViolationType) {
258
+		$this->emailValidator = $this->newFailingEmailValidator($emailViolationType);
259 259
 
260 260
 		$request = $this->newValidRequest();
261
-		$request->setApplicantEmailAddress( 'this is not a valid email' );
261
+		$request->setApplicantEmailAddress('this is not a valid email');
262 262
 
263 263
 		$this->assertRequestValidationResultInErrors(
264 264
 			$request,
265
-			[ Result::SOURCE_APPLICANT_EMAIL => Result::VIOLATION_NOT_EMAIL ]
265
+			[Result::SOURCE_APPLICANT_EMAIL => Result::VIOLATION_NOT_EMAIL]
266 266
 		);
267 267
 	}
268 268
 
269 269
 	public function emailViolationTypeProvider() {
270 270
 		return [
271
-			[ 'email_address_wrong_format' ],
272
-			[ 'email_address_invalid' ],
273
-			[ 'email_address_domain_record_not_found' ],
271
+			['email_address_wrong_format'],
272
+			['email_address_invalid'],
273
+			['email_address_domain_record_not_found'],
274 274
 		];
275 275
 	}
276 276
 
@@ -279,12 +279,12 @@  discard block
 block discarded – undo
279 279
 	 *
280 280
 	 * @return EmailValidator
281 281
 	 */
282
-	private function newFailingEmailValidator( string $violationType ): EmailValidator {
283
-		$feeValidator = $this->getMockBuilder( EmailValidator::class )
282
+	private function newFailingEmailValidator(string $violationType): EmailValidator {
283
+		$feeValidator = $this->getMockBuilder(EmailValidator::class)
284 284
 			->disableOriginalConstructor()->getMock();
285 285
 
286
-		$feeValidator->method( 'validate' )
287
-			->willReturn( new ValidationResult( new ConstraintViolation( 'this is not a valid email', $violationType ) ) );
286
+		$feeValidator->method('validate')
287
+			->willReturn(new ValidationResult(new ConstraintViolation('this is not a valid email', $violationType)));
288 288
 
289 289
 		return $feeValidator;
290 290
 	}
@@ -292,109 +292,109 @@  discard block
 block discarded – undo
292 292
 	public function testWhenCompanyIsMissingFromCompanyApplication_validationFails() {
293 293
 		$request = $this->newValidRequest();
294 294
 		$request->markApplicantAsCompany();
295
-		$request->setApplicantCompanyName( '' );
295
+		$request->setApplicantCompanyName('');
296 296
 
297 297
 		$this->assertRequestValidationResultInErrors(
298 298
 			$request,
299
-			[ Result::SOURCE_APPLICANT_COMPANY => Result::VIOLATION_MISSING ]
299
+			[Result::SOURCE_APPLICANT_COMPANY => Result::VIOLATION_MISSING]
300 300
 		);
301 301
 	}
302 302
 
303 303
 	public function testWhenFirstNameIsMissingFromPersonalApplication_validationFails() {
304 304
 		$request = $this->newValidRequest();
305
-		$request->setApplicantFirstName( '' );
305
+		$request->setApplicantFirstName('');
306 306
 
307 307
 		$this->assertRequestValidationResultInErrors(
308 308
 			$request,
309
-			[ Result::SOURCE_APPLICANT_FIRST_NAME => Result::VIOLATION_MISSING ]
309
+			[Result::SOURCE_APPLICANT_FIRST_NAME => Result::VIOLATION_MISSING]
310 310
 		);
311 311
 	}
312 312
 
313 313
 	public function testWhenLastNameIsMissingFromPersonalApplication_validationFails() {
314 314
 		$request = $this->newValidRequest();
315
-		$request->setApplicantLastName( '' );
315
+		$request->setApplicantLastName('');
316 316
 
317 317
 		$this->assertRequestValidationResultInErrors(
318 318
 			$request,
319
-			[ Result::SOURCE_APPLICANT_LAST_NAME => Result::VIOLATION_MISSING ]
319
+			[Result::SOURCE_APPLICANT_LAST_NAME => Result::VIOLATION_MISSING]
320 320
 		);
321 321
 	}
322 322
 
323 323
 	public function testWhenSalutationIsMissingFromPersonalApplication_validationFails() {
324 324
 		$request = $this->newValidRequest();
325
-		$request->setApplicantSalutation( '' );
325
+		$request->setApplicantSalutation('');
326 326
 
327 327
 		$this->assertRequestValidationResultInErrors(
328 328
 			$request,
329
-			[ Result::SOURCE_APPLICANT_SALUTATION => Result::VIOLATION_MISSING ]
329
+			[Result::SOURCE_APPLICANT_SALUTATION => Result::VIOLATION_MISSING]
330 330
 		);
331 331
 	}
332 332
 
333 333
 	public function testWhenStreetAddressIsMissing_validationFails() {
334 334
 		$request = $this->newValidRequest();
335
-		$request->setApplicantStreetAddress( '' );
335
+		$request->setApplicantStreetAddress('');
336 336
 
337 337
 		$this->assertRequestValidationResultInErrors(
338 338
 			$request,
339
-			[ Result::SOURCE_APPLICANT_STREET_ADDRESS => Result::VIOLATION_MISSING ]
339
+			[Result::SOURCE_APPLICANT_STREET_ADDRESS => Result::VIOLATION_MISSING]
340 340
 		);
341 341
 	}
342 342
 
343 343
 	public function testWhenPostalCodeIsMissing_validationFails() {
344 344
 		$request = $this->newValidRequest();
345
-		$request->setApplicantPostalCode( '' );
345
+		$request->setApplicantPostalCode('');
346 346
 
347 347
 		$this->assertRequestValidationResultInErrors(
348 348
 			$request,
349
-			[ Result::SOURCE_APPLICANT_POSTAL_CODE => Result::VIOLATION_MISSING ]
349
+			[Result::SOURCE_APPLICANT_POSTAL_CODE => Result::VIOLATION_MISSING]
350 350
 		);
351 351
 	}
352 352
 
353 353
 	public function testWhenCityIsMissing_validationFails() {
354 354
 		$request = $this->newValidRequest();
355
-		$request->setApplicantCity( '' );
355
+		$request->setApplicantCity('');
356 356
 
357 357
 		$this->assertRequestValidationResultInErrors(
358 358
 			$request,
359
-			[ Result::SOURCE_APPLICANT_CITY => Result::VIOLATION_MISSING ]
359
+			[Result::SOURCE_APPLICANT_CITY => Result::VIOLATION_MISSING]
360 360
 		);
361 361
 	}
362 362
 
363 363
 	public function testWhenCountryCodeIsMissing_validationFails() {
364 364
 		$request = $this->newValidRequest();
365
-		$request->setApplicantCountryCode( '' );
365
+		$request->setApplicantCountryCode('');
366 366
 
367 367
 		$this->assertRequestValidationResultInErrors(
368 368
 			$request,
369
-			[ Result::SOURCE_APPLICANT_COUNTRY => Result::VIOLATION_MISSING ]
369
+			[Result::SOURCE_APPLICANT_COUNTRY => Result::VIOLATION_MISSING]
370 370
 		);
371 371
 	}
372 372
 
373 373
 	public function testPhoneNumberIsNotProvided_validationDoesNotFail() {
374 374
 		$request = $this->newValidRequest();
375
-		$request->setApplicantPhoneNumber( '' );
375
+		$request->setApplicantPhoneNumber('');
376 376
 
377
-		$this->assertTrue( $this->newValidator()->validate( $request )->isSuccessful() );
377
+		$this->assertTrue($this->newValidator()->validate($request)->isSuccessful());
378 378
 	}
379 379
 
380 380
 	public function testDateOfBirthIsNotProvided_validationDoesNotFail() {
381 381
 		$request = $this->newValidRequest();
382
-		$request->setApplicantDateOfBirth( '' );
382
+		$request->setApplicantDateOfBirth('');
383 383
 
384
-		$this->assertTrue( $this->newValidator()->validate( $request )->isSuccessful() );
384
+		$this->assertTrue($this->newValidator()->validate($request)->isSuccessful());
385 385
 	}
386 386
 
387 387
 	public function testPersonalInfoWithLongFields_validationFails() {
388
-		$longText = str_repeat( 'Cats ', 500 );
388
+		$longText = str_repeat('Cats ', 500);
389 389
 		$request = $this->newValidRequest();
390
-		$request->setApplicantFirstName( $longText );
391
-		$request->setApplicantLastName( $longText );
392
-		$request->setApplicantTitle( $longText );
393
-		$request->setApplicantSalutation( $longText );
394
-		$request->setApplicantStreetAddress( $longText );
395
-		$request->setApplicantPostalCode( $longText );
396
-		$request->setApplicantCity( $longText );
397
-		$request->setApplicantCountryCode( $longText );
390
+		$request->setApplicantFirstName($longText);
391
+		$request->setApplicantLastName($longText);
392
+		$request->setApplicantTitle($longText);
393
+		$request->setApplicantSalutation($longText);
394
+		$request->setApplicantStreetAddress($longText);
395
+		$request->setApplicantPostalCode($longText);
396
+		$request->setApplicantCity($longText);
397
+		$request->setApplicantCountryCode($longText);
398 398
 		$this->assertRequestValidationResultInErrors(
399 399
 			$request,
400 400
 			[
@@ -411,8 +411,8 @@  discard block
 block discarded – undo
411 411
 
412 412
 	public function testContactInfoWithLongFields_validationFails() {
413 413
 		$request = $this->newValidRequest();
414
-		$request->setApplicantEmailAddress( str_repeat( 'Cats', 500 ) . '@example.com' );
415
-		$request->setApplicantPhoneNumber( str_repeat( '1234', 500 ) );
414
+		$request->setApplicantEmailAddress(str_repeat('Cats', 500) . '@example.com');
415
+		$request->setApplicantPhoneNumber(str_repeat('1234', 500));
416 416
 
417 417
 		$this->assertRequestValidationResultInErrors(
418 418
 			$request,
@@ -424,11 +424,11 @@  discard block
 block discarded – undo
424 424
 	}
425 425
 
426 426
 	public function testBankDataWithLongFields_validationFails() {
427
-		$longText = str_repeat( 'Cats ', 500 );
427
+		$longText = str_repeat('Cats ', 500);
428 428
 		$request = $this->newValidRequest();
429 429
 		$bankData = $request->getBankData();
430
-		$bankData->setBic( $longText );
431
-		$bankData->setBankName( $longText );
430
+		$bankData->setBic($longText);
431
+		$bankData->setBankName($longText);
432 432
 		// Other length violations will be caught by IBAN validation
433 433
 
434 434
 		$this->assertRequestValidationResultInErrors(
@@ -442,17 +442,17 @@  discard block
 block discarded – undo
442 442
 
443 443
 	public function testGivenValidRequestUsingPayPal_validationSucceeds() {
444 444
 		$validRequest = $this->newValidRequestUsingPayPal();
445
-		$response = $this->newValidator()->validate( $validRequest );
445
+		$response = $this->newValidator()->validate($validRequest);
446 446
 
447
-		$this->assertEquals( new Result(), $response );
448
-		$this->assertEmpty( $response->getViolationSources() );
449
-		$this->assertTrue( $response->isSuccessful() );
447
+		$this->assertEquals(new Result(), $response);
448
+		$this->assertEmpty($response->getViolationSources());
449
+		$this->assertTrue($response->isSuccessful());
450 450
 	}
451 451
 
452 452
 	private function newValidRequestUsingPayPal(): ApplyForMembershipRequest {
453 453
 		$request = ValidMembershipApplicationRequest::newValidRequest();
454
-		$request->setPaymentType( ValidMembershipApplication::PAYMENT_TYPE_PAYPAL );
455
-		$request->setBankData( new BankData() );
454
+		$request->setPaymentType(ValidMembershipApplication::PAYMENT_TYPE_PAYPAL);
455
+		$request->setBankData(new BankData());
456 456
 		return $request;
457 457
 	}
458 458
 
Please login to merge, or discard this patch.
tests/Integration/UseCases/AddDonation/AddDonationValidatorTest.php 1 patch
Spacing   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types = 1);
4 4
 
5 5
 namespace WMDE\Fundraising\Frontend\DonationContext\Tests\Integration\UseCases\AddDonation;
6 6
 
@@ -39,182 +39,182 @@  discard block
 block discarded – undo
39 39
 
40 40
 	public function testGivenValidDonation_validationIsSuccessful() {
41 41
 		$request = ValidAddDonationRequest::getRequest();
42
-		$this->assertEmpty( $this->donationValidator->validate( $request )->getViolations() );
42
+		$this->assertEmpty($this->donationValidator->validate($request)->getViolations());
43 43
 	}
44 44
 
45 45
 	public function testGivenAnonymousDonorAndEmptyAddressFields_validatorReturnsNoViolations() {
46 46
 		$request = ValidAddDonationRequest::getRequest();
47 47
 
48
-		$request->setDonorType( DonorName::PERSON_ANONYMOUS );
49
-		$request->setDonorSalutation( '' );
50
-		$request->setDonorTitle( '' );
51
-		$request->setDonorCompany( '' );
52
-		$request->setDonorFirstName( '' );
53
-		$request->setDonorLastName( '' );
54
-		$request->setDonorStreetAddress( '' );
55
-		$request->setDonorPostalCode( '' );
56
-		$request->setDonorCity( '' );
57
-		$request->setDonorCountryCode( '' );
58
-		$request->setDonorEmailAddress( '' );
59
-
60
-		$this->assertEmpty( $this->donationValidator->validate( $request )->getViolations() );
48
+		$request->setDonorType(DonorName::PERSON_ANONYMOUS);
49
+		$request->setDonorSalutation('');
50
+		$request->setDonorTitle('');
51
+		$request->setDonorCompany('');
52
+		$request->setDonorFirstName('');
53
+		$request->setDonorLastName('');
54
+		$request->setDonorStreetAddress('');
55
+		$request->setDonorPostalCode('');
56
+		$request->setDonorCity('');
57
+		$request->setDonorCountryCode('');
58
+		$request->setDonorEmailAddress('');
59
+
60
+		$this->assertEmpty($this->donationValidator->validate($request)->getViolations());
61 61
 	}
62 62
 
63 63
 	public function testGivenNoPaymentType_validatorReturnsFalse() {
64 64
 		$request = ValidAddDonationRequest::getRequest();
65
-		$request->setPaymentType( '' );
65
+		$request->setPaymentType('');
66 66
 
67
-		$this->assertFalse( $this->donationValidator->validate( $request )->isSuccessful() );
67
+		$this->assertFalse($this->donationValidator->validate($request)->isSuccessful());
68 68
 
69 69
 		$this->assertConstraintWasViolated(
70
-			$this->donationValidator->validate( $request ),
70
+			$this->donationValidator->validate($request),
71 71
 			AddDonationValidationResult::SOURCE_PAYMENT_TYPE
72 72
 		);
73 73
 	}
74 74
 
75 75
 	public function testGivenUnsupportedPaymentType_validatorReturnsFalse() {
76 76
 		$request = ValidAddDonationRequest::getRequest();
77
-		$request->setPaymentType( 'KaiCoin' );
77
+		$request->setPaymentType('KaiCoin');
78 78
 
79
-		$this->assertFalse( $this->donationValidator->validate( $request )->isSuccessful() );
79
+		$this->assertFalse($this->donationValidator->validate($request)->isSuccessful());
80 80
 
81 81
 		$this->assertConstraintWasViolated(
82
-			$this->donationValidator->validate( $request ),
82
+			$this->donationValidator->validate($request),
83 83
 			AddDonationValidationResult::SOURCE_PAYMENT_TYPE
84 84
 		);
85 85
 	}
86 86
 
87 87
 	public function testPersonalInfoValidationFails_validatorReturnsFalse() {
88 88
 		$request = ValidAddDonationRequest::getRequest();
89
-		$request->setDonorType( DonorName::PERSON_COMPANY );
90
-		$request->setDonorCompany( '' );
89
+		$request->setDonorType(DonorName::PERSON_COMPANY);
90
+		$request->setDonorCompany('');
91 91
 
92
-		$this->assertFalse( $this->donationValidator->validate( $request )->isSuccessful() );
92
+		$this->assertFalse($this->donationValidator->validate($request)->isSuccessful());
93 93
 
94 94
 		$this->assertConstraintWasViolated(
95
-			$this->donationValidator->validate( $request ),
95
+			$this->donationValidator->validate($request),
96 96
 			AddDonationValidationResult::SOURCE_DONOR_COMPANY
97 97
 		);
98 98
 	}
99 99
 
100 100
 	public function testDirectDebitMissingBankData_validatorReturnsFalse() {
101 101
 		$bankData = new BankData();
102
-		$bankData->setIban( new Iban( '' ) );
103
-		$bankData->setBic( '' );
104
-		$bankData->setBankName( '' );
102
+		$bankData->setIban(new Iban(''));
103
+		$bankData->setBic('');
104
+		$bankData->setBankName('');
105 105
 		$request = ValidAddDonationRequest::getRequest();
106
-		$request->setBankData( $bankData );
106
+		$request->setBankData($bankData);
107 107
 
108
-		$result = $this->donationValidator->validate( $request );
109
-		$this->assertFalse( $result->isSuccessful() );
108
+		$result = $this->donationValidator->validate($request);
109
+		$this->assertFalse($result->isSuccessful());
110 110
 
111
-		$this->assertConstraintWasViolated( $result, AddDonationValidationResult::SOURCE_IBAN );
112
-		$this->assertConstraintWasViolated( $result, AddDonationValidationResult::SOURCE_BIC );
111
+		$this->assertConstraintWasViolated($result, AddDonationValidationResult::SOURCE_IBAN);
112
+		$this->assertConstraintWasViolated($result, AddDonationValidationResult::SOURCE_BIC);
113 113
 	}
114 114
 
115 115
 	public function testForeignDirectDebitMissingBankData_validationSucceeds() {
116 116
 		$bankData = new BankData();
117
-		$bankData->setIban( new Iban( self::FOREIGN_IBAN ) );
118
-		$bankData->setBic( self::FOREIGN_BIC );
119
-		$bankData->setBankName( '' );
120
-		$bankData->setAccount( '' );
121
-		$bankData->setBankCode( '' );
117
+		$bankData->setIban(new Iban(self::FOREIGN_IBAN));
118
+		$bankData->setBic(self::FOREIGN_BIC);
119
+		$bankData->setBankName('');
120
+		$bankData->setAccount('');
121
+		$bankData->setBankCode('');
122 122
 
123 123
 		$request = ValidAddDonationRequest::getRequest();
124
-		$request->setBankData( $bankData );
124
+		$request->setBankData($bankData);
125 125
 
126
-		$result = $this->donationValidator->validate( $request );
127
-		$this->assertTrue( $result->isSuccessful() );
128
-		$this->assertFalse( $result->hasViolations() );
126
+		$result = $this->donationValidator->validate($request);
127
+		$this->assertTrue($result->isSuccessful());
128
+		$this->assertFalse($result->hasViolations());
129 129
 	}
130 130
 
131 131
 	public function testAmountTooLow_validatorReturnsFalse() {
132 132
 		$request = ValidAddDonationRequest::getRequest();
133
-		$request->setAmount( Euro::newFromCents( 50 ) );
133
+		$request->setAmount(Euro::newFromCents(50));
134 134
 
135
-		$result = $this->donationValidator->validate( $request );
136
-		$this->assertFalse( $result->isSuccessful() );
135
+		$result = $this->donationValidator->validate($request);
136
+		$this->assertFalse($result->isSuccessful());
137 137
 
138
-		$this->assertConstraintWasViolated( $result, AddDonationValidationResult::SOURCE_PAYMENT_AMOUNT );
138
+		$this->assertConstraintWasViolated($result, AddDonationValidationResult::SOURCE_PAYMENT_AMOUNT);
139 139
 	}
140 140
 
141 141
 	public function testPersonalInfoWithLongFields_validationFails() {
142
-		$longText = str_repeat( 'Cats ', 500 );
142
+		$longText = str_repeat('Cats ', 500);
143 143
 		$request = ValidAddDonationRequest::getRequest();
144
-		$request->setDonorFirstName( $longText );
145
-		$request->setDonorLastName( $longText );
146
-		$request->setDonorTitle( $longText );
147
-		$request->setDonorSalutation( $longText );
148
-		$request->setDonorStreetAddress( $longText );
149
-		$request->setDonorPostalCode( $longText );
150
-		$request->setDonorCity( $longText );
151
-		$request->setDonorCountryCode( $longText );
152
-		$request->setDonorEmailAddress( str_repeat( 'Cats', 500 ) . '@example.com' );
153
-
154
-		$result = $this->donationValidator->validate( $request );
155
-		$this->assertFalse( $result->isSuccessful() );
156
-
157
-		$this->assertConstraintWasViolated( $result, AddDonationValidationResult::SOURCE_DONOR_FIRST_NAME );
158
-		$this->assertConstraintWasViolated( $result, AddDonationValidationResult::SOURCE_DONOR_LAST_NAME );
159
-		$this->assertConstraintWasViolated( $result, AddDonationValidationResult::SOURCE_DONOR_SALUTATION );
160
-		$this->assertConstraintWasViolated( $result, AddDonationValidationResult::SOURCE_DONOR_TITLE );
161
-		$this->assertConstraintWasViolated( $result, AddDonationValidationResult::SOURCE_DONOR_STREET_ADDRESS );
162
-		$this->assertConstraintWasViolated( $result, AddDonationValidationResult::SOURCE_DONOR_CITY );
163
-		$this->assertConstraintWasViolated( $result, AddDonationValidationResult::SOURCE_DONOR_POSTAL_CODE );
164
-		$this->assertConstraintWasViolated( $result, AddDonationValidationResult::SOURCE_DONOR_COUNTRY );
165
-		$this->assertConstraintWasViolated( $result, AddDonationValidationResult::SOURCE_DONOR_EMAIL );
144
+		$request->setDonorFirstName($longText);
145
+		$request->setDonorLastName($longText);
146
+		$request->setDonorTitle($longText);
147
+		$request->setDonorSalutation($longText);
148
+		$request->setDonorStreetAddress($longText);
149
+		$request->setDonorPostalCode($longText);
150
+		$request->setDonorCity($longText);
151
+		$request->setDonorCountryCode($longText);
152
+		$request->setDonorEmailAddress(str_repeat('Cats', 500) . '@example.com');
153
+
154
+		$result = $this->donationValidator->validate($request);
155
+		$this->assertFalse($result->isSuccessful());
156
+
157
+		$this->assertConstraintWasViolated($result, AddDonationValidationResult::SOURCE_DONOR_FIRST_NAME);
158
+		$this->assertConstraintWasViolated($result, AddDonationValidationResult::SOURCE_DONOR_LAST_NAME);
159
+		$this->assertConstraintWasViolated($result, AddDonationValidationResult::SOURCE_DONOR_SALUTATION);
160
+		$this->assertConstraintWasViolated($result, AddDonationValidationResult::SOURCE_DONOR_TITLE);
161
+		$this->assertConstraintWasViolated($result, AddDonationValidationResult::SOURCE_DONOR_STREET_ADDRESS);
162
+		$this->assertConstraintWasViolated($result, AddDonationValidationResult::SOURCE_DONOR_CITY);
163
+		$this->assertConstraintWasViolated($result, AddDonationValidationResult::SOURCE_DONOR_POSTAL_CODE);
164
+		$this->assertConstraintWasViolated($result, AddDonationValidationResult::SOURCE_DONOR_COUNTRY);
165
+		$this->assertConstraintWasViolated($result, AddDonationValidationResult::SOURCE_DONOR_EMAIL);
166 166
 	}
167 167
 
168 168
 	public function testBankDataWithLongFields_validationFails() {
169
-		$longText = str_repeat( 'Cats ', 500 );
169
+		$longText = str_repeat('Cats ', 500);
170 170
 		$request = ValidAddDonationRequest::getRequest();
171 171
 		$validBankData = $request->getBankData();
172 172
 		$bankData = new BankData();
173
-		$bankData->setBic( $longText );
174
-		$bankData->setBankName( $longText );
173
+		$bankData->setBic($longText);
174
+		$bankData->setBankName($longText);
175 175
 		// Other length violations will be caught by IBAN validation
176
-		$bankData->setIban( $validBankData->getIban() );
177
-		$bankData->setAccount( $validBankData->getAccount() );
178
-		$bankData->setBankCode( $validBankData->getBankCode() );
176
+		$bankData->setIban($validBankData->getIban());
177
+		$bankData->setAccount($validBankData->getAccount());
178
+		$bankData->setBankCode($validBankData->getBankCode());
179 179
 		$bankData->freeze();
180
-		$request->setBankData( $bankData );
180
+		$request->setBankData($bankData);
181 181
 
182
-		$result = $this->donationValidator->validate( $request );
183
-		$this->assertFalse( $result->isSuccessful() );
182
+		$result = $this->donationValidator->validate($request);
183
+		$this->assertFalse($result->isSuccessful());
184 184
 
185
-		$this->assertConstraintWasViolated( $result, AddDonationValidationResult::SOURCE_BANK_NAME );
186
-		$this->assertConstraintWasViolated( $result, AddDonationValidationResult::SOURCE_BIC );
185
+		$this->assertConstraintWasViolated($result, AddDonationValidationResult::SOURCE_BANK_NAME);
186
+		$this->assertConstraintWasViolated($result, AddDonationValidationResult::SOURCE_BIC);
187 187
 	}
188 188
 
189 189
 	public function testLongSource_validationFails() {
190 190
 		$request = ValidAddDonationRequest::getRequest();
191
-		$request->setSource( 'http://catlady.com/#' . str_repeat( 'Cats ', 500 ) );
191
+		$request->setSource('http://catlady.com/#' . str_repeat('Cats ', 500));
192 192
 
193
-		$result = $this->donationValidator->validate( $request );
194
-		$this->assertFalse( $result->isSuccessful() );
193
+		$result = $this->donationValidator->validate($request);
194
+		$this->assertFalse($result->isSuccessful());
195 195
 
196
-		$this->assertConstraintWasViolated( $result, AddDonationValidationResult::SOURCE_TRACKING_SOURCE );
196
+		$this->assertConstraintWasViolated($result, AddDonationValidationResult::SOURCE_TRACKING_SOURCE);
197 197
 	}
198 198
 
199 199
 	private function newDonationValidator(): AddDonationValidator {
200 200
 		return new AddDonationValidator(
201
-			new PaymentDataValidator( 1.0, 100000 ),
201
+			new PaymentDataValidator(1.0, 100000),
202 202
 			$this->newBankDataValidator(),
203 203
 			$this->newMockEmailValidator()
204 204
 		);
205 205
 	}
206 206
 
207 207
 	private function newBankDataValidator(): BankDataValidator {
208
-		$ibanValidatorMock = $this->getMockBuilder( IbanValidator::class )->disableOriginalConstructor()->getMock();
209
-		$ibanValidatorMock->method( 'validate' )
210
-			->willReturn( new ValidationResult() );
208
+		$ibanValidatorMock = $this->getMockBuilder(IbanValidator::class)->disableOriginalConstructor()->getMock();
209
+		$ibanValidatorMock->method('validate')
210
+			->willReturn(new ValidationResult());
211 211
 
212
-		return new BankDataValidator( $ibanValidatorMock );
212
+		return new BankDataValidator($ibanValidatorMock);
213 213
 	}
214 214
 
215 215
 	private function newMockEmailValidator() {
216
-		$validator = $this->getMockBuilder( EmailValidator::class )->disableOriginalConstructor()->getMock();
217
-		$validator->method( 'validate' )->willReturn( new ValidationResult() );
216
+		$validator = $this->getMockBuilder(EmailValidator::class)->disableOriginalConstructor()->getMock();
217
+		$validator->method('validate')->willReturn(new ValidationResult());
218 218
 		return $validator;
219 219
 	}
220 220
 }
Please login to merge, or discard this patch.
tests/EdgeToEdge/Routes/AddDonationRouteTest.php 1 patch
Spacing   +204 added lines, -204 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types = 1);
4 4
 
5 5
 namespace WMDE\Fundraising\Frontend\Tests\EdgeToEdge\Routes;
6 6
 
@@ -23,17 +23,17 @@  discard block
 block discarded – undo
23 23
 	const SOME_TOKEN = 'SomeToken';
24 24
 
25 25
 	public function setUp() {
26
-		if ( !function_exists( 'lut_init' ) ) {
27
-			$this->markTestSkipped( 'The konto_check needs to be installed!' );
26
+		if (!function_exists('lut_init')) {
27
+			$this->markTestSkipped('The konto_check needs to be installed!');
28 28
 		}
29 29
 		parent::setUp();
30 30
 	}
31 31
 
32 32
 	public function testGivenValidRequest_donationGetsPersisted() {
33
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ) {
33
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory) {
34 34
 
35
-			$client->setServerParameter( 'HTTP_REFERER', 'https://en.wikipedia.org/wiki/Karla_Kennichnich' );
36
-			$client->followRedirects( false );
35
+			$client->setServerParameter('HTTP_REFERER', 'https://en.wikipedia.org/wiki/Karla_Kennichnich');
36
+			$client->followRedirects(false);
37 37
 
38 38
 			$client->request(
39 39
 				'POST',
@@ -41,31 +41,31 @@  discard block
 block discarded – undo
41 41
 				$this->newValidFormInput()
42 42
 			);
43 43
 
44
-			$this->assertIsExpectedDonation( $this->getDonationFromDatabase( $factory ) );
44
+			$this->assertIsExpectedDonation($this->getDonationFromDatabase($factory));
45 45
 		} );
46 46
 	}
47 47
 
48 48
 	public function testWhenDonationGetsPersisted_timestampIsStoredInCookie() {
49
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ) {
49
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory) {
50 50
 
51
-			$client->followRedirects( true );
51
+			$client->followRedirects(true);
52 52
 			$client->request(
53 53
 				'POST',
54 54
 				'/donation/add',
55 55
 				$this->newValidFormInput()
56 56
 			);
57 57
 
58
-			$cookie = $client->getCookieJar()->get( 'donation_timestamp' );
59
-			$this->assertNotNull( $cookie );
60
-			$donationTimestamp = new \DateTime( $cookie->getValue() );
61
-			$this->assertEquals( time(), $donationTimestamp->getTimestamp(), 'Timestamp should be not more than 5 seconds old', 5.0 );
58
+			$cookie = $client->getCookieJar()->get('donation_timestamp');
59
+			$this->assertNotNull($cookie);
60
+			$donationTimestamp = new \DateTime($cookie->getValue());
61
+			$this->assertEquals(time(), $donationTimestamp->getTimestamp(), 'Timestamp should be not more than 5 seconds old', 5.0);
62 62
 
63 63
 		} );
64 64
 	}
65 65
 
66 66
 	public function testWhenMultipleDonationFormSubmissions_requestGetsRejected() {
67
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ) {
68
-			$client->getCookieJar()->set( new Cookie( 'donation_timestamp', $this->getPastTimestamp() ) );
67
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory) {
68
+			$client->getCookieJar()->set(new Cookie('donation_timestamp', $this->getPastTimestamp()));
69 69
 
70 70
 			$client->request(
71 71
 				'POST',
@@ -73,16 +73,16 @@  discard block
 block discarded – undo
73 73
 				$this->newValidFormInput()
74 74
 			);
75 75
 
76
-			$this->assertContains( 'Sie haben vor sehr kurzer Zeit bereits gespendet', $client->getResponse()->getContent() );
76
+			$this->assertContains('Sie haben vor sehr kurzer Zeit bereits gespendet', $client->getResponse()->getContent());
77 77
 		} );
78 78
 	}
79 79
 
80 80
 	public function testWhenMultipleDonationsInAccordanceToTimeLimit_requestIsNotRejected() {
81
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ) {
81
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory) {
82 82
 			$client->getCookieJar()->set(
83 83
 				new Cookie(
84 84
 					'donation_timestamp',
85
-					$this->getPastTimestamp( 'PT35M' )
85
+					$this->getPastTimestamp('PT35M')
86 86
 				)
87 87
 			);
88 88
 
@@ -92,12 +92,12 @@  discard block
 block discarded – undo
92 92
 				$this->newValidFormInput()
93 93
 			);
94 94
 
95
-			$this->assertNotContains( 'Sie haben vor sehr kurzer Zeit bereits gespendet', $client->getResponse()->getContent() );
95
+			$this->assertNotContains('Sie haben vor sehr kurzer Zeit bereits gespendet', $client->getResponse()->getContent());
96 96
 		} );
97 97
 	}
98 98
 
99
-	private function getPastTimestamp( string $interval = 'PT10S' ) {
100
-		return ( new \DateTime() )->sub( new \DateInterval( $interval ) )->format( 'Y-m-d H:i:s' );
99
+	private function getPastTimestamp(string $interval = 'PT10S') {
100
+		return (new \DateTime())->sub(new \DateInterval($interval))->format('Y-m-d H:i:s');
101 101
 	}
102 102
 
103 103
 	private function newValidFormInput() {
@@ -132,43 +132,43 @@  discard block
 block discarded – undo
132 132
 		];
133 133
 	}
134 134
 
135
-	private function assertIsExpectedDonation( Donation $donation ) {
135
+	private function assertIsExpectedDonation(Donation $donation) {
136 136
 		$data = $donation->getDecodedData();
137
-		$this->assertSame( '5.51', $donation->getAmount() );
138
-		$this->assertSame( 'BEZ', $donation->getPaymentType() );
139
-		$this->assertSame( 0, $donation->getPaymentIntervalInMonths() );
140
-		$this->assertSame( 'DE12500105170648489890', $data['iban'] );
141
-		$this->assertSame( 'INGDDEFFXXX', $data['bic'] );
142
-		$this->assertSame( '0648489890', $data['konto'] );
143
-		$this->assertSame( '50010517', $data['blz'] );
144
-		$this->assertSame( 'ING-DiBa', $data['bankname'] );
145
-		$this->assertSame( 'person', $data['adresstyp'] );
146
-		$this->assertSame( 'Frau', $data['anrede'] );
147
-		$this->assertSame( 'Prof. Dr.', $data['titel'] );
148
-		$this->assertSame( '', $data['firma'] );
149
-		$this->assertSame( 'Karla', $data['vorname'] );
150
-		$this->assertSame( 'Kennichnich', $data['nachname'] );
151
-		$this->assertSame( 'Prof. Dr. Karla Kennichnich', $donation->getDonorFullName() );
152
-		$this->assertSame( 'Lehmgasse 12', $data['strasse'] );
153
-		$this->assertSame( '12345', $data['plz'] );
154
-		$this->assertSame( 'Einort', $data['ort'] );
155
-		$this->assertSame( 'Einort', $donation->getDonorCity() );
156
-		$this->assertSame( 'DE', $data['country'] );
157
-		$this->assertSame( '[email protected]', $data['email'] );
158
-		$this->assertSame( '[email protected]', $donation->getDonorEmail() );
159
-		$this->assertSame( 'test/gelb', $data['tracking'] );
160
-		$this->assertSame( 3, $data['impCount'] );
161
-		$this->assertSame( 1, $data['bImpCount'] );
162
-		$this->assertSame( '', $data['layout'] );
163
-		$this->assertSame( '', $data['color'] );
164
-		$this->assertSame( '', $data['skin'] );
165
-		$this->assertSame( 'en.wikipedia.org', $data['source'] );
166
-		$this->assertSame( 'N', $donation->getStatus() );
167
-		$this->assertTrue( $donation->getDonorOptsIntoNewsletter() );
137
+		$this->assertSame('5.51', $donation->getAmount());
138
+		$this->assertSame('BEZ', $donation->getPaymentType());
139
+		$this->assertSame(0, $donation->getPaymentIntervalInMonths());
140
+		$this->assertSame('DE12500105170648489890', $data['iban']);
141
+		$this->assertSame('INGDDEFFXXX', $data['bic']);
142
+		$this->assertSame('0648489890', $data['konto']);
143
+		$this->assertSame('50010517', $data['blz']);
144
+		$this->assertSame('ING-DiBa', $data['bankname']);
145
+		$this->assertSame('person', $data['adresstyp']);
146
+		$this->assertSame('Frau', $data['anrede']);
147
+		$this->assertSame('Prof. Dr.', $data['titel']);
148
+		$this->assertSame('', $data['firma']);
149
+		$this->assertSame('Karla', $data['vorname']);
150
+		$this->assertSame('Kennichnich', $data['nachname']);
151
+		$this->assertSame('Prof. Dr. Karla Kennichnich', $donation->getDonorFullName());
152
+		$this->assertSame('Lehmgasse 12', $data['strasse']);
153
+		$this->assertSame('12345', $data['plz']);
154
+		$this->assertSame('Einort', $data['ort']);
155
+		$this->assertSame('Einort', $donation->getDonorCity());
156
+		$this->assertSame('DE', $data['country']);
157
+		$this->assertSame('[email protected]', $data['email']);
158
+		$this->assertSame('[email protected]', $donation->getDonorEmail());
159
+		$this->assertSame('test/gelb', $data['tracking']);
160
+		$this->assertSame(3, $data['impCount']);
161
+		$this->assertSame(1, $data['bImpCount']);
162
+		$this->assertSame('', $data['layout']);
163
+		$this->assertSame('', $data['color']);
164
+		$this->assertSame('', $data['skin']);
165
+		$this->assertSame('en.wikipedia.org', $data['source']);
166
+		$this->assertSame('N', $donation->getStatus());
167
+		$this->assertTrue($donation->getDonorOptsIntoNewsletter());
168 168
 	}
169 169
 
170 170
 	public function testGivenValidRequest_confirmationPageContainsEnteredData() {
171
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ) {
171
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory) {
172 172
 
173 173
 			$client->request(
174 174
 				'POST',
@@ -179,17 +179,17 @@  discard block
 block discarded – undo
179 179
 
180 180
 			$response = $client->getResponse()->getContent();
181 181
 
182
-			$this->assertContains( '<strong>5,51 €</strong>', $response );
183
-			$this->assertContains( 'per Lastschrift', $response );
184
-			$this->assertContains( 'einmalig', $response );
185
-			$this->assertContains( 'DE12500105170648489890', $response );
186
-			$this->assertContains( 'INGDDEFFXXX', $response );
187
-			$this->assertContains( 'ING-DiBa', $response );
188
-			$this->assertContains( 'Prof. Dr. Karla Kennichnich', $response );
189
-			$this->assertContains( 'Lehmgasse 12', $response );
190
-			$this->assertContains( '<span id="confirm-postcode">12345</span> <span id="confirm-city">Einort</span>', $response );
191
-			$this->assertContains( '[email protected]', $response );
192
-			$this->assertContains( '<div id="send-info"', $response );
182
+			$this->assertContains('<strong>5,51 €</strong>', $response);
183
+			$this->assertContains('per Lastschrift', $response);
184
+			$this->assertContains('einmalig', $response);
185
+			$this->assertContains('DE12500105170648489890', $response);
186
+			$this->assertContains('INGDDEFFXXX', $response);
187
+			$this->assertContains('ING-DiBa', $response);
188
+			$this->assertContains('Prof. Dr. Karla Kennichnich', $response);
189
+			$this->assertContains('Lehmgasse 12', $response);
190
+			$this->assertContains('<span id="confirm-postcode">12345</span> <span id="confirm-city">Einort</span>', $response);
191
+			$this->assertContains('[email protected]', $response);
192
+			$this->assertContains('<div id="send-info"', $response);
193 193
 		} );
194 194
 	}
195 195
 
@@ -199,10 +199,10 @@  discard block
 block discarded – undo
199 199
 		 */
200 200
 		$factory = null;
201 201
 
202
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ) {
202
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory) {
203 203
 
204
-			$client->setServerParameter( 'HTTP_REFERER', 'https://en.wikipedia.org/wiki/Karla_Kennichnich' );
205
-			$client->followRedirects( false );
204
+			$client->setServerParameter('HTTP_REFERER', 'https://en.wikipedia.org/wiki/Karla_Kennichnich');
205
+			$client->followRedirects(false);
206 206
 
207 207
 			$client->request(
208 208
 				'POST',
@@ -210,37 +210,37 @@  discard block
 block discarded – undo
210 210
 				$this->newValidBankTransferInput()
211 211
 			);
212 212
 
213
-			$donation = $this->getDonationFromDatabase( $factory );
213
+			$donation = $this->getDonationFromDatabase($factory);
214 214
 
215 215
 			$data = $donation->getDecodedData();
216
-			$this->assertSame( '12.34', $donation->getAmount() );
217
-			$this->assertSame( 'UEB', $donation->getPaymentType() );
218
-			$this->assertSame( 0, $donation->getPaymentIntervalInMonths() );
219
-			$this->assertSame( 'person', $data['adresstyp'] );
220
-			$this->assertSame( 'Frau', $data['anrede'] );
221
-			$this->assertSame( 'Prof. Dr.', $data['titel'] );
222
-			$this->assertSame( '', $data['firma'] );
223
-			$this->assertSame( 'Karla', $data['vorname'] );
224
-			$this->assertSame( 'Kennichnich', $data['nachname'] );
225
-			$this->assertSame( 'Prof. Dr. Karla Kennichnich', $donation->getDonorFullName() );
226
-			$this->assertSame( 'Lehmgasse 12', $data['strasse'] );
227
-			$this->assertSame( '12345', $data['plz'] );
228
-			$this->assertSame( 'Einort', $data['ort'] );
229
-			$this->assertSame( 'Einort', $donation->getDonorCity() );
230
-			$this->assertSame( 'DE', $data['country'] );
231
-			$this->assertSame( '[email protected]', $data['email'] );
232
-			$this->assertSame( '[email protected]', $donation->getDonorEmail() );
233
-			$this->assertSame( 'test/gelb', $data['tracking'] );
234
-			$this->assertSame( 3, $data['impCount'] );
235
-			$this->assertSame( 1, $data['bImpCount'] );
236
-			$this->assertSame( '', $data['layout'] );
237
-			$this->assertSame( '', $data['color'] );
238
-			$this->assertSame( '', $data['skin'] );
239
-			$this->assertSame( 'en.wikipedia.org', $data['source'] );
240
-			$this->assertSame( true, $donation->getDonorOptsIntoNewsletter() );
241
-
242
-			$this->assertSame( 'Z', $donation->getStatus() );
243
-			$this->assertRegExp( '/W-Q-[A-Z]{6}-[A-Z]/', $donation->getBankTransferCode() );
216
+			$this->assertSame('12.34', $donation->getAmount());
217
+			$this->assertSame('UEB', $donation->getPaymentType());
218
+			$this->assertSame(0, $donation->getPaymentIntervalInMonths());
219
+			$this->assertSame('person', $data['adresstyp']);
220
+			$this->assertSame('Frau', $data['anrede']);
221
+			$this->assertSame('Prof. Dr.', $data['titel']);
222
+			$this->assertSame('', $data['firma']);
223
+			$this->assertSame('Karla', $data['vorname']);
224
+			$this->assertSame('Kennichnich', $data['nachname']);
225
+			$this->assertSame('Prof. Dr. Karla Kennichnich', $donation->getDonorFullName());
226
+			$this->assertSame('Lehmgasse 12', $data['strasse']);
227
+			$this->assertSame('12345', $data['plz']);
228
+			$this->assertSame('Einort', $data['ort']);
229
+			$this->assertSame('Einort', $donation->getDonorCity());
230
+			$this->assertSame('DE', $data['country']);
231
+			$this->assertSame('[email protected]', $data['email']);
232
+			$this->assertSame('[email protected]', $donation->getDonorEmail());
233
+			$this->assertSame('test/gelb', $data['tracking']);
234
+			$this->assertSame(3, $data['impCount']);
235
+			$this->assertSame(1, $data['bImpCount']);
236
+			$this->assertSame('', $data['layout']);
237
+			$this->assertSame('', $data['color']);
238
+			$this->assertSame('', $data['skin']);
239
+			$this->assertSame('en.wikipedia.org', $data['source']);
240
+			$this->assertSame(true, $donation->getDonorOptsIntoNewsletter());
241
+
242
+			$this->assertSame('Z', $donation->getStatus());
243
+			$this->assertRegExp('/W-Q-[A-Z]{6}-[A-Z]/', $donation->getBankTransferCode());
244 244
 		} );
245 245
 	}
246 246
 
@@ -272,10 +272,10 @@  discard block
 block discarded – undo
272 272
 	}
273 273
 
274 274
 	public function testGivenComplementableBankData_donationStillGetsPersisted() {
275
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ) {
275
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory) {
276 276
 
277
-			$client->setServerParameter( 'HTTP_REFERER', 'https://en.wikipedia.org/wiki/Karla_Kennichnich' );
278
-			$client->followRedirects( false );
277
+			$client->setServerParameter('HTTP_REFERER', 'https://en.wikipedia.org/wiki/Karla_Kennichnich');
278
+			$client->followRedirects(false);
279 279
 
280 280
 			$client->request(
281 281
 				'POST',
@@ -283,14 +283,14 @@  discard block
 block discarded – undo
283 283
 				$this->newComplementableFormInput()
284 284
 			);
285 285
 
286
-			$donation = $this->getDonationFromDatabase( $factory );
286
+			$donation = $this->getDonationFromDatabase($factory);
287 287
 
288 288
 			$data = $donation->getDecodedData();
289
-			$this->assertSame( 'DE12500105170648489890', $data['iban'] );
290
-			$this->assertSame( 'INGDDEFFXXX', $data['bic'] );
291
-			$this->assertSame( '0648489890', $data['konto'] );
292
-			$this->assertSame( '50010517', $data['blz'] );
293
-			$this->assertSame( 'ING-DiBa', $data['bankname'] );
289
+			$this->assertSame('DE12500105170648489890', $data['iban']);
290
+			$this->assertSame('INGDDEFFXXX', $data['bic']);
291
+			$this->assertSame('0648489890', $data['konto']);
292
+			$this->assertSame('50010517', $data['blz']);
293
+			$this->assertSame('ING-DiBa', $data['bankname']);
294 294
 		} );
295 295
 	}
296 296
 
@@ -313,16 +313,16 @@  discard block
 block discarded – undo
313 313
 		];
314 314
 	}
315 315
 
316
-	private function getDonationFromDatabase( FunFunFactory $factory ): Donation {
317
-		$donationRepo = $factory->getEntityManager()->getRepository( Donation::class );
318
-		$donation = $donationRepo->find( 1 );
319
-		$this->assertInstanceOf( Donation::class, $donation );
316
+	private function getDonationFromDatabase(FunFunFactory $factory): Donation {
317
+		$donationRepo = $factory->getEntityManager()->getRepository(Donation::class);
318
+		$donation = $donationRepo->find(1);
319
+		$this->assertInstanceOf(Donation::class, $donation);
320 320
 		return $donation;
321 321
 	}
322 322
 
323 323
 	public function testGivenValidPayPalData_redirectsToPayPal() {
324
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ) {
325
-			$client->followRedirects( false );
324
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory) {
325
+			$client->followRedirects(false);
326 326
 
327 327
 			$client->request(
328 328
 				'POST',
@@ -331,8 +331,8 @@  discard block
 block discarded – undo
331 331
 			);
332 332
 
333 333
 			$response = $client->getResponse();
334
-			$this->assertSame( 302, $response->getStatusCode() );
335
-			$this->assertContains( 'sandbox.paypal.com', $response->getContent() );
334
+			$this->assertSame(302, $response->getStatusCode());
335
+			$this->assertContains('sandbox.paypal.com', $response->getContent());
336 336
 		} );
337 337
 	}
338 338
 
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
 	}
347 347
 
348 348
 	public function testGivenValidCreditCardData_showsIframeEmbeddingPage() {
349
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ) {
349
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory) {
350 350
 
351 351
 			$client->request(
352 352
 				'POST',
@@ -355,9 +355,9 @@  discard block
 block discarded – undo
355 355
 			);
356 356
 
357 357
 			$response = $client->getResponse();
358
-			$this->assertSame( 200, $response->getStatusCode() );
359
-			$this->assertContains( 'Ich spende vierteljährlich 12,34 € per Kreditkarte.', $response->getContent() );
360
-			$this->assertContains( 'thatother.paymentprovider.com', $response->getContent() );
358
+			$this->assertSame(200, $response->getStatusCode());
359
+			$this->assertContains('Ich spende vierteljährlich 12,34 € per Kreditkarte.', $response->getContent());
360
+			$this->assertContains('thatother.paymentprovider.com', $response->getContent());
361 361
 		} );
362 362
 	}
363 363
 
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 	}
372 372
 
373 373
 	public function testGivenInvalidRequest_formIsReloadedAndPrefilled() {
374
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ) {
374
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory) {
375 375
 
376 376
 			$client->request(
377 377
 				'POST',
@@ -381,28 +381,28 @@  discard block
 block discarded – undo
381 381
 
382 382
 			$response = $client->getResponse()->getContent();
383 383
 
384
-			$this->assertContains( 'Amount: 0,00', $response );
385
-			$this->assertContains( 'Payment type: BEZ', $response );
386
-			$this->assertContains( 'Interval: 3', $response );
387
-			$this->assertContains( 'IBAN: DE12500105170648489890', $response );
388
-			$this->assertContains( 'BIC: INGDDEFFXXX', $response );
389
-			$this->assertContains( 'Bank name: ING-DiBa', $response );
390
-			$this->assertContains( 'Address type: person', $response );
391
-			$this->assertContains( 'Salutation: Frau', $response );
392
-			$this->assertContains( 'Title: Prof. Dr.', $response );
393
-			$this->assertContains( 'Company: ', $response );
394
-			$this->assertContains( 'First name: Karla', $response );
395
-			$this->assertContains( 'Last name: Kennichnich', $response );
396
-			$this->assertContains( 'Street: Lehmgasse 12', $response );
397
-			$this->assertContains( 'Postal code: 12345', $response );
398
-			$this->assertContains( 'City: Einort', $response );
399
-			$this->assertContains( 'Country code: DE', $response );
400
-			$this->assertContains( 'Email address: [email protected]', $response );
384
+			$this->assertContains('Amount: 0,00', $response);
385
+			$this->assertContains('Payment type: BEZ', $response);
386
+			$this->assertContains('Interval: 3', $response);
387
+			$this->assertContains('IBAN: DE12500105170648489890', $response);
388
+			$this->assertContains('BIC: INGDDEFFXXX', $response);
389
+			$this->assertContains('Bank name: ING-DiBa', $response);
390
+			$this->assertContains('Address type: person', $response);
391
+			$this->assertContains('Salutation: Frau', $response);
392
+			$this->assertContains('Title: Prof. Dr.', $response);
393
+			$this->assertContains('Company: ', $response);
394
+			$this->assertContains('First name: Karla', $response);
395
+			$this->assertContains('Last name: Kennichnich', $response);
396
+			$this->assertContains('Street: Lehmgasse 12', $response);
397
+			$this->assertContains('Postal code: 12345', $response);
398
+			$this->assertContains('City: Einort', $response);
399
+			$this->assertContains('Country code: DE', $response);
400
+			$this->assertContains('Email address: [email protected]', $response);
401 401
 		} );
402 402
 	}
403 403
 
404 404
 	public function testGivenInvalidRequest_formStillContainsBannerTrackingData() {
405
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ) {
405
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory) {
406 406
 
407 407
 			$client->request(
408 408
 				'POST',
@@ -415,13 +415,13 @@  discard block
 block discarded – undo
415 415
 
416 416
 			$response = $client->getResponse()->getContent();
417 417
 
418
-			$this->assertContains( 'Impression Count: 12', $response );
419
-			$this->assertContains( 'Banner Impression Count: 3', $response );
418
+			$this->assertContains('Impression Count: 12', $response);
419
+			$this->assertContains('Banner Impression Count: 3', $response);
420 420
 		} );
421 421
 	}
422 422
 
423 423
 	public function testGivenNegativeDonationAmount_formIsReloadedAndPrefilledWithZero() {
424
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ) {
424
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory) {
425 425
 
426 426
 			$formValues = $this->newInvalidFormInput();
427 427
 			$formValues['betrag'] = '-5,00';
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
 
435 435
 			$response = $client->getResponse()->getContent();
436 436
 
437
-			$this->assertContains( 'Amount: 0,00', $response );
437
+			$this->assertContains('Amount: 0,00', $response);
438 438
 		} );
439 439
 	}
440 440
 
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
 	}
472 472
 
473 473
 	public function testGivenInvalidAnonymousRequest_formIsReloadedAndPrefilled() {
474
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ) {
474
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory) {
475 475
 
476 476
 			$client->request(
477 477
 				'POST',
@@ -481,10 +481,10 @@  discard block
 block discarded – undo
481 481
 
482 482
 			$response = $client->getResponse()->getContent();
483 483
 
484
-			$this->assertContains( 'Amount: 0', $response );
485
-			$this->assertContains( 'Payment type: UEB', $response );
486
-			$this->assertContains( 'Interval: 1', $response );
487
-			$this->assertContains( 'Value of field "amount" violates rule: Amount too low', $response );
484
+			$this->assertContains('Amount: 0', $response);
485
+			$this->assertContains('Payment type: UEB', $response);
486
+			$this->assertContains('Interval: 1', $response);
487
+			$this->assertContains('Value of field "amount" violates rule: Amount too low', $response);
488 488
 		} );
489 489
 	}
490 490
 
@@ -498,11 +498,11 @@  discard block
 block discarded – undo
498 498
 	}
499 499
 
500 500
 	public function testGivenValidRequest_tokensAreReturned() {
501
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ) {
502
-			$factory->setTokenGenerator( new FixedTokenGenerator( self::SOME_TOKEN ) );
501
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory) {
502
+			$factory->setTokenGenerator(new FixedTokenGenerator(self::SOME_TOKEN));
503 503
 
504
-			$client->setServerParameter( 'HTTP_REFERER', 'https://en.wikipedia.org/wiki/Karla_Kennichnich' );
505
-			$client->followRedirects( false );
504
+			$client->setServerParameter('HTTP_REFERER', 'https://en.wikipedia.org/wiki/Karla_Kennichnich');
505
+			$client->followRedirects(false);
506 506
 
507 507
 			$client->request(
508 508
 				'POST',
@@ -512,14 +512,14 @@  discard block
 block discarded – undo
512 512
 
513 513
 			$response = $client->getResponse()->getContent();
514 514
 
515
-			$this->assertContains( self::SOME_TOKEN, $response );
515
+			$this->assertContains(self::SOME_TOKEN, $response);
516 516
 		} );
517 517
 	}
518 518
 
519 519
 	public function testGivenValidRequest_clientIsRedirected() {
520
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ) {
521
-			$factory->setTokenGenerator( new FixedTokenGenerator( self::SOME_TOKEN ) );
522
-			$client->followRedirects( false );
520
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory) {
521
+			$factory->setTokenGenerator(new FixedTokenGenerator(self::SOME_TOKEN));
522
+			$client->followRedirects(false);
523 523
 
524 524
 			$client->request(
525 525
 				'POST',
@@ -527,13 +527,13 @@  discard block
 block discarded – undo
527 527
 				$this->newValidFormInput()
528 528
 			);
529 529
 
530
-			$this->assertTrue( $client->getResponse()->isRedirect() );
530
+			$this->assertTrue($client->getResponse()->isRedirect());
531 531
 		} );
532 532
 	}
533 533
 
534 534
 	public function testWhenTrackingCookieExists_valueIsPersisted() {
535
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ) {
536
-			$client->getCookieJar()->set( new Cookie( 'spenden_tracking', 'test/blue' ) );
535
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory) {
536
+			$client->getCookieJar()->set(new Cookie('spenden_tracking', 'test/blue'));
537 537
 
538 538
 			$client->request(
539 539
 				'POST',
@@ -541,15 +541,15 @@  discard block
 block discarded – undo
541 541
 				$this->newComplementableFormInput()
542 542
 			);
543 543
 
544
-			$donation = $this->getDonationFromDatabase( $factory );
544
+			$donation = $this->getDonationFromDatabase($factory);
545 545
 			$data = $donation->getDecodedData();
546 546
 
547
-			$this->assertSame( 'test/blue', $data['tracking'] );
547
+			$this->assertSame('test/blue', $data['tracking']);
548 548
 		} );
549 549
 	}
550 550
 
551 551
 	public function testWhenTrackableInputDataIsSubmitted_theyAreStoredInSession() {
552
-		$this->createAppEnvironment( [], function ( Client $client, FunFunFactory $factory, Application $app ) {
552
+		$this->createAppEnvironment([], function(Client $client, FunFunFactory $factory, Application $app) {
553 553
 
554 554
 			$client->request(
555 555
 				'GET',
@@ -561,15 +561,15 @@  discard block
 block discarded – undo
561 561
 				]
562 562
 			);
563 563
 
564
-			$piwikTracking = $app['session']->get( 'piwikTracking' );
565
-			$this->assertSame( 'BEZ', $piwikTracking['paymentType'] );
566
-			$this->assertSame( 3, $piwikTracking['paymentInterval'] );
567
-			$this->assertSame( '5,00', $piwikTracking['paymentAmount'] );
564
+			$piwikTracking = $app['session']->get('piwikTracking');
565
+			$this->assertSame('BEZ', $piwikTracking['paymentType']);
566
+			$this->assertSame(3, $piwikTracking['paymentInterval']);
567
+			$this->assertSame('5,00', $piwikTracking['paymentAmount']);
568 568
 		} );
569 569
 	}
570 570
 
571 571
 	public function testWhenTolstojNovelIsPassed_isIsNotStoredInSession() {
572
-		$this->createAppEnvironment( [], function ( Client $client, FunFunFactory $factory, Application $app ) {
572
+		$this->createAppEnvironment([], function(Client $client, FunFunFactory $factory, Application $app) {
573 573
 
574 574
 			$client->request(
575 575
 				'GET',
@@ -587,15 +587,15 @@  discard block
 block discarded – undo
587 587
 				]
588 588
 			);
589 589
 
590
-			$piwikTracking = $app['session']->get( 'piwikTracking' );
591
-			$this->assertArrayNotHasKey( 'paymentType', $piwikTracking );
592
-			$this->assertSame( 3, $piwikTracking['paymentInterval'] );
593
-			$this->assertSame( '5,00', $piwikTracking['paymentAmount'] );
590
+			$piwikTracking = $app['session']->get('piwikTracking');
591
+			$this->assertArrayNotHasKey('paymentType', $piwikTracking);
592
+			$this->assertSame(3, $piwikTracking['paymentInterval']);
593
+			$this->assertSame('5,00', $piwikTracking['paymentAmount']);
594 594
 		} );
595 595
 	}
596 596
 
597 597
 	public function testWhenParameterIsOmitted_itIsNotStoredInSession() {
598
-		$this->createAppEnvironment( [], function ( Client $client, FunFunFactory $factory, Application $app ) {
598
+		$this->createAppEnvironment([], function(Client $client, FunFunFactory $factory, Application $app) {
599 599
 
600 600
 			$client->request(
601 601
 				'GET',
@@ -606,15 +606,15 @@  discard block
 block discarded – undo
606 606
 				]
607 607
 			);
608 608
 
609
-			$piwikTracking = $app['session']->get( 'piwikTracking' );
610
-			$this->assertSame( 'BEZ', $piwikTracking['paymentType'] );
611
-			$this->assertSame( '5,00', $piwikTracking['paymentAmount'] );
612
-			$this->assertArrayNotHasKey( 'paymentInterval', $piwikTracking );
609
+			$piwikTracking = $app['session']->get('piwikTracking');
610
+			$this->assertSame('BEZ', $piwikTracking['paymentType']);
611
+			$this->assertSame('5,00', $piwikTracking['paymentAmount']);
612
+			$this->assertArrayNotHasKey('paymentInterval', $piwikTracking);
613 613
 		} );
614 614
 	}
615 615
 
616 616
 	public function testWhenInitiallyIntendedPaymentOptionsDifferFromActual_itIsReflectedInPiwikTrackingEvents() {
617
-		$client = $this->createClient( [] );
617
+		$client = $this->createClient([]);
618 618
 		$client->request(
619 619
 			'GET',
620 620
 			'/',
@@ -638,28 +638,28 @@  discard block
 block discarded – undo
638 638
 		$client->followRedirect();
639 639
 
640 640
 		$responseContent = $client->getResponse()->getContent();
641
-		$this->assertContains( 'BEZ/UEB', $responseContent );
642
-		$this->assertContains( '5.00/12.34', $responseContent );
643
-		$this->assertContains( '12/0', $responseContent );
641
+		$this->assertContains('BEZ/UEB', $responseContent);
642
+		$this->assertContains('5.00/12.34', $responseContent);
643
+		$this->assertContains('12/0', $responseContent);
644 644
 	}
645 645
 
646 646
 	public function testWhenMobileTrackingIsRequested_piwikTrackerIsCalledForPaypalPayment() {
647
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ) {
647
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory) {
648 648
 			$factory->setNullMessenger();
649
-			$client->followRedirects( false );
649
+			$client->followRedirects(false);
650 650
 
651
-			$tracker = $this->getMockBuilder( PageViewTracker::class )->disableOriginalConstructor()->getMock();
652
-			$tracker->expects( $this->once() )
653
-				->method( 'trackPaypalRedirection' )
654
-				->with( 'test', 'gelb', '10.1.2.3' );
655
-			$factory->setPageViewTracker( $tracker );
651
+			$tracker = $this->getMockBuilder(PageViewTracker::class)->disableOriginalConstructor()->getMock();
652
+			$tracker->expects($this->once())
653
+				->method('trackPaypalRedirection')
654
+				->with('test', 'gelb', '10.1.2.3');
655
+			$factory->setPageViewTracker($tracker);
656 656
 
657 657
 			$client->request(
658 658
 				'POST',
659 659
 				'/donation/add',
660 660
 				$this->newValidMobilePayPalInput(),
661 661
 				[],
662
-				[ 'REMOTE_ADDR' => '10.1.2.3' ]
662
+				['REMOTE_ADDR' => '10.1.2.3']
663 663
 			);
664 664
 
665 665
 			$client->getResponse();
@@ -679,21 +679,21 @@  discard block
 block discarded – undo
679 679
 	}
680 680
 
681 681
 	public function testWhenMobileTrackingIsRequested_piwikTrackerIsNotCalledForNonPaypalPayment() {
682
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ) {
682
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory) {
683 683
 			$factory->setNullMessenger();
684
-			$client->followRedirects( false );
684
+			$client->followRedirects(false);
685 685
 
686
-			$tracker = $this->getMockBuilder( PageViewTracker::class )->disableOriginalConstructor()->getMock();
687
-			$tracker->expects( $this->never() )
688
-				->method( 'trackPaypalRedirection' );
689
-			$factory->setPageViewTracker( $tracker );
686
+			$tracker = $this->getMockBuilder(PageViewTracker::class)->disableOriginalConstructor()->getMock();
687
+			$tracker->expects($this->never())
688
+				->method('trackPaypalRedirection');
689
+			$factory->setPageViewTracker($tracker);
690 690
 
691 691
 			$client->request(
692 692
 				'POST',
693 693
 				'/donation/add',
694 694
 				array_merge(
695 695
 					$this->newValidCreditCardInput(),
696
-					[ 'mbt' => '1' ]
696
+					['mbt' => '1']
697 697
 				)
698 698
 			);
699 699
 
@@ -702,10 +702,10 @@  discard block
 block discarded – undo
702 702
 	}
703 703
 
704 704
 	public function testGivenCommasInStreetInput_donationGetsPersisted() {
705
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ) {
705
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory) {
706 706
 
707
-			$client->setServerParameter( 'HTTP_REFERER', 'https://en.wikipedia.org/wiki/Karla_Kennichnich' );
708
-			$client->followRedirects( false );
707
+			$client->setServerParameter('HTTP_REFERER', 'https://en.wikipedia.org/wiki/Karla_Kennichnich');
708
+			$client->followRedirects(false);
709 709
 
710 710
 			$formInput = $this->newValidFormInput();
711 711
 			$formInput['street'] = ',Lehmgasse, 12,';
@@ -716,12 +716,12 @@  discard block
 block discarded – undo
716 716
 				$formInput
717 717
 			);
718 718
 
719
-			$this->assertIsExpectedDonation( $this->getDonationFromDatabase( $factory ) );
719
+			$this->assertIsExpectedDonation($this->getDonationFromDatabase($factory));
720 720
 		} );
721 721
 	}
722 722
 
723 723
 	public function testGivenSufficientForeignBankData_donationGetsPersisted() {
724
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ) {
724
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory) {
725 725
 			$formInput = $this->newValidFormInput();
726 726
 			$formInput['iban'] = 'AT022050302101023600';
727 727
 			$formInput['bic'] = 'SPIHAT22XXX';
@@ -734,14 +734,14 @@  discard block
 block discarded – undo
734 734
 				$formInput
735 735
 			);
736 736
 
737
-			$donation = $this->getDonationFromDatabase( $factory );
737
+			$donation = $this->getDonationFromDatabase($factory);
738 738
 			$data = $donation->getDecodedData();
739 739
 
740
-			$this->assertSame( 'AT022050302101023600', $data['iban'] );
741
-			$this->assertSame( 'SPIHAT22XXX', $data['bic'] );
742
-			$this->assertSame( '', $data['konto'] );
743
-			$this->assertSame( '', $data['blz'] );
744
-			$this->assertSame( '', $data['bankname'] );
740
+			$this->assertSame('AT022050302101023600', $data['iban']);
741
+			$this->assertSame('SPIHAT22XXX', $data['bic']);
742
+			$this->assertSame('', $data['konto']);
743
+			$this->assertSame('', $data['blz']);
744
+			$this->assertSame('', $data['bankname']);
745 745
 		} );
746 746
 	}
747 747
 
Please login to merge, or discard this patch.
src/Validation/BankDataValidator.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types = 1);
4 4
 
5 5
 namespace WMDE\Fundraising\Frontend\Validation;
6 6
 
@@ -15,28 +15,28 @@  discard block
 block discarded – undo
15 15
 
16 16
 	private $ibanValidator;
17 17
 
18
-	public function __construct( IbanValidator $ibanValidator ) {
18
+	public function __construct(IbanValidator $ibanValidator) {
19 19
 		$this->ibanValidator = $ibanValidator;
20 20
 	}
21 21
 
22
-	public function validate( BankData $bankData ): ValidationResult {
22
+	public function validate(BankData $bankData): ValidationResult {
23 23
 		$validator = new RequiredFieldValidator();
24 24
 		$violations = [];
25 25
 
26
-		$violations[] = $this->getFieldViolation( $validator->validate( $bankData->getIban()->toString() ), 'iban' );
27
-		$violations[] = $this->getFieldViolation( $validator->validate( $bankData->getBic() ), 'bic' );
26
+		$violations[] = $this->getFieldViolation($validator->validate($bankData->getIban()->toString()), 'iban');
27
+		$violations[] = $this->getFieldViolation($validator->validate($bankData->getBic()), 'bic');
28 28
 
29
-		if ( $bankData->getIban()->getCountryCode() === 'DE' ) {
29
+		if ($bankData->getIban()->getCountryCode() === 'DE') {
30 30
 			$stringLengthValidator = new StringLengthValidator();
31
-			$violations[] = $this->getFieldViolation( $validator->validate( $bankData->getAccount() ), 'konto' );
32
-			$violations[] = $this->getFieldViolation( $validator->validate( $bankData->getBankCode() ), 'blz' );
33
-			$violations[] = $this->getFieldViolation( $stringLengthValidator->validate( $bankData->getAccount(), 10 ), 'konto' );
34
-			$violations[] = $this->getFieldViolation( $stringLengthValidator->validate( $bankData->getBankCode(), 8 ), 'blz' );
31
+			$violations[] = $this->getFieldViolation($validator->validate($bankData->getAccount()), 'konto');
32
+			$violations[] = $this->getFieldViolation($validator->validate($bankData->getBankCode()), 'blz');
33
+			$violations[] = $this->getFieldViolation($stringLengthValidator->validate($bankData->getAccount(), 10), 'konto');
34
+			$violations[] = $this->getFieldViolation($stringLengthValidator->validate($bankData->getBankCode(), 8), 'blz');
35 35
 		}
36 36
 
37
-		$violations[] = $this->getFieldViolation( $this->ibanValidator->validate( $bankData->getIban() ), 'iban' );
37
+		$violations[] = $this->getFieldViolation($this->ibanValidator->validate($bankData->getIban()), 'iban');
38 38
 
39
-		return new ValidationResult( ...array_filter( $violations ) );
39
+		return new ValidationResult(...array_filter($violations));
40 40
 	}
41 41
 
42 42
 }
Please login to merge, or discard this patch.