WeWorkProviderTest.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /*
  3. * This file is part of the overtrue/socialite.
  4. *
  5. * (c) overtrue <i@overtrue.me>
  6. *
  7. * This source file is subject to the MIT license that is bundled
  8. * with this source code in the file LICENSE.
  9. */
  10. use Overtrue\Socialite\Providers\WeWorkProvider;
  11. use Symfony\Component\HttpFoundation\Request;
  12. class WeWorkProviderTest extends PHPUnit_Framework_TestCase
  13. {
  14. public function testQrConnect()
  15. {
  16. $response = (new WeWorkProvider(Request::create('foo'), 'ww100000a5f2191', 'client_secret', 'http://www.oa.com'))
  17. ->setAgentId('1000000')
  18. ->stateless()
  19. ->redirect();
  20. $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());
  21. }
  22. public function testOAuthWithAgentId()
  23. {
  24. $response = (new WeWorkProvider(Request::create('foo'), 'CORPID', 'client_secret', 'REDIRECT_URI'))
  25. ->scopes(['snsapi_base'])
  26. ->setAgentId('1000000')
  27. ->stateless()
  28. ->redirect();
  29. $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());
  30. }
  31. public function testOAuthWithoutAgentId()
  32. {
  33. $response = (new WeWorkProvider(Request::create('foo'), 'CORPID', 'client_secret', 'REDIRECT_URI'))
  34. ->scopes(['snsapi_base'])
  35. ->stateless()
  36. ->redirect();
  37. $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());
  38. }
  39. }