Merge pull request #242 from stevenmaguire/migrate-eventbrite

Removing Eventbrite support and adding link in readme to new package
oauth1test
Phil Sturgeon 2015-03-21 12:34:37 -04:00
commit d4d37ccdb0
3 changed files with 1 additions and 148 deletions

View File

@ -107,7 +107,6 @@ $token = $provider->getAccessToken($grant, ['refresh_token' => $refreshToken]);
This package currently has built-in support for:
- Eventbrite
- Facebook
- Github
- Google
@ -129,6 +128,7 @@ so please help them out with a pull request if you notice this.
- [Auth0](https://github.com/RiskioFr/oauth2-auth0)
- [Battle.net](https://packagist.org/packages/depotwarehouse/oauth2-bnet)
- [Dropbox](https://github.com/pixelfear/oauth2-dropbox)
- [Eventbrite](https://github.com/stevenmaguire/oauth2-eventbrite)
- [FreeAgent](https://github.com/CloudManaged/oauth2-freeagent)
- [Google Nest](https://github.com/JC5/nest-oauth2-provider)
- [Mail.ru](https://packagist.org/packages/aego/oauth2-mailru)

View File

@ -1,51 +0,0 @@
<?php
namespace League\OAuth2\Client\Provider;
use League\OAuth2\Client\Entity\User;
class Eventbrite extends AbstractProvider
{
public $authorizationHeader = 'Bearer';
public function urlAuthorize()
{
return 'https://www.eventbrite.com/oauth/authorize';
}
public function urlAccessToken()
{
return 'https://www.eventbrite.com/oauth/token';
}
public function urlUserDetails(\League\OAuth2\Client\Token\AccessToken $token)
{
return 'https://www.eventbrite.com/json/user_get';
}
public function userDetails($response, \League\OAuth2\Client\Token\AccessToken $token)
{
$user = new User();
$user->exchangeArray([
'uid' => $response->user->user_id,
'email' => $response->user->email,
]);
return $user;
}
public function userUid($response, \League\OAuth2\Client\Token\AccessToken $token)
{
return $response->user->user_id;
}
public function userEmail($response, \League\OAuth2\Client\Token\AccessToken $token)
{
return isset($response->user->email) && $response->user->email ? $response->user->email : null;
}
public function userScreenName($response, \League\OAuth2\Client\Token\AccessToken $token)
{
return $response->user->user_id;
}
}

View File

@ -1,96 +0,0 @@
<?php
namespace League\OAuth2\Client\Test\Provider;
use Mockery as m;
class EventbriteTest extends \PHPUnit_Framework_TestCase
{
protected $provider;
protected function setUp()
{
$this->provider = new \League\OAuth2\Client\Provider\Eventbrite([
'clientId' => 'mock_client_id',
'clientSecret' => 'mock_secret',
'redirectUri' => 'none',
]);
}
public function tearDown()
{
m::close();
parent::tearDown();
}
public function testAuthorizationUrl()
{
$url = $this->provider->getAuthorizationUrl();
$uri = parse_url($url);
parse_str($uri['query'], $query);
$this->assertArrayHasKey('client_id', $query);
$this->assertArrayHasKey('redirect_uri', $query);
$this->assertArrayHasKey('state', $query);
$this->assertArrayHasKey('scope', $query);
$this->assertArrayHasKey('response_type', $query);
$this->assertArrayHasKey('approval_prompt', $query);
$this->assertNotNull($this->provider->state);
}
public function testUrlAccessToken()
{
$url = $this->provider->urlAccessToken();
$uri = parse_url($url);
$this->assertEquals('/oauth/token', $uri['path']);
}
public function testGetAccessToken()
{
$response = m::mock('Guzzle\Http\Message\Response');
$response->shouldReceive('getBody')->times(1)->andReturn('{"access_token": "mock_access_token", "expires": 3600, "refresh_token": "mock_refresh_token", "uid": 1}');
$client = m::mock('Guzzle\Service\Client');
$client->shouldReceive('setBaseUrl')->times(1);
$client->shouldReceive('post->send')->times(1)->andReturn($response);
$this->provider->setHttpClient($client);
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
$this->assertEquals('mock_access_token', $token->accessToken);
$this->assertLessThanOrEqual(time() + 3600, $token->expires);
$this->assertGreaterThanOrEqual(time(), $token->expires);
$this->assertEquals('mock_refresh_token', $token->refreshToken);
$this->assertEquals('1', $token->uid);
}
public function testScopes()
{
$this->assertEquals([], $this->provider->getScopes());
}
public function testUserData()
{
$postResponse = m::mock('Guzzle\Http\Message\Response');
$postResponse->shouldReceive('getBody')->times(1)->andReturn('{"access_token": "mock_access_token", "expires": 3600, "refresh_token": "mock_refresh_token", "uid": 1}');
$getResponse = m::mock('Guzzle\Http\Message\Response');
$getResponse->shouldReceive('getBody')->times(4)->andReturn('{"user": {"user_id": 12345, "email": "mock_email"}}');
$client = m::mock('Guzzle\Service\Client');
$client->shouldReceive('setBaseUrl')->times(5);
$client->shouldReceive('post->send')->times(1)->andReturn($postResponse);
$client->shouldReceive('get->send')->times(4)->andReturn($getResponse);
$client->shouldReceive('setDefaultOption')->times(4);
$this->provider->setHttpClient($client);
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
$user = $this->provider->getUserDetails($token);
$this->assertEquals(12345, $this->provider->getUserUid($token));
$this->assertEquals('mock_email', $this->provider->getUserEmail($token));
$this->assertEquals(12345, $this->provider->getUserScreenName($token));
$this->assertEquals('mock_email', $user->email);
}
}