Extension.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. require_once 'Auth/OpenID/Message.php';
  3. require_once 'Auth/OpenID/Extension.php';
  4. class _ExtensionTest_DummyExtension extends Auth_OpenID_Extension {
  5. var $ns_uri = 'http://an.extension/';
  6. var $ns_alias = 'dummy';
  7. function getExtensionArgs()
  8. {
  9. return array();
  10. }
  11. }
  12. class Tests_Auth_OpenID_Extension extends PHPUnit_Framework_TestCase {
  13. function test_OpenID1()
  14. {
  15. $oid1_msg = new Auth_OpenID_Message(Auth_OpenID_OPENID1_NS);
  16. $ext = new _ExtensionTest_DummyExtension();
  17. $ext->toMessage($oid1_msg);
  18. $namespaces = $oid1_msg->namespaces;
  19. $this->assertTrue($namespaces->isImplicit($ext->ns_uri));
  20. $this->assertEquals($ext->ns_uri,
  21. $namespaces->getNamespaceURI($ext->ns_alias));
  22. $this->assertEquals($ext->ns_alias,
  23. $namespaces->getAlias($ext->ns_uri));
  24. }
  25. function test_OpenID2()
  26. {
  27. $oid2_msg = new Auth_OpenID_Message(Auth_OpenID_OPENID2_NS);
  28. $ext = new _ExtensionTest_DummyExtension();
  29. $ext->toMessage($oid2_msg);
  30. $namespaces = $oid2_msg->namespaces;
  31. $this->assertFalse($namespaces->isImplicit($ext->ns_uri));
  32. $this->assertEquals($ext->ns_uri,
  33. $namespaces->getNamespaceURI($ext->ns_alias));
  34. $this->assertEquals($ext->ns_alias,
  35. $namespaces->getAlias($ext->ns_uri));
  36. }
  37. }