ArrayTest.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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-2009 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-2009 Zend Technologies USA Inc. (http://www.zend.com)
  35. * @license http://framework.zend.com/license/new-bsd New BSD License
  36. * @group Zend_Paginator
  37. */
  38. class Zend_Paginator_Adapter_ArrayTest extends PHPUnit_Framework_TestCase
  39. {
  40. /**
  41. * @var Zend_Paginator_Adapter_Array
  42. */
  43. private $_adapter;
  44. /**
  45. * Prepares the environment before running a test.
  46. */
  47. protected function setUp ()
  48. {
  49. parent::setUp();
  50. $this->_adapter = new Zend_Paginator_Adapter_Array(range(1, 101));
  51. }
  52. /**
  53. * Cleans up the environment after running a test.
  54. */
  55. protected function tearDown ()
  56. {
  57. $this->_adapter = null;
  58. parent::tearDown();
  59. }
  60. public function testGetsItemsAtOffsetZero()
  61. {
  62. $expected = range(1, 10);
  63. $actual = $this->_adapter->getItems(0, 10);
  64. $this->assertEquals($expected, $actual);
  65. }
  66. public function testGetsItemsAtOffsetTen()
  67. {
  68. $expected = range(11, 20);
  69. $actual = $this->_adapter->getItems(10, 10);
  70. $this->assertEquals($expected, $actual);
  71. }
  72. public function testReturnsCorrectCount()
  73. {
  74. $this->assertEquals(101, $this->_adapter->count());
  75. }
  76. }