Skip to content

Commit

Permalink
Fix more tests using deprecated request features.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Dec 9, 2017
1 parent 3c71d95 commit dbff1b7
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 27 deletions.
4 changes: 2 additions & 2 deletions tests/TestCase/View/Form/ArrayContextTest.php
Expand Up @@ -135,12 +135,12 @@ public function testIsCreate()
*/
public function testValPresent()
{
$this->request->data = [
$this->request = $this->request->withParsedBody([
'Articles' => [
'title' => 'New title',
'body' => 'My copy',
]
];
]);
$context = new ArrayContext($this->request, [
'defaults' => [
'Articles' => [
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/View/Form/EntityContextTest.php
Expand Up @@ -516,10 +516,10 @@ public function testValGetArrayValue()
*/
public function testValReadsRequest()
{
$this->request->data = [
$this->request = $this->request->withParsedBody([
'title' => 'New title',
'notInEntity' => 'yes',
];
]);
$row = new Article([
'title' => 'Test entity',
'body' => 'Something new'
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/View/Form/FormContextTest.php
Expand Up @@ -81,12 +81,12 @@ public function testIsCreate()
*/
public function testValPresent()
{
$this->request->data = [
$this->request = $this->request->withParsedBody([
'Articles' => [
'title' => 'New title',
'body' => 'My copy',
]
];
]);
$context = new FormContext($this->request, ['entity' => new Form()]);
$this->assertEquals('New title', $context->val('Articles.title'));
$this->assertEquals('My copy', $context->val('Articles.body'));
Expand Down
41 changes: 20 additions & 21 deletions tests/TestCase/View/Helper/PaginatorHelperTest.php
Expand Up @@ -124,9 +124,8 @@ public function testTemplates()
public function testHasPrevious()
{
$this->assertFalse($this->Paginator->hasPrev());
$this->Paginator->request->params['paging']['Article']['prevPage'] = true;
$this->Paginator->request = $this->Paginator->withParam('paging.Article.prevPage', true);
$this->assertTrue($this->Paginator->hasPrev());
$this->Paginator->request->params['paging']['Article']['prevPage'] = false;
}

/**
Expand All @@ -137,9 +136,8 @@ public function testHasPrevious()
public function testHasNext()
{
$this->assertTrue($this->Paginator->hasNext());
$this->Paginator->request->params['paging']['Article']['nextPage'] = false;
$this->Paginator->request = $this->Paginator->withParam('paging.Article.nextPage', false);
$this->assertFalse($this->Paginator->hasNext());
$this->Paginator->request->params['paging']['Article']['nextPage'] = true;
}

/**
Expand All @@ -160,7 +158,7 @@ public function testSortLinks()
Router::setRequestInfo($request);

$this->Paginator->options(['url' => ['param']]);
$this->Paginator->request->params['paging'] = [
$this->Paginator->request = $this->Paginator->request->withParam('paging', [
'Article' => [
'current' => 9,
'count' => 62,
Expand All @@ -171,7 +169,7 @@ public function testSortLinks()
'direction' => 'asc',
'page' => 1,
]
];
]);

$result = $this->Paginator->sort('title');
$expected = [
Expand Down Expand Up @@ -2611,7 +2609,7 @@ public function testLastNonDefaultModel()
*/
public function testCounter()
{
$this->Paginator->request->params['paging'] = [
$this->Paginator->request = $this->Paginator->request->withParam('paging', [
'Client' => [
'page' => 1,
'current' => 3,
Expand All @@ -2624,7 +2622,7 @@ public function testCounter()
'sort' => 'Client.name',
'order' => 'DESC',
]
];
]);
$input = 'Page {{page}} of {{pages}}, showing {{current}} records out of {{count}} total, ';
$input .= 'starting on record {{start}}, ending on {{end}}';

Expand Down Expand Up @@ -2652,7 +2650,7 @@ public function testCounter()
*/
public function testCounterBigNumbers()
{
$this->Paginator->request->params['paging'] = [
$this->Paginator->request = $this->Paginator->withParam('paging', [
'Client' => [
'page' => 1523,
'current' => 1230,
Expand All @@ -2665,7 +2663,7 @@ public function testCounterBigNumbers()
'sort' => 'Client.name',
'order' => 'DESC',
]
];
]);

$input = 'Page {{page}} of {{pages}}, showing {{current}} records out of {{count}} total, ';
$input .= 'starting on record {{start}}, ending on {{end}}';
Expand Down Expand Up @@ -2717,9 +2715,10 @@ public function testNextLinkUsingDotNotation()
]);
Router::setRequestInfo($request);

$this->Paginator->request->params['paging']['Article']['sort'] = 'Article.title';
$this->Paginator->request->params['paging']['Article']['direction'] = 'asc';
$this->Paginator->request->params['paging']['Article']['page'] = 1;
$this->Paginator->request = $this->Paginator->request
->withParam('paging.Article.sort', 'Article.title')
->withParam('paging.Article.direction', 'asc')
->withParam('paging.Article.page', 1);

$test = ['url' => [
'page' => '1',
Expand Down Expand Up @@ -2750,7 +2749,7 @@ public function testNextLinkUsingDotNotation()
public function testCurrent()
{
$result = $this->Paginator->current();
$this->assertEquals($this->Paginator->request->params['paging']['Article']['page'], $result);
$this->assertEquals($this->Paginator->request->getParam('paging.Article.page'), $result);

$result = $this->Paginator->current('Incorrect');
$this->assertEquals(1, $result);
Expand All @@ -2764,7 +2763,7 @@ public function testCurrent()
public function testTotal()
{
$result = $this->Paginator->total();
$this->assertSame($this->Paginator->request->params['paging']['Article']['pageCount'], $result);
$this->assertSame($this->Paginator->request->getParam('paging.Article.pageCount'), $result);

$result = $this->Paginator->total('Incorrect');
$this->assertSame(0, $result);
Expand Down Expand Up @@ -2794,7 +2793,7 @@ public function testNoDefaultModel()
*/
public function testWithOnePage()
{
$this->Paginator->request->params['paging'] = [
$this->Paginator->request = $this->Paginator->request->withParam('paging', [
'Article' => [
'page' => 1,
'current' => 2,
Expand All @@ -2803,7 +2802,7 @@ public function testWithOnePage()
'nextPage' => true,
'pageCount' => 1,
]
];
]);
$this->assertFalse($this->Paginator->numbers());
$this->assertFalse($this->Paginator->first());
$this->assertFalse($this->Paginator->last());
Expand All @@ -2816,7 +2815,7 @@ public function testWithOnePage()
*/
public function testWithZeroPages()
{
$this->Paginator->request->params['paging'] = [
$this->Paginator->request = $this->Paginator->request->withParam('paging', [
'Article' => [
'page' => 0,
'current' => 0,
Expand All @@ -2827,7 +2826,7 @@ public function testWithZeroPages()
'pageCount' => 0,
'limit' => 10,
]
];
]);

$result = $this->Paginator->counter(['format' => 'pages']);
$expected = '0 of 1';
Expand Down Expand Up @@ -2891,14 +2890,14 @@ public function dataMetaProvider()
*/
public function testMeta($page, $prevPage, $nextPage, $pageCount, $options, $expected)
{
$this->Paginator->request->params['paging'] = [
$this->Paginator->request = $this->Paginator->request->withParam('paging', [
'Article' => [
'page' => $page,
'prevPage' => $prevPage,
'nextPage' => $nextPage,
'pageCount' => $pageCount,
]
];
]);

$result = $this->Paginator->meta($options);
$this->assertSame($expected, $result);
Expand Down

0 comments on commit dbff1b7

Please sign in to comment.