QueryTest.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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) 2005-2015 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/Http/Client.php';
  23. require_once 'Zend/Gdata/Query.php';
  24. /**
  25. * @category Zend
  26. * @package Zend_Gdata
  27. * @subpackage UnitTests
  28. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  29. * @license http://framework.zend.com/license/new-bsd New BSD License
  30. * @group Zend_Gdata
  31. */
  32. class Zend_Gdata_QueryTest extends PHPUnit_Framework_TestCase
  33. {
  34. public function setUp()
  35. {
  36. }
  37. public function testSetAndGetAlt()
  38. {
  39. $query = new Zend_Gdata_Query();
  40. $query->setAlt('rss');
  41. $this->assertEquals('rss', $query->alt);
  42. $this->assertContains('alt=rss', $query->getQueryUrl());
  43. }
  44. public function testSetAndGetUpdatedMax()
  45. {
  46. $query = new Zend_Gdata_Query();
  47. $query->setUpdatedMax('2007-01-01');
  48. $this->assertEquals('2007-01-01', $query->getUpdatedMax());
  49. $this->assertContains('updated-max=2007-01-01', $query->getQueryUrl());
  50. }
  51. public function testSetAndGetUpdatedMin()
  52. {
  53. $query = new Zend_Gdata_Query();
  54. $query->setUpdatedMin('2007-01-01');
  55. $this->assertEquals('2007-01-01', $query->getUpdatedMin());
  56. $this->assertContains('updated-min=2007-01-01', $query->getQueryUrl());
  57. }
  58. public function testSetAndGetPublishedMax()
  59. {
  60. $query = new Zend_Gdata_Query();
  61. $query->setPublishedMax('2007-01-01');
  62. $this->assertEquals('2007-01-01', $query->getPublishedMax());
  63. $this->assertContains('published-max=2007-01-01',
  64. $query->getQueryUrl());
  65. }
  66. public function testSetAndGetPublishedMin()
  67. {
  68. $query = new Zend_Gdata_Query();
  69. $query->setPublishedMin('2007-01-01');
  70. $this->assertEquals('2007-01-01', $query->getPublishedMin());
  71. $this->assertContains('published-min=2007-01-01',
  72. $query->getQueryUrl());
  73. }
  74. public function testSetAndGetAuthor()
  75. {
  76. $query = new Zend_Gdata_Query();
  77. $query->setAuthor('My Name');
  78. $this->assertEquals('My Name', $query->getAuthor());
  79. $this->assertContains('author=My+Name', $query->getQueryUrl());
  80. }
  81. public function testSetAndGetMaxResults()
  82. {
  83. $query = new Zend_Gdata_Query();
  84. $query->setMaxResults('300');
  85. $this->assertEquals('300', $query->getMaxResults());
  86. $this->assertContains('max-results=300', $query->getQueryUrl());
  87. }
  88. public function testSetAndGetGenericParam()
  89. {
  90. $query = new Zend_Gdata_Query();
  91. $query->setParam('fw', 'zend');
  92. $this->assertEquals('zend', $query->getParam('fw'));
  93. $this->assertContains('fw=zend', $query->getQueryUrl());
  94. }
  95. public function testSetAndGetFullTextQuery()
  96. {
  97. $query = new Zend_Gdata_Query();
  98. $query->setQuery('geek events');
  99. $this->assertEquals('geek events', $query->getQuery());
  100. $this->assertContains('q=geek+events', $query->getQueryUrl());
  101. }
  102. public function testSetAndGetStartIndex()
  103. {
  104. $query = new Zend_Gdata_Query();
  105. $query->setStartIndex(12);
  106. $this->assertEquals(12, $query->getStartIndex());
  107. $this->assertContains('start-index=12', $query->getQueryUrl());
  108. }
  109. }