BaseTest.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Gdata
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2006-2008 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. */
  21. require_once 'Zend/Gdata/App/MockBase.php';
  22. /**
  23. * @package Zend_Gdata
  24. * @subpackage UnitTests
  25. */
  26. class Zend_Gdata_App_BaseTest extends PHPUnit_Framework_TestCase
  27. {
  28. public function setUp()
  29. {
  30. $this->fileName = 'Zend/Gdata/App/_files/FeedSample1.xml';
  31. $this->base = new Zend_Gdata_App_MockBase();
  32. }
  33. public function testUnknownNamespaceReturnsInput() {
  34. $this->assertEquals('example',
  35. $this->base->lookupNamespace('example'));
  36. }
  37. public function testAtomV1NamespaceReturnedByDefault() {
  38. $this->assertEquals('http://www.w3.org/2005/Atom',
  39. $this->base->lookupNamespace('atom'));
  40. }
  41. public function testAtomPubV1NamespaceReturnedByDefault() {
  42. $this->assertEquals('http://purl.org/atom/app#',
  43. $this->base->lookupNamespace('app'));
  44. }
  45. public function testAtomV1NamespaceReturnedWhenSpecifyingMajorVersion() {
  46. $this->assertEquals('http://www.w3.org/2005/Atom',
  47. $this->base->lookupNamespace('atom',
  48. 1));
  49. }
  50. public function testAtomV1NamespaceReturnedWhenSpecifyingMajorAndMinorVersion() {
  51. $this->assertEquals('http://www.w3.org/2005/Atom',
  52. $this->base->lookupNamespace('atom',
  53. 1, 0));
  54. }
  55. public function testAtomPubV1NamespaceReturnedWhenSpecifyingMajorVersion() {
  56. $this->assertEquals('http://purl.org/atom/app#',
  57. $this->base->lookupNamespace('app',
  58. 1));
  59. }
  60. public function testAtomPubV1NamespaceReturnedWhenSpecifyingMajorAndMinorVersion() {
  61. $this->assertEquals('http://purl.org/atom/app#',
  62. $this->base->lookupNamespace('app',
  63. 1, 0));
  64. }
  65. public function testAtomPubV2NamespaceReturnedWhenSpecifyingMajorVersion() {
  66. $this->assertEquals('http://www.w3.org/2007/app',
  67. $this->base->lookupNamespace('app',
  68. 2));
  69. }
  70. public function testAtomPubV2NamespaceReturnedWhenSpecifyingMajorAndMinorVersion() {
  71. $this->assertEquals('http://www.w3.org/2007/app',
  72. $this->base->lookupNamespace('app',
  73. 2, 0));
  74. }
  75. public function testNullReturnsLatestVersion() {
  76. $this->assertEquals('http://www.w3.org/2007/app',
  77. $this->base->lookupNamespace('app',
  78. null, null));
  79. }
  80. public function testRegisterNamespaceWorksWithoutVersion() {
  81. $ns = 'http://example.net/namespaces.foo';
  82. $prefix = 'foo';
  83. $this->base->registerNamespace($prefix, $ns);
  84. $result = $this->base->lookupNamespace($prefix);
  85. $this->assertEquals($ns, $result);
  86. }
  87. public function testRegisterNamespaceAllowsSettingMajorVersion() {
  88. $ns = 'http://example.net/namespaces.foo';
  89. $prefix = 'foo';
  90. $this->base->registerNamespace($prefix, 'wrong-1', 1);
  91. $this->base->registerNamespace($prefix, $ns, 2);
  92. $this->base->registerNamespace($prefix, 'wrong-3', 3);
  93. $this->base->registerNamespace($prefix, 'wrong-4', 4);
  94. $result = $this->base->lookupNamespace($prefix, 2);
  95. $this->assertEquals($ns, $result);
  96. }
  97. public function testRegisterNamespaceAllowsSettingMinorVersion() {
  98. $ns = 'http://example.net/namespaces.foo';
  99. $prefix = 'foo';
  100. $this->base->registerNamespace($prefix, 'wrong-1', 1);
  101. $this->base->registerNamespace($prefix, 'wrong-2-0', 2,0);
  102. $this->base->registerNamespace($prefix, 'wrong-2-1', 2,1);
  103. $this->base->registerNamespace($prefix, 'wrong-2-2', 2,2);
  104. $this->base->registerNamespace($prefix, $ns, 2, 3);
  105. $this->base->registerNamespace($prefix, 'wrong-2-4', 2,4);
  106. $this->base->registerNamespace($prefix, 'wrong-3-0', 3-0);
  107. $this->base->registerNamespace($prefix, 'wrong-3-1', 3-1);
  108. $this->base->registerNamespace($prefix, 'wrong-4', 4);
  109. $result = $this->base->lookupNamespace($prefix, 2, 3);
  110. $this->assertEquals($ns, $result);
  111. }
  112. }