BaseTest.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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_App
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id $
  21. */
  22. require_once 'Zend/Gdata/App/MockBase.php';
  23. /**
  24. * @category Zend
  25. * @package Zend_Gdata_App
  26. * @subpackage UnitTests
  27. * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
  28. * @license http://framework.zend.com/license/new-bsd New BSD License
  29. * @group Zend_Gdata
  30. * @group Zend_Gdata_App
  31. */
  32. class Zend_Gdata_App_BaseTest extends PHPUnit_Framework_TestCase
  33. {
  34. public function setUp()
  35. {
  36. $this->fileName = 'Zend/Gdata/App/_files/FeedSample1.xml';
  37. $this->base = new Zend_Gdata_App_MockBase();
  38. }
  39. public function testUnknownNamespaceReturnsInput() {
  40. $this->assertEquals('example',
  41. $this->base->lookupNamespace('example'));
  42. }
  43. public function testAtomV1NamespaceReturnedByDefault() {
  44. $this->assertEquals('http://www.w3.org/2005/Atom',
  45. $this->base->lookupNamespace('atom'));
  46. }
  47. public function testAtomPubV1NamespaceReturnedByDefault() {
  48. $this->assertEquals('http://purl.org/atom/app#',
  49. $this->base->lookupNamespace('app'));
  50. }
  51. public function testAtomV1NamespaceReturnedWhenSpecifyingMajorVersion() {
  52. $this->assertEquals('http://www.w3.org/2005/Atom',
  53. $this->base->lookupNamespace('atom',
  54. 1));
  55. }
  56. public function testAtomV1NamespaceReturnedWhenSpecifyingMajorAndMinorVersion() {
  57. $this->assertEquals('http://www.w3.org/2005/Atom',
  58. $this->base->lookupNamespace('atom',
  59. 1, 0));
  60. }
  61. public function testAtomPubV1NamespaceReturnedWhenSpecifyingMajorVersion() {
  62. $this->assertEquals('http://purl.org/atom/app#',
  63. $this->base->lookupNamespace('app',
  64. 1));
  65. }
  66. public function testAtomPubV1NamespaceReturnedWhenSpecifyingMajorAndMinorVersion() {
  67. $this->assertEquals('http://purl.org/atom/app#',
  68. $this->base->lookupNamespace('app',
  69. 1, 0));
  70. }
  71. public function testAtomPubV2NamespaceReturnedWhenSpecifyingMajorVersion() {
  72. $this->assertEquals('http://www.w3.org/2007/app',
  73. $this->base->lookupNamespace('app',
  74. 2));
  75. }
  76. public function testAtomPubV2NamespaceReturnedWhenSpecifyingMajorAndMinorVersion() {
  77. $this->assertEquals('http://www.w3.org/2007/app',
  78. $this->base->lookupNamespace('app',
  79. 2, 0));
  80. }
  81. public function testNullReturnsLatestVersion() {
  82. $this->assertEquals('http://www.w3.org/2007/app',
  83. $this->base->lookupNamespace('app',
  84. null, null));
  85. }
  86. public function testRegisterNamespaceWorksWithoutVersion() {
  87. $ns = 'http://example.net/namespaces.foo';
  88. $prefix = 'foo';
  89. $this->base->registerNamespace($prefix, $ns);
  90. $result = $this->base->lookupNamespace($prefix);
  91. $this->assertEquals($ns, $result);
  92. }
  93. public function testRegisterNamespaceAllowsSettingMajorVersion() {
  94. $ns = 'http://example.net/namespaces.foo';
  95. $prefix = 'foo';
  96. $this->base->registerNamespace($prefix, 'wrong-1', 1);
  97. $this->base->registerNamespace($prefix, $ns, 2);
  98. $this->base->registerNamespace($prefix, 'wrong-3', 3);
  99. $this->base->registerNamespace($prefix, 'wrong-4', 4);
  100. $result = $this->base->lookupNamespace($prefix, 2);
  101. $this->assertEquals($ns, $result);
  102. }
  103. public function testRegisterNamespaceAllowsSettingMinorVersion() {
  104. $ns = 'http://example.net/namespaces.foo';
  105. $prefix = 'foo';
  106. $this->base->registerNamespace($prefix, 'wrong-1', 1);
  107. $this->base->registerNamespace($prefix, 'wrong-2-0', 2,0);
  108. $this->base->registerNamespace($prefix, 'wrong-2-1', 2,1);
  109. $this->base->registerNamespace($prefix, 'wrong-2-2', 2,2);
  110. $this->base->registerNamespace($prefix, $ns, 2, 3);
  111. $this->base->registerNamespace($prefix, 'wrong-2-4', 2,4);
  112. $this->base->registerNamespace($prefix, 'wrong-3-0', 3-0);
  113. $this->base->registerNamespace($prefix, 'wrong-3-1', 3-1);
  114. $this->base->registerNamespace($prefix, 'wrong-4', 4);
  115. $result = $this->base->lookupNamespace($prefix, 2, 3);
  116. $this->assertEquals($ns, $result);
  117. }
  118. }