mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 00:48:25 +00:00
Fixing more boundary issues with first() and last(). When you entered a first/last range a wonky page link would be generated. Tests added.
This commit is contained in:
parent
85baa180d9
commit
eb38b8b60c
2 changed files with 9 additions and 2 deletions
|
@ -782,7 +782,7 @@ class PaginatorHelper extends AppHelper {
|
|||
}
|
||||
}
|
||||
$out .= $after;
|
||||
} elseif ($params['page'] > 1) {
|
||||
} elseif ($params['page'] > 1 && is_string($first)) {
|
||||
$options += array('rel' => 'first');
|
||||
$out = $this->Html->tag($tag, $this->link($first, array('page' => 1), $options))
|
||||
. $after;
|
||||
|
@ -848,7 +848,7 @@ class PaginatorHelper extends AppHelper {
|
|||
}
|
||||
}
|
||||
$out = $before . $out;
|
||||
} elseif ($params['page'] < $params['pageCount']) {
|
||||
} elseif ($params['page'] < $params['pageCount'] && is_string($last)) {
|
||||
$options += array('rel' => 'last');
|
||||
$out = $before . $this->Html->tag(
|
||||
$tag, $this->link($last, array('page' => $params['pageCount']), $options
|
||||
|
|
|
@ -1878,6 +1878,10 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
'/span'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$this->Paginator->request->params['paging']['Article']['page'] = 2;
|
||||
$result = $this->Paginator->first(3);
|
||||
$this->assertEquals('', $result, 'When inside the first links range, no links should be made');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1922,6 +1926,9 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
'/span',
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Paginator->last(3);
|
||||
$this->assertEquals('', $result, 'When inside the last links range, no links should be made');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue