Skip to content

Commit f9c26a9

Browse files
author
Mikael Capelle
committed
Fix tests and travis for CakePHP 3.7.
1 parent abc4ba2 commit f9c26a9

File tree

3 files changed

+83
-56
lines changed

3 files changed

+83
-56
lines changed

.travis.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ php:
99
dist: trusty
1010

1111
env:
12-
- CAKEPHP_VERSION=3.6.* DEFAULT=1
12+
- CAKEPHP_VERSION=3.7.* DEFAULT=1
1313

1414
matrix:
1515
include:
@@ -29,6 +29,22 @@ matrix:
2929
env: CAKEPHP_VERSION=3.5.0
3030
- php: 7.2
3131
env: CAKEPHP_VERSION=3.5.*
32+
- php: 5.6
33+
env: CAKEPHP_VERSION=3.6.0
34+
- php: 5.6
35+
env: CAKEPHP_VERSION=3.6.*
36+
- php: 7.0
37+
env: CAKEPHP_VERSION=3.6.0
38+
- php: 7.0
39+
env: CAKEPHP_VERSION=3.6.*
40+
- php: 7.1
41+
env: CAKEPHP_VERSION=3.6.0
42+
- php: 7.1
43+
env: CAKEPHP_VERSION=3.6.*
44+
- php: 7.2
45+
env: CAKEPHP_VERSION=3.6.0
46+
- php: 7.2
47+
env: CAKEPHP_VERSION=3.6.*
3248

3349
cache:
3450
directories:

tests/TestCase/View/Helper/FormHelperTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,17 +1158,17 @@ public function testUploadCustomFileInput() {
11581158
$result = $this->form->file('Contact.picture');
11591159
$this->assertHtml($expected, $result);
11601160

1161-
$this->form->request = $this->form->request->withData('Contact.picture', [
1161+
$this->form->getView()->setRequest($this->form->getView()->getRequest()->withData('Contact.picture', [
11621162
'name' => '', 'type' => '', 'tmp_name' => '',
11631163
'error' => 4, 'size' => 0
1164-
]);
1164+
]));
11651165
$result = $this->form->file('Contact.picture');
11661166
$this->assertHtml($expected, $result);
11671167

1168-
$this->form->request = $this->form->request->withData(
1168+
$this->form->getView()->setRequest($this->form->getView()->getRequest()->withData(
11691169
'Contact.picture',
11701170
'no data should be set in value'
1171-
);
1171+
));
11721172
$result = $this->form->file('Contact.picture');
11731173
$this->assertHtml($expected, $result);
11741174
}

tests/TestCase/View/Helper/PaginatorHelperTest.php

Lines changed: 62 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Bootstrap\View\Helper\PaginatorHelper;
66
use Cake\Core\Configure;
7-
use Cake\Network\Request;
7+
use Cake\Http\ServerRequest;
88
use Cake\Routing\Router;
99
use Cake\TestSuite\TestCase;
1010
use Cake\View\View;
@@ -16,7 +16,14 @@ class PaginatorHelperTest extends TestCase {
1616
*
1717
* @var PaginatorHelper
1818
*/
19-
public $paginator;
19+
public $Paginator;
20+
21+
/**
22+
* View associated with the PaginatorHelper.
23+
*
24+
* @var View
25+
*/
26+
public $View;
2027

2128
/**
2229
* setUp method
@@ -26,25 +33,29 @@ class PaginatorHelperTest extends TestCase {
2633
public function setUp()
2734
{
2835
parent::setUp();
29-
$view = new View();
30-
$view->loadHelper('Html', [
36+
$request = new ServerRequest([
37+
'url' => '/',
38+
'params' => [
39+
'paging' => [
40+
'Article' => [
41+
'page' => 1,
42+
'current' => 9,
43+
'count' => 62,
44+
'prevPage' => false,
45+
'nextPage' => true,
46+
'pageCount' => 7,
47+
'sort' => null,
48+
'direction' => null,
49+
'limit' => null,
50+
]
51+
]
52+
]
53+
]);
54+
$this->View = new View($request);
55+
$this->View->loadHelper('Html', [
3156
'className' => 'Bootstrap.Html'
3257
]);
33-
$this->paginator = new PaginatorHelper($view);
34-
$this->paginator->request = (new Request())
35-
->withParam('paging', [
36-
'Article' => [
37-
'page' => 1,
38-
'current' => 9,
39-
'count' => 62,
40-
'prevPage' => false,
41-
'nextPage' => true,
42-
'pageCount' => 7,
43-
'sort' => null,
44-
'direction' => null,
45-
'limit' => null,
46-
]
47-
]);
58+
$this->Paginator = new PaginatorHelper($this->View);
4859
Configure::write('Routing.prefixes', []);
4960
Router::reload();
5061
Router::connect('/:controller/:action/*');
@@ -53,7 +64,7 @@ public function setUp()
5364

5465
public function testNumbers()
5566
{
56-
$this->paginator->request = $this->paginator->request->withParam('paging', [
67+
$this->View->setRequest($this->View->getRequest()->withParam('paging', [
5768
'Client' => [
5869
'page' => 8,
5970
'current' => 3,
@@ -62,8 +73,8 @@ public function testNumbers()
6273
'nextPage' => 2,
6374
'pageCount' => 15,
6475
]
65-
]);
66-
$result = $this->paginator->numbers();
76+
]));
77+
$result = $this->Paginator->numbers();
6778
$expected = [
6879
['ul' => ['class' => 'pagination']],
6980
['li' => []], ['a' => ['href' => '/index?page=4']], '4', '/a', '/li',
@@ -78,7 +89,7 @@ public function testNumbers()
7889
'/ul'
7990
];
8091
$this->assertHtml($expected, $result);
81-
$result = $this->paginator->numbers(['first' => 'first', 'last' => 'last']);
92+
$result = $this->Paginator->numbers(['first' => 'first', 'last' => 'last']);
8293
$expected = [
8394
['ul' => ['class' => 'pagination']],
8495
['li' => []], ['a' => ['href' => '/index']], 'first', '/a', '/li',
@@ -97,7 +108,7 @@ public function testNumbers()
97108
'/ul'
98109
];
99110
$this->assertHtml($expected, $result);
100-
$result = $this->paginator->numbers(['first' => '2', 'last' => '8']);
111+
$result = $this->Paginator->numbers(['first' => '2', 'last' => '8']);
101112
$expected = [
102113
['ul' => ['class' => 'pagination']],
103114
['li' => []], ['a' => ['href' => '/index']], '2', '/a', '/li',
@@ -116,7 +127,7 @@ public function testNumbers()
116127
'/ul'
117128
];
118129
$this->assertHtml($expected, $result);
119-
$result = $this->paginator->numbers(['first' => '8', 'last' => '8']);
130+
$result = $this->Paginator->numbers(['first' => '8', 'last' => '8']);
120131
$expected = [
121132
['ul' => ['class' => 'pagination']],
122133
['li' => []], ['a' => ['href' => '/index']], '8', '/a', '/li',
@@ -135,7 +146,7 @@ public function testNumbers()
135146
'/ul'
136147
];
137148
$this->assertHtml($expected, $result);
138-
$this->paginator->request = $this->paginator->request->withParam('paging', [
149+
$this->View->setRequest($this->View->getRequest()->withParam('paging', [
139150
'Client' => [
140151
'page' => 1,
141152
'current' => 3,
@@ -144,8 +155,8 @@ public function testNumbers()
144155
'nextPage' => 2,
145156
'pageCount' => 15,
146157
]
147-
]);
148-
$result = $this->paginator->numbers();
158+
]));
159+
$result = $this->Paginator->numbers();
149160
$expected = [
150161
['ul' => ['class' => 'pagination']],
151162
['li' => ['class' => 'active']], ['a' => ['href' => '/index']], '1', '/a', '/li',
@@ -160,7 +171,7 @@ public function testNumbers()
160171
'/ul'
161172
];
162173
$this->assertHtml($expected, $result);
163-
$this->paginator->request = $this->paginator->request->withParam('paging', [
174+
$this->View->setRequest($this->View->getRequest()->withParam('paging', [
164175
'Client' => [
165176
'page' => 14,
166177
'current' => 3,
@@ -169,8 +180,8 @@ public function testNumbers()
169180
'nextPage' => 2,
170181
'pageCount' => 15,
171182
]
172-
]);
173-
$result = $this->paginator->numbers();
183+
]));
184+
$result = $this->Paginator->numbers();
174185
$expected = [
175186
['ul' => ['class' => 'pagination']],
176187
['li' => []], ['a' => ['href' => '/index?page=7']], '7', '/a', '/li',
@@ -185,7 +196,7 @@ public function testNumbers()
185196
'/ul'
186197
];
187198
$this->assertHtml($expected, $result);
188-
$this->paginator->request = $this->paginator->request->withParam('paging', [
199+
$this->View->setRequest($this->View->getRequest()->withParam('paging', [
189200
'Client' => [
190201
'page' => 2,
191202
'current' => 3,
@@ -194,8 +205,8 @@ public function testNumbers()
194205
'nextPage' => 2,
195206
'pageCount' => 9,
196207
]
197-
]);
198-
$result = $this->paginator->numbers(['first' => 1]);
208+
]));
209+
$result = $this->Paginator->numbers(['first' => 1]);
199210
$expected = [
200211
['ul' => ['class' => 'pagination']],
201212
['li' => []], ['a' => ['href' => '/index']], '1', '/a', '/li',
@@ -210,7 +221,7 @@ public function testNumbers()
210221
'/ul'
211222
];
212223
$this->assertHtml($expected, $result);
213-
$result = $this->paginator->numbers(['last' => 1]);
224+
$result = $this->Paginator->numbers(['last' => 1]);
214225
$expected = [
215226
['ul' => ['class' => 'pagination']],
216227
['li' => []], ['a' => ['href' => '/index']], '1', '/a', '/li',
@@ -225,7 +236,7 @@ public function testNumbers()
225236
'/ul'
226237
];
227238
$this->assertHtml($expected, $result);
228-
$this->paginator->request = $this->paginator->request->withParam('paging', [
239+
$this->View->setRequest($this->View->getRequest()->withParam('paging', [
229240
'Client' => [
230241
'page' => 15,
231242
'current' => 3,
@@ -234,8 +245,8 @@ public function testNumbers()
234245
'nextPage' => 2,
235246
'pageCount' => 15,
236247
]
237-
]);
238-
$result = $this->paginator->numbers(['first' => 1]);
248+
]));
249+
$result = $this->Paginator->numbers(['first' => 1]);
239250
$expected = [
240251
['ul' => ['class' => 'pagination']],
241252
['li' => []], ['a' => ['href' => '/index']], '1', '/a', '/li',
@@ -252,7 +263,7 @@ public function testNumbers()
252263
'/ul'
253264
];
254265
$this->assertHtml($expected, $result);
255-
$this->paginator->request = $this->paginator->request->withParam('paging', [
266+
$this->View->setRequest($this->View->getRequest()->withParam('paging', [
256267
'Client' => [
257268
'page' => 10,
258269
'current' => 3,
@@ -261,8 +272,8 @@ public function testNumbers()
261272
'nextPage' => 2,
262273
'pageCount' => 15,
263274
]
264-
]);
265-
$result = $this->paginator->numbers(['first' => 1, 'last' => 1]);
275+
]));
276+
$result = $this->Paginator->numbers(['first' => 1, 'last' => 1]);
266277
$expected = [
267278
['ul' => ['class' => 'pagination']],
268279
['li' => []], ['a' => ['href' => '/index']], '1', '/a', '/li',
@@ -280,7 +291,7 @@ public function testNumbers()
280291
'/ul'
281292
];
282293
$this->assertHtml($expected, $result);
283-
$this->paginator->request = $this->paginator->request->withParam('paging', [
294+
$this->View->setRequest($this->View->getRequest()->withParam('paging', [
284295
'Client' => [
285296
'page' => 6,
286297
'current' => 15,
@@ -289,8 +300,8 @@ public function testNumbers()
289300
'nextPage' => 1,
290301
'pageCount' => 42,
291302
]
292-
]);
293-
$result = $this->paginator->numbers(['first' => 1, 'last' => 1]);
303+
]));
304+
$result = $this->Paginator->numbers(['first' => 1, 'last' => 1]);
294305
$expected = [
295306
['ul' => ['class' => 'pagination']],
296307
['li' => []], ['a' => ['href' => '/index']], '1', '/a', '/li',
@@ -308,7 +319,7 @@ public function testNumbers()
308319
'/ul'
309320
];
310321
$this->assertHtml($expected, $result);
311-
$this->paginator->request = $this->paginator->request->withParam('paging', [
322+
$this->View->setRequest($this->View->getRequest()->withParam('paging', [
312323
'Client' => [
313324
'page' => 37,
314325
'current' => 15,
@@ -317,8 +328,8 @@ public function testNumbers()
317328
'nextPage' => 1,
318329
'pageCount' => 42,
319330
]
320-
]);
321-
$result = $this->paginator->numbers(['first' => 1, 'last' => 1]);
331+
]));
332+
$result = $this->Paginator->numbers(['first' => 1, 'last' => 1]);
322333
$expected = [
323334
['ul' => ['class' => 'pagination']],
324335
['li' => []], ['a' => ['href' => '/index']], '1', '/a', '/li',
@@ -345,7 +356,7 @@ public function testPrev() {
345356
]],
346357
['a' => true], '<', '/a',
347358
'/li'
348-
], $this->paginator->prev('<'));
359+
], $this->Paginator->prev('<'));
349360
$this->assertHtml([
350361
['li' => [
351362
'class' => 'disabled'
@@ -356,7 +367,7 @@ public function testPrev() {
356367
'aria-hidden' => 'true'
357368
]],
358369
'/i', '/a', '/li'
359-
], $this->paginator->prev('i:chevron-left'));
370+
], $this->Paginator->prev('i:chevron-left'));
360371
}
361372

362373
public function testNext() {
@@ -366,7 +377,7 @@ public function testNext() {
366377
'href' => '/index?page=2'
367378
]], '&gt;', '/a',
368379
'/li'
369-
], $this->paginator->next('>'));
380+
], $this->Paginator->next('>'));
370381
$this->assertHtml([
371382
['li' => true],
372383
['a' => [
@@ -377,7 +388,7 @@ public function testNext() {
377388
'aria-hidden' => 'true'
378389
]],
379390
'/i', '/a', '/li'
380-
], $this->paginator->next('i:chevron-right'));
391+
], $this->Paginator->next('i:chevron-right'));
381392
}
382393

383394
};

0 commit comments

Comments
 (0)