2
0

ArrayTest.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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_Paginator
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2008 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. /**
  23. * @see Zend_Paginator_Adapter_Array
  24. */
  25. require_once 'Zend/Paginator/Adapter/Array.php';
  26. /**
  27. * @see PHPUnit_Framework_TestCase
  28. */
  29. require_once 'PHPUnit/Framework/TestCase.php';
  30. /**
  31. * @category Zend
  32. * @package Zend_Paginator
  33. * @subpackage UnitTests
  34. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  35. * @license http://framework.zend.com/license/new-bsd New BSD License
  36. */
  37. class Zend_Paginator_Adapter_ArrayTest extends PHPUnit_Framework_TestCase
  38. {
  39. /**
  40. * @var Zend_Paginator_Adapter_Array
  41. */
  42. private $_adapter;
  43. /**
  44. * Prepares the environment before running a test.
  45. */
  46. protected function setUp ()
  47. {
  48. parent::setUp();
  49. $this->_adapter = new Zend_Paginator_Adapter_Array(range(1, 101));
  50. }
  51. /**
  52. * Cleans up the environment after running a test.
  53. */
  54. protected function tearDown ()
  55. {
  56. $this->_adapter = null;
  57. parent::tearDown();
  58. }
  59. public function testGetsItemsAtOffsetZero()
  60. {
  61. $expected = range(1, 10);
  62. $actual = $this->_adapter->getItems(0, 10);
  63. $this->assertEquals($expected, $actual);
  64. }
  65. public function testGetsItemsAtOffsetTen()
  66. {
  67. $expected = range(11, 20);
  68. $actual = $this->_adapter->getItems(10, 10);
  69. $this->assertEquals($expected, $actual);
  70. }
  71. public function testReturnsCorrectCount()
  72. {
  73. $this->assertEquals(101, $this->_adapter->count());
  74. }
  75. }