Extension.php 1.4 KB

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