ClientTest.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace Alipay\EasySDK\Test\base\oauth;
  3. use Alipay\EasySDK\Kernel\Factory;
  4. use Alipay\EasySDK\Test\TestAccount;
  5. use PHPUnit\Framework\TestCase;
  6. class ClientTest extends TestCase
  7. {
  8. public function __construct($name = null, array $data = [], $dataName = '')
  9. {
  10. parent::__construct($name, $data, $dataName);
  11. $account = new TestAccount();
  12. Factory::setOptions($account->getTestAccount());
  13. }
  14. public function testGetTokenWhenGrantTypeIsAuthorizationCode()
  15. {
  16. $result = Factory::base()->oauth()->getToken('ee4b3c871f7c4f30a82251908458VB64');
  17. $this->assertEquals('40002', $result->code);
  18. $this->assertEquals('Invalid Arguments', $result->msg);
  19. $this->assertEquals('isv.code-invalid', $result->subCode);
  20. $this->assertEquals('授权码code无效', $result->subMsg);
  21. }
  22. public function testGetTokenWhenGrantTypeIsRefreshToken()
  23. {
  24. $result = Factory::base()->oauth()->refreshToken('1234567890');
  25. $this->assertEquals('40002', $result->code);
  26. $this->assertEquals('Invalid Arguments', $result->msg);
  27. $this->assertEquals('isv.refresh-token-invalid', $result->subCode);
  28. $this->assertEquals('刷新令牌refresh_token无效', $result->subMsg);
  29. }
  30. }