Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
141 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
/** | ||
* @author AlloVince | ||
* @copyright Copyright (c) 2015 EvaEngine Team (https://github.com/EvaEngine) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
*/ | ||
|
||
namespace Eva\EvaOAuth\OAuth2\Providers; | ||
|
||
use Eva\EvaOAuth\OAuth2\ResourceServerInterface; | ||
|
||
/** | ||
* Class Weibo | ||
* @package Eva\EvaOAuth\OAuth2\Providers | ||
*/ | ||
class Weibo extends AbstractProvider | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $authorizeUrl = 'https://api.weibo.com/oauth2/authorize'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $accessTokenUrl = 'https://api.weibo.com/oauth2/access_token'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $accessTokenFormat = ResourceServerInterface::FORMAT_JSON; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
|
||
namespace Eva\EvaOAuthTest; | ||
|
||
use Eva\EvaOAuth\Service; | ||
use Eva\EvaOAuth\OAuth1\Consumer; | ||
use Eva\EvaOAuth\OAuth2\Client; | ||
|
||
class ServiceTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
|
||
public function setUp() | ||
{ | ||
} | ||
|
||
/** | ||
* @expectedException Eva\EvaOAuth\Exception\BadMethodCallException | ||
*/ | ||
public function testNotExistProvider() | ||
{ | ||
new Service('foo_service', []); | ||
} | ||
|
||
public function testConstruct() | ||
{ | ||
$service = new Service('douban', [ | ||
'key' => 'test_key', | ||
'secret' => 'test_secret', | ||
'callback' => 'test_callback', | ||
]); | ||
$this->assertInstanceOf('Eva\EvaOAuth\OAuth2\Client', $service->getAdapter()); | ||
|
||
$service = new Service('twitter', [ | ||
'key' => 'test_key', | ||
'secret' => 'test_secret', | ||
'callback' => 'test_callback', | ||
]); | ||
$this->assertInstanceOf('Eva\EvaOAuth\OAuth1\Consumer', $service->getAdapter()); | ||
} | ||
|
||
/** | ||
* @expectedException Eva\EvaOAuth\Exception\InvalidArgumentException | ||
*/ | ||
public function testProviderInterface() | ||
{ | ||
\Mockery::namedMock('FooProvider'); | ||
Service::registerProvider('foo', 'FooProvider'); | ||
$service = new Service('foo', [ | ||
'key' => 'test_key', | ||
'secret' => 'test_secret', | ||
'callback' => 'test_callback', | ||
]); | ||
} | ||
|
||
public function testRegisterProvider() | ||
{ | ||
\Mockery::namedMock('FooOAuth2Provider', 'Eva\EvaOAuth\OAuth2\Providers\AbstractProvider'); | ||
\Mockery::namedMock('BarOAuth1Provider', 'Eva\EvaOAuth\OAuth1\Providers\AbstractProvider'); | ||
Service::registerProviders([ | ||
'foo' => 'FooOAuth2Provider', | ||
'bar' => 'BarOAuth2Provider', | ||
]); | ||
$this->assertArrayHasKey('foo', Service::getProviders()); | ||
$this->assertArrayHasKey('bar', Service::getProviders()); | ||
|
||
$service = new Service('foo', [ | ||
'key' => 'test_key', | ||
'secret' => 'test_secret', | ||
'callback' => 'test_callback', | ||
]); | ||
$this->assertInstanceOf('FooOAuth2Provider', $service->getProvider()); | ||
} | ||
} |