Completed
Pull Request — master (#956)
by Jeroen De
103:25 queued 38:26
created
tests/EdgeToEdge/WebRouteTestCase.php 1 patch
Spacing   +50 added lines, -50 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;
6 6
 
@@ -32,16 +32,16 @@  discard block
 block discarded – undo
32 32
 	 *
33 33
 	 * @return Client
34 34
 	 */
35
-	protected function createClient( array $config = [], callable $onEnvironmentCreated = null, bool $debug = true,
36
-								  array $serverConfig = [] ): Client {
37
-		$testEnvironment = TestEnvironment::newInstance( $config );
35
+	protected function createClient(array $config = [], callable $onEnvironmentCreated = null, bool $debug = true,
36
+								  array $serverConfig = []): Client {
37
+		$testEnvironment = TestEnvironment::newInstance($config);
38 38
 
39
-		if ( is_callable( $onEnvironmentCreated ) ) {
40
-			call_user_func( $onEnvironmentCreated, $testEnvironment->getFactory(), $testEnvironment->getConfig() );
39
+		if (is_callable($onEnvironmentCreated)) {
40
+			call_user_func($onEnvironmentCreated, $testEnvironment->getFactory(), $testEnvironment->getConfig());
41 41
 		}
42 42
 
43 43
 		return new Client(
44
-			$this->createApplication( $testEnvironment->getFactory(), $debug ),
44
+			$this->createApplication($testEnvironment->getFactory(), $debug),
45 45
 			$serverConfig
46 46
 		);
47 47
 	}
@@ -57,11 +57,11 @@  discard block
 block discarded – undo
57 57
 	 * @param array $config
58 58
 	 * @param callable $onEnvironmentCreated
59 59
 	 */
60
-	protected function createEnvironment( array $config, callable $onEnvironmentCreated ): void {
61
-		$testEnvironment = TestEnvironment::newInstance( $config );
60
+	protected function createEnvironment(array $config, callable $onEnvironmentCreated): void {
61
+		$testEnvironment = TestEnvironment::newInstance($config);
62 62
 
63 63
 		$client = new Client(
64
-			$this->createApplication( $testEnvironment->getFactory(), self::ENABLE_DEBUG )
64
+			$this->createApplication($testEnvironment->getFactory(), self::ENABLE_DEBUG)
65 65
 		);
66 66
 
67 67
 		call_user_func(
@@ -83,11 +83,11 @@  discard block
 block discarded – undo
83 83
 	 * @param array $config
84 84
 	 * @param callable $onEnvironmentCreated
85 85
 	 */
86
-	protected function createAppEnvironment( array $config, callable $onEnvironmentCreated ): void {
87
-		$testEnvironment = TestEnvironment::newInstance( $config );
86
+	protected function createAppEnvironment(array $config, callable $onEnvironmentCreated): void {
87
+		$testEnvironment = TestEnvironment::newInstance($config);
88 88
 
89
-		$application = $this->createApplication( $testEnvironment->getFactory(), self::ENABLE_DEBUG );
90
-		$client = new Client( $application );
89
+		$application = $this->createApplication($testEnvironment->getFactory(), self::ENABLE_DEBUG);
90
+		$client = new Client($application);
91 91
 
92 92
 		call_user_func(
93 93
 			$onEnvironmentCreated,
@@ -98,84 +98,84 @@  discard block
 block discarded – undo
98 98
 	}
99 99
 
100 100
 	// @codingStandardsIgnoreStart
101
-	private function createApplication( FunFunFactory $ffFactory, bool $debug ): Application {
101
+	private function createApplication(FunFunFactory $ffFactory, bool $debug): Application {
102 102
 		// @codingStandardsIgnoreEnd
103 103
 		$app = require __DIR__ . ' /../../app/bootstrap.php';
104 104
 
105
-		if ( $debug ) {
105
+		if ($debug) {
106 106
 			$app['debug'] = true;
107 107
 			$app['session.test'] = true;
108
-			unset( $app['exception_handler'] );
108
+			unset($app['exception_handler']);
109 109
 		}
110 110
 
111
-		$ffFactory->setSkinTwigEnvironment( $app['twig'] );
111
+		$ffFactory->setSkinTwigEnvironment($app['twig']);
112 112
 
113 113
 		return $app;
114 114
 	}
115 115
 
116 116
 	protected function createSilexApplication(): Application {
117
-		$testEnvironment = TestEnvironment::newInstance( [] );
117
+		$testEnvironment = TestEnvironment::newInstance([]);
118 118
 
119
-		return $this->createApplication( $testEnvironment->getFactory(), self::ENABLE_DEBUG );
119
+		return $this->createApplication($testEnvironment->getFactory(), self::ENABLE_DEBUG);
120 120
 	}
121 121
 
122
-	protected function assert404( Response $response ): void {
123
-		$this->assertSame( 404, $response->getStatusCode() );
122
+	protected function assert404(Response $response): void {
123
+		$this->assertSame(404, $response->getStatusCode());
124 124
 	}
125 125
 
126
-	protected function assertJsonResponse( array $expected, Response $response ): void {
126
+	protected function assertJsonResponse(array $expected, Response $response): void {
127 127
 		$this->assertSame(
128
-			json_encode( $expected, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ),
128
+			json_encode($expected, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES),
129 129
 			$response->getContent()
130 130
 		);
131 131
 	}
132 132
 
133
-	protected function assertJsonSuccessResponse( array $expected, Response $response ): void {
134
-		$this->assertTrue( $response->isSuccessful(), 'request is successful' );
135
-		$this->assertJson( $response->getContent(), 'response is json' );
136
-		$this->assertJsonResponse( $expected, $response );
133
+	protected function assertJsonSuccessResponse(array $expected, Response $response): void {
134
+		$this->assertTrue($response->isSuccessful(), 'request is successful');
135
+		$this->assertJson($response->getContent(), 'response is json');
136
+		$this->assertJsonResponse($expected, $response);
137 137
 	}
138 138
 
139
-	protected function assertGetRequestCausesMethodNotAllowedResponse( string $route, array $params ): void {
139
+	protected function assertGetRequestCausesMethodNotAllowedResponse(string $route, array $params): void {
140 140
 		$client = $this->createClient();
141 141
 
142
-		$this->expectException( MethodNotAllowedHttpException::class );
143
-		$client->request( 'GET', $route, $params );
142
+		$this->expectException(MethodNotAllowedHttpException::class);
143
+		$client->request('GET', $route, $params);
144 144
 	}
145 145
 
146
-	protected function assertErrorJsonResponse( Response $response ): void {
147
-		$responseData = $this->getJsonFromResponse( $response );
148
-		$this->assertArrayHasKey( 'status', $responseData );
149
-		$this->assertEquals( $responseData['status'], 'ERR' );
146
+	protected function assertErrorJsonResponse(Response $response): void {
147
+		$responseData = $this->getJsonFromResponse($response);
148
+		$this->assertArrayHasKey('status', $responseData);
149
+		$this->assertEquals($responseData['status'], 'ERR');
150 150
 		$this->assertThat(
151 151
 			$responseData,
152 152
 			$this->logicalOr(
153
-				$this->arrayHasKey( 'message' ),
154
-				$this->arrayHasKey( 'messages' )
153
+				$this->arrayHasKey('message'),
154
+				$this->arrayHasKey('messages')
155 155
 			)
156 156
 		);
157 157
 	}
158 158
 
159
-	protected function getJsonFromResponse( Response $response ): array {
160
-		$this->assertJson( $response->getContent(), 'response is json' );
161
-		return json_decode( $response->getContent(), true );
159
+	protected function getJsonFromResponse(Response $response): array {
160
+		$this->assertJson($response->getContent(), 'response is json');
161
+		return json_decode($response->getContent(), true);
162 162
 	}
163 163
 
164
-	protected function assertSuccessJsonResponse( Response $response ): void {
165
-		$responseData = $this->getJsonFromResponse( $response );
166
-		$this->assertArrayHasKey( 'status', $responseData );
167
-		$this->assertEquals( $responseData['status'], 'OK' );
168
-		$this->assertArrayHasKey( 'message', $responseData );
164
+	protected function assertSuccessJsonResponse(Response $response): void {
165
+		$responseData = $this->getJsonFromResponse($response);
166
+		$this->assertArrayHasKey('status', $responseData);
167
+		$this->assertEquals($responseData['status'], 'OK');
168
+		$this->assertArrayHasKey('message', $responseData);
169 169
 	}
170 170
 
171
-	protected function assertInitialFormValues( array $expected, Client $client ): void {
172
-		$initialFormValues = $client->getCrawler()->filter( 'script[data-initial-form-values]' );
171
+	protected function assertInitialFormValues(array $expected, Client $client): void {
172
+		$initialFormValues = $client->getCrawler()->filter('script[data-initial-form-values]');
173 173
 		$this->assertGreaterThan(
174 174
 			0,
175 175
 			$initialFormValues->count()
176 176
 		);
177
-		$json = $initialFormValues->attr( 'data-initial-form-values' );
178
-		$data = json_decode( $json, true );
179
-		$this->assertEquals( $expected, $data );
177
+		$json = $initialFormValues->attr('data-initial-form-values');
178
+		$data = json_decode($json, true);
179
+		$this->assertEquals($expected, $data);
180 180
 	}
181 181
 }
Please login to merge, or discard this patch.
tests/EdgeToEdge/Routes/AddDonationRouteTest.php 1 patch
Spacing   +209 added lines, -209 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
 
@@ -28,10 +28,10 @@  discard block
 block discarded – undo
28 28
 	const SOME_TOKEN = 'SomeToken';
29 29
 
30 30
 	public function testGivenValidRequest_donationGetsPersisted(): void {
31
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ) {
31
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory) {
32 32
 
33
-			$client->setServerParameter( 'HTTP_REFERER', 'https://en.wikipedia.org/wiki/Karla_Kennichnich' );
34
-			$client->followRedirects( false );
33
+			$client->setServerParameter('HTTP_REFERER', 'https://en.wikipedia.org/wiki/Karla_Kennichnich');
34
+			$client->followRedirects(false);
35 35
 
36 36
 			$client->request(
37 37
 				'POST',
@@ -39,28 +39,28 @@  discard block
 block discarded – undo
39 39
 				$this->newValidFormInput()
40 40
 			);
41 41
 
42
-			$this->assertIsExpectedDonation( $this->getDonationFromDatabase( $factory ) );
42
+			$this->assertIsExpectedDonation($this->getDonationFromDatabase($factory));
43 43
 		} );
44 44
 	}
45 45
 
46 46
 	public function testWhenDonationGetsPersisted_timestampIsStoredInCookie(): void {
47 47
 		$client = $this->createClient();
48
-		$client->followRedirects( true );
48
+		$client->followRedirects(true);
49 49
 		$client->request(
50 50
 			'POST',
51 51
 			'/donation/add',
52 52
 			$this->newValidFormInput()
53 53
 		);
54 54
 
55
-		$cookie = $client->getCookieJar()->get( 'donation_timestamp' );
56
-		$this->assertNotNull( $cookie );
57
-		$donationTimestamp = new \DateTime( $cookie->getValue() );
58
-		$this->assertEquals( time(), $donationTimestamp->getTimestamp(), 'Timestamp should be not more than 5 seconds old', 5.0 );
55
+		$cookie = $client->getCookieJar()->get('donation_timestamp');
56
+		$this->assertNotNull($cookie);
57
+		$donationTimestamp = new \DateTime($cookie->getValue());
58
+		$this->assertEquals(time(), $donationTimestamp->getTimestamp(), 'Timestamp should be not more than 5 seconds old', 5.0);
59 59
 	}
60 60
 
61 61
 	public function testWhenMultipleDonationFormSubmissions_requestGetsRejected(): void {
62 62
 		$client = $this->createClient();
63
-		$client->getCookieJar()->set( new Cookie( 'donation_timestamp', $this->getPastTimestamp() ) );
63
+		$client->getCookieJar()->set(new Cookie('donation_timestamp', $this->getPastTimestamp()));
64 64
 
65 65
 		$client->request(
66 66
 			'POST',
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 			$this->newValidFormInput()
69 69
 		);
70 70
 
71
-		$this->assertContains( 'donation_rejected_limit', $client->getResponse()->getContent() );
71
+		$this->assertContains('donation_rejected_limit', $client->getResponse()->getContent());
72 72
 	}
73 73
 
74 74
 	public function testWhenMultipleDonationsInAccordanceToTimeLimit_requestIsNotRejected(): void {
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 		$client->getCookieJar()->set(
77 77
 			new Cookie(
78 78
 				'donation_timestamp',
79
-				$this->getPastTimestamp( 'PT35M' )
79
+				$this->getPastTimestamp('PT35M')
80 80
 			)
81 81
 		);
82 82
 
@@ -86,11 +86,11 @@  discard block
 block discarded – undo
86 86
 			$this->newValidFormInput()
87 87
 		);
88 88
 
89
-		$this->assertNotContains( 'donation_rejected_limit', $client->getResponse()->getContent() );
89
+		$this->assertNotContains('donation_rejected_limit', $client->getResponse()->getContent());
90 90
 	}
91 91
 
92
-	private function getPastTimestamp( string $interval = 'PT10S' ): string {
93
-		return ( new \DateTime() )->sub( new \DateInterval( $interval ) )->format( 'Y-m-d H:i:s' );
92
+	private function getPastTimestamp(string $interval = 'PT10S'): string {
93
+		return (new \DateTime())->sub(new \DateInterval($interval))->format('Y-m-d H:i:s');
94 94
 	}
95 95
 
96 96
 	private function newValidFormInput(): array {
@@ -125,39 +125,39 @@  discard block
 block discarded – undo
125 125
 		];
126 126
 	}
127 127
 
128
-	private function assertIsExpectedDonation( Donation $donation ): void {
128
+	private function assertIsExpectedDonation(Donation $donation): void {
129 129
 		$data = $donation->getDecodedData();
130
-		$this->assertSame( '5.51', $donation->getAmount() );
131
-		$this->assertSame( 'BEZ', $donation->getPaymentType() );
132
-		$this->assertSame( 0, $donation->getPaymentIntervalInMonths() );
133
-		$this->assertSame( 'DE12500105170648489890', $data['iban'] );
134
-		$this->assertSame( 'INGDDEFFXXX', $data['bic'] );
135
-		$this->assertSame( '0648489890', $data['konto'] );
136
-		$this->assertSame( '50010517', $data['blz'] );
137
-		$this->assertSame( 'ING-DiBa', $data['bankname'] );
138
-		$this->assertSame( 'person', $data['adresstyp'] );
139
-		$this->assertSame( 'Frau', $data['anrede'] );
140
-		$this->assertSame( 'Prof. Dr.', $data['titel'] );
141
-		$this->assertSame( '', $data['firma'] );
142
-		$this->assertSame( 'Karla', $data['vorname'] );
143
-		$this->assertSame( 'Kennichnich', $data['nachname'] );
144
-		$this->assertSame( 'Prof. Dr. Karla Kennichnich', $donation->getDonorFullName() );
145
-		$this->assertSame( 'Lehmgasse 12', $data['strasse'] );
146
-		$this->assertSame( '12345', $data['plz'] );
147
-		$this->assertSame( 'Einort', $data['ort'] );
148
-		$this->assertSame( 'Einort', $donation->getDonorCity() );
149
-		$this->assertSame( 'DE', $data['country'] );
150
-		$this->assertSame( '[email protected]', $data['email'] );
151
-		$this->assertSame( '[email protected]', $donation->getDonorEmail() );
152
-		$this->assertSame( 'test/gelb', $data['tracking'] );
153
-		$this->assertSame( 3, $data['impCount'] );
154
-		$this->assertSame( 1, $data['bImpCount'] );
155
-		$this->assertSame( '', $data['layout'] );
156
-		$this->assertSame( '', $data['color'] );
157
-		$this->assertSame( '', $data['skin'] );
158
-		$this->assertSame( 'en.wikipedia.org', $data['source'] );
159
-		$this->assertSame( 'N', $donation->getStatus() );
160
-		$this->assertTrue( $donation->getDonorOptsIntoNewsletter() );
130
+		$this->assertSame('5.51', $donation->getAmount());
131
+		$this->assertSame('BEZ', $donation->getPaymentType());
132
+		$this->assertSame(0, $donation->getPaymentIntervalInMonths());
133
+		$this->assertSame('DE12500105170648489890', $data['iban']);
134
+		$this->assertSame('INGDDEFFXXX', $data['bic']);
135
+		$this->assertSame('0648489890', $data['konto']);
136
+		$this->assertSame('50010517', $data['blz']);
137
+		$this->assertSame('ING-DiBa', $data['bankname']);
138
+		$this->assertSame('person', $data['adresstyp']);
139
+		$this->assertSame('Frau', $data['anrede']);
140
+		$this->assertSame('Prof. Dr.', $data['titel']);
141
+		$this->assertSame('', $data['firma']);
142
+		$this->assertSame('Karla', $data['vorname']);
143
+		$this->assertSame('Kennichnich', $data['nachname']);
144
+		$this->assertSame('Prof. Dr. Karla Kennichnich', $donation->getDonorFullName());
145
+		$this->assertSame('Lehmgasse 12', $data['strasse']);
146
+		$this->assertSame('12345', $data['plz']);
147
+		$this->assertSame('Einort', $data['ort']);
148
+		$this->assertSame('Einort', $donation->getDonorCity());
149
+		$this->assertSame('DE', $data['country']);
150
+		$this->assertSame('[email protected]', $data['email']);
151
+		$this->assertSame('[email protected]', $donation->getDonorEmail());
152
+		$this->assertSame('test/gelb', $data['tracking']);
153
+		$this->assertSame(3, $data['impCount']);
154
+		$this->assertSame(1, $data['bImpCount']);
155
+		$this->assertSame('', $data['layout']);
156
+		$this->assertSame('', $data['color']);
157
+		$this->assertSame('', $data['skin']);
158
+		$this->assertSame('en.wikipedia.org', $data['source']);
159
+		$this->assertSame('N', $donation->getStatus());
160
+		$this->assertTrue($donation->getDonorOptsIntoNewsletter());
161 161
 	}
162 162
 
163 163
 	public function testGivenValidRequest_confirmationPageContainsEnteredData(): void {
@@ -171,16 +171,16 @@  discard block
 block discarded – undo
171 171
 
172 172
 		$response = $client->getResponse()->getContent();
173 173
 
174
-		$this->assertContains( '5,51 €', $response );
175
-		$this->assertContains( 'donation.interval: 0', $response );
176
-		$this->assertContains( 'DE12500105170648489890', $response );
177
-		$this->assertContains( 'INGDDEFFXXX', $response );
178
-		$this->assertContains( 'ING-DiBa', $response );
179
-		$this->assertContains( 'Prof. Dr. Karla Kennichnich', $response );
180
-		$this->assertContains( 'Lehmgasse 12', $response );
181
-		$this->assertContains( '<span id="confirm-postcode">12345</span> <span id="confirm-city">Einort</span>', $response );
182
-		$this->assertContains( '[email protected]', $response );
183
-		$this->assertContains( 'send-info', $response );
174
+		$this->assertContains('5,51 €', $response);
175
+		$this->assertContains('donation.interval: 0', $response);
176
+		$this->assertContains('DE12500105170648489890', $response);
177
+		$this->assertContains('INGDDEFFXXX', $response);
178
+		$this->assertContains('ING-DiBa', $response);
179
+		$this->assertContains('Prof. Dr. Karla Kennichnich', $response);
180
+		$this->assertContains('Lehmgasse 12', $response);
181
+		$this->assertContains('<span id="confirm-postcode">12345</span> <span id="confirm-city">Einort</span>', $response);
182
+		$this->assertContains('[email protected]', $response);
183
+		$this->assertContains('send-info', $response);
184 184
 	}
185 185
 
186 186
 	public function testGivenValidBankTransferRequest_donationGetsPersisted(): void {
@@ -189,10 +189,10 @@  discard block
 block discarded – undo
189 189
 		 */
190 190
 		$factory = null;
191 191
 
192
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ) {
192
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory) {
193 193
 
194
-			$client->setServerParameter( 'HTTP_REFERER', 'https://en.wikipedia.org/wiki/Karla_Kennichnich' );
195
-			$client->followRedirects( false );
194
+			$client->setServerParameter('HTTP_REFERER', 'https://en.wikipedia.org/wiki/Karla_Kennichnich');
195
+			$client->followRedirects(false);
196 196
 
197 197
 			$client->request(
198 198
 				'POST',
@@ -200,37 +200,37 @@  discard block
 block discarded – undo
200 200
 				$this->newValidBankTransferInput()
201 201
 			);
202 202
 
203
-			$donation = $this->getDonationFromDatabase( $factory );
203
+			$donation = $this->getDonationFromDatabase($factory);
204 204
 
205 205
 			$data = $donation->getDecodedData();
206
-			$this->assertSame( '12.34', $donation->getAmount() );
207
-			$this->assertSame( 'UEB', $donation->getPaymentType() );
208
-			$this->assertSame( 0, $donation->getPaymentIntervalInMonths() );
209
-			$this->assertSame( 'person', $data['adresstyp'] );
210
-			$this->assertSame( 'Frau', $data['anrede'] );
211
-			$this->assertSame( 'Prof. Dr.', $data['titel'] );
212
-			$this->assertSame( '', $data['firma'] );
213
-			$this->assertSame( 'Karla', $data['vorname'] );
214
-			$this->assertSame( 'Kennichnich', $data['nachname'] );
215
-			$this->assertSame( 'Prof. Dr. Karla Kennichnich', $donation->getDonorFullName() );
216
-			$this->assertSame( 'Lehmgasse 12', $data['strasse'] );
217
-			$this->assertSame( '12345', $data['plz'] );
218
-			$this->assertSame( 'Einort', $data['ort'] );
219
-			$this->assertSame( 'Einort', $donation->getDonorCity() );
220
-			$this->assertSame( 'DE', $data['country'] );
221
-			$this->assertSame( '[email protected]', $data['email'] );
222
-			$this->assertSame( '[email protected]', $donation->getDonorEmail() );
223
-			$this->assertSame( 'test/gelb', $data['tracking'] );
224
-			$this->assertSame( 3, $data['impCount'] );
225
-			$this->assertSame( 1, $data['bImpCount'] );
226
-			$this->assertSame( '', $data['layout'] );
227
-			$this->assertSame( '', $data['color'] );
228
-			$this->assertSame( '', $data['skin'] );
229
-			$this->assertSame( 'en.wikipedia.org', $data['source'] );
230
-			$this->assertSame( true, $donation->getDonorOptsIntoNewsletter() );
231
-
232
-			$this->assertSame( 'Z', $donation->getStatus() );
233
-			$this->assertRegExp( '/W-Q-[A-Z]{6}-[A-Z]/', $donation->getBankTransferCode() );
206
+			$this->assertSame('12.34', $donation->getAmount());
207
+			$this->assertSame('UEB', $donation->getPaymentType());
208
+			$this->assertSame(0, $donation->getPaymentIntervalInMonths());
209
+			$this->assertSame('person', $data['adresstyp']);
210
+			$this->assertSame('Frau', $data['anrede']);
211
+			$this->assertSame('Prof. Dr.', $data['titel']);
212
+			$this->assertSame('', $data['firma']);
213
+			$this->assertSame('Karla', $data['vorname']);
214
+			$this->assertSame('Kennichnich', $data['nachname']);
215
+			$this->assertSame('Prof. Dr. Karla Kennichnich', $donation->getDonorFullName());
216
+			$this->assertSame('Lehmgasse 12', $data['strasse']);
217
+			$this->assertSame('12345', $data['plz']);
218
+			$this->assertSame('Einort', $data['ort']);
219
+			$this->assertSame('Einort', $donation->getDonorCity());
220
+			$this->assertSame('DE', $data['country']);
221
+			$this->assertSame('[email protected]', $data['email']);
222
+			$this->assertSame('[email protected]', $donation->getDonorEmail());
223
+			$this->assertSame('test/gelb', $data['tracking']);
224
+			$this->assertSame(3, $data['impCount']);
225
+			$this->assertSame(1, $data['bImpCount']);
226
+			$this->assertSame('', $data['layout']);
227
+			$this->assertSame('', $data['color']);
228
+			$this->assertSame('', $data['skin']);
229
+			$this->assertSame('en.wikipedia.org', $data['source']);
230
+			$this->assertSame(true, $donation->getDonorOptsIntoNewsletter());
231
+
232
+			$this->assertSame('Z', $donation->getStatus());
233
+			$this->assertRegExp('/W-Q-[A-Z]{6}-[A-Z]/', $donation->getBankTransferCode());
234 234
 		} );
235 235
 	}
236 236
 
@@ -262,10 +262,10 @@  discard block
 block discarded – undo
262 262
 	}
263 263
 
264 264
 	public function testGivenComplementableBankData_donationStillGetsPersisted(): void {
265
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ) {
265
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory) {
266 266
 
267
-			$client->setServerParameter( 'HTTP_REFERER', 'https://en.wikipedia.org/wiki/Karla_Kennichnich' );
268
-			$client->followRedirects( false );
267
+			$client->setServerParameter('HTTP_REFERER', 'https://en.wikipedia.org/wiki/Karla_Kennichnich');
268
+			$client->followRedirects(false);
269 269
 
270 270
 			$client->request(
271 271
 				'POST',
@@ -273,14 +273,14 @@  discard block
 block discarded – undo
273 273
 				$this->newComplementableFormInput()
274 274
 			);
275 275
 
276
-			$donation = $this->getDonationFromDatabase( $factory );
276
+			$donation = $this->getDonationFromDatabase($factory);
277 277
 
278 278
 			$data = $donation->getDecodedData();
279
-			$this->assertSame( 'DE12500105170648489890', $data['iban'] );
280
-			$this->assertSame( 'INGDDEFFXXX', $data['bic'] );
281
-			$this->assertSame( '0648489890', $data['konto'] );
282
-			$this->assertSame( '50010517', $data['blz'] );
283
-			$this->assertSame( 'ING-DiBa', $data['bankname'] );
279
+			$this->assertSame('DE12500105170648489890', $data['iban']);
280
+			$this->assertSame('INGDDEFFXXX', $data['bic']);
281
+			$this->assertSame('0648489890', $data['konto']);
282
+			$this->assertSame('50010517', $data['blz']);
283
+			$this->assertSame('ING-DiBa', $data['bankname']);
284 284
 		} );
285 285
 	}
286 286
 
@@ -303,16 +303,16 @@  discard block
 block discarded – undo
303 303
 		];
304 304
 	}
305 305
 
306
-	private function getDonationFromDatabase( FunFunFactory $factory ): Donation {
307
-		$donationRepo = $factory->getEntityManager()->getRepository( Donation::class );
308
-		$donation = $donationRepo->find( 1 );
309
-		$this->assertInstanceOf( Donation::class, $donation );
306
+	private function getDonationFromDatabase(FunFunFactory $factory): Donation {
307
+		$donationRepo = $factory->getEntityManager()->getRepository(Donation::class);
308
+		$donation = $donationRepo->find(1);
309
+		$this->assertInstanceOf(Donation::class, $donation);
310 310
 		return $donation;
311 311
 	}
312 312
 
313 313
 	public function testGivenValidPayPalData_redirectsToPayPal(): void {
314 314
 		$client = $this->createClient();
315
-		$client->followRedirects( false );
315
+		$client->followRedirects(false);
316 316
 
317 317
 		$client->request(
318 318
 			'POST',
@@ -321,13 +321,13 @@  discard block
 block discarded – undo
321 321
 		);
322 322
 
323 323
 		$response = $client->getResponse();
324
-		$this->assertSame( 302, $response->getStatusCode() );
325
-		$this->assertContains( 'sandbox.paypal.com', $response->getContent() );
324
+		$this->assertSame(302, $response->getStatusCode());
325
+		$this->assertContains('sandbox.paypal.com', $response->getContent());
326 326
 	}
327 327
 
328 328
 	public function testWhenRedirectingToPayPal_translatedItemNameIsPassed(): void {
329 329
 		$client = $this->createClient();
330
-		$client->followRedirects( false );
330
+		$client->followRedirects(false);
331 331
 
332 332
 		$client->request(
333 333
 			'POST',
@@ -336,8 +336,8 @@  discard block
 block discarded – undo
336 336
 		);
337 337
 
338 338
 		$response = $client->getResponse();
339
-		$this->assertSame( 302, $response->getStatusCode() );
340
-		$this->assertContains( 'item_name=item_name_donation', $response->getContent() );
339
+		$this->assertSame(302, $response->getStatusCode());
340
+		$this->assertContains('item_name=item_name_donation', $response->getContent());
341 341
 	}
342 342
 
343 343
 	private function newValidPayPalInput(): array {
@@ -358,36 +358,36 @@  discard block
 block discarded – undo
358 358
 		);
359 359
 
360 360
 		$response = $client->getResponse();
361
-		$this->assertSame( 200, $response->getStatusCode() );
362
-		$this->assertContains( 'paytext_cc 3 12,34 € per Kreditkarte.', $response->getContent() );
363
-		$this->assertContains( 'thatother.paymentprovider.com', $response->getContent() );
361
+		$this->assertSame(200, $response->getStatusCode());
362
+		$this->assertContains('paytext_cc 3 12,34 € per Kreditkarte.', $response->getContent());
363
+		$this->assertContains('thatother.paymentprovider.com', $response->getContent());
364 364
 	}
365 365
 
366 366
 	public function testValidSofortInput_savesDonationAndRedirectsTo3rdPartyPage(): void {
367
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ) {
367
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory) {
368 368
 			$response = new SofortResponse();
369
-			$response->setPaymentUrl( 'https://bankingpin.please' );
369
+			$response->setPaymentUrl('https://bankingpin.please');
370 370
 
371
-			$sofortClient = $this->createMock( SofortClient::class );
371
+			$sofortClient = $this->createMock(SofortClient::class);
372 372
 			$sofortClient
373
-				->method( 'get' )
374
-				->willReturn( $response );
375
-			$factory->setSofortClient( $sofortClient );
373
+				->method('get')
374
+				->willReturn($response);
375
+			$factory->setSofortClient($sofortClient);
376 376
 
377 377
 
378
-			$client->followRedirects( false );
378
+			$client->followRedirects(false);
379 379
 			$client->request(
380 380
 				'POST',
381 381
 				'/donation/add',
382 382
 				$this->newValidSofortInput()
383 383
 			);
384 384
 
385
-			$donation = $this->getDonationFromDatabase( $factory );
385
+			$donation = $this->getDonationFromDatabase($factory);
386 386
 
387
-			$this->assertSame( 'Z', $donation->getStatus() );
388
-			$this->assertRegExp( '/W-Q-[A-Z]{6}-[A-Z]/', $donation->getBankTransferCode() );
387
+			$this->assertSame('Z', $donation->getStatus());
388
+			$this->assertRegExp('/W-Q-[A-Z]{6}-[A-Z]/', $donation->getBankTransferCode());
389 389
 
390
-			$this->assertTrue( $client->getResponse()->isRedirect( 'https://bankingpin.please' ) );
390
+			$this->assertTrue($client->getResponse()->isRedirect('https://bankingpin.please'));
391 391
 		} );
392 392
 	}
393 393
 
@@ -419,23 +419,23 @@  discard block
 block discarded – undo
419 419
 
420 420
 		$response = $client->getResponse()->getContent();
421 421
 
422
-		$this->assertContains( 'Amount: 0,00', $response );
423
-		$this->assertContains( 'Payment type: BEZ', $response );
424
-		$this->assertContains( 'Interval: 3', $response );
425
-		$this->assertContains( 'IBAN: DE12500105170648489890', $response );
426
-		$this->assertContains( 'BIC: INGDDEFFXXX', $response );
427
-		$this->assertContains( 'Bank name: ING-DiBa', $response );
428
-		$this->assertContains( 'Address type: person', $response );
429
-		$this->assertContains( 'Salutation: Frau', $response );
430
-		$this->assertContains( 'Title: Prof. Dr.', $response );
431
-		$this->assertContains( 'Company: ', $response );
432
-		$this->assertContains( 'First name: Karla', $response );
433
-		$this->assertContains( 'Last name: Kennichnich', $response );
434
-		$this->assertContains( 'Street: Lehmgasse 12', $response );
435
-		$this->assertContains( 'Postal code: 12345', $response );
436
-		$this->assertContains( 'City: Einort', $response );
437
-		$this->assertContains( 'Country code: DE', $response );
438
-		$this->assertContains( 'Email address: [email protected]', $response );
422
+		$this->assertContains('Amount: 0,00', $response);
423
+		$this->assertContains('Payment type: BEZ', $response);
424
+		$this->assertContains('Interval: 3', $response);
425
+		$this->assertContains('IBAN: DE12500105170648489890', $response);
426
+		$this->assertContains('BIC: INGDDEFFXXX', $response);
427
+		$this->assertContains('Bank name: ING-DiBa', $response);
428
+		$this->assertContains('Address type: person', $response);
429
+		$this->assertContains('Salutation: Frau', $response);
430
+		$this->assertContains('Title: Prof. Dr.', $response);
431
+		$this->assertContains('Company: ', $response);
432
+		$this->assertContains('First name: Karla', $response);
433
+		$this->assertContains('Last name: Kennichnich', $response);
434
+		$this->assertContains('Street: Lehmgasse 12', $response);
435
+		$this->assertContains('Postal code: 12345', $response);
436
+		$this->assertContains('City: Einort', $response);
437
+		$this->assertContains('Country code: DE', $response);
438
+		$this->assertContains('Email address: [email protected]', $response);
439 439
 	}
440 440
 
441 441
 	public function testGivenInvalidRequest_formStillContainsBannerTrackingData(): void {
@@ -451,8 +451,8 @@  discard block
 block discarded – undo
451 451
 
452 452
 		$response = $client->getResponse()->getContent();
453 453
 
454
-		$this->assertContains( 'Impression Count: 12', $response );
455
-		$this->assertContains( 'Banner Impression Count: 3', $response );
454
+		$this->assertContains('Impression Count: 12', $response);
455
+		$this->assertContains('Banner Impression Count: 3', $response);
456 456
 	}
457 457
 
458 458
 	public function testGivenNegativeDonationAmount_formIsReloadedAndPrefilledWithZero(): void {
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
 
470 470
 		$response = $client->getResponse()->getContent();
471 471
 
472
-		$this->assertContains( 'Amount: 0,00', $response );
472
+		$this->assertContains('Amount: 0,00', $response);
473 473
 	}
474 474
 
475 475
 	private function newInvalidFormInput(): array {
@@ -514,10 +514,10 @@  discard block
 block discarded – undo
514 514
 
515 515
 		$response = $client->getResponse()->getContent();
516 516
 
517
-		$this->assertContains( 'Amount: 0', $response );
518
-		$this->assertContains( 'Payment type: UEB', $response );
519
-		$this->assertContains( 'Interval: 1', $response );
520
-		$this->assertContains( 'Value of field "amount" violates rule: Amount too low', $response );
517
+		$this->assertContains('Amount: 0', $response);
518
+		$this->assertContains('Payment type: UEB', $response);
519
+		$this->assertContains('Interval: 1', $response);
520
+		$this->assertContains('Value of field "amount" violates rule: Amount too low', $response);
521 521
 	}
522 522
 
523 523
 	private function newAnonymousFormInput(): array {
@@ -530,11 +530,11 @@  discard block
 block discarded – undo
530 530
 	}
531 531
 
532 532
 	public function testGivenValidRequest_tokensAreReturned(): void {
533
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ) {
534
-			$factory->setTokenGenerator( new FixedTokenGenerator( self::SOME_TOKEN ) );
533
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory) {
534
+			$factory->setTokenGenerator(new FixedTokenGenerator(self::SOME_TOKEN));
535 535
 
536
-			$client->setServerParameter( 'HTTP_REFERER', 'https://en.wikipedia.org/wiki/Karla_Kennichnich' );
537
-			$client->followRedirects( false );
536
+			$client->setServerParameter('HTTP_REFERER', 'https://en.wikipedia.org/wiki/Karla_Kennichnich');
537
+			$client->followRedirects(false);
538 538
 
539 539
 			$client->request(
540 540
 				'POST',
@@ -544,14 +544,14 @@  discard block
 block discarded – undo
544 544
 
545 545
 			$response = $client->getResponse()->getContent();
546 546
 
547
-			$this->assertContains( self::SOME_TOKEN, $response );
547
+			$this->assertContains(self::SOME_TOKEN, $response);
548 548
 		} );
549 549
 	}
550 550
 
551 551
 	public function testGivenValidRequest_clientIsRedirected(): void {
552
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ) {
553
-			$factory->setTokenGenerator( new FixedTokenGenerator( self::SOME_TOKEN ) );
554
-			$client->followRedirects( false );
552
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory) {
553
+			$factory->setTokenGenerator(new FixedTokenGenerator(self::SOME_TOKEN));
554
+			$client->followRedirects(false);
555 555
 
556 556
 			$client->request(
557 557
 				'POST',
@@ -559,13 +559,13 @@  discard block
 block discarded – undo
559 559
 				$this->newValidFormInput()
560 560
 			);
561 561
 
562
-			$this->assertTrue( $client->getResponse()->isRedirect() );
562
+			$this->assertTrue($client->getResponse()->isRedirect());
563 563
 		} );
564 564
 	}
565 565
 
566 566
 	public function testWhenTrackingCookieExists_valueIsPersisted(): void {
567
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ) {
568
-			$client->getCookieJar()->set( new Cookie( 'spenden_tracking', 'test/blue' ) );
567
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory) {
568
+			$client->getCookieJar()->set(new Cookie('spenden_tracking', 'test/blue'));
569 569
 
570 570
 			$client->request(
571 571
 				'POST',
@@ -573,15 +573,15 @@  discard block
 block discarded – undo
573 573
 				$this->newComplementableFormInput()
574 574
 			);
575 575
 
576
-			$donation = $this->getDonationFromDatabase( $factory );
576
+			$donation = $this->getDonationFromDatabase($factory);
577 577
 			$data = $donation->getDecodedData();
578 578
 
579
-			$this->assertSame( 'test/blue', $data['tracking'] );
579
+			$this->assertSame('test/blue', $data['tracking']);
580 580
 		} );
581 581
 	}
582 582
 
583 583
 	public function testWhenTrackableInputDataIsSubmitted_theyAreStoredInSession(): void {
584
-		$this->createAppEnvironment( [], function ( Client $client, FunFunFactory $factory, Application $app ) {
584
+		$this->createAppEnvironment([], function(Client $client, FunFunFactory $factory, Application $app) {
585 585
 
586 586
 			$client->request(
587 587
 				'GET',
@@ -593,15 +593,15 @@  discard block
 block discarded – undo
593 593
 				]
594 594
 			);
595 595
 
596
-			$piwikTracking = $app['session']->get( 'piwikTracking' );
597
-			$this->assertSame( 'BEZ', $piwikTracking['paymentType'] );
598
-			$this->assertSame( 3, $piwikTracking['paymentInterval'] );
599
-			$this->assertSame( '5,00', $piwikTracking['paymentAmount'] );
596
+			$piwikTracking = $app['session']->get('piwikTracking');
597
+			$this->assertSame('BEZ', $piwikTracking['paymentType']);
598
+			$this->assertSame(3, $piwikTracking['paymentInterval']);
599
+			$this->assertSame('5,00', $piwikTracking['paymentAmount']);
600 600
 		} );
601 601
 	}
602 602
 
603 603
 	public function testWhenTolstojNovelIsPassed_isIsNotStoredInSession(): void {
604
-		$this->createAppEnvironment( [], function ( Client $client, FunFunFactory $factory, Application $app ) {
604
+		$this->createAppEnvironment([], function(Client $client, FunFunFactory $factory, Application $app) {
605 605
 
606 606
 			$client->request(
607 607
 				'GET',
@@ -619,15 +619,15 @@  discard block
 block discarded – undo
619 619
 				]
620 620
 			);
621 621
 
622
-			$piwikTracking = $app['session']->get( 'piwikTracking' );
623
-			$this->assertArrayNotHasKey( 'paymentType', $piwikTracking );
624
-			$this->assertSame( 3, $piwikTracking['paymentInterval'] );
625
-			$this->assertSame( '5,00', $piwikTracking['paymentAmount'] );
622
+			$piwikTracking = $app['session']->get('piwikTracking');
623
+			$this->assertArrayNotHasKey('paymentType', $piwikTracking);
624
+			$this->assertSame(3, $piwikTracking['paymentInterval']);
625
+			$this->assertSame('5,00', $piwikTracking['paymentAmount']);
626 626
 		} );
627 627
 	}
628 628
 
629 629
 	public function testWhenParameterIsOmitted_itIsNotStoredInSession(): void {
630
-		$this->createAppEnvironment( [], function ( Client $client, FunFunFactory $factory, Application $app ) {
630
+		$this->createAppEnvironment([], function(Client $client, FunFunFactory $factory, Application $app) {
631 631
 
632 632
 			$client->request(
633 633
 				'GET',
@@ -638,15 +638,15 @@  discard block
 block discarded – undo
638 638
 				]
639 639
 			);
640 640
 
641
-			$piwikTracking = $app['session']->get( 'piwikTracking' );
642
-			$this->assertSame( 'BEZ', $piwikTracking['paymentType'] );
643
-			$this->assertSame( '5,00', $piwikTracking['paymentAmount'] );
644
-			$this->assertArrayNotHasKey( 'paymentInterval', $piwikTracking );
641
+			$piwikTracking = $app['session']->get('piwikTracking');
642
+			$this->assertSame('BEZ', $piwikTracking['paymentType']);
643
+			$this->assertSame('5,00', $piwikTracking['paymentAmount']);
644
+			$this->assertArrayNotHasKey('paymentInterval', $piwikTracking);
645 645
 		} );
646 646
 	}
647 647
 
648 648
 	public function testWhenInitiallyIntendedPaymentOptionsDifferFromActual_itIsReflectedInPiwikTrackingEvents(): void {
649
-		$client = $this->createClient( [] );
649
+		$client = $this->createClient([]);
650 650
 		$client->request(
651 651
 			'GET',
652 652
 			'/',
@@ -670,21 +670,21 @@  discard block
 block discarded – undo
670 670
 		$client->followRedirect();
671 671
 
672 672
 		$responseContent = $client->getResponse()->getContent();
673
-		$this->assertContains( 'BEZ/UEB', $responseContent );
674
-		$this->assertContains( '5.00/12.34', $responseContent );
675
-		$this->assertContains( '12/0', $responseContent );
673
+		$this->assertContains('BEZ/UEB', $responseContent);
674
+		$this->assertContains('5.00/12.34', $responseContent);
675
+		$this->assertContains('12/0', $responseContent);
676 676
 	}
677 677
 
678 678
 	public function testWhenMobileTrackingIsRequested_piwikTrackerIsCalledForPaypalPayment(): void {
679
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ) {
679
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory) {
680 680
 			$factory->setNullMessenger();
681
-			$client->followRedirects( false );
681
+			$client->followRedirects(false);
682 682
 
683
-			$tracker = $this->getMockBuilder( PageViewTracker::class )->disableOriginalConstructor()->getMock();
684
-			$tracker->expects( $this->once() )
685
-				->method( 'trackPaypalRedirection' )
686
-				->with( 'test', 'gelb', '10.1.2.3' );
687
-			$factory->setPageViewTracker( $tracker );
683
+			$tracker = $this->getMockBuilder(PageViewTracker::class)->disableOriginalConstructor()->getMock();
684
+			$tracker->expects($this->once())
685
+				->method('trackPaypalRedirection')
686
+				->with('test', 'gelb', '10.1.2.3');
687
+			$factory->setPageViewTracker($tracker);
688 688
 
689 689
 			$client->request(
690 690
 				'POST',
@@ -711,14 +711,14 @@  discard block
 block discarded – undo
711 711
 	}
712 712
 
713 713
 	public function testWhenMobileTrackingIsRequested_piwikTrackerIsNotCalledForNonPaypalPayment(): void {
714
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ) {
714
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory) {
715 715
 			$factory->setNullMessenger();
716
-			$client->followRedirects( false );
716
+			$client->followRedirects(false);
717 717
 
718
-			$tracker = $this->getMockBuilder( PageViewTracker::class )->disableOriginalConstructor()->getMock();
719
-			$tracker->expects( $this->never() )
720
-				->method( 'trackPaypalRedirection' );
721
-			$factory->setPageViewTracker( $tracker );
718
+			$tracker = $this->getMockBuilder(PageViewTracker::class)->disableOriginalConstructor()->getMock();
719
+			$tracker->expects($this->never())
720
+				->method('trackPaypalRedirection');
721
+			$factory->setPageViewTracker($tracker);
722 722
 
723 723
 			$client->request(
724 724
 				'POST',
@@ -734,10 +734,10 @@  discard block
 block discarded – undo
734 734
 	}
735 735
 
736 736
 	public function testGivenCommasInStreetInput_donationGetsPersisted(): void {
737
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ) {
737
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory) {
738 738
 
739
-			$client->setServerParameter( 'HTTP_REFERER', 'https://en.wikipedia.org/wiki/Karla_Kennichnich' );
740
-			$client->followRedirects( false );
739
+			$client->setServerParameter('HTTP_REFERER', 'https://en.wikipedia.org/wiki/Karla_Kennichnich');
740
+			$client->followRedirects(false);
741 741
 
742 742
 			$formInput = $this->newValidFormInput();
743 743
 			$formInput['street'] = ',Lehmgasse, 12,';
@@ -748,12 +748,12 @@  discard block
 block discarded – undo
748 748
 				$formInput
749 749
 			);
750 750
 
751
-			$this->assertIsExpectedDonation( $this->getDonationFromDatabase( $factory ) );
751
+			$this->assertIsExpectedDonation($this->getDonationFromDatabase($factory));
752 752
 		} );
753 753
 	}
754 754
 
755 755
 	public function testGivenSufficientForeignBankData_donationGetsPersisted(): void {
756
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ) {
756
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory) {
757 757
 			$formInput = $this->newValidFormInput();
758 758
 			$formInput['iban'] = 'AT022050302101023600';
759 759
 			$formInput['bic'] = 'SPIHAT22XXX';
@@ -766,23 +766,23 @@  discard block
 block discarded – undo
766 766
 				$formInput
767 767
 			);
768 768
 
769
-			$donation = $this->getDonationFromDatabase( $factory );
769
+			$donation = $this->getDonationFromDatabase($factory);
770 770
 			$data = $donation->getDecodedData();
771 771
 
772
-			$this->assertSame( 'AT022050302101023600', $data['iban'] );
773
-			$this->assertSame( 'SPIHAT22XXX', $data['bic'] );
774
-			$this->assertSame( '', $data['konto'] );
775
-			$this->assertSame( '', $data['blz'] );
776
-			$this->assertSame( '', $data['bankname'] );
772
+			$this->assertSame('AT022050302101023600', $data['iban']);
773
+			$this->assertSame('SPIHAT22XXX', $data['bic']);
774
+			$this->assertSame('', $data['konto']);
775
+			$this->assertSame('', $data['blz']);
776
+			$this->assertSame('', $data['bankname']);
777 777
 		} );
778 778
 	}
779 779
 
780 780
 	public function testCookieFlagsSecureAndHttpOnlyAreSet(): void {
781 781
 		$client = new Client(
782 782
 			$this->createSilexApplication(),
783
-			[ 'HTTPS' => true ]
783
+			['HTTPS' => true]
784 784
 		);
785
-		$client->followRedirects( true );
785
+		$client->followRedirects(true);
786 786
 
787 787
 		$client->request(
788 788
 			'POST',
@@ -791,10 +791,10 @@  discard block
 block discarded – undo
791 791
 		);
792 792
 
793 793
 		$cookieJar = $client->getCookieJar();
794
-		$cookieJar->updateFromResponse( $client->getInternalResponse() );
795
-		$cookie = $cookieJar->get( ShowDonationConfirmationHandler::SUBMISSION_COOKIE_NAME );
796
-		$this->assertTrue( $cookie->isSecure() );
797
-		$this->assertTrue( $cookie->isHttpOnly() );
794
+		$cookieJar->updateFromResponse($client->getInternalResponse());
795
+		$cookie = $cookieJar->get(ShowDonationConfirmationHandler::SUBMISSION_COOKIE_NAME);
796
+		$this->assertTrue($cookie->isSecure());
797
+		$this->assertTrue($cookie->isHttpOnly());
798 798
 	}
799 799
 
800 800
 }
Please login to merge, or discard this patch.
tests/EdgeToEdge/Routes/ApplyForMembershipRouteTest.php 1 patch
Spacing   +70 added lines, -70 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
 
@@ -31,30 +31,30 @@  discard block
 block discarded – undo
31 31
 	public function testGivenGetRequestMembership_formIsShown(): void {
32 32
 		$client = $this->createClient();
33 33
 
34
-		$crawler = $client->request( 'GET', 'apply-for-membership' );
34
+		$crawler = $client->request('GET', 'apply-for-membership');
35 35
 
36 36
 		$this->assertCount(
37 37
 			1,
38
-			$crawler->filter( 'form#memForm[method="POST"][action="/apply-for-membership"]' )
38
+			$crawler->filter('form#memForm[method="POST"][action="/apply-for-membership"]')
39 39
 		);
40 40
 		$this->assertCount(
41 41
 			1,
42
-			$crawler->filter( 'input[name="showMembershipTypeOption"][type="hidden"][value="true"]' )
42
+			$crawler->filter('input[name="showMembershipTypeOption"][type="hidden"][value="true"]')
43 43
 		);
44 44
 	}
45 45
 
46 46
 	public function testGivenGetRequestSustainingMembership_formIsShown(): void {
47 47
 		$client = $this->createClient();
48 48
 
49
-		$crawler = $client->request( 'GET', 'apply-for-membership', ['type' => 'sustaining'] );
49
+		$crawler = $client->request('GET', 'apply-for-membership', ['type' => 'sustaining']);
50 50
 
51 51
 		$this->assertCount(
52 52
 			1,
53
-			$crawler->filter( 'form#memForm[method="POST"][action="/apply-for-membership"]' )
53
+			$crawler->filter('form#memForm[method="POST"][action="/apply-for-membership"]')
54 54
 		);
55 55
 		$this->assertCount(
56 56
 			1,
57
-			$crawler->filter( 'input[name="showMembershipTypeOption"][type="hidden"][value="false"]' )
57
+			$crawler->filter('input[name="showMembershipTypeOption"][type="hidden"][value="false"]')
58 58
 		);
59 59
 	}
60 60
 
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 		$httpParameters = $this->newValidHttpParameters();
100 100
 		$httpParameters['membership_fee'] = '1.00'; // TODO: change to localized
101 101
 
102
-		$client->request( 'POST', 'apply-for-membership', $httpParameters );
102
+		$client->request('POST', 'apply-for-membership', $httpParameters);
103 103
 
104 104
 		$this->assertInitialFormValues(
105 105
 			[
@@ -140,13 +140,13 @@  discard block
 block discarded – undo
140 140
 
141 141
 		$this->assertCount(
142 142
 			1,
143
-			$crawler->filter( 'input[type="hidden"][name="showMembershipTypeOption"][value="true"]' )
143
+			$crawler->filter('input[type="hidden"][name="showMembershipTypeOption"][value="true"]')
144 144
 		);
145 145
 	}
146 146
 
147 147
 	public function testGivenValidRequest_applicationIsPersisted(): void {
148
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ) {
149
-			$factory->setPaymentDelayCalculator( $this->newFixedPaymentDelayCalculator() );
148
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory) {
149
+			$factory->setPaymentDelayCalculator($this->newFixedPaymentDelayCalculator());
150 150
 
151 151
 			$client->request(
152 152
 				'POST',
@@ -154,20 +154,20 @@  discard block
 block discarded – undo
154 154
 				$this->newValidHttpParameters()
155 155
 			);
156 156
 
157
-			$application = $factory->getMembershipApplicationRepository()->getApplicationById( 1 );
157
+			$application = $factory->getMembershipApplicationRepository()->getApplicationById(1);
158 158
 
159
-			$this->assertNotNull( $application );
159
+			$this->assertNotNull($application);
160 160
 
161 161
 			$expectedApplication = ValidMembershipApplication::newAutoConfirmedDomainEntity();
162
-			$expectedApplication->assignId( 1 );
162
+			$expectedApplication->assignId(1);
163 163
 
164
-			$this->assertEquals( $expectedApplication, $application );
164
+			$this->assertEquals($expectedApplication, $application);
165 165
 		} );
166 166
 	}
167 167
 
168 168
 	public function testGivenValidRequest_confirmationPageContainsCancellationParameters(): void {
169
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ) {
170
-			$factory->setTokenGenerator( new FixedTokenGenerator( self::FIXED_TOKEN ) );
169
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory) {
170
+			$factory->setTokenGenerator(new FixedTokenGenerator(self::FIXED_TOKEN));
171 171
 
172 172
 			$client->request(
173 173
 				'POST',
@@ -177,14 +177,14 @@  discard block
 block discarded – undo
177 177
 
178 178
 			$responseContent = $client->getResponse()->getContent();
179 179
 
180
-			$this->assertContains( 'id=1', $responseContent );
181
-			$this->assertContains( 'accessToken=' . self::FIXED_TOKEN, $responseContent );
180
+			$this->assertContains('id=1', $responseContent);
181
+			$this->assertContains('accessToken=' . self::FIXED_TOKEN, $responseContent);
182 182
 		} );
183 183
 	}
184 184
 
185 185
 	public function testGivenValidRequest_requestIsRedirected(): void {
186 186
 		$client = $this->createClient();
187
-		$client->followRedirects( false );
187
+		$client->followRedirects(false);
188 188
 
189 189
 		$client->request(
190 190
 			'POST',
@@ -193,8 +193,8 @@  discard block
 block discarded – undo
193 193
 		);
194 194
 
195 195
 		$response = $client->getResponse();
196
-		$this->assertTrue( $response->isRedirect() );
197
-		$this->assertContains( 'show-membership-confirmation', $response->headers->get( 'Location' ) );
196
+		$this->assertTrue($response->isRedirect());
197
+		$this->assertContains('show-membership-confirmation', $response->headers->get('Location'));
198 198
 	}
199 199
 
200 200
 	public function testWhenApplicationGetsPersisted_timestampIsStoredInCookie(): void {
@@ -205,15 +205,15 @@  discard block
 block discarded – undo
205 205
 			$this->newValidHttpParameters()
206 206
 		);
207 207
 
208
-		$cookie = $client->getCookieJar()->get( 'memapp_timestamp' );
209
-		$this->assertNotNull( $cookie );
210
-		$donationTimestamp = new \DateTime( $cookie->getValue() );
211
-		$this->assertEquals( time(), $donationTimestamp->getTimestamp(), 'Timestamp should be not more than 5 seconds old', 5.0 );
208
+		$cookie = $client->getCookieJar()->get('memapp_timestamp');
209
+		$this->assertNotNull($cookie);
210
+		$donationTimestamp = new \DateTime($cookie->getValue());
211
+		$this->assertEquals(time(), $donationTimestamp->getTimestamp(), 'Timestamp should be not more than 5 seconds old', 5.0);
212 212
 	}
213 213
 
214 214
 	public function testWhenMultipleMembershipFormSubmissions_requestGetsRejected(): void {
215 215
 		$client = $this->createClient();
216
-		$client->getCookieJar()->set( new Cookie( 'memapp_timestamp', $this->getPastTimestamp() ) );
216
+		$client->getCookieJar()->set(new Cookie('memapp_timestamp', $this->getPastTimestamp()));
217 217
 
218 218
 		$client->request(
219 219
 			'POST',
@@ -221,12 +221,12 @@  discard block
 block discarded – undo
221 221
 			$this->newValidHttpParameters()
222 222
 		);
223 223
 
224
-		$this->assertContains( 'membership_application_rejected_limit', $client->getResponse()->getContent() );
224
+		$this->assertContains('membership_application_rejected_limit', $client->getResponse()->getContent());
225 225
 	}
226 226
 
227 227
 	public function testWhenMultipleMembershipInAccordanceToTimeLimit_isNotRejected(): void {
228 228
 		$client = $this->createClient();
229
-		$client->getCookieJar()->set( new Cookie( 'memapp_timestamp', $this->getPastTimestamp( 'PT12M' ) ) );
229
+		$client->getCookieJar()->set(new Cookie('memapp_timestamp', $this->getPastTimestamp('PT12M')));
230 230
 
231 231
 		$client->request(
232 232
 			'POST',
@@ -234,16 +234,16 @@  discard block
 block discarded – undo
234 234
 			$this->newValidHttpParameters()
235 235
 		);
236 236
 
237
-		$this->assertNotContains( 'membership_application_rejected_limit', $client->getResponse()->getContent() );
237
+		$this->assertNotContains('membership_application_rejected_limit', $client->getResponse()->getContent());
238 238
 	}
239 239
 
240
-	private function getPastTimestamp( string $interval = 'PT10S' ): string {
241
-		return ( new \DateTime() )->sub( new \DateInterval( $interval ) )->format( 'Y-m-d H:i:s' );
240
+	private function getPastTimestamp(string $interval = 'PT10S'): string {
241
+		return (new \DateTime())->sub(new \DateInterval($interval))->format('Y-m-d H:i:s');
242 242
 	}
243 243
 
244 244
 	public function testWhenTrackingCookieExists_valueIsPersisted(): void {
245
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ) {
246
-			$client->getCookieJar()->set( new Cookie( 'spenden_tracking', 'test/blue' ) );
245
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory) {
246
+			$client->getCookieJar()->set(new Cookie('spenden_tracking', 'test/blue'));
247 247
 
248 248
 			$client->request(
249 249
 				'POST',
@@ -251,21 +251,21 @@  discard block
 block discarded – undo
251 251
 				$this->newValidHttpParameters()
252 252
 			);
253 253
 
254
-			$application = $this->getApplicationFromDatabase( $factory );
255
-			$this->assertSame( 'test/blue', $application->getTracking() );
254
+			$application = $this->getApplicationFromDatabase($factory);
255
+			$this->assertSame('test/blue', $application->getTracking());
256 256
 		} );
257 257
 	}
258 258
 
259
-	private function getApplicationFromDatabase( FunFunFactory $factory ): MembershipApplication {
260
-		$repository = $factory->getEntityManager()->getRepository( MembershipApplication::class );
261
-		$application = $repository->find( 1 );
262
-		$this->assertInstanceOf( MembershipApplication::class, $application );
259
+	private function getApplicationFromDatabase(FunFunFactory $factory): MembershipApplication {
260
+		$repository = $factory->getEntityManager()->getRepository(MembershipApplication::class);
261
+		$application = $repository->find(1);
262
+		$this->assertInstanceOf(MembershipApplication::class, $application);
263 263
 		return $application;
264 264
 	}
265 265
 
266 266
 	public function testGivenValidRequestUsingPayPal_applicationIsPersisted(): void {
267
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ) {
268
-			$factory->setPaymentDelayCalculator( $this->newFixedPaymentDelayCalculator() );
267
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory) {
268
+			$factory->setPaymentDelayCalculator($this->newFixedPaymentDelayCalculator());
269 269
 
270 270
 			$client->request(
271 271
 				'POST',
@@ -273,18 +273,18 @@  discard block
 block discarded – undo
273 273
 				$this->newValidHttpParametersUsingPayPal()
274 274
 			);
275 275
 
276
-			$application = $factory->getMembershipApplicationRepository()->getApplicationById( 1 );
276
+			$application = $factory->getMembershipApplicationRepository()->getApplicationById(1);
277 277
 
278
-			$this->assertNotNull( $application );
278
+			$this->assertNotNull($application);
279 279
 
280 280
 			$payPalData = new PayPalData();
281
-			$payPalData->setFirstPaymentDate( self::FIRST_PAYMENT_DATE );
281
+			$payPalData->setFirstPaymentDate(self::FIRST_PAYMENT_DATE);
282 282
 			$payPalData->freeze();
283 283
 
284
-			$expectedApplication = ValidMembershipApplication::newDomainEntityUsingPayPal( $payPalData );
285
-			$expectedApplication->assignId( 1 );
284
+			$expectedApplication = ValidMembershipApplication::newDomainEntityUsingPayPal($payPalData);
285
+			$expectedApplication->assignId(1);
286 286
 
287
-			$this->assertEquals( $expectedApplication, $application );
287
+			$this->assertEquals($expectedApplication, $application);
288 288
 		} );
289 289
 	}
290 290
 
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 
320 320
 	public function testGivenValidRequestUsingPayPal_requestIsRedirectedToPayPalUrl(): void {
321 321
 		$client = $this->createClient();
322
-		$client->followRedirects( false );
322
+		$client->followRedirects(false);
323 323
 
324 324
 		$client->request(
325 325
 			'POST',
@@ -328,13 +328,13 @@  discard block
 block discarded – undo
328 328
 		);
329 329
 
330 330
 		$response = $client->getResponse();
331
-		$this->assertTrue( $response->isRedirect() );
332
-		$this->assertContains( 'sandbox.paypal.com', $response->headers->get( 'Location' ) );
331
+		$this->assertTrue($response->isRedirect());
332
+		$this->assertContains('sandbox.paypal.com', $response->headers->get('Location'));
333 333
 	}
334 334
 
335 335
 	public function testWhenRedirectingToPayPal_translatedItemNameIsPassed(): void {
336 336
 		$client = $this->createClient();
337
-		$client->followRedirects( false );
337
+		$client->followRedirects(false);
338 338
 
339 339
 		$client->request(
340 340
 			'POST',
@@ -343,12 +343,12 @@  discard block
 block discarded – undo
343 343
 		);
344 344
 
345 345
 		$response = $client->getResponse();
346
-		$this->assertSame( 302, $response->getStatusCode() );
347
-		$this->assertContains( 'item_name=item_name_membership', $response->getContent() );
346
+		$this->assertSame(302, $response->getStatusCode());
347
+		$this->assertContains('item_name=item_name_membership', $response->getContent());
348 348
 	}
349 349
 
350 350
 	public function testCommasInStreetNamesAreRemoved(): void {
351
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ) {
351
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory) {
352 352
 
353 353
 			$params = $this->newValidHttpParameters();
354 354
 			$params['strasse'] = 'Nyan, street, ';
@@ -358,20 +358,20 @@  discard block
 block discarded – undo
358 358
 				$params
359 359
 			);
360 360
 
361
-			$application = $factory->getMembershipApplicationRepository()->getApplicationById( 1 );
361
+			$application = $factory->getMembershipApplicationRepository()->getApplicationById(1);
362 362
 
363
-			$this->assertNotNull( $application );
363
+			$this->assertNotNull($application);
364 364
 
365 365
 			$expectedApplication = ValidMembershipApplication::newDomainEntity();
366
-			$expectedApplication->assignId( 1 );
366
+			$expectedApplication->assignId(1);
367 367
 			$expectedApplication->confirm();
368 368
 
369
-			$this->assertEquals( $expectedApplication, $application );
369
+			$this->assertEquals($expectedApplication, $application);
370 370
 		} );
371 371
 	}
372 372
 
373 373
 	public function testWhenCompaniesApply_salutationIsSetToFixedValue(): void {
374
-		$this->createEnvironment( [], function ( Client $client, FunFunFactory $factory ) {
374
+		$this->createEnvironment([], function(Client $client, FunFunFactory $factory) {
375 375
 
376 376
 			$params = $this->newValidHttpParametersForCompanies();
377 377
 			$client->request(
@@ -380,15 +380,15 @@  discard block
 block discarded – undo
380 380
 				$params
381 381
 			);
382 382
 
383
-			$application = $factory->getMembershipApplicationRepository()->getApplicationById( 1 );
383
+			$application = $factory->getMembershipApplicationRepository()->getApplicationById(1);
384 384
 
385
-			$this->assertNotNull( $application );
385
+			$this->assertNotNull($application);
386 386
 
387 387
 			$expectedApplication = ValidMembershipApplication::newCompanyApplication();
388
-			$expectedApplication->assignId( 1 );
388
+			$expectedApplication->assignId(1);
389 389
 			$expectedApplication->confirm();
390 390
 
391
-			$this->assertEquals( $expectedApplication, $application );
391
+			$this->assertEquals($expectedApplication, $application);
392 392
 		} );
393 393
 	}
394 394
 
@@ -422,14 +422,14 @@  discard block
 block discarded – undo
422 422
 
423 423
 	private function newFixedPaymentDelayCalculator(): PaymentDelayCalculator {
424 424
 		return new FixedPaymentDelayCalculator(
425
-			new \DateTime( self::FIRST_PAYMENT_DATE )
425
+			new \DateTime(self::FIRST_PAYMENT_DATE)
426 426
 		);
427 427
 	}
428 428
 
429 429
 	public function testCookieFlagsSecureAndHttpOnlyAreSet(): void {
430 430
 		$client = new Client(
431 431
 			$this->createSilexApplication(),
432
-			[ 'HTTPS' => true ]
432
+			['HTTPS' => true]
433 433
 		);
434 434
 
435 435
 		$client->request(
@@ -439,11 +439,11 @@  discard block
 block discarded – undo
439 439
 		);
440 440
 
441 441
 		$cookieJar = $client->getCookieJar();
442
-		$cookieJar->updateFromResponse( $client->getInternalResponse() );
443
-		$cookie = $cookieJar->get( ShowMembershipConfirmationHandler::SUBMISSION_COOKIE_NAME );
442
+		$cookieJar->updateFromResponse($client->getInternalResponse());
443
+		$cookie = $cookieJar->get(ShowMembershipConfirmationHandler::SUBMISSION_COOKIE_NAME);
444 444
 
445
-		$this->assertTrue( $cookie->isHttpOnly() );
446
-		$this->assertTrue( $cookie->isSecure() );
445
+		$this->assertTrue($cookie->isHttpOnly());
446
+		$this->assertTrue($cookie->isSecure());
447 447
 	}
448 448
 
449 449
 }
Please login to merge, or discard this patch.