Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit 887c846

Browse files
committed
#8 refactored test to getHeaderLine() method
1 parent 29e27fd commit 887c846

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

test/BasicAccessTest.php

+24-24
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ public function testConstructor()
5858

5959

6060
/**
61-
* @param array $authHeaderContent
61+
* @param string $authHeaderContent
6262
* @dataProvider provideInvalidAuthenticationHeader
6363
*/
64-
public function testIsAuthenticatedWithInvalidData(array $authHeaderContent)
64+
public function testIsAuthenticatedWithInvalidData(string $authHeaderContent)
6565
{
6666
$this->request
67-
->getHeader('Authorization')
67+
->getHeaderLine('Authorization')
6868
->willReturn($authHeaderContent);
6969

7070
$basicAccess = new BasicAccess(
@@ -78,13 +78,13 @@ public function testIsAuthenticatedWithInvalidData(array $authHeaderContent)
7878
/**
7979
* @param string $username
8080
* @param string $password
81-
* @param array $header
81+
* @param string $header
8282
* @dataProvider provideValidAuthentication
8383
*/
84-
public function testIsAuthenticatedWithValidCredential(string $username, string $password, array $header)
84+
public function testIsAuthenticatedWithValidCredential(string $username, string $password, string $header)
8585
{
8686
$this->request
87-
->getHeader('Authorization')
87+
->getHeaderLine('Authorization')
8888
->willReturn($header);
8989
$this->request
9090
->withAttribute(UserInterface::class, Argument::type(UserInterface::class))
@@ -111,8 +111,8 @@ public function testIsAuthenticatedWithValidCredential(string $username, string
111111
public function testIsAuthenticatedWithNoCredential()
112112
{
113113
$this->request
114-
->getHeader('Authorization')
115-
->willReturn(['Basic QWxhZGRpbjpPcGVuU2VzYW1l']);
114+
->getHeaderLine('Authorization')
115+
->willReturn('Basic QWxhZGRpbjpPcGVuU2VzYW1l');
116116

117117
$this->userRepository
118118
->authenticate('Aladdin', 'OpenSesame')
@@ -153,31 +153,31 @@ public function testGetUnauthenticatedResponse()
153153
public function provideInvalidAuthenticationHeader(): array
154154
{
155155
return [
156-
'empty-header' => [[]],
157-
'missing-basic-prefix' => [['foo']],
158-
'only-username' => [['Basic ' . base64_encode('Aladdin')]],
159-
'username-with-colon' => [['Basic ' . base64_encode('Aladdin:')]],
160-
'password-without-username' => [['Basic ' . base64_encode(':OpenSesame')]],
161-
'base64-encoded-pile-of-poo-emoji' => [['Basic ' . base64_encode('💩')]],
162-
'password-containing-colon' => [['Basic ' . base64_encode('username:password:containing:colons:')]],
163-
'only-one-colon' => [['Basic ' . base64_encode(':')]],
164-
'multiple-colons' => [['Basic ' . base64_encode(':::::::')]],
165-
'pile-of-poo-emoji' => [['Basic 💩']],
166-
'only-pile-of-poo-emoji' => [['💩']],
167-
'basic-prefix-without-content' => [['Basic ']],
168-
'only-basic' => [['Basic']],
156+
'empty-header' => [''],
157+
'missing-basic-prefix' => ['foo'],
158+
'only-username' => ['Basic ' . base64_encode('Aladdin')],
159+
'username-with-colon' => ['Basic ' . base64_encode('Aladdin:')],
160+
'password-without-username' => ['Basic ' . base64_encode(':OpenSesame')],
161+
'base64-encoded-pile-of-poo-emoji' => ['Basic ' . base64_encode('💩')],
162+
'password-containing-colon' => ['Basic ' . base64_encode('username:password:containing:colons:')],
163+
'only-one-colon' => ['Basic ' . base64_encode(':')],
164+
'multiple-colons' => ['Basic ' . base64_encode(':::::::')],
165+
'pile-of-poo-emoji' => ['Basic 💩'],
166+
'only-pile-of-poo-emoji' => ['💩'],
167+
'basic-prefix-without-content' => ['Basic '],
168+
'only-basic' => ['Basic'],
169169
];
170170
}
171171

172172
public function provideValidAuthentication(): array
173173
{
174174
return [
175-
'aladdin' => ['Aladdin', 'OpenSesame', ['Basic ' . base64_encode('Aladdin:OpenSesame')]],
176-
'passwords-with-colon' => ['Aladdin', 'Open:Sesame', ['Basic ' . base64_encode('Aladdin:Open:Sesame')]],
175+
'aladdin' => ['Aladdin', 'OpenSesame', 'Basic ' . base64_encode('Aladdin:OpenSesame')],
176+
'passwords-with-colon' => ['Aladdin', 'Open:Sesame', 'Basic ' . base64_encode('Aladdin:Open:Sesame')],
177177
'passwords-with-multiple-colons' => [
178178
'Aladdin',
179179
':Open:Sesame:',
180-
['Basic ' . base64_encode('Aladdin::Open:Sesame:')]
180+
'Basic ' . base64_encode('Aladdin::Open:Sesame:')
181181
],
182182
];
183183
}

0 commit comments

Comments
 (0)