From 8e93c4cd349f20ee5fa67307db599bb1d4671ca0 Mon Sep 17 00:00:00 2001 From: Rob McVey Date: Tue, 28 Feb 2012 14:58:28 +0000 Subject: [PATCH 1/5] Fix for Consolce/Task/TestTask::getRealClassName(). Controller names of exactly 10 letters being returned incorrectly Signed-off-by: mark_story --- lib/Cake/Console/Command/Task/TestTask.php | 5 ++++- lib/Cake/Test/Case/Console/Command/Task/TestTaskTest.php | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Console/Command/Task/TestTask.php b/lib/Cake/Console/Command/Task/TestTask.php index 66646f597..b9d8b0373 100644 --- a/lib/Cake/Console/Command/Task/TestTask.php +++ b/lib/Cake/Console/Command/Task/TestTask.php @@ -274,7 +274,10 @@ class TestTask extends BakeTask { if (strtolower($type) == 'model' || empty($this->classTypes[$type])) { return $class; } - if (strlen($class) - strpos($class, $type) == strlen($type)) { + + $position = strpos($class, $type); + + if ($position !== false && strlen($class) - $position == strlen($type)) { return $class; } return $class . $type; diff --git a/lib/Cake/Test/Case/Console/Command/Task/TestTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/TestTaskTest.php index cb7fe00c9..3dcd27839 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/TestTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/TestTaskTest.php @@ -403,6 +403,9 @@ class TestTaskTest extends CakeTestCase { $result = $this->Task->getRealClassname('Controller', 'PostsController'); $this->assertEquals('PostsController', $result); + + $result = $this->Task->getRealClassname('Controller', 'AlertTypes'); + $this->assertEquals('AlertTypesController', $result); $result = $this->Task->getRealClassname('Helper', 'Form'); $this->assertEquals('FormHelper', $result); From 6d3bc7be86ccb512a3c9ea32048f278ef1da9390 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Renan=20Gonc=CC=A7alves?= Date: Fri, 2 Mar 2012 15:55:58 +0100 Subject: [PATCH 2/5] Removing ReflectionMethod::setAccessible() from tests, it was limiting to PHP 5.3.2 or newer. --- .../Model/Datasource/Database/MysqlTest.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php b/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php index 53c42f9da..0a347ff03 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php @@ -1082,14 +1082,27 @@ class MysqlTest extends CakeTestCase { $linkModel = $model->{$className}; $external = isset($assocData['external']); - $reflection = new ReflectionMethod($this->Dbo, '_scrubQueryData'); - $reflection->setAccessible(true); - $queryData = $reflection->invokeArgs($this->Dbo, array($queryData)); + $queryData = $this->_scrubQueryData($queryData); $result = array_merge(array('linkModel' => &$linkModel), compact('type', 'assoc', 'assocData', 'external')); return $result; } +/** + * Helper method copied from DboSource::_scrubQueryData() + * + * @param array $data + * @return array + */ + function _scrubQueryData($data) { + static $base = null; + if ($base === null) { + $base = array_fill_keys(array('conditions', 'fields', 'joins', 'order', 'limit', 'offset', 'group'), array()); + $base['callbacks'] = null; + } + return (array)$data + $base; + } + /** * testGenerateInnerJoinAssociationQuery method * From 0b4f735b4cfea1483f61263c4eff262a219d1604 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 2 Mar 2012 11:18:59 -0500 Subject: [PATCH 3/5] Update API docs for Set::extract() Fixes #2634 --- lib/Cake/Utility/Set.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Utility/Set.php b/lib/Cake/Utility/Set.php index 53a5dce6b..994479153 100644 --- a/lib/Cake/Utility/Set.php +++ b/lib/Cake/Utility/Set.php @@ -319,8 +319,9 @@ class Set { } /** - * Implements partial support for XPath 2.0. If $path is an array or $data is empty it the call - * is delegated to Set::classicExtract. + * Implements partial support for XPath 2.0. If $path does not contain a '/' the call + * is delegated to Set::classicExtract(). Also the $path and $data arguments are + * reversible. * * #### Currently implemented selectors: * From a3a2d55c94a26284833629479334a29e5ace1dc8 Mon Sep 17 00:00:00 2001 From: Cauan Cabral Date: Fri, 2 Mar 2012 17:43:02 -0400 Subject: [PATCH 4/5] Enable UpgradeShell to recognize new line between class name and { --- lib/Cake/Console/Command/UpgradeShell.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Console/Command/UpgradeShell.php b/lib/Cake/Console/Command/UpgradeShell.php index fd73814b9..36b6578a8 100644 --- a/lib/Cake/Console/Command/UpgradeShell.php +++ b/lib/Cake/Console/Command/UpgradeShell.php @@ -191,7 +191,7 @@ class UpgradeShell extends AppShell { $defaultOptions = array( 'recursive' => true, 'checkFolder' => true, - 'regex' => '@class (\S*) .*{@i' + 'regex' => '@class (\S*) .*(\s|\v)*{@i' ); foreach ($sourceDirs as $dir => $options) { if (is_numeric($dir)) { From 1475e87b3823f7ea6f0d7a0f0116ac5d45b161fd Mon Sep 17 00:00:00 2001 From: Takayuki Miwa Date: Sat, 3 Mar 2012 13:46:15 +0900 Subject: [PATCH 5/5] Update PaginatorHelper::beforeRender to merge request->query with url options --- .../Case/View/Helper/PaginatorHelperTest.php | 84 +++++++++++++++++-- lib/Cake/View/Helper/PaginatorHelper.php | 3 + 2 files changed, 79 insertions(+), 8 deletions(-) diff --git a/lib/Cake/Test/Case/View/Helper/PaginatorHelperTest.php b/lib/Cake/Test/Case/View/Helper/PaginatorHelperTest.php index 0f513f24e..cfbd558db 100644 --- a/lib/Cake/Test/Case/View/Helper/PaginatorHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/PaginatorHelperTest.php @@ -661,11 +661,12 @@ class PaginatorHelperTest extends CakeTestCase { $this->Paginator->request->params['pass'] = array(2); $this->Paginator->request->params['named'] = array('foo' => 'bar'); + $this->Paginator->request->query = array('x' => 'y'); $this->Paginator->beforeRender('posts/index'); $result = $this->Paginator->sort('title'); $expected = array( - 'a' => array('href' => '/articles/index/2/page:1/foo:bar/sort:title/direction:asc'), + 'a' => array('href' => '/articles/index/2/page:1/foo:bar/sort:title/direction:asc?x=y'), 'Title', '/a' ); @@ -675,24 +676,91 @@ class PaginatorHelperTest extends CakeTestCase { $expected = array( array('span' => array('class' => 'current')), '1', '/span', ' | ', - array('span' => array()), array('a' => array('href' => '/articles/index/2/page:2/foo:bar')), '2', '/a', '/span', + array('span' => array()), array('a' => array('href' => '/articles/index/2/page:2/foo:bar?x=y')), '2', '/a', '/span', ' | ', - array('span' => array()), array('a' => array('href' => '/articles/index/2/page:3/foo:bar')), '3', '/a', '/span', + array('span' => array()), array('a' => array('href' => '/articles/index/2/page:3/foo:bar?x=y')), '3', '/a', '/span', ' | ', - array('span' => array()), array('a' => array('href' => '/articles/index/2/page:4/foo:bar')), '4', '/a', '/span', + array('span' => array()), array('a' => array('href' => '/articles/index/2/page:4/foo:bar?x=y')), '4', '/a', '/span', ' | ', - array('span' => array()), array('a' => array('href' => '/articles/index/2/page:5/foo:bar')), '5', '/a', '/span', + array('span' => array()), array('a' => array('href' => '/articles/index/2/page:5/foo:bar?x=y')), '5', '/a', '/span', ' | ', - array('span' => array()), array('a' => array('href' => '/articles/index/2/page:6/foo:bar')), '6', '/a', '/span', + array('span' => array()), array('a' => array('href' => '/articles/index/2/page:6/foo:bar?x=y')), '6', '/a', '/span', ' | ', - array('span' => array()), array('a' => array('href' => '/articles/index/2/page:7/foo:bar')), '7', '/a', '/span', + array('span' => array()), array('a' => array('href' => '/articles/index/2/page:7/foo:bar?x=y')), '7', '/a', '/span', ); $this->assertTags($result, $expected); $result = $this->Paginator->next('Next'); $expected = array( 'span' => array('class' => 'next'), - 'a' => array('href' => '/articles/index/2/page:2/foo:bar', 'rel' => 'next'), + 'a' => array('href' => '/articles/index/2/page:2/foo:bar?x=y', 'rel' => 'next'), + 'Next', + '/a', + '/span' + ); + $this->assertTags($result, $expected); + } + +/** + * testPassedArgsMergingWithUrlOptionsParamTypeQuerystring method + * + * @return void + */ + public function testPassedArgsMergingWithUrlOptionsParamTypeQuerystring() { + Router::reload(); + Router::parse('/'); + Router::setRequestInfo(array( + array('plugin' => null, 'controller' => 'articles', 'action' => 'index', 'pass' => array('2'), 'named' => array('foo' => 'bar'), 'url' => array('url' => 'articles/index/2/foo:bar')), + array('base' => '/', 'here' => '/articles/', 'webroot' => '/') + )); + $this->Paginator->request->params['paging'] = array( + 'Article' => array( + 'page' => 1, 'current' => 3, 'count' => 13, + 'prevPage' => false, 'nextPage' => true, 'pageCount' => 8, + 'options' => array( + 'page' => 1, + 'order' => array(), + 'conditions' => array() + ), + 'paramType' => 'querystring' + ) + ); + + $this->Paginator->request->params['pass'] = array(2); + $this->Paginator->request->params['named'] = array('foo' => 'bar'); + $this->Paginator->request->query = array('x' => 'y'); + $this->Paginator->beforeRender('posts/index'); + + $result = $this->Paginator->sort('title'); + $expected = array( + 'a' => array('href' => '/articles/index/2/foo:bar?x=y&page=1&sort=title&direction=asc'), + 'Title', + '/a' + ); + $this->assertTags($result, $expected); + + $result = $this->Paginator->numbers(); + $expected = array( + array('span' => array('class' => 'current')), '1', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/articles/index/2/foo:bar?x=y&page=2')), '2', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/articles/index/2/foo:bar?x=y&page=3')), '3', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/articles/index/2/foo:bar?x=y&page=4')), '4', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/articles/index/2/foo:bar?x=y&page=5')), '5', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/articles/index/2/foo:bar?x=y&page=6')), '6', '/a', '/span', + ' | ', + array('span' => array()), array('a' => array('href' => '/articles/index/2/foo:bar?x=y&page=7')), '7', '/a', '/span', + ); + $this->assertTags($result, $expected); + + $result = $this->Paginator->next('Next'); + $expected = array( + 'span' => array('class' => 'next'), + 'a' => array('href' => '/articles/index/2/foo:bar?x=y&page=2', 'rel' => 'next'), 'Next', '/a', '/span' diff --git a/lib/Cake/View/Helper/PaginatorHelper.php b/lib/Cake/View/Helper/PaginatorHelper.php index 7d654faf9..ad72a0fe3 100644 --- a/lib/Cake/View/Helper/PaginatorHelper.php +++ b/lib/Cake/View/Helper/PaginatorHelper.php @@ -109,6 +109,9 @@ class PaginatorHelper extends AppHelper { */ public function beforeRender($viewFile) { $this->options['url'] = array_merge($this->request->params['pass'], $this->request->params['named']); + if (!empty($this->request->query)) { + $this->options['url']['?'] = $this->request->query; + } parent::beforeRender($viewFile); }