2014-04-25 23:53:08 +04:00
|
|
|
<?php
|
|
|
|
|
2014-05-04 21:51:12 +04:00
|
|
|
namespace League\OAuth2\Client\Test\Provider;
|
2014-04-25 23:53:08 +04:00
|
|
|
|
|
|
|
|
2014-05-04 21:51:12 +04:00
|
|
|
class AbstractProviderTest extends \PHPUnit_Framework_TestCase
|
2014-04-25 23:53:08 +04:00
|
|
|
{
|
|
|
|
protected $provider;
|
|
|
|
|
|
|
|
protected function setUp()
|
|
|
|
{
|
2014-11-09 00:30:40 +03:00
|
|
|
$this->provider = new \League\OAuth2\Client\Provider\Google([
|
2014-04-25 23:53:08 +04:00
|
|
|
'clientId' => 'mock_client_id',
|
|
|
|
'clientSecret' => 'mock_secret',
|
|
|
|
'redirectUri' => 'none',
|
2014-11-09 00:30:40 +03:00
|
|
|
]);
|
2014-04-25 23:53:08 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @expectedException InvalidArgumentException
|
|
|
|
*/
|
|
|
|
public function testInvalidGrantString()
|
|
|
|
{
|
2014-11-09 00:30:40 +03:00
|
|
|
$this->provider->getAccessToken('invalid_grant', ['invalid_parameter' => 'none']);
|
2014-04-25 23:53:08 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @expectedException InvalidArgumentException
|
|
|
|
*/
|
|
|
|
public function testInvalidGrantObject()
|
|
|
|
{
|
2014-11-09 00:30:40 +03:00
|
|
|
$grant = new \StdClass();
|
|
|
|
$this->provider->getAccessToken($grant, ['invalid_parameter' => 'none']);
|
2014-04-25 23:53:08 +04:00
|
|
|
}
|
2014-11-26 16:57:23 +03:00
|
|
|
|
|
|
|
public function testAuthorizationUrlStateParam()
|
|
|
|
{
|
|
|
|
$this->assertContains('state=XXX', $this->provider->getAuthorizationUrl([
|
|
|
|
'state' => 'XXX'
|
|
|
|
]));
|
|
|
|
}
|
|
|
|
|
2014-04-25 23:53:08 +04:00
|
|
|
}
|