Skip to content

Commit

Permalink
Overtrue master (overtrue#31)
Browse files Browse the repository at this point in the history
* Merge custom parameters to codefields

* r

* Fixed data loss when multiple retrieve data.

* fixed

* add support wechat open platform oauth.

* update test
  • Loading branch information
mingyoung authored and overtrue committed Dec 1, 2016
1 parent a785f4d commit 2d773f1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,4 @@ public function offsetUnset($offset)
{
$this->set($offset, null);
}
}
}
13 changes: 9 additions & 4 deletions tests/OAuthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

use Mockery as m;
use Overtrue\Socialite\Config;
use Overtrue\Socialite\AccessTokenInterface;
use Overtrue\Socialite\Providers\AbstractProvider;
use Overtrue\Socialite\User;
Expand Down Expand Up @@ -38,11 +39,12 @@ public function testRedirectUrl()
{
$request = Request::create('foo', 'GET', ['state' => str_repeat('A', 40), 'code' => 'code']);
$request->setSession($session = m::mock('Symfony\Component\HttpFoundation\Session\SessionInterface'));


$provider = new OAuthTwoTestProviderStub($request, 'client_id', 'client_secret');
$provider = new OAuthTwoTestProviderStub($request, new Config([]), 'client_id', 'client_secret');
$this->assertNull($provider->getRedirectUrl());

$provider = new OAuthTwoTestProviderStub($request, 'client_id', 'client_secret', 'redirect_uri');
$provider = new OAuthTwoTestProviderStub($request, new Config([]), 'client_id', 'client_secret', 'redirect_uri');
$this->assertSame('redirect_uri', $provider->getRedirectUrl());
$provider->setRedirectUrl('overtrue.me');
$this->assertSame('overtrue.me', $provider->getRedirectUrl());
Expand All @@ -55,8 +57,10 @@ public function testUserReturnsAUserInstanceForTheAuthenticatedRequest()
{
$request = Request::create('foo', 'GET', ['state' => str_repeat('A', 40), 'code' => 'code']);
$request->setSession($session = m::mock('Symfony\Component\HttpFoundation\Session\SessionInterface'));


$session->shouldReceive('get')->once()->with('state')->andReturn(str_repeat('A', 40));
$provider = new OAuthTwoTestProviderStub($request, 'client_id', 'client_secret', 'redirect_uri');
$provider = new OAuthTwoTestProviderStub($request, new Config([]), 'client_id', 'client_secret', 'redirect_uri');
$provider->http = m::mock('StdClass');
$provider->http->shouldReceive('post')->once()->with('http://token.url', [
'headers' => ['Accept' => 'application/json'], 'form_params' => ['client_id' => 'client_id', 'client_secret' => 'client_secret', 'code' => 'code', 'redirect_uri' => 'redirect_uri'],
Expand Down Expand Up @@ -89,7 +93,7 @@ public function testExceptionisThrownIfAuthorizeFailed()
$request = Request::create('foo', 'GET', ['state' => str_repeat('A', 40), 'code' => 'code']);
$request->setSession($session = m::mock('Symfony\Component\HttpFoundation\Session\SessionInterface'));
$session->shouldReceive('get')->once()->with('state')->andReturn(str_repeat('A', 40));
$provider = new OAuthTwoTestProviderStub($request, 'client_id', 'client_secret', 'redirect_uri');
$provider = new OAuthTwoTestProviderStub($request, new Config([]), 'client_id', 'client_secret', 'redirect_uri');
$provider->http = m::mock('StdClass');
$provider->http->shouldReceive('post')->once()->with('http://token.url', [
'headers' => ['Accept' => 'application/json'], 'form_params' => ['client_id' => 'client_id', 'client_secret' => 'client_secret', 'code' => 'code', 'redirect_uri' => 'redirect_uri'],
Expand Down Expand Up @@ -148,4 +152,5 @@ protected function getHttpClient()

return $this->http = m::mock('StdClass');
}

}

0 comments on commit 2d773f1

Please sign in to comment.