Skip to content
This repository
Browse code

Adding missing test scenarios in the paginator helper

  • Loading branch information...
commit 653163c891365da0b79f8a507a5b185060103bff 1 parent 608e5ee
Jelle Henkens authored September 09, 2011 markstory committed September 09, 2011
86  lib/Cake/Test/Case/View/Helper/PaginatorHelperTest.php
@@ -359,6 +359,9 @@ public function testSortKey() {
359 359
 		)));
360 360
 		$this->assertEqual('Article.title', $result);
361 361
 
  362
+		$result = $this->Paginator->sortKey('Article', array('order' => 'Article.title'));
  363
+		$this->assertEqual($result, 'Article.title');
  364
+
362 365
 		$result = $this->Paginator->sortKey('Article', array('sort' => 'Article.title'));
363 366
 		$this->assertEqual($result, 'Article.title');
364 367
 
@@ -1273,25 +1276,25 @@ public function testNumbers() {
1273 1276
 			)
1274 1277
 		);
1275 1278
 
1276  
-		$result = $this->Paginator->numbers(array('first' => 1));
  1279
+		$result = $this->Paginator->numbers(array('first' => 1, 'class' => 'page-link'));
1277 1280
 		$expected = array(
1278  
-			array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
  1281
+			array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
1279 1282
 			' | ',
1280  
-			array('span' => array('class' => 'current')), '2', '/span',
  1283
+			array('span' => array('class' => 'current page-link')), '2', '/span',
1281 1284
 			' | ',
1282  
-			array('span' => array()), array('a' => array('href' => '/index/page:3')), '3', '/a', '/span',
  1285
+			array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:3')), '3', '/a', '/span',
1283 1286
 			' | ',
1284  
-			array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span',
  1287
+			array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span',
1285 1288
 			' | ',
1286  
-			array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span',
  1289
+			array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span',
1287 1290
 			' | ',
1288  
-			array('span' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span',
  1291
+			array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span',
1289 1292
 			' | ',
1290  
-			array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span',
  1293
+			array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span',
1291 1294
 			' | ',
1292  
-			array('span' => array()), array('a' => array('href' => '/index/page:8')), '8', '/a', '/span',
  1295
+			array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:8')), '8', '/a', '/span',
1293 1296
 			' | ',
1294  
-			array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span',
  1297
+			array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span',
1295 1298
 		);
1296 1299
 		$this->assertTags($result, $expected);
1297 1300
 
@@ -2260,7 +2263,6 @@ public function testOptionsConvertKeys() {
2260 2263
 		$this->assertEquals($expected, $result);
2261 2264
 	}
2262 2265
 
2263  
-
2264 2266
 /**
2265 2267
  * test the current() method
2266 2268
  *
@@ -2274,4 +2276,66 @@ public function testCurrent() {
2274 2276
 		$this->assertEquals(1, $result);
2275 2277
 	}
2276 2278
 
  2279
+/**
  2280
+ * test the defaultModel() method
  2281
+ *
  2282
+ * @return void
  2283
+ */
  2284
+	public function testNoDefaultModel() {
  2285
+		$this->Paginator->request = new CakeRequest(null, false);
  2286
+		$this->assertNull($this->Paginator->defaultModel());
  2287
+	}
  2288
+
  2289
+/**
  2290
+ * test the numbers() method when there is only one page
  2291
+ *
  2292
+ * @return void
  2293
+ */
  2294
+	public function testWithOnePage() {
  2295
+		$this->Paginator->request['paging'] = array(
  2296
+			'Article' => array(
  2297
+				'page' => 1,
  2298
+				'current' => 2,
  2299
+				'count' => 2,
  2300
+				'prevPage' => false,
  2301
+				'nextPage' => true,
  2302
+				'pageCount' => 1,
  2303
+				'options' => array(
  2304
+					'page' => 1,
  2305
+				),
  2306
+				'paramType' => 'named',
  2307
+			)
  2308
+		);
  2309
+		$this->assertFalse($this->Paginator->numbers());
  2310
+		$this->assertFalse($this->Paginator->first());
  2311
+		$this->assertFalse($this->Paginator->last());
  2312
+	}
  2313
+
  2314
+/**
  2315
+ * test the numbers() method when there is only one page
  2316
+ *
  2317
+ * @return void
  2318
+ */
  2319
+	public function testWithZeroPages() {
  2320
+		$this->Paginator->request['paging'] = array(
  2321
+			'Article' => array(
  2322
+				'page' => 0,
  2323
+				'current' => 0,
  2324
+				'count' => 0,
  2325
+				'prevPage' => false,
  2326
+				'nextPage' => false,
  2327
+				'pageCount' => 0,
  2328
+				'limit' => 10,
  2329
+				'options' => array(
  2330
+					'page' => 0,
  2331
+					'conditions' => array()
  2332
+				),
  2333
+				'paramType' => 'named',
  2334
+			)
  2335
+		);
  2336
+
  2337
+		$result = $this->Paginator->counter(array('format' => 'pages'));
  2338
+		$expected = '0 of 1';
  2339
+		$this->assertEqual($expected, $result);
  2340
+	}
2277 2341
 }

0 notes on commit 653163c

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