RtmTokenBuilder2Test.php 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. require_once "../src/AccessToken2.php";
  3. require_once "../src/RtmTokenBuilder2.php";
  4. class RtmTokenBuilder2Test
  5. {
  6. public $appId = "970CA35de60c44645bbae8a215061b33";
  7. public $appCertificate = "5CFd2fd1755d40ecb72977518be15d3b";
  8. public $expire = 600;
  9. public $userId = "test_user";
  10. public function run()
  11. {
  12. $this->test_buildToken();
  13. }
  14. public function test_buildToken()
  15. {
  16. $token = RtmTokenBuilder2::buildToken($this->appId, $this->appCertificate, $this->userId, $this->expire);
  17. $accessToken = new AccessToken2();
  18. $accessToken->parse($token);
  19. Util::assertEqual($this->appId, $accessToken->appId);
  20. Util::assertEqual($this->expire, $accessToken->expire);
  21. Util::assertEqual($this->userId, $accessToken->services[ServiceRtm::SERVICE_TYPE]->userId);
  22. Util::assertEqual(ServiceRtm::SERVICE_TYPE, $accessToken->services[ServiceRtm::SERVICE_TYPE]->type);
  23. Util::assertEqual($this->expire, $accessToken->services[ServiceRtm::SERVICE_TYPE]->privileges[ServiceRtm::PRIVILEGE_LOGIN]);
  24. }
  25. }
  26. $rtmTokenBuilder2Test = new RtmTokenBuilder2Test();
  27. $rtmTokenBuilder2Test->run();