ArrayTest.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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-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. /**
  23. * @see Zend_Paginator_Adapter_Array
  24. */
  25. require_once 'Zend/Paginator/Adapter/Array.php';
  26. /**
  27. * @see PHPUnit_Framework_TestCase
  28. */
  29. /**
  30. * @category Zend
  31. * @package Zend_Paginator
  32. * @subpackage UnitTests
  33. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  34. * @license http://framework.zend.com/license/new-bsd New BSD License
  35. * @group Zend_Paginator
  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. /**
  76. * @group ZF-4151
  77. */
  78. public function testEmptySet() {
  79. $this->_adapter = new Zend_Paginator_Adapter_Array(array());
  80. $actual = $this->_adapter->getItems(0, 10);
  81. $this->assertEquals(array(), $actual);
  82. }
  83. }