WeWorkProviderTest.php
2.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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\WeWorkProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
class WeWorkProviderTest extends TestCase
{
public function testQrConnect()
{
$response = (new WeWorkProvider(Request::create('foo'), [
'client_id' => 'ww100000a5f2191',
'client_secret' => 'client_secret',
'redirect' => 'http://www.oa.com',
]))
->setAgentId('1000000')
->stateless()
->redirect();
$this->assertSame('https://open.work.weixin.qq.com/wwopen/sso/qrConnect?appid=ww100000a5f2191&agentid=1000000&redirect_uri=http%3A%2F%2Fwww.oa.com', $response->getTargetUrl());
}
public function testOAuthWithAgentId()
{
$response = (new WeWorkProvider(Request::create('foo'), [
'client_id' => 'CORPID',
'client_secret' => 'client_secret',
'redirect' => 'REDIRECT_URI',
]))
->scopes(['snsapi_base'])
->setAgentId('1000000')
->stateless()
->redirect();
$this->assertSame('https://open.weixin.qq.com/connect/oauth2/authorize?appid=CORPID&redirect_uri=REDIRECT_URI&response_type=code&scope=snsapi_base&agentid=1000000#wechat_redirect', $response->getTargetUrl());
}
public function testOAuthWithoutAgentId()
{
$response = (new WeWorkProvider(Request::create('foo'), [
'client_id' => 'CORPID',
'client_secret' => 'client_secret',
'redirect' => 'REDIRECT_URI',
]))
->scopes(['snsapi_base'])
->stateless()
->redirect();
$this->assertSame('https://open.weixin.qq.com/connect/oauth2/authorize?appid=CORPID&redirect_uri=REDIRECT_URI&response_type=code&scope=snsapi_base#wechat_redirect', $response->getTargetUrl());
}
}