mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge branch 'master' into 2.5
This commit is contained in:
commit
8578708e76
5 changed files with 60 additions and 15 deletions
|
@ -212,9 +212,6 @@ class PaginatorComponent extends Component {
|
|||
$pageCount = intval(ceil($count / $limit));
|
||||
$requestedPage = $page;
|
||||
$page = max(min($page, $pageCount), 1);
|
||||
if ($requestedPage > $page) {
|
||||
throw new NotFoundException();
|
||||
}
|
||||
|
||||
$paging = array(
|
||||
'page' => $page,
|
||||
|
@ -237,6 +234,10 @@ class PaginatorComponent extends Component {
|
|||
array($object->alias => $paging)
|
||||
);
|
||||
|
||||
if ($requestedPage > $page) {
|
||||
throw new NotFoundException();
|
||||
}
|
||||
|
||||
if (
|
||||
!in_array('Paginator', $this->Controller->helpers) &&
|
||||
!array_key_exists('Paginator', $this->Controller->helpers)
|
||||
|
|
|
@ -919,7 +919,6 @@ class PaginatorComponentTest extends CakeTestCase {
|
|||
/**
|
||||
* testOutOfRangePageNumberAndPageCountZero
|
||||
*
|
||||
* @expectedException NotFoundException
|
||||
* @return void
|
||||
*/
|
||||
public function testOutOfRangePageNumberAndPageCountZero() {
|
||||
|
@ -933,7 +932,17 @@ class PaginatorComponentTest extends CakeTestCase {
|
|||
$Controller->paginate = array(
|
||||
'conditions' => array('PaginatorControllerPost.id >' => 100)
|
||||
);
|
||||
$Controller->Paginator->paginate('PaginatorControllerPost');
|
||||
|
||||
try {
|
||||
$Controller->Paginator->paginate('PaginatorControllerPost');
|
||||
$this->fail();
|
||||
} catch (NotFoundException $e) {
|
||||
$this->assertEquals(
|
||||
1,
|
||||
$Controller->request->params['paging']['PaginatorControllerPost']['page'],
|
||||
'Page number should not be 0'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -142,7 +142,27 @@ class TextHelperTest extends CakeTestCase {
|
|||
$expected = 'This is a test text with URL <a href="http://www.cakephp.org">http://www.cakephp.org</a>(and some more text)';
|
||||
$result = $this->Text->autoLink($text);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test mixing URLs and Email addresses in one confusing string.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAutoLinkMixed() {
|
||||
$text = 'Text with a url/email http://example.com/store?email=mark@example.com and email.';
|
||||
$expected = 'Text with a url/email <a href="http://example.com/store?email=mark@example.com">' .
|
||||
'http://example.com/store?email=mark@example.com</a> and email.';
|
||||
$result = $this->Text->autoLink($text);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* test autoLink() and options.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAutoLinkOptions() {
|
||||
$text = 'This is a test text with URL http://www.cakephp.org';
|
||||
$expected = 'This is a test text with URL <a href="http://www.cakephp.org" class="link">http://www.cakephp.org</a>';
|
||||
$result = $this->Text->autoLink($text, array('class' => 'link'));
|
||||
|
@ -246,7 +266,7 @@ class TextHelperTest extends CakeTestCase {
|
|||
array(
|
||||
'Text with a partial http://www.küchenschöhn-not-working.de URL',
|
||||
'Text with a partial <a href="http://www.küchenschöhn-not-working.de">http://www.küchenschöhn-not-working.de</a> URL'
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -343,10 +363,25 @@ class TextHelperTest extends CakeTestCase {
|
|||
$result = $this->Text->autoLinkUrls($text);
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
$text = 'Text with email@example.com address';
|
||||
$expected = 'Text with <a href="mailto:email@example.com"\s*>email@example.com</a> address';
|
||||
$text = 'email@example.com address';
|
||||
$expected = '<a href="mailto:email@example.com">email@example.com</a> address';
|
||||
$result = $this->Text->autoLinkEmails($text);
|
||||
$this->assertRegExp('#^' . $expected . '$#', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
$text = 'email@example.com address';
|
||||
$expected = '<a href="mailto:email@example.com">email@example.com</a> address';
|
||||
$result = $this->Text->autoLinkEmails($text);
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
$text = '(email@example.com) address';
|
||||
$expected = '(<a href="mailto:email@example.com">email@example.com</a>) address';
|
||||
$result = $this->Text->autoLinkEmails($text);
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
$text = 'Text with email@example.com address';
|
||||
$expected = 'Text with <a href="mailto:email@example.com">email@example.com</a> address';
|
||||
$result = $this->Text->autoLinkEmails($text);
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
$text = "Text with o'hare._-bob@example.com address";
|
||||
$expected = 'Text with <a href="mailto:o'hare._-bob@example.com">o'hare._-bob@example.com</a> address';
|
||||
|
@ -354,19 +389,19 @@ class TextHelperTest extends CakeTestCase {
|
|||
$this->assertEquals($expected, $result);
|
||||
|
||||
$text = 'Text with email@example.com address';
|
||||
$expected = 'Text with <a href="mailto:email@example.com" \s*class="link">email@example.com</a> address';
|
||||
$expected = 'Text with <a href="mailto:email@example.com" class="link">email@example.com</a> address';
|
||||
$result = $this->Text->autoLinkEmails($text, array('class' => 'link'));
|
||||
$this->assertRegExp('#^' . $expected . '$#', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
$text = 'Text with düsentrieb@küchenschöhn-not-working.de address';
|
||||
$expected = 'Text with <a href="mailto:düsentrieb@küchenschöhn-not-working.de">düsentrieb@küchenschöhn-not-working.de</a> address';
|
||||
$result = $this->Text->autoLinkEmails($text);
|
||||
$this->assertRegExp('#^' . $expected . '$#', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
$text = 'Text with me@subdomain.küchenschöhn.de address';
|
||||
$expected = 'Text with <a href="mailto:me@subdomain.küchenschöhn.de">me@subdomain.küchenschöhn.de</a> address';
|
||||
$result = $this->Text->autoLinkEmails($text);
|
||||
$this->assertRegExp('#^' . $expected . '$#', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -187,7 +187,7 @@ class TextHelper extends AppHelper {
|
|||
|
||||
$atom = '[\p{L}0-9!#$%&\'*+\/=?^_`{|}~-]';
|
||||
$text = preg_replace_callback(
|
||||
'/(' . $atom . '+(?:\.' . $atom . '+)*@[\p{L}0-9-]+(?:\.[\p{L}0-9-]+)+)/ui',
|
||||
'/(?<=\s|^|\()(' . $atom . '*(?:\.' . $atom . '+)*@[\p{L}0-9-]+(?:\.[\p{L}0-9-]+)+)/ui',
|
||||
array(&$this, '_insertPlaceholder'),
|
||||
$text
|
||||
);
|
||||
|
|
|
@ -1095,7 +1095,7 @@ class View extends Object {
|
|||
* Return all possible paths to find view files in order
|
||||
*
|
||||
* @param string $plugin Optional plugin name to scan for view files.
|
||||
* @param boolean $cached Set to true to force a refresh of view paths.
|
||||
* @param boolean $cached Set to false to force a refresh of view paths. Default true.
|
||||
* @return array paths
|
||||
*/
|
||||
protected function _paths($plugin = null, $cached = true) {
|
||||
|
|
Loading…
Reference in a new issue