Skip to content

Commit 9492ade

Browse files
committed
Renames Request::setAuth to be a bit more specific.
1 parent 0c5a430 commit 9492ade

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

src/VCR/LibraryHooks/SoapHook.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,12 @@ public function doRequest($request, $location, $action, $version, $one_way = 0,
7373
$vcrRequest->setHeader('Content-Type', $contentType . '; charset=utf-8; action="' . $action . '"');
7474
$vcrRequest->setBody($request);
7575

76-
if (isset($options['login'])) {
77-
$vcrRequest->setAuth($options['login'], $options['password']);
76+
if (!empty($options['login'])) {
77+
$vcrRequest->setAuthorization($options['login'], $options['password']);
7878
}
79+
80+
/* @var \VCR\Response $response */
7981
$requestCallback = self::$requestCallback;
80-
/**
81-
* @var \VCR\Response $response
82-
*/
8382
$response = $requestCallback($vcrRequest);
8483

8584
return $response->getBody();

src/VCR/Request.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ public function toArray()
9494
);
9595
}
9696

97-
9897
/**
9998
* Creates a new Request from a specified array.
10099
*
@@ -272,12 +271,12 @@ public function setBody($body)
272271
}
273272

274273
/**
275-
* Sets the auth credentials.
274+
* Sets the authorization credentials as header.
276275
*
277-
* @param string $username
278-
* @param string $password
276+
* @param string $username Username.
277+
* @param string $password Password.
279278
*/
280-
public function setAuth($username, $password)
279+
public function setAuthorization($username, $password)
281280
{
282281
$this->setHeader('Authorization', 'Basic ' . base64_encode($username . ':' . $password));
283282
}

tests/VCR/RequestTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ public function testSetMethod()
3535
$this->assertEquals('POST', $this->request->getMethod());
3636
}
3737

38+
public function testSetAuthorization()
39+
{
40+
$this->request->setAuthorization('login', 'password');
41+
42+
$this->assertEquals('Basic bG9naW46cGFzc3dvcmQ=', $this->request->getHeader('Authorization'));
43+
}
44+
3845
public function testMatches()
3946
{
4047
$request = new Request('GET', 'http://example.com', array('User-Agent' => 'Unit-Test'));

0 commit comments

Comments
 (0)