TYPO3 CMS  TYPO3_6-2
All Classes Namespaces Files Functions Variables Pages
PaginateControllerTest.php
Go to the documentation of this file.
1 <?php
3 
4 /* *
5  * This script is backported from the TYPO3 Flow package "TYPO3.Fluid". *
6  * *
7  * It is free software; you can redistribute it and/or modify it under *
8  * the terms of the GNU Lesser General Public License, either version 3 *
9  * of the License, or (at your option) any later version. *
10  * *
11  * The TYPO3 project - inspiring people to share! *
12  * */
13 
18 
22  protected $controller;
23 
29  public function setUp() {
30  $this->controller = $this->getAccessibleMock('TYPO3\CMS\Fluid\ViewHelpers\Widget\Controller\PaginateController', array('dummy'), array(), '', FALSE);
31  }
32 
37  $this->controller->_set('maximumNumberOfLinks', 8);
38  $this->controller->_set('numberOfPages', 100);
39  $this->controller->_set('currentPage', 50);
40  $this->controller->_call('calculateDisplayRange');
41  $this->assertSame(46, $this->controller->_get('displayRangeStart'));
42  $this->assertSame(53, $this->controller->_get('displayRangeEnd'));
43  }
44 
49  $this->controller->_set('maximumNumberOfLinks', 7);
50  $this->controller->_set('numberOfPages', 100);
51  $this->controller->_set('currentPage', 50);
52  $this->controller->_call('calculateDisplayRange');
53  $this->assertSame(47, $this->controller->_get('displayRangeStart'));
54  $this->assertSame(53, $this->controller->_get('displayRangeEnd'));
55  }
56 
61  $this->controller->_set('maximumNumberOfLinks', 8);
62  $this->controller->_set('numberOfPages', 100);
63  $this->controller->_set('currentPage', 1);
64  $this->controller->_call('calculateDisplayRange');
65  $this->assertSame(1, $this->controller->_get('displayRangeStart'));
66  $this->assertSame(8, $this->controller->_get('displayRangeEnd'));
67  }
68 
73  $this->controller->_set('maximumNumberOfLinks', 7);
74  $this->controller->_set('numberOfPages', 100);
75  $this->controller->_set('currentPage', 1);
76  $this->controller->_call('calculateDisplayRange');
77  $this->assertSame(1, $this->controller->_get('displayRangeStart'));
78  $this->assertSame(7, $this->controller->_get('displayRangeEnd'));
79  }
80 
85  $this->controller->_set('maximumNumberOfLinks', 8);
86  $this->controller->_set('numberOfPages', 100);
87  $this->controller->_set('currentPage', 100);
88  $this->controller->_call('calculateDisplayRange');
89  $this->assertSame(93, $this->controller->_get('displayRangeStart'));
90  $this->assertSame(100, $this->controller->_get('displayRangeEnd'));
91  }
92 
97  $this->controller->_set('maximumNumberOfLinks', 7);
98  $this->controller->_set('numberOfPages', 100);
99  $this->controller->_set('currentPage', 100);
100  $this->controller->_call('calculateDisplayRange');
101  $this->assertSame(94, $this->controller->_get('displayRangeStart'));
102  $this->assertSame(100, $this->controller->_get('displayRangeEnd'));
103  }
104 }
getAccessibleMock( $originalClassName, array $methods=array(), array $arguments=array(), $mockClassName='', $callOriginalConstructor=TRUE, $callOriginalClone=TRUE, $callAutoload=TRUE)