Completed
Pull Request — master (#975)
by wiese
61:13
created
app/RouteHandlers/AddDonationHandler.php 1 patch
Spacing   +75 added lines, -75 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
 				return $this->app->redirect(
@@ -105,107 +105,107 @@  discard block
 block discarded – undo
105 105
 				break;
106 106
 			case PaymentType::CREDIT_CARD:
107 107
 				return $this->app->redirect(
108
-					$this->ffFactory->newCreditCardPaymentUrlGenerator()->buildUrl( $responseModel )
108
+					$this->ffFactory->newCreditCardPaymentUrlGenerator()->buildUrl($responseModel)
109 109
 				);
110 110
 				break;
111 111
 			default:
112
-				throw new \LogicException( 'This code should not be reached' );
112
+				throw new \LogicException('This code should not be reached');
113 113
 		}
114 114
 	}
115 115
 
116
-	private function createDonationRequest( Request $request ): AddDonationRequest {
116
+	private function createDonationRequest(Request $request): AddDonationRequest {
117 117
 		$donationRequest = new AddDonationRequest();
118 118
 
119
-		$donationRequest->setAmount( $this->getEuroAmountFromString( $request->get( 'betrag', '' ) ) );
120
-
121
-		$donationRequest->setPaymentType( $request->get( 'zahlweise', '' ) );
122
-		$donationRequest->setInterval( intval( $request->get( 'periode', 0 ) ) );
123
-
124
-		$donationRequest->setDonorType( $request->get( 'addressType', '' ) );
125
-		$donationRequest->setDonorSalutation( $request->get( 'salutation', '' ) );
126
-		$donationRequest->setDonorTitle( $request->get( 'title', '' ) );
127
-		$donationRequest->setDonorCompany( $request->get( 'companyName', '' ) );
128
-		$donationRequest->setDonorFirstName( $request->get( 'firstName', '' ) );
129
-		$donationRequest->setDonorLastName( $request->get( 'lastName', '' ) );
130
-		$donationRequest->setDonorStreetAddress( $this->filterAutofillCommas( $request->get( 'street', '' ) ) );
131
-		$donationRequest->setDonorPostalCode( $request->get( 'postcode', '' ) );
132
-		$donationRequest->setDonorCity( $request->get( 'city', '' ) );
133
-		$donationRequest->setDonorCountryCode( $request->get( 'country', '' ) );
134
-		$donationRequest->setDonorEmailAddress( $request->get( 'email', '' ) );
135
-
136
-		if ( $request->get( 'zahlweise', '' ) === PaymentType::DIRECT_DEBIT ) {
137
-			$donationRequest->setBankData( $this->getBankDataFromRequest( $request ) );
119
+		$donationRequest->setAmount($this->getEuroAmountFromString($request->get('betrag', '')));
120
+
121
+		$donationRequest->setPaymentType($request->get('zahlweise', ''));
122
+		$donationRequest->setInterval(intval($request->get('periode', 0)));
123
+
124
+		$donationRequest->setDonorType($request->get('addressType', ''));
125
+		$donationRequest->setDonorSalutation($request->get('salutation', ''));
126
+		$donationRequest->setDonorTitle($request->get('title', ''));
127
+		$donationRequest->setDonorCompany($request->get('companyName', ''));
128
+		$donationRequest->setDonorFirstName($request->get('firstName', ''));
129
+		$donationRequest->setDonorLastName($request->get('lastName', ''));
130
+		$donationRequest->setDonorStreetAddress($this->filterAutofillCommas($request->get('street', '')));
131
+		$donationRequest->setDonorPostalCode($request->get('postcode', ''));
132
+		$donationRequest->setDonorCity($request->get('city', ''));
133
+		$donationRequest->setDonorCountryCode($request->get('country', ''));
134
+		$donationRequest->setDonorEmailAddress($request->get('email', ''));
135
+
136
+		if ($request->get('zahlweise', '') === PaymentType::DIRECT_DEBIT) {
137
+			$donationRequest->setBankData($this->getBankDataFromRequest($request));
138 138
 		}
139 139
 
140
-		$donationRequest->setTracking( $request->attributes->get( 'trackingCode' ) );
141
-		$donationRequest->setOptIn( $request->get( 'info', '' ) );
142
-		$donationRequest->setSource( $request->attributes->get( 'trackingSource' ) );
143
-		$donationRequest->setTotalImpressionCount( intval( $request->get( 'impCount', 0 ) ) );
144
-		$donationRequest->setSingleBannerImpressionCount( intval( $request->get( 'bImpCount', 0 ) ) );
145
-		$donationRequest->setOptsIntoDonationReceipt( $request->request->getBoolean( 'donationReceipt', true ) );
140
+		$donationRequest->setTracking($request->attributes->get('trackingCode'));
141
+		$donationRequest->setOptIn($request->get('info', ''));
142
+		$donationRequest->setSource($request->attributes->get('trackingSource'));
143
+		$donationRequest->setTotalImpressionCount(intval($request->get('impCount', 0)));
144
+		$donationRequest->setSingleBannerImpressionCount(intval($request->get('bImpCount', 0)));
145
+		$donationRequest->setOptsIntoDonationReceipt($request->request->getBoolean('donationReceipt', true));
146 146
 
147 147
 		return $donationRequest;
148 148
 	}
149 149
 
150
-	private function getBankDataFromRequest( Request $request ): BankData {
150
+	private function getBankDataFromRequest(Request $request): BankData {
151 151
 		$bankData = new BankData();
152
-		$bankData->setIban( new Iban( $request->get( 'iban', '' ) ) )
153
-			->setBic( $request->get( 'bic', '' ) )
154
-			->setAccount( $request->get( 'konto', '' ) )
155
-			->setBankCode( $request->get( 'blz', '' ) )
156
-			->setBankName( $request->get( 'bankname', '' ) );
152
+		$bankData->setIban(new Iban($request->get('iban', '')))
153
+			->setBic($request->get('bic', ''))
154
+			->setAccount($request->get('konto', ''))
155
+			->setBankCode($request->get('blz', ''))
156
+			->setBankName($request->get('bankname', ''));
157 157
 
158
-		if ( $bankData->isComplete() ) {
158
+		if ($bankData->isComplete()) {
159 159
 			return $bankData->freeze()->assertNoNullFields();
160 160
 		}
161 161
 
162
-		if ( $bankData->hasIban() ) {
163
-			$bankData = $this->newBankDataFromIban( $bankData->getIban() );
164
-		} elseif ( $bankData->hasCompleteLegacyBankData() ) {
165
-			$bankData = $this->newBankDataFromAccountAndBankCode( $bankData->getAccount(), $bankData->getBankCode() );
162
+		if ($bankData->hasIban()) {
163
+			$bankData = $this->newBankDataFromIban($bankData->getIban());
164
+		} elseif ($bankData->hasCompleteLegacyBankData()) {
165
+			$bankData = $this->newBankDataFromAccountAndBankCode($bankData->getAccount(), $bankData->getBankCode());
166 166
 		}
167 167
 		return $bankData->freeze()->assertNoNullFields();
168 168
 	}
169 169
 
170
-	private function newBankDataFromIban( Iban $iban ): BankData {
171
-		return $this->ffFactory->newBankDataConverter()->getBankDataFromIban( $iban );
170
+	private function newBankDataFromIban(Iban $iban): BankData {
171
+		return $this->ffFactory->newBankDataConverter()->getBankDataFromIban($iban);
172 172
 	}
173 173
 
174
-	private function newBankDataFromAccountAndBankCode( string $account, string $bankCode ): BankData {
175
-		return $this->ffFactory->newBankDataConverter()->getBankDataFromAccountData( $account, $bankCode );
174
+	private function newBankDataFromAccountAndBankCode(string $account, string $bankCode): BankData {
175
+		return $this->ffFactory->newBankDataConverter()->getBankDataFromAccountData($account, $bankCode);
176 176
 	}
177 177
 
178
-	private function getEuroAmountFromString( string $amount ): Euro {
178
+	private function getEuroAmountFromString(string $amount): Euro {
179 179
 		$locale = 'de_DE'; // TODO: make this configurable for multilanguage support
180 180
 		try {
181
-			return Euro::newFromFloat( ( new AmountParser( $locale ) )->parseAsFloat( $amount ) );
182
-		} catch ( \InvalidArgumentException $ex ) {
183
-			return Euro::newFromCents( 0 );
181
+			return Euro::newFromFloat((new AmountParser($locale))->parseAsFloat($amount));
182
+		} catch (\InvalidArgumentException $ex) {
183
+			return Euro::newFromCents(0);
184 184
 		}
185 185
 
186 186
 	}
187 187
 
188
-	private function isSubmissionAllowed( Request $request ) {
189
-		$lastSubmission = $request->cookies->get( ShowDonationConfirmationHandler::SUBMISSION_COOKIE_NAME, '' );
190
-		if ( $lastSubmission === '' ) {
188
+	private function isSubmissionAllowed(Request $request) {
189
+		$lastSubmission = $request->cookies->get(ShowDonationConfirmationHandler::SUBMISSION_COOKIE_NAME, '');
190
+		if ($lastSubmission === '') {
191 191
 			return true;
192 192
 		}
193 193
 
194 194
 		$minNextTimestamp =
195
-			\DateTime::createFromFormat( ShowDonationConfirmationHandler::TIMESTAMP_FORMAT, $lastSubmission )
196
-			->add( new \DateInterval( $this->ffFactory->getDonationTimeframeLimit() ) );
195
+			\DateTime::createFromFormat(ShowDonationConfirmationHandler::TIMESTAMP_FORMAT, $lastSubmission)
196
+			->add(new \DateInterval($this->ffFactory->getDonationTimeframeLimit()));
197 197
 
198
-		if ( $minNextTimestamp > new \DateTime() ) {
198
+		if ($minNextTimestamp > new \DateTime()) {
199 199
 			return false;
200 200
 		}
201 201
 
202 202
 		return true;
203 203
 	}
204 204
 
205
-	private function newTrackingInfoFromRequest( Request $request ): DonationTrackingInfo {
205
+	private function newTrackingInfoFromRequest(Request $request): DonationTrackingInfo {
206 206
 		$tracking = new DonationTrackingInfo();
207
-		$tracking->setSingleBannerImpressionCount( intval( $request->get( 'bImpCount', 0 ) ) );
208
-		$tracking->setTotalImpressionCount( intval( $request->get( 'impCount', 0 ) ) );
207
+		$tracking->setSingleBannerImpressionCount(intval($request->get('bImpCount', 0)));
208
+		$tracking->setTotalImpressionCount(intval($request->get('impCount', 0)));
209 209
 
210 210
 		return $tracking;
211 211
 	}
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 	 * @param string $value
218 218
 	 * @return string
219 219
 	 */
220
-	private function filterAutofillCommas( string $value ): string {
221
-		return trim( preg_replace( ['/,/', '/\s{2,}/'], [' ', ' '], $value ) );
220
+	private function filterAutofillCommas(string $value): string {
221
+		return trim(preg_replace(['/,/', '/\s{2,}/'], [' ', ' '], $value));
222 222
 	}
223 223
 }
224 224
\ No newline at end of file
Please login to merge, or discard this patch.
tests/EdgeToEdge/Routes/AddDonationRouteTest.php 1 patch
Spacing   +223 added lines, -223 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
 
@@ -32,10 +32,10 @@  discard block
 block discarded – undo
32 32
 	private const ADD_DONATION_PATH = '/donation/add';
33 33
 
34 34
 	public function testGivenValidRequest_donationGetsPersisted(): void {
35
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ): void {
35
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory): void {
36 36
 
37
-			$client->setServerParameter( 'HTTP_REFERER', 'https://en.wikipedia.org/wiki/Karla_Kennichnich' );
38
-			$client->followRedirects( false );
37
+			$client->setServerParameter('HTTP_REFERER', 'https://en.wikipedia.org/wiki/Karla_Kennichnich');
38
+			$client->followRedirects(false);
39 39
 
40 40
 			$client->request(
41 41
 				'POST',
@@ -43,28 +43,28 @@  discard block
 block discarded – undo
43 43
 				$this->newValidFormInput()
44 44
 			);
45 45
 
46
-			$this->assertIsExpectedDonation( $this->getDonationFromDatabase( $factory ) );
46
+			$this->assertIsExpectedDonation($this->getDonationFromDatabase($factory));
47 47
 		} );
48 48
 	}
49 49
 
50 50
 	public function testWhenDonationGetsPersisted_timestampIsStoredInCookie(): void {
51 51
 		$client = $this->createClient();
52
-		$client->followRedirects( true );
52
+		$client->followRedirects(true);
53 53
 		$client->request(
54 54
 			'POST',
55 55
 			'/donation/add',
56 56
 			$this->newValidFormInput()
57 57
 		);
58 58
 
59
-		$cookie = $client->getCookieJar()->get( 'donation_timestamp' );
60
-		$this->assertNotNull( $cookie );
61
-		$donationTimestamp = new \DateTime( $cookie->getValue() );
62
-		$this->assertEquals( time(), $donationTimestamp->getTimestamp(), 'Timestamp should be not more than 5 seconds old', 5.0 );
59
+		$cookie = $client->getCookieJar()->get('donation_timestamp');
60
+		$this->assertNotNull($cookie);
61
+		$donationTimestamp = new \DateTime($cookie->getValue());
62
+		$this->assertEquals(time(), $donationTimestamp->getTimestamp(), 'Timestamp should be not more than 5 seconds old', 5.0);
63 63
 	}
64 64
 
65 65
 	public function testWhenMultipleDonationFormSubmissions_requestGetsRejected(): void {
66 66
 		$client = $this->createClient();
67
-		$client->getCookieJar()->set( new Cookie( 'donation_timestamp', $this->getPastTimestamp() ) );
67
+		$client->getCookieJar()->set(new Cookie('donation_timestamp', $this->getPastTimestamp()));
68 68
 
69 69
 		$client->request(
70 70
 			'POST',
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 			$this->newValidFormInput()
73 73
 		);
74 74
 
75
-		$this->assertContains( 'donation_rejected_limit', $client->getResponse()->getContent() );
75
+		$this->assertContains('donation_rejected_limit', $client->getResponse()->getContent());
76 76
 	}
77 77
 
78 78
 	public function testWhenMultipleDonationsInAccordanceToTimeLimit_requestIsNotRejected(): void {
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 		$client->getCookieJar()->set(
81 81
 			new Cookie(
82 82
 				'donation_timestamp',
83
-				$this->getPastTimestamp( 'PT35M' )
83
+				$this->getPastTimestamp('PT35M')
84 84
 			)
85 85
 		);
86 86
 
@@ -90,11 +90,11 @@  discard block
 block discarded – undo
90 90
 			$this->newValidFormInput()
91 91
 		);
92 92
 
93
-		$this->assertNotContains( 'donation_rejected_limit', $client->getResponse()->getContent() );
93
+		$this->assertNotContains('donation_rejected_limit', $client->getResponse()->getContent());
94 94
 	}
95 95
 
96
-	private function getPastTimestamp( string $interval = 'PT10S' ): string {
97
-		return ( new \DateTime() )->sub( new \DateInterval( $interval ) )->format( 'Y-m-d H:i:s' );
96
+	private function getPastTimestamp(string $interval = 'PT10S'): string {
97
+		return (new \DateTime())->sub(new \DateInterval($interval))->format('Y-m-d H:i:s');
98 98
 	}
99 99
 
100 100
 	private function newValidFormInput(): array {
@@ -129,40 +129,40 @@  discard block
 block discarded – undo
129 129
 		];
130 130
 	}
131 131
 
132
-	private function assertIsExpectedDonation( Donation $donation ): void {
132
+	private function assertIsExpectedDonation(Donation $donation): void {
133 133
 		$data = $donation->getDecodedData();
134
-		$this->assertSame( '5.51', $donation->getAmount() );
135
-		$this->assertSame( 'BEZ', $donation->getPaymentType() );
136
-		$this->assertSame( 0, $donation->getPaymentIntervalInMonths() );
137
-		$this->assertSame( 'DE12500105170648489890', $data['iban'] );
138
-		$this->assertSame( 'INGDDEFFXXX', $data['bic'] );
139
-		$this->assertSame( '0648489890', $data['konto'] );
140
-		$this->assertSame( '50010517', $data['blz'] );
141
-		$this->assertSame( 'ING-DiBa', $data['bankname'] );
142
-		$this->assertSame( 'person', $data['adresstyp'] );
143
-		$this->assertSame( 'Frau', $data['anrede'] );
144
-		$this->assertSame( 'Prof. Dr.', $data['titel'] );
145
-		$this->assertSame( '', $data['firma'] );
146
-		$this->assertSame( 'Karla', $data['vorname'] );
147
-		$this->assertSame( 'Kennichnich', $data['nachname'] );
148
-		$this->assertSame( 'Prof. Dr. Karla Kennichnich', $donation->getDonorFullName() );
149
-		$this->assertSame( 'Lehmgasse 12', $data['strasse'] );
150
-		$this->assertSame( '12345', $data['plz'] );
151
-		$this->assertSame( 'Einort', $data['ort'] );
152
-		$this->assertSame( 'Einort', $donation->getDonorCity() );
153
-		$this->assertSame( 'DE', $data['country'] );
154
-		$this->assertSame( '[email protected]', $data['email'] );
155
-		$this->assertSame( '[email protected]', $donation->getDonorEmail() );
156
-		$this->assertSame( 'test/gelb', $data['tracking'] );
157
-		$this->assertSame( 3, $data['impCount'] );
158
-		$this->assertSame( 1, $data['bImpCount'] );
159
-		$this->assertSame( '', $data['layout'] );
160
-		$this->assertSame( '', $data['color'] );
161
-		$this->assertSame( '', $data['skin'] );
162
-		$this->assertSame( 'en.wikipedia.org', $data['source'] );
163
-		$this->assertSame( 'N', $donation->getStatus() );
164
-		$this->assertTrue( $donation->getDonorOptsIntoNewsletter() );
165
-		$this->assertTrue( $donation->getDonationReceipt() );
134
+		$this->assertSame('5.51', $donation->getAmount());
135
+		$this->assertSame('BEZ', $donation->getPaymentType());
136
+		$this->assertSame(0, $donation->getPaymentIntervalInMonths());
137
+		$this->assertSame('DE12500105170648489890', $data['iban']);
138
+		$this->assertSame('INGDDEFFXXX', $data['bic']);
139
+		$this->assertSame('0648489890', $data['konto']);
140
+		$this->assertSame('50010517', $data['blz']);
141
+		$this->assertSame('ING-DiBa', $data['bankname']);
142
+		$this->assertSame('person', $data['adresstyp']);
143
+		$this->assertSame('Frau', $data['anrede']);
144
+		$this->assertSame('Prof. Dr.', $data['titel']);
145
+		$this->assertSame('', $data['firma']);
146
+		$this->assertSame('Karla', $data['vorname']);
147
+		$this->assertSame('Kennichnich', $data['nachname']);
148
+		$this->assertSame('Prof. Dr. Karla Kennichnich', $donation->getDonorFullName());
149
+		$this->assertSame('Lehmgasse 12', $data['strasse']);
150
+		$this->assertSame('12345', $data['plz']);
151
+		$this->assertSame('Einort', $data['ort']);
152
+		$this->assertSame('Einort', $donation->getDonorCity());
153
+		$this->assertSame('DE', $data['country']);
154
+		$this->assertSame('[email protected]', $data['email']);
155
+		$this->assertSame('[email protected]', $donation->getDonorEmail());
156
+		$this->assertSame('test/gelb', $data['tracking']);
157
+		$this->assertSame(3, $data['impCount']);
158
+		$this->assertSame(1, $data['bImpCount']);
159
+		$this->assertSame('', $data['layout']);
160
+		$this->assertSame('', $data['color']);
161
+		$this->assertSame('', $data['skin']);
162
+		$this->assertSame('en.wikipedia.org', $data['source']);
163
+		$this->assertSame('N', $donation->getStatus());
164
+		$this->assertTrue($donation->getDonorOptsIntoNewsletter());
165
+		$this->assertTrue($donation->getDonationReceipt());
166 166
 	}
167 167
 
168 168
 	public function testGivenValidRequest_confirmationPageContainsEnteredData(): void {
@@ -176,16 +176,16 @@  discard block
 block discarded – undo
176 176
 
177 177
 		$response = $client->getResponse()->getContent();
178 178
 
179
-		$this->assertContains( '5,51 €', $response );
180
-		$this->assertContains( 'donation.interval: 0', $response );
181
-		$this->assertContains( 'DE12500105170648489890', $response );
182
-		$this->assertContains( 'INGDDEFFXXX', $response );
183
-		$this->assertContains( 'ING-DiBa', $response );
184
-		$this->assertContains( 'Prof. Dr. Karla Kennichnich', $response );
185
-		$this->assertContains( 'Lehmgasse 12', $response );
186
-		$this->assertContains( '<span id="confirm-postcode">12345</span> <span id="confirm-city">Einort</span>', $response );
187
-		$this->assertContains( '[email protected]', $response );
188
-		$this->assertContains( 'send-info', $response );
179
+		$this->assertContains('5,51 €', $response);
180
+		$this->assertContains('donation.interval: 0', $response);
181
+		$this->assertContains('DE12500105170648489890', $response);
182
+		$this->assertContains('INGDDEFFXXX', $response);
183
+		$this->assertContains('ING-DiBa', $response);
184
+		$this->assertContains('Prof. Dr. Karla Kennichnich', $response);
185
+		$this->assertContains('Lehmgasse 12', $response);
186
+		$this->assertContains('<span id="confirm-postcode">12345</span> <span id="confirm-city">Einort</span>', $response);
187
+		$this->assertContains('[email protected]', $response);
188
+		$this->assertContains('send-info', $response);
189 189
 	}
190 190
 
191 191
 	public function testGivenValidBankTransferRequest_donationGetsPersisted(): void {
@@ -194,10 +194,10 @@  discard block
 block discarded – undo
194 194
 		 */
195 195
 		$factory = null;
196 196
 
197
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ): void {
197
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory): void {
198 198
 
199
-			$client->setServerParameter( 'HTTP_REFERER', 'https://en.wikipedia.org/wiki/Karla_Kennichnich' );
200
-			$client->followRedirects( false );
199
+			$client->setServerParameter('HTTP_REFERER', 'https://en.wikipedia.org/wiki/Karla_Kennichnich');
200
+			$client->followRedirects(false);
201 201
 
202 202
 			$client->request(
203 203
 				'POST',
@@ -205,37 +205,37 @@  discard block
 block discarded – undo
205 205
 				$this->newValidBankTransferInput()
206 206
 			);
207 207
 
208
-			$donation = $this->getDonationFromDatabase( $factory );
208
+			$donation = $this->getDonationFromDatabase($factory);
209 209
 
210 210
 			$data = $donation->getDecodedData();
211
-			$this->assertSame( '12.34', $donation->getAmount() );
212
-			$this->assertSame( 'UEB', $donation->getPaymentType() );
213
-			$this->assertSame( 0, $donation->getPaymentIntervalInMonths() );
214
-			$this->assertSame( 'person', $data['adresstyp'] );
215
-			$this->assertSame( 'Frau', $data['anrede'] );
216
-			$this->assertSame( 'Prof. Dr.', $data['titel'] );
217
-			$this->assertSame( '', $data['firma'] );
218
-			$this->assertSame( 'Karla', $data['vorname'] );
219
-			$this->assertSame( 'Kennichnich', $data['nachname'] );
220
-			$this->assertSame( 'Prof. Dr. Karla Kennichnich', $donation->getDonorFullName() );
221
-			$this->assertSame( 'Lehmgasse 12', $data['strasse'] );
222
-			$this->assertSame( '12345', $data['plz'] );
223
-			$this->assertSame( 'Einort', $data['ort'] );
224
-			$this->assertSame( 'Einort', $donation->getDonorCity() );
225
-			$this->assertSame( 'DE', $data['country'] );
226
-			$this->assertSame( '[email protected]', $data['email'] );
227
-			$this->assertSame( '[email protected]', $donation->getDonorEmail() );
228
-			$this->assertSame( 'test/gelb', $data['tracking'] );
229
-			$this->assertSame( 3, $data['impCount'] );
230
-			$this->assertSame( 1, $data['bImpCount'] );
231
-			$this->assertSame( '', $data['layout'] );
232
-			$this->assertSame( '', $data['color'] );
233
-			$this->assertSame( '', $data['skin'] );
234
-			$this->assertSame( 'en.wikipedia.org', $data['source'] );
235
-			$this->assertSame( true, $donation->getDonorOptsIntoNewsletter() );
236
-
237
-			$this->assertSame( 'Z', $donation->getStatus() );
238
-			$this->assertRegExp( '/W-Q-[A-Z]{6}-[A-Z]/', $donation->getBankTransferCode() );
211
+			$this->assertSame('12.34', $donation->getAmount());
212
+			$this->assertSame('UEB', $donation->getPaymentType());
213
+			$this->assertSame(0, $donation->getPaymentIntervalInMonths());
214
+			$this->assertSame('person', $data['adresstyp']);
215
+			$this->assertSame('Frau', $data['anrede']);
216
+			$this->assertSame('Prof. Dr.', $data['titel']);
217
+			$this->assertSame('', $data['firma']);
218
+			$this->assertSame('Karla', $data['vorname']);
219
+			$this->assertSame('Kennichnich', $data['nachname']);
220
+			$this->assertSame('Prof. Dr. Karla Kennichnich', $donation->getDonorFullName());
221
+			$this->assertSame('Lehmgasse 12', $data['strasse']);
222
+			$this->assertSame('12345', $data['plz']);
223
+			$this->assertSame('Einort', $data['ort']);
224
+			$this->assertSame('Einort', $donation->getDonorCity());
225
+			$this->assertSame('DE', $data['country']);
226
+			$this->assertSame('[email protected]', $data['email']);
227
+			$this->assertSame('[email protected]', $donation->getDonorEmail());
228
+			$this->assertSame('test/gelb', $data['tracking']);
229
+			$this->assertSame(3, $data['impCount']);
230
+			$this->assertSame(1, $data['bImpCount']);
231
+			$this->assertSame('', $data['layout']);
232
+			$this->assertSame('', $data['color']);
233
+			$this->assertSame('', $data['skin']);
234
+			$this->assertSame('en.wikipedia.org', $data['source']);
235
+			$this->assertSame(true, $donation->getDonorOptsIntoNewsletter());
236
+
237
+			$this->assertSame('Z', $donation->getStatus());
238
+			$this->assertRegExp('/W-Q-[A-Z]{6}-[A-Z]/', $donation->getBankTransferCode());
239 239
 		} );
240 240
 	}
241 241
 
@@ -267,10 +267,10 @@  discard block
 block discarded – undo
267 267
 	}
268 268
 
269 269
 	public function testGivenComplementableBankData_donationStillGetsPersisted(): void {
270
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ): void {
270
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory): void {
271 271
 
272
-			$client->setServerParameter( 'HTTP_REFERER', 'https://en.wikipedia.org/wiki/Karla_Kennichnich' );
273
-			$client->followRedirects( false );
272
+			$client->setServerParameter('HTTP_REFERER', 'https://en.wikipedia.org/wiki/Karla_Kennichnich');
273
+			$client->followRedirects(false);
274 274
 
275 275
 			$client->request(
276 276
 				'POST',
@@ -278,14 +278,14 @@  discard block
 block discarded – undo
278 278
 				$this->newComplementableFormInput()
279 279
 			);
280 280
 
281
-			$donation = $this->getDonationFromDatabase( $factory );
281
+			$donation = $this->getDonationFromDatabase($factory);
282 282
 
283 283
 			$data = $donation->getDecodedData();
284
-			$this->assertSame( 'DE12500105170648489890', $data['iban'] );
285
-			$this->assertSame( 'INGDDEFFXXX', $data['bic'] );
286
-			$this->assertSame( '0648489890', $data['konto'] );
287
-			$this->assertSame( '50010517', $data['blz'] );
288
-			$this->assertSame( 'ING-DiBa', $data['bankname'] );
284
+			$this->assertSame('DE12500105170648489890', $data['iban']);
285
+			$this->assertSame('INGDDEFFXXX', $data['bic']);
286
+			$this->assertSame('0648489890', $data['konto']);
287
+			$this->assertSame('50010517', $data['blz']);
288
+			$this->assertSame('ING-DiBa', $data['bankname']);
289 289
 		} );
290 290
 	}
291 291
 
@@ -308,16 +308,16 @@  discard block
 block discarded – undo
308 308
 		];
309 309
 	}
310 310
 
311
-	private function getDonationFromDatabase( FunFunFactory $factory ): Donation {
312
-		$donationRepo = $factory->getEntityManager()->getRepository( Donation::class );
313
-		$donation = $donationRepo->find( 1 );
314
-		$this->assertInstanceOf( Donation::class, $donation );
311
+	private function getDonationFromDatabase(FunFunFactory $factory): Donation {
312
+		$donationRepo = $factory->getEntityManager()->getRepository(Donation::class);
313
+		$donation = $donationRepo->find(1);
314
+		$this->assertInstanceOf(Donation::class, $donation);
315 315
 		return $donation;
316 316
 	}
317 317
 
318 318
 	public function testGivenValidPayPalData_redirectsToPayPal(): void {
319 319
 		$client = $this->createClient();
320
-		$client->followRedirects( false );
320
+		$client->followRedirects(false);
321 321
 
322 322
 		$client->request(
323 323
 			'POST',
@@ -326,13 +326,13 @@  discard block
 block discarded – undo
326 326
 		);
327 327
 
328 328
 		$response = $client->getResponse();
329
-		$this->assertSame( Response::HTTP_FOUND, $response->getStatusCode() );
330
-		$this->assertContains( 'sandbox.paypal.com', $response->getContent() );
329
+		$this->assertSame(Response::HTTP_FOUND, $response->getStatusCode());
330
+		$this->assertContains('sandbox.paypal.com', $response->getContent());
331 331
 	}
332 332
 
333 333
 	public function testWhenRedirectingToPayPal_translatedItemNameIsPassed(): void {
334 334
 		$client = $this->createClient();
335
-		$client->followRedirects( false );
335
+		$client->followRedirects(false);
336 336
 
337 337
 		$client->request(
338 338
 			'POST',
@@ -341,8 +341,8 @@  discard block
 block discarded – undo
341 341
 		);
342 342
 
343 343
 		$response = $client->getResponse();
344
-		$this->assertSame( Response::HTTP_FOUND, $response->getStatusCode() );
345
-		$this->assertContains( 'item_name=item_name_donation', $response->getContent() );
344
+		$this->assertSame(Response::HTTP_FOUND, $response->getStatusCode());
345
+		$this->assertContains('item_name=item_name_donation', $response->getContent());
346 346
 	}
347 347
 
348 348
 	private function newValidPayPalInput(): array {
@@ -363,37 +363,37 @@  discard block
 block discarded – undo
363 363
 		);
364 364
 
365 365
 		$response = $client->getResponse();
366
-		$this->assertSame( Response::HTTP_FOUND, $response->getStatusCode() );
367
-		$this->assertTrue( $response->isRedirect() );
368
-		$this->assertContains( 'amount=1234', $response->headers->get( 'Location' ) );
369
-		$this->assertContains( 'thatother.paymentprovider.com', $response->headers->get( 'Location' ) );
366
+		$this->assertSame(Response::HTTP_FOUND, $response->getStatusCode());
367
+		$this->assertTrue($response->isRedirect());
368
+		$this->assertContains('amount=1234', $response->headers->get('Location'));
369
+		$this->assertContains('thatother.paymentprovider.com', $response->headers->get('Location'));
370 370
 	}
371 371
 
372 372
 	public function testValidSofortInput_savesDonationAndRedirectsTo3rdPartyPage(): void {
373
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ): void {
373
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory): void {
374 374
 			$response = new SofortResponse();
375
-			$response->setPaymentUrl( 'https://bankingpin.please' );
375
+			$response->setPaymentUrl('https://bankingpin.please');
376 376
 
377
-			$sofortClient = $this->createMock( SofortClient::class );
377
+			$sofortClient = $this->createMock(SofortClient::class);
378 378
 			$sofortClient
379
-				->method( 'get' )
380
-				->willReturn( $response );
381
-			$factory->setSofortClient( $sofortClient );
379
+				->method('get')
380
+				->willReturn($response);
381
+			$factory->setSofortClient($sofortClient);
382 382
 
383 383
 
384
-			$client->followRedirects( false );
384
+			$client->followRedirects(false);
385 385
 			$client->request(
386 386
 				'POST',
387 387
 				'/donation/add',
388 388
 				$this->newValidSofortInput()
389 389
 			);
390 390
 
391
-			$donation = $this->getDonationFromDatabase( $factory );
391
+			$donation = $this->getDonationFromDatabase($factory);
392 392
 
393
-			$this->assertSame( 'Z', $donation->getStatus() );
394
-			$this->assertRegExp( '/W-Q-[A-Z]{6}-[A-Z]/', $donation->getBankTransferCode() );
393
+			$this->assertSame('Z', $donation->getStatus());
394
+			$this->assertRegExp('/W-Q-[A-Z]{6}-[A-Z]/', $donation->getBankTransferCode());
395 395
 
396
-			$this->assertTrue( $client->getResponse()->isRedirect( 'https://bankingpin.please' ) );
396
+			$this->assertTrue($client->getResponse()->isRedirect('https://bankingpin.please'));
397 397
 		} );
398 398
 	}
399 399
 
@@ -425,23 +425,23 @@  discard block
 block discarded – undo
425 425
 
426 426
 		$response = $client->getResponse()->getContent();
427 427
 
428
-		$this->assertContains( 'Amount: 0,00', $response );
429
-		$this->assertContains( 'Payment type: BEZ', $response );
430
-		$this->assertContains( 'Interval: 3', $response );
431
-		$this->assertContains( 'IBAN: DE12500105170648489890', $response );
432
-		$this->assertContains( 'BIC: INGDDEFFXXX', $response );
433
-		$this->assertContains( 'Bank name: ING-DiBa', $response );
434
-		$this->assertContains( 'Address type: person', $response );
435
-		$this->assertContains( 'Salutation: Frau', $response );
436
-		$this->assertContains( 'Title: Prof. Dr.', $response );
437
-		$this->assertContains( 'Company: ', $response );
438
-		$this->assertContains( 'First name: Karla', $response );
439
-		$this->assertContains( 'Last name: Kennichnich', $response );
440
-		$this->assertContains( 'Street: Lehmgasse 12', $response );
441
-		$this->assertContains( 'Postal code: 12345', $response );
442
-		$this->assertContains( 'City: Einort', $response );
443
-		$this->assertContains( 'Country code: DE', $response );
444
-		$this->assertContains( 'Email address: [email protected]', $response );
428
+		$this->assertContains('Amount: 0,00', $response);
429
+		$this->assertContains('Payment type: BEZ', $response);
430
+		$this->assertContains('Interval: 3', $response);
431
+		$this->assertContains('IBAN: DE12500105170648489890', $response);
432
+		$this->assertContains('BIC: INGDDEFFXXX', $response);
433
+		$this->assertContains('Bank name: ING-DiBa', $response);
434
+		$this->assertContains('Address type: person', $response);
435
+		$this->assertContains('Salutation: Frau', $response);
436
+		$this->assertContains('Title: Prof. Dr.', $response);
437
+		$this->assertContains('Company: ', $response);
438
+		$this->assertContains('First name: Karla', $response);
439
+		$this->assertContains('Last name: Kennichnich', $response);
440
+		$this->assertContains('Street: Lehmgasse 12', $response);
441
+		$this->assertContains('Postal code: 12345', $response);
442
+		$this->assertContains('City: Einort', $response);
443
+		$this->assertContains('Country code: DE', $response);
444
+		$this->assertContains('Email address: [email protected]', $response);
445 445
 	}
446 446
 
447 447
 	public function testGivenInvalidRequest_formStillContainsBannerTrackingData(): void {
@@ -457,8 +457,8 @@  discard block
 block discarded – undo
457 457
 
458 458
 		$response = $client->getResponse()->getContent();
459 459
 
460
-		$this->assertContains( 'Impression Count: 12', $response );
461
-		$this->assertContains( 'Banner Impression Count: 3', $response );
460
+		$this->assertContains('Impression Count: 12', $response);
461
+		$this->assertContains('Banner Impression Count: 3', $response);
462 462
 	}
463 463
 
464 464
 	public function testGivenNegativeDonationAmount_formIsReloadedAndPrefilledWithZero(): void {
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
 
476 476
 		$response = $client->getResponse()->getContent();
477 477
 
478
-		$this->assertContains( 'Amount: 0,00', $response );
478
+		$this->assertContains('Amount: 0,00', $response);
479 479
 	}
480 480
 
481 481
 	private function newInvalidFormInput(): array {
@@ -520,10 +520,10 @@  discard block
 block discarded – undo
520 520
 
521 521
 		$response = $client->getResponse()->getContent();
522 522
 
523
-		$this->assertContains( 'Amount: 0', $response );
524
-		$this->assertContains( 'Payment type: UEB', $response );
525
-		$this->assertContains( 'Interval: 1', $response );
526
-		$this->assertContains( 'Value of field "amount" violates rule: Amount too low', $response );
523
+		$this->assertContains('Amount: 0', $response);
524
+		$this->assertContains('Payment type: UEB', $response);
525
+		$this->assertContains('Interval: 1', $response);
526
+		$this->assertContains('Value of field "amount" violates rule: Amount too low', $response);
527 527
 	}
528 528
 
529 529
 	private function newAnonymousFormInput(): array {
@@ -536,11 +536,11 @@  discard block
 block discarded – undo
536 536
 	}
537 537
 
538 538
 	public function testGivenValidRequest_tokensAreReturned(): void {
539
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ): void {
540
-			$factory->setTokenGenerator( new FixedTokenGenerator( self::SOME_TOKEN ) );
539
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory): void {
540
+			$factory->setTokenGenerator(new FixedTokenGenerator(self::SOME_TOKEN));
541 541
 
542
-			$client->setServerParameter( 'HTTP_REFERER', 'https://en.wikipedia.org/wiki/Karla_Kennichnich' );
543
-			$client->followRedirects( false );
542
+			$client->setServerParameter('HTTP_REFERER', 'https://en.wikipedia.org/wiki/Karla_Kennichnich');
543
+			$client->followRedirects(false);
544 544
 
545 545
 			$client->request(
546 546
 				'POST',
@@ -550,14 +550,14 @@  discard block
 block discarded – undo
550 550
 
551 551
 			$response = $client->getResponse()->getContent();
552 552
 
553
-			$this->assertContains( self::SOME_TOKEN, $response );
553
+			$this->assertContains(self::SOME_TOKEN, $response);
554 554
 		} );
555 555
 	}
556 556
 
557 557
 	public function testGivenValidRequest_clientIsRedirected(): void {
558
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ): void {
559
-			$factory->setTokenGenerator( new FixedTokenGenerator( self::SOME_TOKEN ) );
560
-			$client->followRedirects( false );
558
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory): void {
559
+			$factory->setTokenGenerator(new FixedTokenGenerator(self::SOME_TOKEN));
560
+			$client->followRedirects(false);
561 561
 
562 562
 			$client->request(
563 563
 				'POST',
@@ -565,13 +565,13 @@  discard block
 block discarded – undo
565 565
 				$this->newValidFormInput()
566 566
 			);
567 567
 
568
-			$this->assertTrue( $client->getResponse()->isRedirect() );
568
+			$this->assertTrue($client->getResponse()->isRedirect());
569 569
 		} );
570 570
 	}
571 571
 
572 572
 	public function testWhenTrackingCookieExists_valueIsPersisted(): void {
573
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ): void {
574
-			$client->getCookieJar()->set( new Cookie( 'spenden_tracking', 'test/blue' ) );
573
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory): void {
574
+			$client->getCookieJar()->set(new Cookie('spenden_tracking', 'test/blue'));
575 575
 
576 576
 			$client->request(
577 577
 				'POST',
@@ -579,15 +579,15 @@  discard block
 block discarded – undo
579 579
 				$this->newComplementableFormInput()
580 580
 			);
581 581
 
582
-			$donation = $this->getDonationFromDatabase( $factory );
582
+			$donation = $this->getDonationFromDatabase($factory);
583 583
 			$data = $donation->getDecodedData();
584 584
 
585
-			$this->assertSame( 'test/blue', $data['tracking'] );
585
+			$this->assertSame('test/blue', $data['tracking']);
586 586
 		} );
587 587
 	}
588 588
 
589 589
 	public function testWhenTrackableInputDataIsSubmitted_theyAreStoredInSession(): void {
590
-		$this->createAppEnvironment( [], function ( Client $client, FunFunFactory $factory, Application $app ): void {
590
+		$this->createAppEnvironment([], function(Client $client, FunFunFactory $factory, Application $app): void {
591 591
 
592 592
 			$client->request(
593 593
 				'GET',
@@ -599,15 +599,15 @@  discard block
 block discarded – undo
599 599
 				]
600 600
 			);
601 601
 
602
-			$piwikTracking = $app['session']->get( 'piwikTracking' );
603
-			$this->assertSame( 'BEZ', $piwikTracking['paymentType'] );
604
-			$this->assertSame( 3, $piwikTracking['paymentInterval'] );
605
-			$this->assertSame( '5,00', $piwikTracking['paymentAmount'] );
602
+			$piwikTracking = $app['session']->get('piwikTracking');
603
+			$this->assertSame('BEZ', $piwikTracking['paymentType']);
604
+			$this->assertSame(3, $piwikTracking['paymentInterval']);
605
+			$this->assertSame('5,00', $piwikTracking['paymentAmount']);
606 606
 		} );
607 607
 	}
608 608
 
609 609
 	public function testWhenTolstojNovelIsPassed_isIsNotStoredInSession(): void {
610
-		$this->createAppEnvironment( [], function ( Client $client, FunFunFactory $factory, Application $app ): void {
610
+		$this->createAppEnvironment([], function(Client $client, FunFunFactory $factory, Application $app): void {
611 611
 
612 612
 			$client->request(
613 613
 				'GET',
@@ -625,15 +625,15 @@  discard block
 block discarded – undo
625 625
 				]
626 626
 			);
627 627
 
628
-			$piwikTracking = $app['session']->get( 'piwikTracking' );
629
-			$this->assertArrayNotHasKey( 'paymentType', $piwikTracking );
630
-			$this->assertSame( 3, $piwikTracking['paymentInterval'] );
631
-			$this->assertSame( '5,00', $piwikTracking['paymentAmount'] );
628
+			$piwikTracking = $app['session']->get('piwikTracking');
629
+			$this->assertArrayNotHasKey('paymentType', $piwikTracking);
630
+			$this->assertSame(3, $piwikTracking['paymentInterval']);
631
+			$this->assertSame('5,00', $piwikTracking['paymentAmount']);
632 632
 		} );
633 633
 	}
634 634
 
635 635
 	public function testWhenParameterIsOmitted_itIsNotStoredInSession(): void {
636
-		$this->createAppEnvironment( [], function ( Client $client, FunFunFactory $factory, Application $app ): void {
636
+		$this->createAppEnvironment([], function(Client $client, FunFunFactory $factory, Application $app): void {
637 637
 
638 638
 			$client->request(
639 639
 				'GET',
@@ -644,15 +644,15 @@  discard block
 block discarded – undo
644 644
 				]
645 645
 			);
646 646
 
647
-			$piwikTracking = $app['session']->get( 'piwikTracking' );
648
-			$this->assertSame( 'BEZ', $piwikTracking['paymentType'] );
649
-			$this->assertSame( '5,00', $piwikTracking['paymentAmount'] );
650
-			$this->assertArrayNotHasKey( 'paymentInterval', $piwikTracking );
647
+			$piwikTracking = $app['session']->get('piwikTracking');
648
+			$this->assertSame('BEZ', $piwikTracking['paymentType']);
649
+			$this->assertSame('5,00', $piwikTracking['paymentAmount']);
650
+			$this->assertArrayNotHasKey('paymentInterval', $piwikTracking);
651 651
 		} );
652 652
 	}
653 653
 
654 654
 	public function testWhenInitiallyIntendedPaymentOptionsDifferFromActual_itIsReflectedInPiwikTrackingEvents(): void {
655
-		$client = $this->createClient( [] );
655
+		$client = $this->createClient([]);
656 656
 		$client->request(
657 657
 			'GET',
658 658
 			'/',
@@ -676,21 +676,21 @@  discard block
 block discarded – undo
676 676
 		$client->followRedirect();
677 677
 
678 678
 		$responseContent = $client->getResponse()->getContent();
679
-		$this->assertContains( 'BEZ/UEB', $responseContent );
680
-		$this->assertContains( '5.00/12.34', $responseContent );
681
-		$this->assertContains( '12/0', $responseContent );
679
+		$this->assertContains('BEZ/UEB', $responseContent);
680
+		$this->assertContains('5.00/12.34', $responseContent);
681
+		$this->assertContains('12/0', $responseContent);
682 682
 	}
683 683
 
684 684
 	public function testWhenMobileTrackingIsRequested_piwikTrackerIsCalledForPaypalPayment(): void {
685
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ): void {
685
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory): void {
686 686
 			$factory->setNullMessenger();
687
-			$client->followRedirects( false );
687
+			$client->followRedirects(false);
688 688
 
689
-			$tracker = $this->getMockBuilder( PageViewTracker::class )->disableOriginalConstructor()->getMock();
690
-			$tracker->expects( $this->once() )
691
-				->method( 'trackPaypalRedirection' )
692
-				->with( 'test', 'gelb', '10.1.2.3' );
693
-			$factory->setPageViewTracker( $tracker );
689
+			$tracker = $this->getMockBuilder(PageViewTracker::class)->disableOriginalConstructor()->getMock();
690
+			$tracker->expects($this->once())
691
+				->method('trackPaypalRedirection')
692
+				->with('test', 'gelb', '10.1.2.3');
693
+			$factory->setPageViewTracker($tracker);
694 694
 
695 695
 			$client->request(
696 696
 				'POST',
@@ -717,14 +717,14 @@  discard block
 block discarded – undo
717 717
 	}
718 718
 
719 719
 	public function testWhenMobileTrackingIsRequested_piwikTrackerIsNotCalledForNonPaypalPayment(): void {
720
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ): void {
720
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory): void {
721 721
 			$factory->setNullMessenger();
722
-			$client->followRedirects( false );
722
+			$client->followRedirects(false);
723 723
 
724
-			$tracker = $this->getMockBuilder( PageViewTracker::class )->disableOriginalConstructor()->getMock();
725
-			$tracker->expects( $this->never() )
726
-				->method( 'trackPaypalRedirection' );
727
-			$factory->setPageViewTracker( $tracker );
724
+			$tracker = $this->getMockBuilder(PageViewTracker::class)->disableOriginalConstructor()->getMock();
725
+			$tracker->expects($this->never())
726
+				->method('trackPaypalRedirection');
727
+			$factory->setPageViewTracker($tracker);
728 728
 
729 729
 			$client->request(
730 730
 				'POST',
@@ -740,10 +740,10 @@  discard block
 block discarded – undo
740 740
 	}
741 741
 
742 742
 	public function testGivenCommasInStreetInput_donationGetsPersisted(): void {
743
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ): void {
743
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory): void {
744 744
 
745
-			$client->setServerParameter( 'HTTP_REFERER', 'https://en.wikipedia.org/wiki/Karla_Kennichnich' );
746
-			$client->followRedirects( false );
745
+			$client->setServerParameter('HTTP_REFERER', 'https://en.wikipedia.org/wiki/Karla_Kennichnich');
746
+			$client->followRedirects(false);
747 747
 
748 748
 			$formInput = $this->newValidFormInput();
749 749
 			$formInput['street'] = ',Lehmgasse, 12,';
@@ -754,12 +754,12 @@  discard block
 block discarded – undo
754 754
 				$formInput
755 755
 			);
756 756
 
757
-			$this->assertIsExpectedDonation( $this->getDonationFromDatabase( $factory ) );
757
+			$this->assertIsExpectedDonation($this->getDonationFromDatabase($factory));
758 758
 		} );
759 759
 	}
760 760
 
761 761
 	public function testGivenSufficientForeignBankData_donationGetsPersisted(): void {
762
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ): void {
762
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory): void {
763 763
 			$formInput = $this->newValidFormInput();
764 764
 			$formInput['iban'] = 'AT022050302101023600';
765 765
 			$formInput['bic'] = 'SPIHAT22XXX';
@@ -772,23 +772,23 @@  discard block
 block discarded – undo
772 772
 				$formInput
773 773
 			);
774 774
 
775
-			$donation = $this->getDonationFromDatabase( $factory );
775
+			$donation = $this->getDonationFromDatabase($factory);
776 776
 			$data = $donation->getDecodedData();
777 777
 
778
-			$this->assertSame( 'AT022050302101023600', $data['iban'] );
779
-			$this->assertSame( 'SPIHAT22XXX', $data['bic'] );
780
-			$this->assertSame( '', $data['konto'] );
781
-			$this->assertSame( '', $data['blz'] );
782
-			$this->assertSame( '', $data['bankname'] );
778
+			$this->assertSame('AT022050302101023600', $data['iban']);
779
+			$this->assertSame('SPIHAT22XXX', $data['bic']);
780
+			$this->assertSame('', $data['konto']);
781
+			$this->assertSame('', $data['blz']);
782
+			$this->assertSame('', $data['bankname']);
783 783
 		} );
784 784
 	}
785 785
 
786 786
 	public function testCookieFlagsSecureAndHttpOnlyAreSet(): void {
787 787
 		$client = new Client(
788 788
 			$this->createSilexApplication(),
789
-			[ 'HTTPS' => true ]
789
+			['HTTPS' => true]
790 790
 		);
791
-		$client->followRedirects( true );
791
+		$client->followRedirects(true);
792 792
 
793 793
 		$client->request(
794 794
 			'POST',
@@ -797,47 +797,47 @@  discard block
 block discarded – undo
797 797
 		);
798 798
 
799 799
 		$cookieJar = $client->getCookieJar();
800
-		$cookieJar->updateFromResponse( $client->getInternalResponse() );
801
-		$cookie = $cookieJar->get( ShowDonationConfirmationHandler::SUBMISSION_COOKIE_NAME );
802
-		$this->assertTrue( $cookie->isSecure() );
803
-		$this->assertTrue( $cookie->isHttpOnly() );
800
+		$cookieJar->updateFromResponse($client->getInternalResponse());
801
+		$cookie = $cookieJar->get(ShowDonationConfirmationHandler::SUBMISSION_COOKIE_NAME);
802
+		$this->assertTrue($cookie->isSecure());
803
+		$this->assertTrue($cookie->isHttpOnly());
804 804
 	}
805 805
 
806 806
 	public function testAllPaymentTypesAreOffered(): void {
807
-		$client = $this->createClient( [ 'skin' => [ 'default' => '10h16' ] ] );
807
+		$client = $this->createClient(['skin' => ['default' => '10h16']]);
808 808
 		$client->request(
809 809
 			'GET',
810 810
 			'/donation/new'
811 811
 		);
812 812
 		$crawler = $client->getCrawler();
813 813
 
814
-		$this->assertSame( 1, $crawler->filter( '#donation-payment input[name="zahlweise"][value="BEZ"]' )->count() );
815
-		$this->assertSame( 1, $crawler->filter( '#donation-payment input[name="zahlweise"][value="UEB"]' )->count() );
816
-		$this->assertSame( 1, $crawler->filter( '#donation-payment input[name="zahlweise"][value="MCP"]' )->count() );
817
-		$this->assertSame( 1, $crawler->filter( '#donation-payment input[name="zahlweise"][value="PPL"]' )->count() );
818
-		$this->assertSame( 1, $crawler->filter( '#donation-payment input[name="zahlweise"][value="SUB"]' )->count() );
814
+		$this->assertSame(1, $crawler->filter('#donation-payment input[name="zahlweise"][value="BEZ"]')->count());
815
+		$this->assertSame(1, $crawler->filter('#donation-payment input[name="zahlweise"][value="UEB"]')->count());
816
+		$this->assertSame(1, $crawler->filter('#donation-payment input[name="zahlweise"][value="MCP"]')->count());
817
+		$this->assertSame(1, $crawler->filter('#donation-payment input[name="zahlweise"][value="PPL"]')->count());
818
+		$this->assertSame(1, $crawler->filter('#donation-payment input[name="zahlweise"][value="SUB"]')->count());
819 819
 	}
820 820
 
821 821
 	public function testSofortPaymentTypeCanByDisabledViaQuery(): void {
822
-		$client = $this->createClient( [ 'skin' => [ 'default' => '10h16' ] ] );
822
+		$client = $this->createClient(['skin' => ['default' => '10h16']]);
823 823
 		$client->request(
824 824
 			'GET',
825 825
 			'/donation/new',
826
-			[ 'pmt' => '0' ]
826
+			['pmt' => '0']
827 827
 		);
828 828
 		$crawler = $client->getCrawler();
829 829
 
830
-		$this->assertSame( 0, $crawler->filter( '#donation-payment input[name="zahlweise"][value="SUB"]' )->count() );
830
+		$this->assertSame(0, $crawler->filter('#donation-payment input[name="zahlweise"][value="SUB"]')->count());
831 831
 	}
832 832
 
833 833
 	public function testDonationReceiptOptOut_persistedInDonation(): void {
834
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ): void {
834
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory): void {
835 835
 			$parameters = $this->newValidFormInput();
836 836
 			$parameters['donationReceipt'] = '0';
837 837
 
838
-			$client->request( Request::METHOD_POST, self::ADD_DONATION_PATH, $parameters );
838
+			$client->request(Request::METHOD_POST, self::ADD_DONATION_PATH, $parameters);
839 839
 
840
-			$this->assertFalse( $this->getDonationFromDatabase( $factory )->getDonationReceipt() );
840
+			$this->assertFalse($this->getDonationFromDatabase($factory)->getDonationReceipt());
841 841
 		} );
842 842
 	}
843 843
 }
Please login to merge, or discard this patch.