Skip to content
This repository
Browse code

Applying optimization patch to PaginatorHelper and test refactorings …

…to PaginatorHelper test case. Thanks Phally. Fixes #6526

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8259 3807eeeb-6ff5-0310-8944-8be069107fe0
  • Loading branch information...
commit 47cd941b530f0c892fb93b8a4d2311d3f5c1d5b3 1 parent 9da7b6e
Mark Story authored July 28, 2009
30  cake/libs/view/helpers/paginator.php
@@ -491,15 +491,12 @@ function numbers($options = array()) {
491 491
 				$end = $params['page'] + ($modulus  - $params['page']) + 1;
492 492
 			}
493 493
 
494  
-			if ($first) {
495  
-				if ($start > (int)$first) {
496  
-					if ($start == $first + 1) {
497  
-						$out .= $this->first($first, array('tag' => $tag, 'after' => $separator, 'separator' => $separator));
498  
-					} else {
499  
-						$out .= $this->first($first, array('tag' => $tag, 'separator' => $separator));
500  
-					}
501  
-				} elseif ($start == 2) {
502  
-					$out .= $this->Html->tag($tag, $this->link(1, array('page' => 1), $options)) . $separator;
  494
+			if ($first && $start > 1) {
  495
+				$offset = ($start <= (int)$first) ? $start - 1 : $first;
  496
+				if ($offset < $start - 1) {
  497
+					$out .= $this->first($offset, array('tag' => $tag, 'separator' => $separator));
  498
+				} else {
  499
+					$out .= $this->first($offset, array('tag' => $tag, 'after' => $separator, 'separator' => $separator));
503 500
 				}
504 501
 			}
505 502
 
@@ -525,15 +522,12 @@ function numbers($options = array()) {
525 522
 
526 523
 			$out .= $after;
527 524
 
528  
-			if ($last) {
529  
-				if ($end <= $params['pageCount'] - (int)$last) {
530  
-					if ($end + 1 == $params['pageCount']) {
531  
-						$out .= $this->last($last, array('tag' => $tag, 'before' => $separator, 'separator' => $separator));
532  
-					} else {
533  
-						$out .= $this->last($last, array('tag' => $tag, 'separator' => $separator));
534  
-					}
535  
-				} elseif ($end == $params['pageCount'] - 1) {
536  
-					$out .= $separator . $this->Html->tag($tag, $this->link($params['pageCount'], array('page' => $params['pageCount']), $options));
  525
+			if ($last && $end < $params['pageCount']) {
  526
+				$offset = ($params['pageCount'] < $end + (int)$last) ? $params['pageCount'] - $end : $last;
  527
+				if ($offset <= $last && $params['pageCount'] - $end > $offset) {
  528
+					$out .= $this->last($offset, array('tag' => $tag, 'separator' => $separator));
  529
+				} else {
  530
+					$out .= $this->last($offset, array('tag' => $tag, 'before' => $separator, 'separator' => $separator));
537 531
 				}
538 532
 			}
539 533
 
426  cake/tests/cases/libs/view/helpers/paginator.test.php
@@ -745,29 +745,116 @@ function testNumbers() {
745 745
 			'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()))
746 746
 		);
747 747
 		$result = $this->Paginator->numbers();
748  
-		$expected = '<span><a href="/index/page:4">4</a></span> | <span><a href="/index/page:5">5</a></span> | <span><a href="/index/page:6">6</a></span> | <span><a href="/index/page:7">7</a></span> | <span class="current">8</span> | <span><a href="/index/page:9">9</a></span> | <span><a href="/index/page:10">10</a></span> | <span><a href="/index/page:11">11</a></span> | <span><a href="/index/page:12">12</a></span>';
749  
-		$this->assertEqual($result, $expected);
  748
+		$expected = array(
  749
+			array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span',
  750
+			' | ',
  751
+			array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span',
  752
+			' | ',
  753
+			array('span' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span',
  754
+			' | ',
  755
+			array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span',
  756
+			' | ',
  757
+			array('span' => array('class' => 'current')), '8', '/span',
  758
+			' | ',
  759
+			array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span',
  760
+			' | ',
  761
+			array('span' => array()), array('a' => array('href' => '/index/page:10')), '10', '/a', '/span',
  762
+			' | ',
  763
+			array('span' => array()), array('a' => array('href' => '/index/page:11')), '11', '/a', '/span',
  764
+			' | ',
  765
+			array('span' => array()), array('a' => array('href' => '/index/page:12')), '12', '/a', '/span',
  766
+		);
  767
+		$this->assertTags($result, $expected);
750 768
 
751 769
 		$result = $this->Paginator->numbers(array('tag' => 'li'));
752  
-		$expected = '<li><a href="/index/page:4">4</a></li> | <li><a href="/index/page:5">5</a></li> | <li><a href="/index/page:6">6</a></li> | <li><a href="/index/page:7">7</a></li> | <li class="current">8</li> | <li><a href="/index/page:9">9</a></li> | <li><a href="/index/page:10">10</a></li> | <li><a href="/index/page:11">11</a></li> | <li><a href="/index/page:12">12</a></li>';
753  
-		$this->assertEqual($result, $expected);
  770
+		$expected = array(
  771
+			array('li' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/li',
  772
+			' | ',
  773
+			array('li' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/li',
  774
+			' | ',
  775
+			array('li' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/li',
  776
+			' | ',
  777
+			array('li' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/li',
  778
+			' | ',
  779
+			array('li' => array('class' => 'current')), '8', '/li',
  780
+			' | ',
  781
+			array('li' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/li',
  782
+			' | ',
  783
+			array('li' => array()), array('a' => array('href' => '/index/page:10')), '10', '/a', '/li',
  784
+			' | ',
  785
+			array('li' => array()), array('a' => array('href' => '/index/page:11')), '11', '/a', '/li',
  786
+			' | ',
  787
+			array('li' => array()), array('a' => array('href' => '/index/page:12')), '12', '/a', '/li',
  788
+		);
  789
+		$this->assertTags($result, $expected);
754 790
 
755 791
 		$result = $this->Paginator->numbers(array('tag' => 'li', 'separator' => false));
756  
-		$expected = '<li><a href="/index/page:4">4</a></li><li><a href="/index/page:5">5</a></li><li><a href="/index/page:6">6</a></li><li><a href="/index/page:7">7</a></li><li class="current">8</li><li><a href="/index/page:9">9</a></li><li><a href="/index/page:10">10</a></li><li><a href="/index/page:11">11</a></li><li><a href="/index/page:12">12</a></li>';
757  
-		$this->assertEqual($result, $expected);
  792
+		$expected = array(
  793
+			array('li' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/li',
  794
+			array('li' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/li',
  795
+			array('li' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/li',
  796
+			array('li' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/li',
  797
+			array('li' => array('class' => 'current')), '8', '/li',
  798
+			array('li' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/li',
  799
+			array('li' => array()), array('a' => array('href' => '/index/page:10')), '10', '/a', '/li',
  800
+			array('li' => array()), array('a' => array('href' => '/index/page:11')), '11', '/a', '/li',
  801
+			array('li' => array()), array('a' => array('href' => '/index/page:12')), '12', '/a', '/li',
  802
+		);
  803
+		$this->assertTags($result, $expected);
758 804
 
759 805
 		$result = $this->Paginator->numbers(true);
760  
-		$expected = '<span><a href="/index/page:1">first</a></span> | <span><a href="/index/page:4">4</a></span> | <span><a href="/index/page:5">5</a></span> | <span><a href="/index/page:6">6</a></span> | <span><a href="/index/page:7">7</a></span> | <span class="current">8</span> | <span><a href="/index/page:9">9</a></span> | <span><a href="/index/page:10">10</a></span> | <span><a href="/index/page:11">11</a></span> | <span><a href="/index/page:12">12</a></span> | <span><a href="/index/page:15">last</a></span>';
761  
-		$this->assertEqual($result, $expected);
762  
-
  806
+		$expected = array(
  807
+			array('span' => array()), array('a' => array('href' => '/index/page:1')), 'first', '/a', '/span',
  808
+			' | ',
  809
+			array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span',
  810
+			' | ',
  811
+			array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span',
  812
+			' | ',
  813
+			array('span' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span',
  814
+			' | ',
  815
+			array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span',
  816
+			' | ',
  817
+			array('span' => array('class' => 'current')), '8', '/span',
  818
+			' | ',
  819
+			array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span',
  820
+			' | ',
  821
+			array('span' => array()), array('a' => array('href' => '/index/page:10')), '10', '/a', '/span',
  822
+			' | ',
  823
+			array('span' => array()), array('a' => array('href' => '/index/page:11')), '11', '/a', '/span',
  824
+			' | ',
  825
+			array('span' => array()), array('a' => array('href' => '/index/page:12')), '12', '/a', '/span',
  826
+			' | ',
  827
+			array('span' => array()), array('a' => array('href' => '/index/page:15')), 'last', '/a', '/span',
  828
+		);
  829
+		$this->assertTags($result, $expected);
  830
+		
763 831
 		$this->Paginator->params['paging'] = array('Client' => array(
764 832
 			'page' => 1, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15,
765 833
 			'defaults' => array('limit' => 3, 'step' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()),
766 834
 			'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()))
767 835
 		);
768 836
 		$result = $this->Paginator->numbers();
769  
-		$expected = '<span class="current">1</span> | <span><a href="/index/page:2">2</a></span> | <span><a href="/index/page:3">3</a></span> | <span><a href="/index/page:4">4</a></span> | <span><a href="/index/page:5">5</a></span> | <span><a href="/index/page:6">6</a></span> | <span><a href="/index/page:7">7</a></span> | <span><a href="/index/page:8">8</a></span> | <span><a href="/index/page:9">9</a></span>';
770  
-		$this->assertEqual($result, $expected);
  837
+		$expected = array(
  838
+			array('span' => array('class' => 'current')), '1', '/span',
  839
+			' | ',
  840
+			array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span',
  841
+			' | ',
  842
+			array('span' => array()), array('a' => array('href' => '/index/page:3')), '3', '/a', '/span',
  843
+			' | ',
  844
+			array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span',
  845
+			' | ',
  846
+			array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span',
  847
+			' | ',
  848
+			array('span' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span',
  849
+			' | ',
  850
+			array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span',
  851
+			' | ',
  852
+			array('span' => array()), array('a' => array('href' => '/index/page:8')), '8', '/a', '/span',
  853
+			' | ',
  854
+			array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span',
  855
+		);
  856
+		$this->assertTags($result, $expected);
  857
+		
771 858
 
772 859
 		$this->Paginator->params['paging'] = array('Client' => array(
773 860
 			'page' => 14, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15,
@@ -775,8 +862,26 @@ function testNumbers() {
775 862
 			'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()))
776 863
 		);
777 864
 		$result = $this->Paginator->numbers();
778  
-		$expected = '<span><a href="/index/page:7">7</a></span> | <span><a href="/index/page:8">8</a></span> | <span><a href="/index/page:9">9</a></span> | <span><a href="/index/page:10">10</a></span> | <span><a href="/index/page:11">11</a></span> | <span><a href="/index/page:12">12</a></span> | <span><a href="/index/page:13">13</a></span> | <span class="current">14</span> | <span><a href="/index/page:15">15</a></span>';
779  
-		$this->assertEqual($result, $expected);
  865
+		$expected = array(
  866
+			array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span',
  867
+			' | ',
  868
+			array('span' => array()), array('a' => array('href' => '/index/page:8')), '8', '/a', '/span',
  869
+			' | ',
  870
+			array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span',
  871
+			' | ',
  872
+			array('span' => array()), array('a' => array('href' => '/index/page:10')), '10', '/a', '/span',
  873
+			' | ',
  874
+			array('span' => array()), array('a' => array('href' => '/index/page:11')), '11', '/a', '/span',
  875
+			' | ',
  876
+			array('span' => array()), array('a' => array('href' => '/index/page:12')), '12', '/a', '/span',
  877
+			' | ',
  878
+			array('span' => array()), array('a' => array('href' => '/index/page:13')), '13', '/a', '/span',
  879
+			' | ',
  880
+			array('span' => array('class' => 'current')), '14', '/span',
  881
+			' | ',
  882
+			array('span' => array()), array('a' => array('href' => '/index/page:15')), '15', '/a', '/span',
  883
+		);
  884
+		$this->assertTags($result, $expected);
780 885
 
781 886
 		$this->Paginator->params['paging'] = array('Client' => array(
782 887
 			'page' => 2, 'current' => 3, 'count' => 27, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 9,
@@ -785,12 +890,48 @@ function testNumbers() {
785 890
 		);
786 891
 
787 892
 		$result = $this->Paginator->numbers(array('first' => 1));
788  
-		$expected = '<span><a href="/index/page:1">1</a></span> | <span class="current">2</span> | <span><a href="/index/page:3">3</a></span> | <span><a href="/index/page:4">4</a></span> | <span><a href="/index/page:5">5</a></span> | <span><a href="/index/page:6">6</a></span> | <span><a href="/index/page:7">7</a></span> | <span><a href="/index/page:8">8</a></span> | <span><a href="/index/page:9">9</a></span>';
789  
-		$this->assertEqual($result, $expected);
  893
+		$expected = array(
  894
+			array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
  895
+			' | ',
  896
+			array('span' => array('class' => 'current')), '2', '/span',
  897
+			' | ',
  898
+			array('span' => array()), array('a' => array('href' => '/index/page:3')), '3', '/a', '/span',
  899
+			' | ',
  900
+			array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span',
  901
+			' | ',
  902
+			array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span',
  903
+			' | ',
  904
+			array('span' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span',
  905
+			' | ',
  906
+			array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span',
  907
+			' | ',
  908
+			array('span' => array()), array('a' => array('href' => '/index/page:8')), '8', '/a', '/span',
  909
+			' | ',
  910
+			array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span',
  911
+		);
  912
+		$this->assertTags($result, $expected);
790 913
 
791 914
 		$result = $this->Paginator->numbers(array('last' => 1));
792  
-		$expected = '<span><a href="/index/page:1">1</a></span> | <span class="current">2</span> | <span><a href="/index/page:3">3</a></span> | <span><a href="/index/page:4">4</a></span> | <span><a href="/index/page:5">5</a></span> | <span><a href="/index/page:6">6</a></span> | <span><a href="/index/page:7">7</a></span> | <span><a href="/index/page:8">8</a></span> | <span><a href="/index/page:9">9</a></span>';
793  
-		$this->assertEqual($result, $expected);
  915
+		$expected = array(
  916
+			array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
  917
+			' | ',
  918
+			array('span' => array('class' => 'current')), '2', '/span',
  919
+			' | ',
  920
+			array('span' => array()), array('a' => array('href' => '/index/page:3')), '3', '/a', '/span',
  921
+			' | ',
  922
+			array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span',
  923
+			' | ',
  924
+			array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span',
  925
+			' | ',
  926
+			array('span' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span',
  927
+			' | ',
  928
+			array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span',
  929
+			' | ',
  930
+			array('span' => array()), array('a' => array('href' => '/index/page:8')), '8', '/a', '/span',
  931
+			' | ',
  932
+			array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span',
  933
+		);
  934
+		$this->assertTags($result, $expected);
794 935
 
795 936
 		$this->Paginator->params['paging'] = array('Client' => array(
796 937
 			'page' => 15, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15,
@@ -799,8 +940,29 @@ function testNumbers() {
799 940
 		);
800 941
 
801 942
 		$result = $this->Paginator->numbers(array('first' => 1));
802  
-		$expected = '<span><a href="/index/page:1">1</a></span>...<span><a href="/index/page:7">7</a></span> | <span><a href="/index/page:8">8</a></span> | <span><a href="/index/page:9">9</a></span> | <span><a href="/index/page:10">10</a></span> | <span><a href="/index/page:11">11</a></span> | <span><a href="/index/page:12">12</a></span> | <span><a href="/index/page:13">13</a></span> | <span><a href="/index/page:14">14</a></span> | <span class="current">15</span>';
803  
-		$this->assertEqual($result, $expected);
  943
+		$expected = array(
  944
+			array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
  945
+			'...',
  946
+			array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span',
  947
+			' | ',
  948
+			array('span' => array()), array('a' => array('href' => '/index/page:8')), '8', '/a', '/span',
  949
+			' | ',
  950
+			array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span',
  951
+			' | ',
  952
+			array('span' => array()), array('a' => array('href' => '/index/page:10')), '10', '/a', '/span',
  953
+			' | ',
  954
+			array('span' => array()), array('a' => array('href' => '/index/page:11')), '11', '/a', '/span',
  955
+			' | ',
  956
+			array('span' => array()), array('a' => array('href' => '/index/page:12')), '12', '/a', '/span',
  957
+			' | ',
  958
+			array('span' => array()), array('a' => array('href' => '/index/page:13')), '13', '/a', '/span',
  959
+			' | ',
  960
+			array('span' => array()), array('a' => array('href' => '/index/page:14')), '14', '/a', '/span',
  961
+			' | ',
  962
+			array('span' => array('class' => 'current')), '15', '/span',
  963
+
  964
+		);
  965
+		$this->assertTags($result, $expected);
804 966
 
805 967
 		$this->Paginator->params['paging'] = array('Client' => array(
806 968
 			'page' => 10, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15,
@@ -809,8 +971,30 @@ function testNumbers() {
809 971
 		);
810 972
 
811 973
 		$result = $this->Paginator->numbers(array('first' => 1, 'last' => 1));
812  
-		$expected = '<span><a href="/index/page:1">1</a></span>...<span><a href="/index/page:6">6</a></span> | <span><a href="/index/page:7">7</a></span> | <span><a href="/index/page:8">8</a></span> | <span><a href="/index/page:9">9</a></span> | <span class="current">10</span> | <span><a href="/index/page:11">11</a></span> | <span><a href="/index/page:12">12</a></span> | <span><a href="/index/page:13">13</a></span> | <span><a href="/index/page:14">14</a></span> | <span><a href="/index/page:15">15</a></span>';
813  
-		$this->assertEqual($result, $expected);
  974
+		$expected = array(
  975
+			array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
  976
+			'...',
  977
+			array('span' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span',
  978
+			' | ',
  979
+			array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span',
  980
+			' | ',
  981
+			array('span' => array()), array('a' => array('href' => '/index/page:8')), '8', '/a', '/span',
  982
+			' | ',
  983
+			array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span',
  984
+			' | ',
  985
+			array('span' => array('class' => 'current')), '10', '/span',
  986
+			' | ',
  987
+			array('span' => array()), array('a' => array('href' => '/index/page:11')), '11', '/a', '/span',
  988
+			' | ',
  989
+			array('span' => array()), array('a' => array('href' => '/index/page:12')), '12', '/a', '/span',
  990
+			' | ',
  991
+			array('span' => array()), array('a' => array('href' => '/index/page:13')), '13', '/a', '/span',
  992
+			' | ',
  993
+			array('span' => array()), array('a' => array('href' => '/index/page:14')), '14', '/a', '/span',
  994
+			' | ',
  995
+			array('span' => array()), array('a' => array('href' => '/index/page:15')), '15', '/a', '/span',
  996
+		);
  997
+		$this->assertTags($result, $expected);
814 998
 
815 999
 		$this->Paginator->params['paging'] = array('Client' => array(
816 1000
 			'page' => 6, 'current' => 15, 'count' => 623, 'prevPage' => 1, 'nextPage' => 1, 'pageCount' => 42,
@@ -819,8 +1003,30 @@ function testNumbers() {
819 1003
 		);
820 1004
 
821 1005
 		$result = $this->Paginator->numbers(array('first' => 1, 'last' => 1));
822  
-		$expected = '<span><a href="/index/page:1">1</a></span> | <span><a href="/index/page:2">2</a></span> | <span><a href="/index/page:3">3</a></span> | <span><a href="/index/page:4">4</a></span> | <span><a href="/index/page:5">5</a></span> | <span class="current">6</span> | <span><a href="/index/page:7">7</a></span> | <span><a href="/index/page:8">8</a></span> | <span><a href="/index/page:9">9</a></span> | <span><a href="/index/page:10">10</a></span>...<span><a href="/index/page:42">42</a></span>';
823  
-		$this->assertEqual($result, $expected);
  1006
+		$expected = array(
  1007
+			array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
  1008
+			' | ',
  1009
+			array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span',
  1010
+			' | ',
  1011
+			array('span' => array()), array('a' => array('href' => '/index/page:3')), '3', '/a', '/span',
  1012
+			' | ',
  1013
+			array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span',
  1014
+			' | ',
  1015
+			array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span',
  1016
+			' | ',
  1017
+			array('span' => array('class' => 'current')), '6', '/span',
  1018
+			' | ',
  1019
+			array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span',
  1020
+			' | ',
  1021
+			array('span' => array()), array('a' => array('href' => '/index/page:8')), '8', '/a', '/span',
  1022
+			' | ',
  1023
+			array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span',
  1024
+			' | ',
  1025
+			array('span' => array()), array('a' => array('href' => '/index/page:10')), '10', '/a', '/span',
  1026
+			'...',
  1027
+			array('span' => array()), array('a' => array('href' => '/index/page:42')), '42', '/a', '/span',
  1028
+		);
  1029
+		$this->assertTags($result, $expected);
824 1030
 
825 1031
 		$this->Paginator->params['paging'] = array('Client' => array(
826 1032
 			'page' => 37, 'current' => 15, 'count' => 623, 'prevPage' => 1, 'nextPage' => 1, 'pageCount' => 42,
@@ -829,8 +1035,30 @@ function testNumbers() {
829 1035
 		);
830 1036
 
831 1037
 		$result = $this->Paginator->numbers(array('first' => 1, 'last' => 1));
832  
-		$expected = '<span><a href="/index/page:1">1</a></span>...<span><a href="/index/page:33">33</a></span> | <span><a href="/index/page:34">34</a></span> | <span><a href="/index/page:35">35</a></span> | <span><a href="/index/page:36">36</a></span> | <span class="current">37</span> | <span><a href="/index/page:38">38</a></span> | <span><a href="/index/page:39">39</a></span> | <span><a href="/index/page:40">40</a></span> | <span><a href="/index/page:41">41</a></span> | <span><a href="/index/page:42">42</a></span>';
833  
-		$this->assertEqual($result, $expected);
  1038
+		$expected = array(
  1039
+			array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
  1040
+			'...',
  1041
+			array('span' => array()), array('a' => array('href' => '/index/page:33')), '33', '/a', '/span',
  1042
+			' | ',
  1043
+			array('span' => array()), array('a' => array('href' => '/index/page:34')), '34', '/a', '/span',
  1044
+			' | ',
  1045
+			array('span' => array()), array('a' => array('href' => '/index/page:35')), '35', '/a', '/span',
  1046
+			' | ',
  1047
+			array('span' => array()), array('a' => array('href' => '/index/page:36')), '36', '/a', '/span',
  1048
+			' | ',
  1049
+			array('span' => array('class' => 'current')), '37', '/span',
  1050
+			' | ',
  1051
+			array('span' => array()), array('a' => array('href' => '/index/page:38')), '38', '/a', '/span',
  1052
+			' | ',
  1053
+			array('span' => array()), array('a' => array('href' => '/index/page:39')), '39', '/a', '/span',
  1054
+			' | ',
  1055
+			array('span' => array()), array('a' => array('href' => '/index/page:40')), '40', '/a', '/span',
  1056
+			' | ',
  1057
+			array('span' => array()), array('a' => array('href' => '/index/page:41')), '41', '/a', '/span',
  1058
+			' | ',
  1059
+			array('span' => array()), array('a' => array('href' => '/index/page:42')), '42', '/a', '/span',
  1060
+		);
  1061
+		$this->assertTags($result, $expected);
834 1062
 
835 1063
 		$this->Paginator->params['paging'] = array(
836 1064
 			'Client' => array(
@@ -856,8 +1084,14 @@ function testNumbers() {
856 1084
 		);
857 1085
 		$options = array('modulus' => 10);
858 1086
 		$result = $this->Paginator->numbers($options);
859  
-		$expected = '<span class="current">1</span> | <span><a href="/index/page:2">2</a></span> | <span><a href="/index/page:3">3</a></span>';
860  
-		$this->assertEqual($result, $expected);
  1087
+		$expected = array(
  1088
+			array('span' => array('class' => 'current')), '1', '/span',
  1089
+			' | ',
  1090
+			array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span',
  1091
+			' | ',
  1092
+			array('span' => array()), array('a' => array('href' => '/index/page:3')), '3', '/a', '/span',
  1093
+		);
  1094
+		$this->assertTags($result, $expected);
861 1095
 
862 1096
 		$this->Paginator->params['paging'] = array('Client' => array(
863 1097
 			'page' => 2, 'current' => 10, 'count' => 31, 'prevPage' => true, 'nextPage' => true, 'pageCount' => 4,
@@ -865,8 +1099,17 @@ function testNumbers() {
865 1099
 			'options' => array('page' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()))
866 1100
 		);
867 1101
 		$result = $this->Paginator->numbers();
868  
-		$expected = '<span><a href="/index/page:1/sort:Client.name/direction:DESC">1</a></span> | <span class="current">2</span> | <span><a href="/index/page:3/sort:Client.name/direction:DESC">3</a></span> | <span><a href="/index/page:4/sort:Client.name/direction:DESC">4</a></span>';
869  
-		$this->assertEqual($result, $expected);
  1102
+		$expected = array(
  1103
+			array('span' => array()), array('a' => array('href' => '/index/page:1/sort:Client.name/direction:DESC')), '1', '/a', '/span',
  1104
+			' | ',
  1105
+			array('span' => array('class' => 'current')), '2', '/span',
  1106
+			' | ',
  1107
+			array('span' => array()), array('a' => array('href' => '/index/page:3/sort:Client.name/direction:DESC')), '3', '/a', '/span',
  1108
+			' | ',
  1109
+			array('span' => array()), array('a' => array('href' => '/index/page:4/sort:Client.name/direction:DESC')), '4', '/a', '/span',
  1110
+		);
  1111
+		$this->assertTags($result, $expected);
  1112
+		
870 1113
 
871 1114
 		$this->Paginator->params['paging'] = array('Client' => array(
872 1115
 			'page' => 4895, 'current' => 10, 'count' => 48962, 'prevPage' => 1, 'nextPage' => 1, 'pageCount' => 4897,
@@ -890,11 +1133,7 @@ function testNumbers() {
890 1133
 		);
891 1134
 		$this->assertTags($result, $expected);
892 1135
 
893  
-		$this->Paginator->params['paging'] = array('Client' => array(
894  
-			'page' => 3, 'current' => 10, 'count' => 48962, 'prevPage' => 1, 'nextPage' => 1, 'pageCount' => 4897,
895  
-			'defaults' => array('limit' => 10),
896  
-			'options' => array('page' => 4894, 'limit' => 10, 'order' => 'Client.name DESC', 'conditions' => array()))
897  
-		);
  1136
+		$this->Paginator->params['paging']['Client']['page'] = 3;
898 1137
 
899 1138
 		$result = $this->Paginator->numbers(array('first' => 2, 'modulus' => 2, 'last' => 2));
900 1139
 		$expected = array(
@@ -927,6 +1166,125 @@ function testNumbers() {
927 1166
 			array('span' => array()), array('a' => array('href' => '/index/page:4897')), '4897', '/a', '/span',
928 1167
 		);
929 1168
 		$this->assertTags($result, $expected);
  1169
+		
  1170
+		$result = $this->Paginator->numbers(array('first' => 5, 'modulus' => 5, 'last' => 5, 'separator' => ' - '));
  1171
+		$expected = array(
  1172
+			array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
  1173
+			' - ',
  1174
+			array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span',
  1175
+			' - ',
  1176
+			array('span' => array('class' => 'current')), '3', '/span',
  1177
+			' - ',
  1178
+			array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span',
  1179
+			' - ',
  1180
+			array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span',
  1181
+			' - ',
  1182
+			array('span' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span',
  1183
+			'...',
  1184
+			array('span' => array()), array('a' => array('href' => '/index/page:4893')), '4893', '/a', '/span',
  1185
+			' - ',
  1186
+			array('span' => array()), array('a' => array('href' => '/index/page:4894')), '4894', '/a', '/span',
  1187
+			' - ',
  1188
+			array('span' => array()), array('a' => array('href' => '/index/page:4895')), '4895', '/a', '/span',
  1189
+			' - ',
  1190
+			array('span' => array()), array('a' => array('href' => '/index/page:4896')), '4896', '/a', '/span',
  1191
+			' - ',
  1192
+			array('span' => array()), array('a' => array('href' => '/index/page:4897')), '4897', '/a', '/span',
  1193
+		);
  1194
+		$this->assertTags($result, $expected);
  1195
+		
  1196
+		$this->Paginator->params['paging']['Client']['page'] = 4893;
  1197
+		$result = $this->Paginator->numbers(array('first' => 5, 'modulus' => 4, 'last' => 5, 'separator' => ' - '));
  1198
+		$expected = array(
  1199
+			array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
  1200
+			' - ',
  1201
+			array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span',
  1202
+			' - ',
  1203
+			array('span' => array()), array('a' => array('href' => '/index/page:3')), '3', '/a', '/span',
  1204
+			' - ',
  1205
+			array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span',
  1206
+			' - ',
  1207
+			array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span',
  1208
+			'...',
  1209
+			array('span' => array()), array('a' => array('href' => '/index/page:4891')), '4891', '/a', '/span',
  1210
+			' - ',
  1211
+			array('span' => array()), array('a' => array('href' => '/index/page:4892')), '4892', '/a', '/span',
  1212
+			' - ',
  1213
+			array('span' => array('class' => 'current')), '4893', '/span',
  1214
+			' - ',
  1215
+			array('span' => array()), array('a' => array('href' => '/index/page:4894')), '4894', '/a', '/span',
  1216
+			' - ',
  1217
+			array('span' => array()), array('a' => array('href' => '/index/page:4895')), '4895', '/a', '/span',
  1218
+			' - ',
  1219
+			array('span' => array()), array('a' => array('href' => '/index/page:4896')), '4896', '/a', '/span',
  1220
+			' - ',
  1221
+			array('span' => array()), array('a' => array('href' => '/index/page:4897')), '4897', '/a', '/span',
  1222
+		);
  1223
+		$this->assertTags($result, $expected);
  1224
+		
  1225
+		$this->Paginator->params['paging']['Client']['page'] = 58;
  1226
+		$result = $this->Paginator->numbers(array('first' => 5, 'modulus' => 4, 'last' => 5, 'separator' => ' - '));
  1227
+		$expected = array(
  1228
+			array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
  1229
+			' - ',
  1230
+			array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span',
  1231
+			' - ',
  1232
+			array('span' => array()), array('a' => array('href' => '/index/page:3')), '3', '/a', '/span',
  1233
+			' - ',
  1234
+			array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span',
  1235
+			' - ',
  1236
+			array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span',
  1237
+			'...',
  1238
+			array('span' => array()), array('a' => array('href' => '/index/page:56')), '56', '/a', '/span',
  1239
+			' - ',
  1240
+			array('span' => array()), array('a' => array('href' => '/index/page:57')), '57', '/a', '/span',
  1241
+			' - ',
  1242
+			array('span' => array('class' => 'current')), '58', '/span',
  1243
+			' - ',
  1244
+			array('span' => array()), array('a' => array('href' => '/index/page:59')), '59', '/a', '/span',
  1245
+			' - ',
  1246
+			array('span' => array()), array('a' => array('href' => '/index/page:60')), '60', '/a', '/span',
  1247
+			'...',
  1248
+			array('span' => array()), array('a' => array('href' => '/index/page:4893')), '4893', '/a', '/span',
  1249
+			' - ',
  1250
+			array('span' => array()), array('a' => array('href' => '/index/page:4894')), '4894', '/a', '/span',
  1251
+			' - ',
  1252
+			array('span' => array()), array('a' => array('href' => '/index/page:4895')), '4895', '/a', '/span',
  1253
+			' - ',
  1254
+			array('span' => array()), array('a' => array('href' => '/index/page:4896')), '4896', '/a', '/span',
  1255
+			' - ',
  1256
+			array('span' => array()), array('a' => array('href' => '/index/page:4897')), '4897', '/a', '/span',
  1257
+		);
  1258
+		$this->assertTags($result, $expected);
  1259
+		
  1260
+		$this->Paginator->params['paging']['Client']['page'] = 5;
  1261
+		$result = $this->Paginator->numbers(array('first' => 5, 'modulus' => 4, 'last' => 5, 'separator' => ' - '));
  1262
+		$expected = array(
  1263
+			array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
  1264
+			' - ',
  1265
+			array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span',
  1266
+			' - ',
  1267
+			array('span' => array()), array('a' => array('href' => '/index/page:3')), '3', '/a', '/span',
  1268
+			' - ',
  1269
+			array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span',
  1270
+			' - ',
  1271
+			array('span' => array('class' => 'current')), '5', '/span',
  1272
+			' - ',
  1273
+			array('span' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span',
  1274
+			' - ',
  1275
+			array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span',
  1276
+			'...',
  1277
+			array('span' => array()), array('a' => array('href' => '/index/page:4893')), '4893', '/a', '/span',
  1278
+			' - ',
  1279
+			array('span' => array()), array('a' => array('href' => '/index/page:4894')), '4894', '/a', '/span',
  1280
+			' - ',
  1281
+			array('span' => array()), array('a' => array('href' => '/index/page:4895')), '4895', '/a', '/span',
  1282
+			' - ',
  1283
+			array('span' => array()), array('a' => array('href' => '/index/page:4896')), '4896', '/a', '/span',
  1284
+			' - ',
  1285
+			array('span' => array()), array('a' => array('href' => '/index/page:4897')), '4897', '/a', '/span',
  1286
+		);
  1287
+		$this->assertTags($result, $expected);
930 1288
 	}
931 1289
 /**
932 1290
  * testFirstAndLast method

0 notes on commit 47cd941

Please sign in to comment.
Something went wrong with that request. Please try again.