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.
16 * @package Zend_Paginator
17 * @subpackage UnitTests
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
19 * @license http://framework.zend.com/license/new-bsd New BSD License
26 require_once 'Zend/Paginator.php';
29 * @see Zend_Paginator_ScrollingStyle_All
31 require_once 'Zend/Paginator/ScrollingStyle/All.php';
34 * @see PHPUnit_Framework_TestCase
36 require_once 'PHPUnit/Framework/TestCase.php';
40 * @package Zend_Paginator
41 * @subpackage UnitTests
42 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
43 * @license http://framework.zend.com/license/new-bsd New BSD License
44 * @group Zend_Paginator
46 class Zend_Paginator_ScrollingStyle_AllTest
extends PHPUnit_Framework_TestCase
49 * @var Zend_Paginator_ScrollingStyle_All
51 private $_scrollingStyle = null;
52 private $_paginator = null;
55 * Prepares the environment before running a test.
57 protected function setUp()
60 $this->_scrollingStyle
= new Zend_Paginator_ScrollingStyle_All();
61 $this->_paginator
= Zend_Paginator
::factory(range(1, 101));
62 $this->_paginator
->setItemCountPerPage(10);
65 * Cleans up the environment after running a test.
67 protected function tearDown ()
69 $this->_scrollingStyle
= null;
70 $this->_paginator
= null;
75 * Tests Zend_Paginator_ScrollingStyle_All->getPages()
77 public function testGetsPages()
79 $expected = array_combine(range(1, 11), range(1, 11));
80 $pages = $this->_scrollingStyle
->getPages($this->_paginator
);
81 $this->assertEquals($expected, $pages);
84 public function testGetsNextAndPreviousPageForFirstPage()
86 $this->_paginator
->setCurrentPageNumber(1);
87 $pages = $this->_paginator
->getPages('All');
89 $this->assertEquals(2, $pages->next
);
92 public function testGetsNextAndPreviousPageForSecondPage()
94 $this->_paginator
->setCurrentPageNumber(2);
95 $pages = $this->_paginator
->getPages('All');
96 $this->assertEquals(1, $pages->previous
);
97 $this->assertEquals(3, $pages->next
);
100 public function testGetsNextAndPreviousPageForMiddlePage()
102 $this->_paginator
->setCurrentPageNumber(6);
103 $pages = $this->_paginator
->getPages('All');
104 $this->assertEquals(5, $pages->previous
);
105 $this->assertEquals(7, $pages->next
);
108 public function testGetsNextAndPreviousPageForSecondLastPage()
110 $this->_paginator
->setCurrentPageNumber(10);
111 $pages = $this->_paginator
->getPages('All');
112 $this->assertEquals(9, $pages->previous
);
113 $this->assertEquals(11, $pages->next
);
116 public function testGetsNextAndPreviousPageForLastPage()
118 $this->_paginator
->setCurrentPageNumber(11);
119 $pages = $this->_paginator
->getPages('All');
120 $this->assertEquals(10, $pages->previous
);