Skip to content

Commit ccc6e08

Browse files
committed
Start adding test for BootstrapPaginatorHelper.
1 parent 167385c commit ccc6e08

File tree

2 files changed

+96
-8
lines changed

2 files changed

+96
-8
lines changed

tests/TestCase/View/Helper/BootstrapFormHelperTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function testCreate () {
3939
'role' => 'form',
4040
'action'
4141
]]
42-
], $this->Form->create ()) ;
42+
], $this->Form->create ()) ;
4343
// Horizontal form
4444
$result = $this->Form->create (null, ['horizontal' => true]) ;
4545
$this->assertEquals($this->Form->horizontal, true) ;
@@ -57,12 +57,12 @@ public function testCreate () {
5757
'action',
5858
'class' => 'form-inline'
5959
]]
60-
], $result) ;
60+
], $result) ;
6161
// Automatically return to non horizonal form
6262
$result = $this->Form->create () ;
6363
$this->assertEquals($this->Form->inline, false) ;
6464
}
65-
65+
6666
protected function _testInput ($expected, $fieldName, $options = []) {
6767
$formOptions = [] ;
6868
if (isset($options['_formOptions'])) {
@@ -72,7 +72,7 @@ protected function _testInput ($expected, $fieldName, $options = []) {
7272
$this->Form->create (null, $formOptions) ;
7373
return $this->assertHtml ($expected, $this->Form->input ($fieldName, $options)) ;
7474
}
75-
75+
7676
public function testInput () {
7777
$fieldName = 'field' ;
7878
// Standard form
@@ -142,7 +142,7 @@ public function testInputText () {
142142
'/div'
143143
], $fieldName, ['type' => 'text']) ;
144144
}
145-
145+
146146
public function testInputSelect () {
147147

148148
}
@@ -320,9 +320,9 @@ public function testInputRadio () {
320320
}
321321

322322
public function testInputCheckbox () {
323-
323+
324324
}
325-
325+
326326
public function testInputGroup () {
327327
$fieldName = 'field' ;
328328
$options = [
@@ -495,7 +495,7 @@ public function testInputGroup () {
495495
'/div'
496496
] ;
497497
$this->_testInput ($expected, $fieldName, $options + [
498-
'append' => [$this->Form->button('Go!'), $this->Form->button('GoGo!')]
498+
'append' => [$this->Form->button('Go!'), $this->Form->button('GoGo!')]
499499
]) ;
500500
// Test with append dropdown
501501
$expected = [
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?php
2+
3+
namespace Bootstrap\Test\TestCase\View\Helper;
4+
5+
use Bootstrap\View\Helper\BootstrapHtmlHelper;
6+
use Bootstrap\View\Helper\BootstrapPaginatorHelper;
7+
use Cake\Core\Configure;
8+
use Cake\Network\Request;
9+
use Cake\Routing\Router;
10+
use Cake\TestSuite\TestCase;
11+
use Cake\View\View;
12+
13+
class BootstrapPaginatorHelperTest extends TestCase {
14+
15+
/**
16+
* setUp method
17+
*
18+
* @return void
19+
*/
20+
public function setUp()
21+
{
22+
parent::setUp();
23+
$this->View = new View();
24+
$this->View->Html = new BootstrapHtmlHelper($this->View);
25+
$this->Paginator = new BootstrapPaginatorHelper($this->View);
26+
$this->Paginator->request = new Request();
27+
$this->Paginator->request->addParams([
28+
'paging' => [
29+
'Article' => [
30+
'page' => 1,
31+
'current' => 9,
32+
'count' => 62,
33+
'prevPage' => false,
34+
'nextPage' => true,
35+
'pageCount' => 7,
36+
'sort' => null,
37+
'direction' => null,
38+
'limit' => null,
39+
]
40+
]
41+
]);
42+
Configure::write('Routing.prefixes', []);
43+
Router::reload();
44+
Router::connect('/:controller/:action/*');
45+
Router::connect('/:plugin/:controller/:action/*');
46+
}
47+
48+
public function testPrev () {
49+
$this->assertHtml([
50+
['li' => [
51+
'class' => 'disabled'
52+
]],
53+
['a' => true], '&lt;', '/a',
54+
'/li'
55+
], $this->Paginator->prev('<'));
56+
$this->assertHtml([
57+
['li' => [
58+
'class' => 'disabled'
59+
]],
60+
['a' => true],
61+
['i' => [
62+
'class' => 'glyphicon glyphicon-chevron-left'
63+
]],
64+
'/i', '/a', '/li'
65+
], $this->Paginator->prev('i:chevron-left'));
66+
}
67+
68+
public function testNext () {
69+
$this->assertHtml([
70+
['li' => true],
71+
['a' => [
72+
'href' => '/index?page=2'
73+
]], '&gt;', '/a',
74+
'/li'
75+
], $this->Paginator->next('>'));
76+
$this->assertHtml([
77+
['li' => true],
78+
['a' => [
79+
'href' => '/index?page=2'
80+
]],
81+
['i' => [
82+
'class' => 'glyphicon glyphicon-chevron-right'
83+
]],
84+
'/i', '/a', '/li'
85+
], $this->Paginator->next('i:chevron-right'));
86+
}
87+
88+
};

0 commit comments

Comments
 (0)