@@ -23,16 +23,16 @@ class BasicAccessTest extends TestCase
23
23
{
24
24
use ProphecyTrait;
25
25
26
- /** @var ServerRequestInterface| ObjectProphecy */
26
+ /** @var ObjectProphecy<ServerRequestInterface> */
27
27
private $ request ;
28
28
29
- /** @var UserRepositoryInterface| ObjectProphecy */
29
+ /** @var ObjectProphecy<UserRepositoryInterface> */
30
30
private $ userRepository ;
31
31
32
- /** @var UserInterface| ObjectProphecy */
32
+ /** @var ObjectProphecy<UserInterface> */
33
33
private $ authenticatedUser ;
34
34
35
- /** @var ResponseInterface| ObjectProphecy */
35
+ /** @var ObjectProphecy<ResponseInterface> */
36
36
private $ responsePrototype ;
37
37
38
38
/** @var callable */
@@ -44,12 +44,12 @@ protected function setUp(): void
44
44
$ this ->userRepository = $ this ->prophesize (UserRepositoryInterface::class);
45
45
$ this ->authenticatedUser = $ this ->prophesize (UserInterface::class);
46
46
$ this ->responsePrototype = $ this ->prophesize (ResponseInterface::class);
47
- $ this ->responseFactory = function () {
47
+ $ this ->responseFactory = function (): ResponseInterface {
48
48
return $ this ->responsePrototype ->reveal ();
49
49
};
50
50
}
51
51
52
- public function testConstructor ()
52
+ public function testConstructor (): void
53
53
{
54
54
$ basicAccess = new BasicAccess (
55
55
$ this ->userRepository ->reveal (),
@@ -59,12 +59,10 @@ public function testConstructor()
59
59
$ this ->assertInstanceOf (AuthenticationInterface::class, $ basicAccess );
60
60
}
61
61
62
-
63
62
/**
64
- * @param array $authHeader
65
63
* @dataProvider provideInvalidAuthenticationHeader
66
64
*/
67
- public function testIsAuthenticatedWithInvalidData (array $ authHeader )
65
+ public function testIsAuthenticatedWithInvalidData (array $ authHeader ): void
68
66
{
69
67
$ this ->request
70
68
->getHeader ('Authorization ' )
@@ -77,16 +75,14 @@ public function testIsAuthenticatedWithInvalidData(array $authHeader)
77
75
'test ' ,
78
76
$ this ->responseFactory
79
77
);
78
+
80
79
$ this ->assertNull ($ basicAccess ->authenticate ($ this ->request ->reveal ()));
81
80
}
82
81
83
82
/**
84
- * @param string $username
85
- * @param string $password
86
- * @param array $authHeader
87
83
* @dataProvider provideValidAuthentication
88
84
*/
89
- public function testIsAuthenticatedWithValidCredential (string $ username , string $ password , array $ authHeader )
85
+ public function testIsAuthenticatedWithValidCredential (string $ username , string $ password , array $ authHeader ): void
90
86
{
91
87
$ this ->request
92
88
->getHeader ('Authorization ' )
@@ -112,7 +108,7 @@ public function testIsAuthenticatedWithValidCredential(string $username, string
112
108
$ this ->assertInstanceOf (UserInterface::class, $ user );
113
109
}
114
110
115
- public function testIsAuthenticatedWithNoCredential ()
111
+ public function testIsAuthenticatedWithNoCredential (): void
116
112
{
117
113
$ this ->request
118
114
->getHeader ('Authorization ' )
@@ -131,7 +127,7 @@ public function testIsAuthenticatedWithNoCredential()
131
127
$ this ->assertNull ($ basicAccess ->authenticate ($ this ->request ->reveal ()));
132
128
}
133
129
134
- public function testGetUnauthenticatedResponse ()
130
+ public function testGetUnauthenticatedResponse (): void
135
131
{
136
132
$ this ->responsePrototype
137
133
->getHeader ('WWW-Authenticate ' )
@@ -154,6 +150,19 @@ public function testGetUnauthenticatedResponse()
154
150
$ this ->assertEquals (['Basic realm="test" ' ], $ response ->getHeader ('WWW-Authenticate ' ));
155
151
}
156
152
153
+ /**
154
+ * @psalm-return array{
155
+ * empty-header: array{0: array<empty, empty>},
156
+ * missing-basic-prefix: array{0: array{0: string}},
157
+ * only-username-without-colon: array{0: array{0: string}},
158
+ * base64-encoded-pile-of-poo-emoji: array{0: array{0: string}},
159
+ * pile-of-poo-emoji: array{0: array{0: string}},
160
+ * only-pile-of-poo-emoji: array{0: array{0: string}},
161
+ * basic-prefix-without-content: array{0: array{0: string}},
162
+ * only-basic: array{0: array{0: string}},
163
+ * multiple-auth-headers: array{0: array{0: array{0: string}, 1: array{0: string}}}
164
+ * }
165
+ */
157
166
public function provideInvalidAuthenticationHeader (): array
158
167
{
159
168
return [
@@ -174,6 +183,19 @@ public function provideInvalidAuthenticationHeader(): array
174
183
];
175
184
}
176
185
186
+ /**
187
+ * @psalm-return array{
188
+ * aladdin: array{0: string, 1: string, 2: array{0: string}},
189
+ * aladdin-with-nonzero-array-index: array{0: string, 1: string, 2: array{-200: string}},
190
+ * passwords-with-colon: array{0: string, 1: string, 2: array{0: string}},
191
+ * username-without-password: array{0: string, 1: string, 2: array{0: string}},
192
+ * password-without-username: array{0: string, 1: string, 2: array{0: string}},
193
+ * passwords-with-multiple-colons: array{0: string, 1: string, 2: array{0: string}},
194
+ * no-username-or-password: array{0: string, 1: string, 2: array{0: string}},
195
+ * no-username-password-only-colons: array{0: string, 1: string, 2: array{0: string}},
196
+ * unicode-username-and-password: array{0: string, 1: string, 2: array{0: string}}
197
+ * }
198
+ */
177
199
public function provideValidAuthentication (): array
178
200
{
179
201
return [
0 commit comments