PageTest.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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_Service_Amazon_SimpleDb
  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: OfflineTest.php 8064 2008-02-16 10:58:39Z thomas $
  21. */
  22. require_once 'Zend/Service/Amazon/SimpleDb/Page.php';
  23. /**
  24. * @category Zend
  25. * @package Zend_Service_Amazon_SimpleDb
  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. */
  30. class Zend_Service_Amazon_SimpleDb_PageTest extends PHPUnit_Framework_TestCase
  31. {
  32. /**
  33. * @var Zend_Service_Amazon_SimpleDb_Page
  34. */
  35. protected $page;
  36. public function setUp()
  37. {
  38. $this->page = new Zend_Service_Amazon_SimpleDb_Page('foobar');
  39. }
  40. public function testSetAndGetDataPerMethods()
  41. {
  42. $this->page->setData('data');
  43. $this->assertEquals('data', $this->page->getData());
  44. }
  45. public function testSetDataPerConstructor()
  46. {
  47. $page = new Zend_Service_Amazon_SimpleDb_Page('data');
  48. $this->assertEquals('data', $page->getData());
  49. }
  50. public function testSetAndGetTokenPerMethods()
  51. {
  52. $this->page->setToken('token');
  53. $this->assertEquals('token', $this->page->getToken());
  54. }
  55. public function testSetTokenPerConstructor()
  56. {
  57. $page = new Zend_Service_Amazon_SimpleDb_Page('data', 'token');
  58. $this->assertEquals('token', $page->getToken());
  59. }
  60. public function testSetTokenShouldAcceptsNullValue()
  61. {
  62. $this->page->setToken('token');
  63. $this->page->setToken(null);
  64. $this->assertNull($this->page->getToken());
  65. }
  66. public function testSetTokenDoesNotAcceptsEmptyStrings()
  67. {
  68. $this->page->setToken('token');
  69. $this->page->setToken('');
  70. $this->assertNull($this->page->getToken());
  71. }
  72. public function testIsLastShouldReturnTrueWhenNoTokenIsSet()
  73. {
  74. $this->assertTrue($this->page->isLast());
  75. }
  76. public function testIsLastShouldReturnFalseWhenTokenIsSet()
  77. {
  78. $this->page->setToken('token');
  79. $this->assertFalse($this->page->isLast());
  80. }
  81. public function testIsLastShouldReturnTrueWhenTokenIsRemoved()
  82. {
  83. $this->page->setToken('');
  84. $this->assertTrue($this->page->isLast());
  85. }
  86. public function testToStringMethod()
  87. {
  88. $this->page->setData('data');
  89. $this->page->setToken('token');
  90. $this->assertEquals(
  91. "Page with token: token\n and data: data",
  92. $this->page->__toString()
  93. );
  94. }
  95. }