CS fixes
parent
660dd93fb6
commit
ca6745027a
|
@ -52,7 +52,7 @@ class User
|
|||
|
||||
public function getArrayCopy()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
'uid' => $this->uid,
|
||||
'nickname' => $this->nickname,
|
||||
'name' => $this->name,
|
||||
|
@ -65,7 +65,7 @@ class User
|
|||
'urls' => $this->urls,
|
||||
'gender' => $this->gender,
|
||||
'locale' => $this->locale,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
public function exchangeArray(array $data)
|
||||
|
|
|
@ -13,19 +13,13 @@ class IDPException extends \Exception
|
|||
$code = isset($result['code']) ? $result['code'] : 0;
|
||||
|
||||
if (isset($result['error'])) {
|
||||
|
||||
// OAuth 2.0 Draft 10 style
|
||||
$message = $result['error'];
|
||||
|
||||
} elseif (isset($result['message'])) {
|
||||
|
||||
// cURL style
|
||||
$message = $result['message'];
|
||||
|
||||
} else {
|
||||
|
||||
$message = 'Unknown Error.';
|
||||
|
||||
}
|
||||
|
||||
parent::__construct($message, $code);
|
||||
|
@ -34,7 +28,6 @@ class IDPException extends \Exception
|
|||
public function getType()
|
||||
{
|
||||
if (isset($this->result['error'])) {
|
||||
|
||||
$message = $this->result['error'];
|
||||
|
||||
if (is_string($message)) {
|
||||
|
@ -53,12 +46,12 @@ class IDPException extends \Exception
|
|||
*/
|
||||
public function __toString()
|
||||
{
|
||||
$str = $this->getType() . ': ';
|
||||
$str = $this->getType().': ';
|
||||
|
||||
if ($this->code != 0) {
|
||||
$str .= $this->code . ': ';
|
||||
$str .= $this->code.': ';
|
||||
}
|
||||
|
||||
return $str . $this->message;
|
||||
return $str.$this->message;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ class AuthorizationCode implements GrantInterface
|
|||
return array_merge($defaultParams, $params);
|
||||
}
|
||||
|
||||
public function handleResponse($response = array())
|
||||
public function handleResponse($response = [])
|
||||
{
|
||||
return new AccessToken($response);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ interface GrantInterface
|
|||
{
|
||||
public function __toString();
|
||||
|
||||
public function handleResponse($response = array());
|
||||
public function handleResponse($response = []);
|
||||
|
||||
public function prepRequestParams($defaultParams, $params);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ class RefreshToken implements GrantInterface
|
|||
return array_merge($defaultParams, $params);
|
||||
}
|
||||
|
||||
public function handleResponse($response = array())
|
||||
public function handleResponse($response = [])
|
||||
{
|
||||
return new AccessToken($response);
|
||||
}
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
namespace League\OAuth2\Client\Provider;
|
||||
|
||||
use Guzzle\Service\Client as GuzzleClient;
|
||||
use Guzzle\Http\Exception\BadResponseException;
|
||||
use League\OAuth2\Client\Token\AccessToken as AccessToken;
|
||||
use Guzzle\Service\Client as GuzzleClient;
|
||||
use League\OAuth2\Client\Exception\IDPException as IDPException;
|
||||
use League\OAuth2\Client\Grant\GrantInterface;
|
||||
use League\OAuth2\Client\Token\AccessToken as AccessToken;
|
||||
|
||||
abstract class AbstractProvider implements ProviderInterface
|
||||
{
|
||||
|
@ -22,7 +22,7 @@ abstract class AbstractProvider implements ProviderInterface
|
|||
|
||||
public $uidKey = 'uid';
|
||||
|
||||
public $scopes = array();
|
||||
public $scopes = [];
|
||||
|
||||
public $method = 'post';
|
||||
|
||||
|
@ -40,7 +40,7 @@ abstract class AbstractProvider implements ProviderInterface
|
|||
*/
|
||||
protected $httpBuildEncType = 1;
|
||||
|
||||
public function __construct($options = array())
|
||||
public function __construct($options = [])
|
||||
{
|
||||
foreach ($options as $option => $value) {
|
||||
if (isset($this->{$option})) {
|
||||
|
@ -48,7 +48,7 @@ abstract class AbstractProvider implements ProviderInterface
|
|||
}
|
||||
}
|
||||
|
||||
$this->setHttpClient(new GuzzleClient);
|
||||
$this->setHttpClient(new GuzzleClient());
|
||||
}
|
||||
|
||||
public function setHttpClient(GuzzleClient $client)
|
||||
|
@ -83,51 +83,51 @@ abstract class AbstractProvider implements ProviderInterface
|
|||
$this->scopes = $scopes;
|
||||
}
|
||||
|
||||
public function getAuthorizationUrl($options = array())
|
||||
public function getAuthorizationUrl($options = [])
|
||||
{
|
||||
$this->state = md5(uniqid(rand(), true));
|
||||
|
||||
$params = array(
|
||||
$params = [
|
||||
'client_id' => $this->clientId,
|
||||
'redirect_uri' => $this->redirectUri,
|
||||
'state' => $this->state,
|
||||
'scope' => is_array($this->scopes) ? implode($this->scopeSeparator, $this->scopes) : $this->scopes,
|
||||
'response_type' => isset($options['response_type']) ? $options['response_type'] : 'code',
|
||||
'approval_prompt' => 'auto'
|
||||
);
|
||||
'approval_prompt' => 'auto',
|
||||
];
|
||||
|
||||
return $this->urlAuthorize() . '?' . $this->httpBuildQuery($params, '', '&');
|
||||
return $this->urlAuthorize().'?'.$this->httpBuildQuery($params, '', '&');
|
||||
}
|
||||
|
||||
// @codeCoverageIgnoreStart
|
||||
public function authorize($options = array())
|
||||
public function authorize($options = [])
|
||||
{
|
||||
header('Location: ' . $this->getAuthorizationUrl($options));
|
||||
header('Location: '.$this->getAuthorizationUrl($options));
|
||||
exit;
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
||||
public function getAccessToken($grant = 'authorization_code', $params = array())
|
||||
public function getAccessToken($grant = 'authorization_code', $params = [])
|
||||
{
|
||||
if (is_string($grant)) {
|
||||
// PascalCase the grant. E.g: 'authorization_code' becomes 'AuthorizationCode'
|
||||
$className = str_replace(' ', '', ucwords(str_replace(array('-', '_'), ' ', $grant)));
|
||||
$className = str_replace(' ', '', ucwords(str_replace(['-', '_'], ' ', $grant)));
|
||||
$grant = 'League\\OAuth2\\Client\\Grant\\'.$className;
|
||||
if (! class_exists($grant)) {
|
||||
throw new \InvalidArgumentException('Unknown grant "'.$grant.'"');
|
||||
}
|
||||
$grant = new $grant;
|
||||
$grant = new $grant();
|
||||
} elseif (! $grant instanceof GrantInterface) {
|
||||
$message = get_class($grant).' is not an instance of League\OAuth2\Client\Grant\GrantInterface';
|
||||
throw new \InvalidArgumentException($message);
|
||||
}
|
||||
|
||||
$defaultParams = array(
|
||||
$defaultParams = [
|
||||
'client_id' => $this->clientId,
|
||||
'client_secret' => $this->clientSecret,
|
||||
'redirect_uri' => $this->redirectUri,
|
||||
'grant_type' => $grant,
|
||||
);
|
||||
];
|
||||
|
||||
$requestParams = $grant->prepRequestParams($defaultParams, $params);
|
||||
|
||||
|
@ -137,7 +137,7 @@ abstract class AbstractProvider implements ProviderInterface
|
|||
// @codeCoverageIgnoreStart
|
||||
// No providers included with this library use get but 3rd parties may
|
||||
$client = $this->getHttpClient();
|
||||
$client->setBaseUrl($this->urlAccessToken() . '?' . $this->httpBuildQuery($requestParams, '', '&'));
|
||||
$client->setBaseUrl($this->urlAccessToken().'?'.$this->httpBuildQuery($requestParams, '', '&'));
|
||||
$request = $client->send();
|
||||
$response = $request->getBody();
|
||||
break;
|
||||
|
@ -235,7 +235,6 @@ abstract class AbstractProvider implements ProviderInterface
|
|||
$url = $this->urlUserDetails($token);
|
||||
|
||||
try {
|
||||
|
||||
$client = $this->getHttpClient();
|
||||
$client->setBaseUrl($url);
|
||||
|
||||
|
@ -245,7 +244,6 @@ abstract class AbstractProvider implements ProviderInterface
|
|||
|
||||
$request = $client->get()->send();
|
||||
$response = $request->getBody();
|
||||
|
||||
} catch (BadResponseException $e) {
|
||||
// @codeCoverageIgnoreStart
|
||||
$raw_response = explode("\n", $e->getResponse());
|
||||
|
|
|
@ -6,13 +6,12 @@ use League\OAuth2\Client\Entity\User;
|
|||
|
||||
class Eventbrite extends AbstractProvider
|
||||
{
|
||||
|
||||
public function __construct($options)
|
||||
{
|
||||
parent::__construct($options);
|
||||
$this->headers = array(
|
||||
'Authorization' => 'Bearer'
|
||||
);
|
||||
$this->headers = [
|
||||
'Authorization' => 'Bearer',
|
||||
];
|
||||
}
|
||||
|
||||
public function urlAuthorize()
|
||||
|
@ -32,11 +31,11 @@ class Eventbrite extends AbstractProvider
|
|||
|
||||
public function userDetails($response, \League\OAuth2\Client\Token\AccessToken $token)
|
||||
{
|
||||
$user = new User;
|
||||
$user->exchangeArray(array(
|
||||
$user = new User();
|
||||
$user->exchangeArray([
|
||||
'uid' => $response->user->user_id,
|
||||
'email' => $response->user->email,
|
||||
));
|
||||
]);
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ use League\OAuth2\Client\Entity\User;
|
|||
|
||||
class Facebook extends AbstractProvider
|
||||
{
|
||||
public $scopes = array('offline_access', 'email', 'read_stream');
|
||||
public $scopes = ['offline_access', 'email', 'read_stream'];
|
||||
public $responseType = 'string';
|
||||
|
||||
public function urlAuthorize()
|
||||
|
@ -27,12 +27,12 @@ class Facebook extends AbstractProvider
|
|||
public function userDetails($response, \League\OAuth2\Client\Token\AccessToken $token)
|
||||
{
|
||||
$client = $this->getHttpClient();
|
||||
$client->setBaseUrl('https://graph.facebook.com/me/picture?type=normal&access_token=' . $token->accessToken);
|
||||
$client->setBaseUrl('https://graph.facebook.com/me/picture?type=normal&access_token='.$token->accessToken);
|
||||
$request = $client->get()->send();
|
||||
$info = $request->getInfo();
|
||||
$imageUrl = $info['url'];
|
||||
|
||||
$user = new User;
|
||||
$user = new User();
|
||||
|
||||
$username = (isset($response->username)) ? $response->username : null;
|
||||
$email = (isset($response->email)) ? $response->email : null;
|
||||
|
@ -40,7 +40,7 @@ class Facebook extends AbstractProvider
|
|||
$description = (isset($response->bio)) ? $response->bio : null;
|
||||
$imageUrl = ($imageUrl) ?: null;
|
||||
|
||||
$user->exchangeArray(array(
|
||||
$user->exchangeArray([
|
||||
'uid' => $response->id,
|
||||
'nickname' => $username,
|
||||
'name' => $response->name,
|
||||
|
@ -50,8 +50,8 @@ class Facebook extends AbstractProvider
|
|||
'location' => $location,
|
||||
'description' => $description,
|
||||
'imageurl' => $imageUrl,
|
||||
'urls' => array( 'Facebook' => $response->link ),
|
||||
));
|
||||
'urls' => [ 'Facebook' => $response->link ],
|
||||
]);
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
@ -68,6 +68,6 @@ class Facebook extends AbstractProvider
|
|||
|
||||
public function userScreenName($response, \League\OAuth2\Client\Token\AccessToken $token)
|
||||
{
|
||||
return array($response->first_name, $response->last_name);
|
||||
return [$response->first_name, $response->last_name];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,20 +25,20 @@ class Github extends AbstractProvider
|
|||
|
||||
public function userDetails($response, \League\OAuth2\Client\Token\AccessToken $token)
|
||||
{
|
||||
$user = new User;
|
||||
$user = new User();
|
||||
|
||||
$name = (isset($response->name)) ? $response->name : null;
|
||||
$email = (isset($response->email)) ? $response->email : null;
|
||||
|
||||
$user->exchangeArray(array(
|
||||
$user->exchangeArray([
|
||||
'uid' => $response->id,
|
||||
'nickname' => $response->login,
|
||||
'name' => $name,
|
||||
'email' => $email,
|
||||
'urls' =>array(
|
||||
'GitHub' => 'http://github.com/' . $response->login,
|
||||
),
|
||||
));
|
||||
'urls' => [
|
||||
'GitHub' => 'http://github.com/'.$response->login,
|
||||
],
|
||||
]);
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
|
|
@ -8,10 +8,10 @@ class Google extends AbstractProvider
|
|||
{
|
||||
public $scopeSeparator = ' ';
|
||||
|
||||
public $scopes = array(
|
||||
public $scopes = [
|
||||
'https://www.googleapis.com/auth/userinfo.profile',
|
||||
'https://www.googleapis.com/auth/userinfo.email'
|
||||
);
|
||||
'https://www.googleapis.com/auth/userinfo.email',
|
||||
];
|
||||
|
||||
public function urlAuthorize()
|
||||
{
|
||||
|
@ -32,18 +32,18 @@ class Google extends AbstractProvider
|
|||
{
|
||||
$response = (array) $response;
|
||||
|
||||
$user = new User;
|
||||
$user = new User();
|
||||
|
||||
$imageUrl = (isset($response['picture'])) ? $response['picture'] : null;
|
||||
|
||||
$user->exchangeArray(array(
|
||||
$user->exchangeArray([
|
||||
'uid' => $response['id'],
|
||||
'name' => $response['name'],
|
||||
'firstname' => $response['given_name'],
|
||||
'lastName' => $response['family_name'],
|
||||
'email' => $response['email'],
|
||||
'imageUrl' => $imageUrl,
|
||||
));
|
||||
]);
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
@ -60,6 +60,6 @@ class Google extends AbstractProvider
|
|||
|
||||
public function userScreenName($response, \League\OAuth2\Client\Token\AccessToken $token)
|
||||
{
|
||||
return array($response->given_name, $response->family_name);
|
||||
return [$response->given_name, $response->family_name];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ use League\OAuth2\Client\Entity\User;
|
|||
|
||||
class Instagram extends AbstractProvider
|
||||
{
|
||||
public $scopes = array('basic');
|
||||
public $scopes = ['basic'];
|
||||
public $responseType = 'json';
|
||||
|
||||
public function urlAuthorize()
|
||||
|
@ -26,18 +26,17 @@ class Instagram extends AbstractProvider
|
|||
|
||||
public function userDetails($response, \League\OAuth2\Client\Token\AccessToken $token)
|
||||
{
|
||||
|
||||
$user = new User;
|
||||
$user = new User();
|
||||
|
||||
$description = (isset($response->data->bio)) ? $response->data->bio : null;
|
||||
|
||||
$user->exchangeArray(array(
|
||||
$user->exchangeArray([
|
||||
'uid' => $response->data->id,
|
||||
'nickname' => $response->data->username,
|
||||
'name' => $response->data->full_name,
|
||||
'description' => $description,
|
||||
'imageUrl' => $response->data->profile_picture,
|
||||
));
|
||||
]);
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
|
|
@ -7,12 +7,12 @@ use League\OAuth2\Client\Token\AccessToken;
|
|||
|
||||
class LinkedIn extends AbstractProvider
|
||||
{
|
||||
public $scopes = array('r_basicprofile r_emailaddress r_contactinfo');
|
||||
public $scopes = ['r_basicprofile r_emailaddress r_contactinfo'];
|
||||
public $responseType = 'json';
|
||||
public $fields = array(
|
||||
public $fields = [
|
||||
'id', 'email-address', 'first-name', 'last-name', 'headline',
|
||||
'location', 'industry', 'picture-url', 'public-profile-url'
|
||||
);
|
||||
'location', 'industry', 'picture-url', 'public-profile-url',
|
||||
];
|
||||
|
||||
public function urlAuthorize()
|
||||
{
|
||||
|
@ -26,21 +26,21 @@ class LinkedIn extends AbstractProvider
|
|||
|
||||
public function urlUserDetails(AccessToken $token)
|
||||
{
|
||||
return 'https://api.linkedin.com/v1/people/~:(' . implode(",", $this->fields)
|
||||
. ')?format=json&oauth2_access_token=' . $token;
|
||||
return 'https://api.linkedin.com/v1/people/~:('.implode(",", $this->fields)
|
||||
.')?format=json&oauth2_access_token='.$token;
|
||||
}
|
||||
|
||||
public function userDetails($response, AccessToken $token)
|
||||
{
|
||||
$user = new User;
|
||||
$user = new User();
|
||||
|
||||
$email = (isset($response->emailAddress)) ? $response->emailAddress : null;
|
||||
$location = (isset($response->location->name)) ? $response->location->name : null;
|
||||
$description = (isset($response->headline)) ? $response->headline : null;
|
||||
|
||||
$user->exchangeArray(array(
|
||||
$user->exchangeArray([
|
||||
'uid' => $response->id,
|
||||
'name' => $response->firstName . ' ' . $response->lastName,
|
||||
'name' => $response->firstName.' '.$response->lastName,
|
||||
'firstname' => $response->firstName,
|
||||
'lastname' => $response->lastName,
|
||||
'email' => $email,
|
||||
|
@ -48,7 +48,7 @@ class LinkedIn extends AbstractProvider
|
|||
'description' => $description,
|
||||
'imageurl' => $response->pictureUrl,
|
||||
'urls' => $response->publicProfileUrl,
|
||||
));
|
||||
]);
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
@ -67,6 +67,6 @@ class LinkedIn extends AbstractProvider
|
|||
|
||||
public function userScreenName($response, AccessToken $token)
|
||||
{
|
||||
return array($response->firstName, $response->lastName);
|
||||
return [$response->firstName, $response->lastName];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ use League\OAuth2\Client\Token\AccessToken;
|
|||
|
||||
class Microsoft extends AbstractProvider
|
||||
{
|
||||
public $scopes = array('wl.basic', 'wl.emails');
|
||||
public $scopes = ['wl.basic', 'wl.emails'];
|
||||
public $responseType = 'json';
|
||||
|
||||
public function urlAuthorize()
|
||||
|
@ -28,24 +28,24 @@ class Microsoft extends AbstractProvider
|
|||
public function userDetails($response, AccessToken $token)
|
||||
{
|
||||
$client = $this->getHttpClient();
|
||||
$client->setBaseUrl('https://apis.live.net/v5.0/' . $response->id . '/picture');
|
||||
$client->setBaseUrl('https://apis.live.net/v5.0/'.$response->id.'/picture');
|
||||
$request = $client->get()->send();
|
||||
$info = $request->getInfo();
|
||||
$imageUrl = $info['url'];
|
||||
|
||||
$user = new User;
|
||||
$user = new User();
|
||||
|
||||
$email = (isset($response->emails->preferred)) ? $response->emails->preferred : null;
|
||||
|
||||
$user->exchangeArray(array(
|
||||
$user->exchangeArray([
|
||||
'uid' => $response->id,
|
||||
'name' => $response->name,
|
||||
'firstname' => $response->first_name,
|
||||
'lastname' => $response->last_name,
|
||||
'email' => $email,
|
||||
'imageurl' => $imageUrl,
|
||||
'urls' => $response->link . '/cid-' . $response->id,
|
||||
));
|
||||
'urls' => $response->link.'/cid-'.$response->id,
|
||||
]);
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
@ -64,6 +64,6 @@ class Microsoft extends AbstractProvider
|
|||
|
||||
public function userScreenName($response, AccessToken $token)
|
||||
{
|
||||
return array($response->first_name, $response->last_name);
|
||||
return [$response->first_name, $response->last_name];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,11 +18,11 @@ interface ProviderInterface
|
|||
|
||||
public function setScopes(array $scopes);
|
||||
|
||||
public function getAuthorizationUrl($options = array());
|
||||
public function getAuthorizationUrl($options = []);
|
||||
|
||||
public function authorize($options = array());
|
||||
public function authorize($options = []);
|
||||
|
||||
public function getAccessToken($grant = 'authorization_code', $params = array());
|
||||
public function getAccessToken($grant = 'authorization_code', $params = []);
|
||||
|
||||
public function getUserDetails(AccessToken $token);
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ use League\OAuth2\Client\Token\AccessToken;
|
|||
|
||||
class Vkontakte extends AbstractProvider
|
||||
{
|
||||
public $scopes = array();
|
||||
public $scopes = [];
|
||||
public $responseType = 'json';
|
||||
|
||||
public function urlAuthorize()
|
||||
|
@ -22,7 +22,7 @@ class Vkontakte extends AbstractProvider
|
|||
|
||||
public function urlUserDetails(AccessToken $token)
|
||||
{
|
||||
$fields = array('nickname',
|
||||
$fields = ['nickname',
|
||||
'screen_name',
|
||||
'sex',
|
||||
'bdate',
|
||||
|
@ -46,23 +46,23 @@ class Vkontakte extends AbstractProvider
|
|||
'can_post',
|
||||
'universities',
|
||||
'schools',
|
||||
'verified');
|
||||
'verified', ];
|
||||
|
||||
return "https://api.vk.com/method/users.get?user_id={$token->uid}&fields="
|
||||
. implode(",", $fields)."&access_token={$token}";
|
||||
.implode(",", $fields)."&access_token={$token}";
|
||||
}
|
||||
|
||||
public function userDetails($response, AccessToken $token)
|
||||
{
|
||||
$response = $response->response[0];
|
||||
|
||||
$user = new User;
|
||||
$user = new User();
|
||||
|
||||
$email = (isset($response->email)) ? $response->email : null;
|
||||
$location = (isset($response->country)) ? $response->country : null;
|
||||
$description = (isset($response->status)) ? $response->status : null;
|
||||
|
||||
$user->exchangeArray(array(
|
||||
$user->exchangeArray([
|
||||
'uid' => $response->uid,
|
||||
'nickname' => $response->nickname,
|
||||
'name' => $response->screen_name,
|
||||
|
@ -72,7 +72,7 @@ class Vkontakte extends AbstractProvider
|
|||
'location' => $location,
|
||||
'description' => $description,
|
||||
'imageUrl' => $response->photo_200_orig,
|
||||
));
|
||||
]);
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
@ -95,6 +95,6 @@ class Vkontakte extends AbstractProvider
|
|||
{
|
||||
$response = $response->response[0];
|
||||
|
||||
return array($response->first_name, $response->last_name);
|
||||
return [$response->first_name, $response->last_name];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,8 +36,8 @@ class AccessToken
|
|||
{
|
||||
if (! isset($options['access_token'])) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Required option not passed: access_token'. PHP_EOL
|
||||
. print_r($options, true)
|
||||
'Required option not passed: access_token'.PHP_EOL
|
||||
.print_r($options, true)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,20 +23,22 @@ class Bootstrap
|
|||
{
|
||||
$vendorPath = static::findParentPath('vendor');
|
||||
|
||||
$loader = include $vendorPath . '/autoload.php';
|
||||
$loader = include $vendorPath.'/autoload.php';
|
||||
}
|
||||
|
||||
protected static function findParentPath($path)
|
||||
{
|
||||
$dir = __DIR__;
|
||||
$previousDir = '.';
|
||||
while (!is_dir($dir . '/' . $path)) {
|
||||
while (!is_dir($dir.'/'.$path)) {
|
||||
$dir = dirname($dir);
|
||||
if ($previousDir === $dir) return false;
|
||||
if ($previousDir === $dir) {
|
||||
return false;
|
||||
}
|
||||
$previousDir = $dir;
|
||||
}
|
||||
|
||||
return $dir . '/' . $path;
|
||||
return $dir.'/'.$path;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,9 +12,9 @@ class UserTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
public function setUp()
|
||||
{
|
||||
$this->user = new User;
|
||||
$this->user = new User();
|
||||
|
||||
$this->userArray = array(
|
||||
$this->userArray = [
|
||||
'uid' => 'mock_uid',
|
||||
'nickname' => 'mock_nickname',
|
||||
'name' => 'mock_name',
|
||||
|
@ -26,8 +26,8 @@ class UserTest extends \PHPUnit_Framework_TestCase
|
|||
'imageUrl' => 'mock_imageUrl',
|
||||
'urls' => 'mock_urls',
|
||||
'gender' => 'mock_gender',
|
||||
'locale' => 'mock_locale'
|
||||
);
|
||||
'locale' => 'mock_locale',
|
||||
];
|
||||
}
|
||||
|
||||
public function testExchangeArrayGetArrayCopy()
|
||||
|
|
|
@ -10,11 +10,11 @@ class AuthorizationCodeTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->provider = new \League\OAuth2\Client\Provider\Google(array(
|
||||
$this->provider = new \League\OAuth2\Client\Provider\Google([
|
||||
'clientId' => 'mock_client_id',
|
||||
'clientSecret' => 'mock_secret',
|
||||
'redirectUri' => 'none',
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
public function testGetAccessToken()
|
||||
|
@ -36,6 +36,6 @@ class AuthorizationCodeTest extends \PHPUnit_Framework_TestCase
|
|||
$client->shouldReceive('post->send')->times(1)->andReturn($response);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$this->provider->getAccessToken('authorization_code', array('invalid_code' => 'mock_authorization_code'));
|
||||
$this->provider->getAccessToken('authorization_code', ['invalid_code' => 'mock_authorization_code']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,11 +10,11 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->provider = new \League\OAuth2\Client\Provider\Google(array(
|
||||
$this->provider = new \League\OAuth2\Client\Provider\Google([
|
||||
'clientId' => 'mock_client_id',
|
||||
'clientSecret' => 'mock_secret',
|
||||
'redirectUri' => 'none',
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
public function testGetAccessToken()
|
||||
|
@ -27,13 +27,13 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase
|
|||
$client->shouldReceive('post->send')->times(1)->andReturn($response);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', array('code' => 'mock_authorization_code'));
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
$this->assertInstanceOf('League\OAuth2\Client\Token\AccessToken', $token);
|
||||
|
||||
$grant = new \League\OAuth2\Client\Grant\RefreshToken();
|
||||
$this->assertEquals('refresh_token', (string) $grant);
|
||||
|
||||
$newToken = $this->provider->getAccessToken($grant, array('refresh_token' => $token->refreshToken));
|
||||
$newToken = $this->provider->getAccessToken($grant, ['refresh_token' => $token->refreshToken]);
|
||||
$this->assertInstanceOf('League\OAuth2\Client\Token\AccessToken', $newToken);
|
||||
}
|
||||
|
||||
|
@ -50,9 +50,9 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase
|
|||
$client->shouldReceive('post->send')->times(1)->andReturn($response);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', array('code' => 'mock_authorization_code'));
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
|
||||
$grant = new \League\OAuth2\Client\Grant\RefreshToken();
|
||||
$refreshToken = $this->provider->getAccessToken($grant, array('invalid_refresh_token' => $token->refreshToken));
|
||||
$refreshToken = $this->provider->getAccessToken($grant, ['invalid_refresh_token' => $token->refreshToken]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace League\OAuth2\Client\Test\Provider;
|
||||
|
||||
use \Mockery as m;
|
||||
|
||||
class AbstractProviderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
@ -10,11 +9,11 @@ class AbstractProviderTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->provider = new \League\OAuth2\Client\Provider\Google(array(
|
||||
$this->provider = new \League\OAuth2\Client\Provider\Google([
|
||||
'clientId' => 'mock_client_id',
|
||||
'clientSecret' => 'mock_secret',
|
||||
'redirectUri' => 'none',
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -22,7 +21,7 @@ class AbstractProviderTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
public function testInvalidGrantString()
|
||||
{
|
||||
$this->provider->getAccessToken('invalid_grant', array('invalid_parameter' => 'none'));
|
||||
$this->provider->getAccessToken('invalid_grant', ['invalid_parameter' => 'none']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -30,7 +29,7 @@ class AbstractProviderTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
public function testInvalidGrantObject()
|
||||
{
|
||||
$grant = new \StdClass;
|
||||
$this->provider->getAccessToken($grant, array('invalid_parameter' => 'none'));
|
||||
$grant = new \StdClass();
|
||||
$this->provider->getAccessToken($grant, ['invalid_parameter' => 'none']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,11 +10,11 @@ class EventbriteTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->provider = new \League\OAuth2\Client\Provider\Eventbrite(array(
|
||||
$this->provider = new \League\OAuth2\Client\Provider\Eventbrite([
|
||||
'clientId' => 'mock_client_id',
|
||||
'clientSecret' => 'mock_secret',
|
||||
'redirectUri' => 'none',
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
public function testAuthorizationUrl()
|
||||
|
@ -50,7 +50,7 @@ class EventbriteTest extends \PHPUnit_Framework_TestCase
|
|||
$client->shouldReceive('post->send')->times(1)->andReturn($response);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', array('code' => 'mock_authorization_code'));
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
|
||||
$this->assertEquals('mock_access_token', $token->accessToken);
|
||||
$this->assertLessThanOrEqual(time() + 3600, $token->expires);
|
||||
|
@ -61,7 +61,7 @@ class EventbriteTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
public function testScopes()
|
||||
{
|
||||
$this->assertEquals(array(), $this->provider->getScopes());
|
||||
$this->assertEquals([], $this->provider->getScopes());
|
||||
}
|
||||
|
||||
public function testUserData()
|
||||
|
@ -79,7 +79,7 @@ class EventbriteTest extends \PHPUnit_Framework_TestCase
|
|||
$client->shouldReceive('setDefaultOption')->times(1);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', array('code' => 'mock_authorization_code'));
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
$user = $this->provider->getUserDetails($token);
|
||||
|
||||
$this->assertEquals(12345, $this->provider->getUserUid($token));
|
||||
|
|
|
@ -10,11 +10,11 @@ class FacebookTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->provider = new \League\OAuth2\Client\Provider\Facebook(array(
|
||||
$this->provider = new \League\OAuth2\Client\Provider\Facebook([
|
||||
'clientId' => 'mock_client_id',
|
||||
'clientSecret' => 'mock_secret',
|
||||
'redirectUri' => 'none',
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
public function testAuthorizationUrl()
|
||||
|
@ -50,7 +50,7 @@ class FacebookTest extends \PHPUnit_Framework_TestCase
|
|||
$client->shouldReceive('post->send')->times(1)->andReturn($response);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', array('code' => 'mock_authorization_code'));
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
|
||||
# print_r($token);die();
|
||||
|
||||
|
@ -63,7 +63,7 @@ class FacebookTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
public function testScopes()
|
||||
{
|
||||
$this->assertEquals(array('offline_access', 'email', 'read_stream'), $this->provider->getScopes());
|
||||
$this->assertEquals(['offline_access', 'email', 'read_stream'], $this->provider->getScopes());
|
||||
}
|
||||
|
||||
public function testUserData()
|
||||
|
@ -73,7 +73,7 @@ class FacebookTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
$getResponse = m::mock('Guzzle\Http\Message\Response');
|
||||
$getResponse->shouldReceive('getBody')->andReturn('{"id": 12345, "name": "mock_name", "username": "mock_username", "first_name": "mock_first_name", "last_name": "mock_last_name", "email": "mock_email", "Location": "mock_home", "bio": "mock_description", "link": "mock_facebook_url"}');
|
||||
$getResponse->shouldReceive('getInfo')->andReturn(array('url' => 'mock_image_url'));
|
||||
$getResponse->shouldReceive('getInfo')->andReturn(['url' => 'mock_image_url']);
|
||||
|
||||
$client = m::mock('Guzzle\Service\Client');
|
||||
$client->shouldReceive('setBaseUrl')->times(1);
|
||||
|
@ -81,11 +81,11 @@ class FacebookTest extends \PHPUnit_Framework_TestCase
|
|||
$client->shouldReceive('get->send')->andReturn($getResponse);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', array('code' => 'mock_authorization_code'));
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
$user = $this->provider->getUserDetails($token);
|
||||
|
||||
$this->assertEquals(12345, $this->provider->getUserUid($token));
|
||||
$this->assertEquals(array('mock_first_name', 'mock_last_name'), $this->provider->getUserScreenName($token));
|
||||
$this->assertEquals(['mock_first_name', 'mock_last_name'], $this->provider->getUserScreenName($token));
|
||||
$this->assertEquals('mock_email', $this->provider->getUserEmail($token));
|
||||
$this->assertEquals('mock_email', $user->email);
|
||||
}
|
||||
|
|
|
@ -10,11 +10,11 @@ class GithubTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->provider = new \League\OAuth2\Client\Provider\Github(array(
|
||||
$this->provider = new \League\OAuth2\Client\Provider\Github([
|
||||
'clientId' => 'mock',
|
||||
'clientSecret' => 'mock_secret',
|
||||
'redirectUri' => 'none',
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
public function testAuthorizationUrl()
|
||||
|
@ -50,7 +50,7 @@ class GithubTest extends \PHPUnit_Framework_TestCase
|
|||
$client->shouldReceive('post->send')->times(1)->andReturn($response);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', array('code' => 'mock_authorization_code'));
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
|
||||
$this->assertEquals('mock_access_token', $token->accessToken);
|
||||
$this->assertLessThanOrEqual(time() + 3600, $token->expires);
|
||||
|
@ -61,8 +61,8 @@ class GithubTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
public function testScopes()
|
||||
{
|
||||
$this->provider->setScopes(array('user', 'repo'));
|
||||
$this->assertEquals(array('user', 'repo'), $this->provider->getScopes());
|
||||
$this->provider->setScopes(['user', 'repo']);
|
||||
$this->assertEquals(['user', 'repo'], $this->provider->getScopes());
|
||||
}
|
||||
|
||||
public function testUserData()
|
||||
|
@ -79,7 +79,7 @@ class GithubTest extends \PHPUnit_Framework_TestCase
|
|||
$client->shouldReceive('get->send')->times(1)->andReturn($getResponse);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', array('code' => 'mock_authorization_code'));
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
$user = $this->provider->getUserDetails($token);
|
||||
|
||||
$this->assertEquals(12345, $this->provider->getUserUid($token));
|
||||
|
|
|
@ -10,11 +10,11 @@ class GoogleTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->provider = new \League\OAuth2\Client\Provider\Google(array(
|
||||
$this->provider = new \League\OAuth2\Client\Provider\Google([
|
||||
'clientId' => 'mock_client_id',
|
||||
'clientSecret' => 'mock_secret',
|
||||
'redirectUri' => 'none',
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
public function testAuthorizationUrl()
|
||||
|
@ -50,7 +50,7 @@ class GoogleTest extends \PHPUnit_Framework_TestCase
|
|||
$client->shouldReceive('post->send')->times(1)->andReturn($response);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', array('code' => 'mock_authorization_code'));
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
|
||||
# print_r($token);die();
|
||||
|
||||
|
@ -63,7 +63,7 @@ class GoogleTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
public function testScopes()
|
||||
{
|
||||
$this->assertEquals(array('https://www.googleapis.com/auth/userinfo.profile', 'https://www.googleapis.com/auth/userinfo.email'), $this->provider->getScopes());
|
||||
$this->assertEquals(['https://www.googleapis.com/auth/userinfo.profile', 'https://www.googleapis.com/auth/userinfo.email'], $this->provider->getScopes());
|
||||
}
|
||||
|
||||
public function testUserData()
|
||||
|
@ -80,11 +80,11 @@ class GoogleTest extends \PHPUnit_Framework_TestCase
|
|||
$client->shouldReceive('get->send')->times(1)->andReturn($getResponse);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', array('code' => 'mock_authorization_code'));
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
$user = $this->provider->getUserDetails($token);
|
||||
|
||||
$this->assertEquals(12345, $this->provider->getUserUid($token));
|
||||
$this->assertEquals(array('mock_first_name', 'mock_last_name'), $this->provider->getUserScreenName($token));
|
||||
$this->assertEquals(['mock_first_name', 'mock_last_name'], $this->provider->getUserScreenName($token));
|
||||
$this->assertEquals('mock_email', $this->provider->getUserEmail($token));
|
||||
$this->assertEquals('mock_email', $user->email);
|
||||
}
|
||||
|
|
|
@ -10,11 +10,11 @@ class InstagramTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->provider = new \League\OAuth2\Client\Provider\Instagram(array(
|
||||
$this->provider = new \League\OAuth2\Client\Provider\Instagram([
|
||||
'clientId' => 'mock_client_id',
|
||||
'clientSecret' => 'mock_secret',
|
||||
'redirectUri' => 'none',
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
public function testAuthorizationUrl()
|
||||
|
@ -50,7 +50,7 @@ class InstagramTest extends \PHPUnit_Framework_TestCase
|
|||
$client->shouldReceive('post->send')->times(1)->andReturn($response);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', array('code' => 'mock_authorization_code'));
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
|
||||
# print_r($token);die();
|
||||
|
||||
|
@ -63,7 +63,7 @@ class InstagramTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
public function testScopes()
|
||||
{
|
||||
$this->assertEquals(array('basic'), $this->provider->getScopes());
|
||||
$this->assertEquals(['basic'], $this->provider->getScopes());
|
||||
}
|
||||
|
||||
public function testUserData()
|
||||
|
@ -80,7 +80,7 @@ class InstagramTest extends \PHPUnit_Framework_TestCase
|
|||
$client->shouldReceive('get->send')->times(1)->andReturn($getResponse);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', array('code' => 'mock_authorization_code'));
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
$user = $this->provider->getUserDetails($token);
|
||||
|
||||
$this->assertEquals(12345, $this->provider->getUserUid($token));
|
||||
|
|
|
@ -10,11 +10,11 @@ class LinkedInTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->provider = new \League\OAuth2\Client\Provider\LinkedIn(array(
|
||||
$this->provider = new \League\OAuth2\Client\Provider\LinkedIn([
|
||||
'clientId' => 'mock_client_id',
|
||||
'clientSecret' => 'mock_secret',
|
||||
'redirectUri' => 'none',
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
public function testAuthorizationUrl()
|
||||
|
@ -50,7 +50,7 @@ class LinkedInTest extends \PHPUnit_Framework_TestCase
|
|||
$client->shouldReceive('post->send')->times(1)->andReturn($response);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', array('code' => 'mock_authorization_code'));
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
|
||||
# print_r($token);die();
|
||||
|
||||
|
@ -63,7 +63,7 @@ class LinkedInTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
public function testScopes()
|
||||
{
|
||||
$this->assertEquals(array('r_basicprofile r_emailaddress r_contactinfo'), $this->provider->getScopes());
|
||||
$this->assertEquals(['r_basicprofile r_emailaddress r_contactinfo'], $this->provider->getScopes());
|
||||
}
|
||||
|
||||
public function testUserData()
|
||||
|
@ -80,11 +80,11 @@ class LinkedInTest extends \PHPUnit_Framework_TestCase
|
|||
$client->shouldReceive('get->send')->times(1)->andReturn($getResponse);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', array('code' => 'mock_authorization_code'));
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
$user = $this->provider->getUserDetails($token);
|
||||
|
||||
$this->assertEquals(12345, $this->provider->getUserUid($token));
|
||||
$this->assertEquals(array('mock_first_name', 'mock_last_name'), $this->provider->getUserScreenName($token));
|
||||
$this->assertEquals(['mock_first_name', 'mock_last_name'], $this->provider->getUserScreenName($token));
|
||||
$this->assertEquals('mock_email', $this->provider->getUserEmail($token));
|
||||
$this->assertEquals('mock_email', $user->email);
|
||||
}
|
||||
|
|
|
@ -10,11 +10,11 @@ class MicrosoftTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->provider = new \League\OAuth2\Client\Provider\Microsoft(array(
|
||||
$this->provider = new \League\OAuth2\Client\Provider\Microsoft([
|
||||
'clientId' => 'mock_client_id',
|
||||
'clientSecret' => 'mock_secret',
|
||||
'redirectUri' => 'none',
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
public function testAuthorizationUrl()
|
||||
|
@ -50,7 +50,7 @@ class MicrosoftTest extends \PHPUnit_Framework_TestCase
|
|||
$client->shouldReceive('post->send')->times(1)->andReturn($response);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', array('code' => 'mock_authorization_code'));
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
|
||||
# print_r($token);die();
|
||||
|
||||
|
@ -63,7 +63,7 @@ class MicrosoftTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
public function testScopes()
|
||||
{
|
||||
$this->assertEquals(array('wl.basic', 'wl.emails'), $this->provider->getScopes());
|
||||
$this->assertEquals(['wl.basic', 'wl.emails'], $this->provider->getScopes());
|
||||
}
|
||||
|
||||
public function testUserData()
|
||||
|
@ -73,7 +73,7 @@ class MicrosoftTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
$getResponse = m::mock('Guzzle\Http\Message\Response');
|
||||
$getResponse->shouldReceive('getBody')->times(1)->andReturn('{"id": 12345, "name": "mock_name", "first_name": "mock_first_name", "last_name": "mock_last_name", "emails": {"preferred": "mock_email"}, "link": "mock_link"}');
|
||||
$getResponse->shouldReceive('getInfo')->andReturn(array('url' => 'mock_image_url'));
|
||||
$getResponse->shouldReceive('getInfo')->andReturn(['url' => 'mock_image_url']);
|
||||
|
||||
$client = m::mock('Guzzle\Service\Client');
|
||||
$client->shouldReceive('setBaseUrl')->times(1);
|
||||
|
@ -81,11 +81,11 @@ class MicrosoftTest extends \PHPUnit_Framework_TestCase
|
|||
$client->shouldReceive('get->send')->times(1)->andReturn($getResponse);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', array('code' => 'mock_authorization_code'));
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
$user = $this->provider->getUserDetails($token);
|
||||
|
||||
$this->assertEquals(12345, $this->provider->getUserUid($token));
|
||||
$this->assertEquals(array('mock_first_name', 'mock_last_name'), $this->provider->getUserScreenName($token));
|
||||
$this->assertEquals(['mock_first_name', 'mock_last_name'], $this->provider->getUserScreenName($token));
|
||||
$this->assertEquals('mock_email', $this->provider->getUserEmail($token));
|
||||
$this->assertEquals('mock_email', $user->email);
|
||||
$this->assertEquals('mock_image_url', $user->imageUrl);
|
||||
|
|
|
@ -10,11 +10,11 @@ class VkontakteTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->provider = new \League\OAuth2\Client\Provider\Vkontakte(array(
|
||||
$this->provider = new \League\OAuth2\Client\Provider\Vkontakte([
|
||||
'clientId' => 'mock_client_id',
|
||||
'clientSecret' => 'mock_secret',
|
||||
'redirectUri' => 'none',
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
public function testAuthorizationUrl()
|
||||
|
@ -50,7 +50,7 @@ class VkontakteTest extends \PHPUnit_Framework_TestCase
|
|||
$client->shouldReceive('post->send')->times(1)->andReturn($response);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', array('code' => 'mock_authorization_code'));
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
|
||||
$this->assertEquals('mock_access_token', $token->accessToken);
|
||||
$this->assertLessThanOrEqual(time() + 3600, $token->expires);
|
||||
|
@ -61,7 +61,7 @@ class VkontakteTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
public function testScopes()
|
||||
{
|
||||
$this->assertEquals(array(), $this->provider->getScopes());
|
||||
$this->assertEquals([], $this->provider->getScopes());
|
||||
}
|
||||
|
||||
public function testUserData()
|
||||
|
@ -78,11 +78,11 @@ class VkontakteTest extends \PHPUnit_Framework_TestCase
|
|||
$client->shouldReceive('get->send')->times(1)->andReturn($getResponse);
|
||||
$this->provider->setHttpClient($client);
|
||||
|
||||
$token = $this->provider->getAccessToken('authorization_code', array('code' => 'mock_authorization_code'));
|
||||
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
|
||||
$user = $this->provider->getUserDetails($token);
|
||||
|
||||
$this->assertEquals(12345, $this->provider->getUserUid($token));
|
||||
$this->assertEquals(array('mock_first_name', 'mock_last_name'), $this->provider->getUserScreenName($token));
|
||||
$this->assertEquals(['mock_first_name', 'mock_last_name'], $this->provider->getUserScreenName($token));
|
||||
$this->assertEquals('mock_email', $this->provider->getUserEmail($token));
|
||||
$this->assertEquals('mock_email', $user->email);
|
||||
}
|
||||
|
|
|
@ -9,6 +9,6 @@ class AccessTokenTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
public function testInvalidRefreshToken()
|
||||
{
|
||||
new \League\OAuth2\Client\Token\AccessToken(array('invalid_access_token' => 'none'));
|
||||
new \League\OAuth2\Client\Token\AccessToken(['invalid_access_token' => 'none']);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue