[ZF-10089] Zend_Log
[zend.git] / tests / Zend / Paginator / ScrollingStyle / JumpingTest.php
blob4f80da023b4d6d06e9f8041a0b9b7dd23a7b7206
1 <?php
2 /**
3 * Zend Framework
5 * LICENSE
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.
15 * @category Zend
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
20 * @version $Id$
23 /**
24 * @see Zend_Paginator
26 require_once 'Zend/Paginator.php';
28 /**
29 * @see Zend_Paginator_ScrollingStyle_Jumping
31 require_once 'Zend/Paginator/ScrollingStyle/Jumping.php';
33 /**
34 * @see PHPUnit_Framework_TestCase
36 require_once 'PHPUnit/Framework/TestCase.php';
38 /**
39 * @category Zend
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_JumpingTest extends PHPUnit_Framework_TestCase
48 /**
49 * @var Zend_Paginator_ScrollingStyle_Jumping
51 private $_scrollingStyle;
52 /**
53 * @var Zend_Paginator
55 private $_paginator;
57 private $_expectedRange;
59 /**
60 * Prepares the environment before running a test.
62 protected function setUp()
64 parent::setUp();
65 $this->_scrollingStyle = new Zend_Paginator_ScrollingStyle_Jumping();
66 $this->_paginator = Zend_Paginator::factory(range(1, 101));
67 $this->_paginator->setItemCountPerPage(10);
68 $this->_paginator->setPageRange(10);
69 $this->_expectedRange = array_combine(range(1, 10), range(1, 10));
71 /**
72 * Cleans up the environment after running a test.
74 protected function tearDown()
76 $this->_scrollingStyle = null;
77 $this->_paginator = null;
78 parent::tearDown();
81 public function testGetsPagesInRangeForFirstPage()
83 $this->_paginator->setCurrentPageNumber(1);
84 $actual = $this->_scrollingStyle->getPages($this->_paginator);
85 $this->assertEquals($this->_expectedRange, $actual);
88 public function testGetsPagesInRangeForSecondPage()
90 $this->_paginator->setCurrentPageNumber(2);
91 $actual = $this->_scrollingStyle->getPages($this->_paginator);
92 $this->assertEquals($this->_expectedRange, $actual);
95 public function testGetsPagesInRangeForSecondLastPage()
97 $this->_paginator->setCurrentPageNumber(10);
98 $actual = $this->_scrollingStyle->getPages($this->_paginator);
99 $this->assertEquals($this->_expectedRange, $actual);
102 public function testGetsPagesInRangeForLastPage()
104 $this->_paginator->setCurrentPageNumber(11);
105 $actual = $this->_scrollingStyle->getPages($this->_paginator);
106 $expected = array(11 => 11);
107 $this->assertEquals($expected, $actual);
110 public function testGetsNextAndPreviousPageForFirstPage()
112 $this->_paginator->setCurrentPageNumber(1);
113 $pages = $this->_paginator->getPages('Jumping');
115 $this->assertEquals(2, $pages->next);
118 public function testGetsNextAndPreviousPageForSecondPage()
120 $this->_paginator->setCurrentPageNumber(2);
121 $pages = $this->_paginator->getPages('Jumping');
122 $this->assertEquals(1, $pages->previous);
123 $this->assertEquals(3, $pages->next);
126 public function testGetsNextAndPreviousPageForMiddlePage()
128 $this->_paginator->setCurrentPageNumber(6);
129 $pages = $this->_paginator->getPages('Jumping');
130 $this->assertEquals(5, $pages->previous);
131 $this->assertEquals(7, $pages->next);
134 public function testGetsNextAndPreviousPageForSecondLastPage()
136 $this->_paginator->setCurrentPageNumber(10);
137 $pages = $this->_paginator->getPages('Jumping');
138 $this->assertEquals(9, $pages->previous);
139 $this->assertEquals(11, $pages->next);
142 public function testGetsNextAndPreviousPageForLastPage()
144 $this->_paginator->setCurrentPageNumber(11);
145 $pages = $this->_paginator->getPages('Jumping');
146 $this->assertEquals(10, $pages->previous);