summaryrefslogtreecommitdiff
path: root/tests/units/Core
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-02-07 12:32:47 -0500
committerFrederic Guillot <fred@kanboard.net>2016-02-07 12:32:47 -0500
commitb34e151d6a9f2d18d8f3baea3bcbae97abee4cc8 (patch)
tree8e779c1a4e79d539223b609d0c92a772a891d185 /tests/units/Core
parent7b9e8897ebbebe4dfca596aa9bdb7ae81ab3f147 (diff)
Use mock object instead of FakeHttpClient class
Diffstat (limited to 'tests/units/Core')
-rw-r--r--tests/units/Core/Http/OAuth2Test.php28
1 files changed, 19 insertions, 9 deletions
diff --git a/tests/units/Core/Http/OAuth2Test.php b/tests/units/Core/Http/OAuth2Test.php
index d703dd7a..c68ae116 100644
--- a/tests/units/Core/Http/OAuth2Test.php
+++ b/tests/units/Core/Http/OAuth2Test.php
@@ -27,17 +27,27 @@ class OAuth2Test extends Base
public function testAccessToken()
{
+ $params = array(
+ 'code' => 'something',
+ 'client_id' => 'A',
+ 'client_secret' => 'B',
+ 'redirect_uri' => 'C',
+ 'grant_type' => 'authorization_code',
+ );
+
+ $response = json_encode(array(
+ 'token_type' => 'bearer',
+ 'access_token' => 'plop',
+ ));
+
+ $this->container['httpClient']
+ ->expects($this->once())
+ ->method('postForm')
+ ->with('E', $params, array('Accept: application/json'))
+ ->will($this->returnValue($response));
+
$oauth = new OAuth2($this->container);
$oauth->createService('A', 'B', 'C', 'D', 'E', array('f', 'g'));
$oauth->getAccessToken('something');
-
- $data = $this->container['httpClient']->getData();
- $this->assertEquals('something', $data['code']);
- $this->assertEquals('A', $data['client_id']);
- $this->assertEquals('B', $data['client_secret']);
- $this->assertEquals('C', $data['redirect_uri']);
- $this->assertEquals('authorization_code', $data['grant_type']);
-
- $this->assertEquals('E', $this->container['httpClient']->getUrl());
}
}