Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 59e6380

Browse files
minor #30564 [HttpClient] Fix HttpOptions::setAuthBearer() (dunglas)
This PR was merged into the 4.3-dev branch. Discussion ---------- [HttpClient] Fix HttpOptions::setAuthBearer() | Q | A | ------------- | --- | Branch? | master <!-- see below --> | Bug fix? | yes | New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | n/a <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | n/a I messed up the option name while rebasing... Commits ------- 7308e5a [HttpClient] Fix HttpOptions::setAuthBearer()
2 parents 8af6395 + 7308e5a commit 59e6380

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/Symfony/Component/HttpClient/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
}

src/Symfony/Component/HttpClient/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)