Skip to content

Commit 3e356de

Browse files
committed
Moved 'Location' string to test class const
1 parent 45981af commit 3e356de

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

tests/bundle/Functional/UserTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
class UserTest extends RESTFunctionalTestCase
1212
{
13+
private const HEADER_LOCATION = 'Location';
14+
1315
/**
1416
* Covers GET /user/groups/root.
1517
*/
@@ -59,9 +61,9 @@ public function testCreateUserGroup()
5961
$response = $this->sendHttpRequest($request);
6062

6163
self::assertHttpResponseCodeEquals($response, 201);
62-
self::assertHttpResponseHasHeader($response, 'Location');
64+
self::assertHttpResponseHasHeader($response, self::HEADER_LOCATION);
6365

64-
$href = $response->getHeader('Location')[0];
66+
$href = $response->getHeader(self::HEADER_LOCATION)[0];
6567
$this->addCreatedElement($href);
6668

6769
return $href;
@@ -153,9 +155,9 @@ public function testCreateUser($userGroupHref)
153155
$response = $this->sendHttpRequest($request);
154156

155157
self::assertHttpResponseCodeEquals($response, 201);
156-
self::assertHttpResponseHasHeader($response, 'Location');
158+
self::assertHttpResponseHasHeader($response, self::HEADER_LOCATION);
157159

158-
$href = $response->getHeader('Location')[0];
160+
$href = $response->getHeader(self::HEADER_LOCATION)[0];
159161
$this->addCreatedElement($href);
160162

161163
return $href;
@@ -181,9 +183,7 @@ public function testRedirectToCurrentUser(): void
181183
$response = $this->sendHttpRequest($request);
182184

183185
self::assertHttpResponseCodeEquals($response, 307);
184-
self::assertTrue($response->hasHeader('Location'));
185-
[ $location ] = $response->getHeader('Location');
186-
self::assertSame('/api/ibexa/v2/user/users/14', $location);
186+
self::assertHttpResponseHasHeader($response, self::HEADER_LOCATION, '/api/ibexa/v2/user/users/14');
187187
}
188188

189189
public function testRedirectToCurrentUserWhenNotLoggedIn(): void
@@ -195,7 +195,7 @@ public function testRedirectToCurrentUserWhenNotLoggedIn(): void
195195
$response = $this->sendHttpRequest($request);
196196

197197
self::assertHttpResponseCodeEquals($response, 401);
198-
self::assertFalse($response->hasHeader('Location'));
198+
self::assertFalse($response->hasHeader(self::HEADER_LOCATION));
199199
}
200200

201201
/**
@@ -418,9 +418,9 @@ public function testCreateSession()
418418
$response = $this->sendHttpRequest($request);
419419

420420
self::assertHttpResponseCodeEquals($response, 201);
421-
self::assertHttpResponseHasHeader($response, 'Location');
421+
self::assertHttpResponseHasHeader($response, self::HEADER_LOCATION);
422422

423-
$href = $response->getHeader('Location')[0];
423+
$href = $response->getHeader(self::HEADER_LOCATION)[0];
424424
$this->addCreatedElement($href);
425425

426426
return $href;

0 commit comments

Comments
 (0)