vendor/overtrue/socialite/tests/WechatProviderTest.php
(开头部分) 4KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
/*
* This file is part of the overtrue/socialite.
*
* (c) overtrue <i@overtrue.me>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
use Overtrue\Socialite\Providers\WeChatProvider as RealWeChatProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
class WechatProviderTest extends TestCase
{
public function testWeChatProviderHasCorrectlyRedirectResponse()
{
$response = (new WeChatProvider(Request::create('foo'), [
'client_id' => 'client_id',
'client_secret' => 'client_secret',
'redirect' => 'http://localhost/socialite/callback.php',
]))->redirect();
$this->assertInstanceOf('Symfony\Component\HttpFoundation\RedirectResponse', $response);
$this->assertStringStartsWith('https://open.weixin.qq.com/connect/qrconnect', $response->getTargetUrl());
$this->assertRegExp('/redirect_uri=http%3A%2F%2Flocalhost%2Fsocialite%2Fcallback.php/', $response->getTargetUrl());
}
public function testWeChatProviderTokenUrlAndRequestFields()
{
$provider = new WeChatProvider(Request::create('foo'), [
'client_id' => 'client_id',
'client_secret' => 'client_secret',
'redirect' => 'http://localhost/socialite/callback.php',
]);
$this->assertSame('https://api.weixin.qq.com/sns/oauth2/access_token', $provider->tokenUrl());
$this->assertSame([
'appid' => 'client_id',
'secret' => 'client_secret',
'code' => 'iloveyou',
'grant_type' => 'authorization_code',
], $provider->tokenFields('iloveyou'));
$this->assertSame([
'appid' => 'client_id',
'redirect_uri' => 'http://localhost/socialite/callback.php',
'response_type' => 'code',
'scope' => 'snsapi_login',
'state' => 'wechat-state',
'connect_redirect' => 1,
], $provider->codeFields('wechat-state'));
}
public function testOpenPlatformComponent()
{
$provider = new WeChatProvider(Request::create('foo'), [
'client_id' => 'client_id',
后面还有 77 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
