
7 changed files with 108 additions and 16 deletions
@ -1,5 +1,8 @@ |
|||
/vendor/ |
|||
/composer.lock |
|||
vendor/ |
|||
composer.lock |
|||
composer.phar |
|||
.DS_Store |
|||
/testing/ |
|||
/nbproject/private/ |
|||
testing/ |
|||
nbproject/private/ |
|||
test/log |
|||
build |
|||
|
@ -1,5 +1,43 @@ |
|||
<?php |
|||
|
|||
if ( ! @include_once __DIR__ . '/../vendor/autoload.php') { |
|||
exit("You must set up the project dependencies, run the following commands:\n> wget http://getcomposer.org/composer.phar\n> php composer.phar install\n"); |
|||
namespace LeagueTests\OAuth2\Client; |
|||
|
|||
error_reporting(E_ALL | E_STRICT); |
|||
chdir(__DIR__); |
|||
|
|||
/** |
|||
* Test bootstrap, for setting up autoloading |
|||
* |
|||
* @subpackage UnitTest |
|||
*/ |
|||
class Bootstrap |
|||
{ |
|||
protected static $serviceManager; |
|||
|
|||
public static function init() |
|||
{ |
|||
static::initAutoloader(); |
|||
} |
|||
|
|||
protected static function initAutoloader() |
|||
{ |
|||
$vendorPath = static::findParentPath('vendor'); |
|||
|
|||
$loader = include $vendorPath . '/autoload.php'; |
|||
} |
|||
|
|||
protected static function findParentPath($path) |
|||
{ |
|||
$dir = __DIR__; |
|||
$previousDir = '.'; |
|||
while (!is_dir($dir . '/' . $path)) { |
|||
$dir = dirname($dir); |
|||
if ($previousDir === $dir) return false; |
|||
$previousDir = $dir; |
|||
} |
|||
|
|||
return $dir . '/' . $path; |
|||
} |
|||
} |
|||
|
|||
Bootstrap::init(); |
|||
|
@ -0,0 +1,54 @@ |
|||
<?php |
|||
|
|||
namespace LeagueTest\OAuth2\Client\Provider; |
|||
|
|||
use \Mockery as m; |
|||
use Zend\Uri\UriFactory; |
|||
|
|||
class GithubTest extends \PHPUnit_Framework_TestCase |
|||
{ |
|||
protected $provider; |
|||
|
|||
protected function setUp() |
|||
{ |
|||
$this->provider = new \League\OAuth2\Client\Provider\Github(array( |
|||
'clientId' => 'mock', |
|||
'clientSecret' => 'mock_secret', |
|||
'redirectUri' => 'none', |
|||
)); |
|||
} |
|||
|
|||
protected function tearDown() |
|||
{ |
|||
# m::close(); |
|||
} |
|||
|
|||
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); |
|||
} |
|||
|
|||
public function testUrlAccessToken() |
|||
{ |
|||
$url = $this->provider->urlAccessToken(); |
|||
$uri = parse_url($url); |
|||
|
|||
$this->assertEquals('/login/oauth/access_token', $uri['path']); |
|||
} |
|||
|
|||
/* |
|||
public function testGetAccessToken() |
|||
{ |
|||
$t = $this->provider->getAccessToken('authorization_code', array('code' => 'mock_authorization_code')); |
|||
} |
|||
*/ |
|||
} |
Loading…
Reference in new issue