Skip to content

Commit

Permalink
Release 0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Art4 committed Nov 1, 2016
1 parent 39300c0 commit 276d785
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 24 deletions.
15 changes: 9 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

## [0.5] - 2016-11-01

### Added

- Implementation for OAuth2 Authorization Code Grant was added.
Expand All @@ -18,7 +20,7 @@ All notable changes to this project will be documented in this file.

### Changed

- [Youthweb API 0.6](https://github.com/youthweb/youthweb-api/releases/tag/0.6) Support.
- [Youthweb-API 0.6](https://github.com/youthweb/youthweb-api/releases/tag/0.6) Support.
- **Breaking:** All classes are set to `final` and implement interfaces. All protected methods are now private. If you had extend some classes, implement the interface instead.
- **Breaking:** `$data` in `Client::getUnauthorized()`, `Client::getUnauthorized()` and `Client::postUnauthorized()` must be an array. It cannot be `null` anymore.
- Switch LICENSE from GPLv2 to GPLv3.
Expand All @@ -39,7 +41,7 @@ All notable changes to this project will be documented in this file.

### Changed

- [Youthweb API 0.5](https://github.com/youthweb/youthweb-api/releases/tag/0.5) Support
- [Youthweb-API 0.5](https://github.com/youthweb/youthweb-api/releases/tag/0.5) Support

### Added

Expand All @@ -50,7 +52,7 @@ All notable changes to this project will be documented in this file.

### Changed

- [Youthweb API 0.3](https://github.com/youthweb/youthweb-api/releases/tag/0.3) Support
- [Youthweb-API 0.3](https://github.com/youthweb/youthweb-api/releases/tag/0.3) Support
- **Breaking:** API Resources return the data as `Art4\JsonApiClient\Document` object instead of `stdClass`

### Removed
Expand All @@ -62,7 +64,7 @@ All notable changes to this project will be documented in this file.

### Added

- [Youthweb API 0.2](https://github.com/youthweb/youthweb-api/releases/tag/0.2) Support
- [Youthweb-API 0.2](https://github.com/youthweb/youthweb-api/releases/tag/0.2) Support
- phpunit tests
- Travis-CI Support
- this CHANGELOG.md
Expand All @@ -71,10 +73,11 @@ All notable changes to this project will be documented in this file.

### Added

- First workable client for Youthweb API [Version 0.1](https://github.com/youthweb/youthweb-api/releases/tag/0.1)
- First workable client for Youthweb-API [Version 0.1](https://github.com/youthweb/youthweb-api/releases/tag/0.1)
- Http client based on [guzzlehttp/guzzle ~5.0](https://github.com/guzzle/guzzle)

[Unreleased]: https://github.com/youthweb/php-youthweb-api/compare/0.4...HEAD
[Unreleased]: https://github.com/youthweb/php-youthweb-api/compare/0.5...HEAD
[0.5]: https://github.com/youthweb/php-youthweb-api/compare/0.4...0.5
[0.4]: https://github.com/youthweb/php-youthweb-api/compare/0.3...0.4
[0.3]: https://github.com/youthweb/php-youthweb-api/compare/0.2...0.3
[0.2]: https://github.com/youthweb/php-youthweb-api/compare/0.1...0.2
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{
"name": "Artur Weigandt",
"email": "[email protected]",
"homepage": "http://wlabs.de"
"homepage": "https://wlabs.de"
}
],
"require": {
Expand Down
6 changes: 3 additions & 3 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ public function getState()
*/
public function get($path, array $data = [])
{
$data['headers']['Authorization'] = 'Bearer ' . $this->getBearerToken();
$data['headers']['Authorization'] = 'Bearer ' . $this->getAccessToken();

$request = $this->createRequest('GET', $this->getUrl() . $path, $data);

Expand Down Expand Up @@ -589,9 +589,9 @@ private function getOauth2Provider()
*
* @throws UnauthorizedException contains the url to get an authorization code
*
* @return string The Bearer token incl. type e.g. "Bearer jcx45..."
* @return string The Bearer token, e.g. "jcx45..."
*/
private function getBearerToken()
private function getAccessToken()
{
if ( ! $this->isAuthorized() )
{
Expand Down
34 changes: 20 additions & 14 deletions tests/unit/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,6 @@ public function testHandleClientExceptionWithResponseException()
$request_factory = $this->createMock('Youthweb\Api\RequestFactoryInterface');
$request = $this->createMock('Psr\Http\Message\RequestInterface');
$response = $this->createMock('Psr\Http\Message\ResponseInterface');
$exception = $this->createMock('GuzzleHttp\Exception\ClientException');
$http_client = $this->createMock('Youthweb\Api\HttpClientInterface');
$auth_resource = $this->createMock('Youthweb\Api\Resource\AuthInterface');
$resource_factory = $this->createMock('Youthweb\Api\ResourceFactoryInterface');
Expand All @@ -742,7 +741,7 @@ public function testHandleClientExceptionWithResponseException()
->method('isHit')
->willReturn(false);

$cache_provider->expects($this->exactly(2))
$cache_provider->expects($this->exactly(3))
->method('getItem')
->will($this->returnValueMap([
['php_youthweb_api.access_token', $cache_item_access],
Expand All @@ -756,9 +755,11 @@ public function testHandleClientExceptionWithResponseException()
->method('getBody')
->willReturn($body);

$exception->expects($this->once())
->method('getResponse')
->willReturn($response);
$response->expects($this->once())
->method('getStatusCode')
->willReturn(401);

$exception = new \GuzzleHttp\Exception\ClientException('The server responses with an unknown error.', $request, $response);

$http_client->expects($this->once())
->method('send')
Expand Down Expand Up @@ -787,7 +788,8 @@ public function testHandleClientExceptionWithResponseException()

$this->setExpectedException(
'Exception',
'Unauthorized'
'Unauthorized',
401
);

$client->get('foobar');
Expand All @@ -800,7 +802,6 @@ public function testHandleClientExceptionWithDetailResponseException()
{
$body = $this->createMock('Psr\Http\Message\StreamInterface');
$response = $this->createMock('Psr\Http\Message\ResponseInterface');
$exception = $this->createMock('GuzzleHttp\Exception\ClientException');
$cache_provider = $this->createMock('Psr\Cache\CacheItemPoolInterface');
$cache_item_access = $this->createMock('Psr\Cache\CacheItemInterface');
$request_factory = $this->createMock('Youthweb\Api\RequestFactoryInterface');
Expand All @@ -817,15 +818,15 @@ public function testHandleClientExceptionWithDetailResponseException()
->method('getBody')
->willReturn($body);

$exception->expects($this->once())
->method('getResponse')
->willReturn($response);
$response->expects($this->once())
->method('getStatusCode')
->willReturn(401);

$cache_item_access->expects($this->exactly(2))
->method('isHit')
->willReturn(false);

$cache_provider->expects($this->exactly(2))
$cache_provider->expects($this->exactly(3))
->method('getItem')
->will($this->returnValueMap([
['php_youthweb_api.access_token', $cache_item_access],
Expand All @@ -835,6 +836,8 @@ public function testHandleClientExceptionWithDetailResponseException()
->method('createRequest')
->willReturn($request);

$exception = new \GuzzleHttp\Exception\ClientException('error message', $request, $response);

$http_client->expects($this->once())
->method('send')
->will($this->throwException($exception));
Expand Down Expand Up @@ -862,7 +865,8 @@ public function testHandleClientExceptionWithDetailResponseException()

$this->setExpectedException(
'Exception',
'Detailed error message'
'Detailed error message',
401
);

$client->get('foobar');
Expand All @@ -873,11 +877,12 @@ public function testHandleClientExceptionWithDetailResponseException()
*/
public function testHandleClientExceptionWithException()
{
$exception = $this->createMock('\Exception');
$http_client = $this->createMock('Youthweb\Api\HttpClientInterface');
$request_factory = $this->createMock('Youthweb\Api\RequestFactoryInterface');
$request = $this->createMock('Psr\Http\Message\RequestInterface');

$exception = new \Exception('error message', 0);

$http_client->expects($this->once())
->method('send')
->will($this->throwException($exception));
Expand All @@ -896,7 +901,8 @@ public function testHandleClientExceptionWithException()

$this->setExpectedException(
'Exception',
'The server responses with an unknown error.'
'The server responses with an unknown error.',
0
);

$client->getUnauthorized('foobar');
Expand Down

0 comments on commit 276d785

Please sign in to comment.