WeWorkTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. use Overtrue\Socialite\Providers\WeWork;
  3. use PHPUnit\Framework\TestCase;
  4. class WeWorkTest extends TestCase
  5. {
  6. public function testQrConnect()
  7. {
  8. $response = (new WeWork([
  9. 'client_id' => 'ww100000a5f2191',
  10. 'client_secret' => 'client_secret',
  11. 'redirect' => 'http://www.oa.com',
  12. ]))
  13. ->setAgentId('1000000')
  14. ->redirect();
  15. $this->assertSame('https://open.work.weixin.qq.com/wwopen/sso/qrConnect?appid=ww100000a5f2191&agentid=1000000&redirect_uri=http%3A%2F%2Fwww.oa.com#wechat_redirect', $response);
  16. }
  17. public function testOAuthWithAgentId()
  18. {
  19. $response = (new WeWork([
  20. 'client_id' => 'CORPID',
  21. 'client_secret' => 'client_secret',
  22. 'redirect' => 'REDIRECT_URI',
  23. ]))
  24. ->scopes(['snsapi_base'])
  25. ->redirect();
  26. $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);
  27. }
  28. public function testOAuthWithoutAgentId()
  29. {
  30. $response = (new WeWork([
  31. 'client_id' => 'CORPID',
  32. 'client_secret' => 'client_secret',
  33. 'redirect' => 'REDIRECT_URI',
  34. ]))
  35. ->scopes(['snsapi_base'])
  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);
  38. }
  39. }