Skip to content

Commit

Permalink
[HttpClient] Fix HttpOptions::setAuthBearer()
Browse files Browse the repository at this point in the history
  • Loading branch information
dunglas committed Mar 14, 2019
1 parent 8af6395 commit 7308e5a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Symfony/Component/HttpClient/HttpOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function setAuthBasic(string $user, string $password = '')
*/
public function setAuthBearer(string $token)
{
$this->options['bearer'] = $token;
$this->options['auth_bearer'] = $token;

return $this;
}
Expand Down
11 changes: 8 additions & 3 deletions src/Symfony/Component/HttpClient/Tests/HttpOptionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/
class HttpOptionsTest extends TestCase
{
public function provideSetAuth()
public function provideSetAuthBasic()
{
yield ['user:password', 'user', 'password'];
yield ['user:password', 'user:password'];
Expand All @@ -28,10 +28,15 @@ public function provideSetAuth()
}

/**
* @dataProvider provideSetAuth
* @dataProvider provideSetAuthBasic
*/
public function testSetAuth(string $expected, string $user, string $password = '')
public function testSetAuthBasic(string $expected, string $user, string $password = '')
{
$this->assertSame($expected, (new HttpOptions())->setAuthBasic($user, $password)->toArray()['auth_basic']);
}

public function testSetAuthBearer()
{
$this->assertSame('foobar', (new HttpOptions())->setAuthBearer('foobar')->toArray()['auth_bearer']);
}
}

0 comments on commit 7308e5a

Please sign in to comment.