diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-02-07 12:32:47 -0500 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-02-07 12:32:47 -0500 |
commit | b34e151d6a9f2d18d8f3baea3bcbae97abee4cc8 (patch) | |
tree | 8e779c1a4e79d539223b609d0c92a772a891d185 /tests/units/Core | |
parent | 7b9e8897ebbebe4dfca596aa9bdb7ae81ab3f147 (diff) |
Use mock object instead of FakeHttpClient class
Diffstat (limited to 'tests/units/Core')
-rw-r--r-- | tests/units/Core/Http/OAuth2Test.php | 28 |
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()); } } |