Skip to content

Commit e5750c8

Browse files
committed
[HttpClient] Fix HttpOptions::setAuthBearer()
1 parent 0d53ac3 commit e5750c8

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

HttpOptions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function setAuthBasic(string $user, string $password = '')
4949
*/
5050
public function setAuthBearer(string $token)
5151
{
52-
$this->options['bearer'] = $token;
52+
$this->options['auth_bearer'] = $token;
5353

5454
return $this;
5555
}

Tests/HttpOptionsTest.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*/
2020
class HttpOptionsTest extends TestCase
2121
{
22-
public function provideSetAuth()
22+
public function provideSetAuthBasic()
2323
{
2424
yield ['user:password', 'user', 'password'];
2525
yield ['user:password', 'user:password'];
@@ -28,10 +28,15 @@ public function provideSetAuth()
2828
}
2929

3030
/**
31-
* @dataProvider provideSetAuth
31+
* @dataProvider provideSetAuthBasic
3232
*/
33-
public function testSetAuth(string $expected, string $user, string $password = '')
33+
public function testSetAuthBasic(string $expected, string $user, string $password = '')
3434
{
3535
$this->assertSame($expected, (new HttpOptions())->setAuthBasic($user, $password)->toArray()['auth_basic']);
3636
}
37+
38+
public function testSetAuthBearer()
39+
{
40+
$this->assertSame('foobar', (new HttpOptions())->setAuthBearer('foobar')->toArray()['auth_bearer']);
41+
}
3742
}

0 commit comments

Comments
 (0)