From 3f9e8e811326a34b848cc804e4b6b6105e81718f Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 18 Jul 2013 11:04:09 -0400 Subject: [PATCH 1/9] Add missing calls to parent. --- lib/Cake/Test/Case/Network/CakeResponseTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/Cake/Test/Case/Network/CakeResponseTest.php b/lib/Cake/Test/Case/Network/CakeResponseTest.php index d2771ef57..e69e39fec 100644 --- a/lib/Cake/Test/Case/Network/CakeResponseTest.php +++ b/lib/Cake/Test/Case/Network/CakeResponseTest.php @@ -30,6 +30,7 @@ class CakeResponseTest extends CakeTestCase { * @return void */ public function setUp() { + parent::setUp(); ob_start(); } @@ -39,6 +40,7 @@ class CakeResponseTest extends CakeTestCase { * @return void */ public function tearDown() { + parent::tearDown(); ob_end_clean(); } From f725779a170444e05949401a9055132806729ae0 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 18 Jul 2013 11:26:55 -0400 Subject: [PATCH 2/9] Better support various ranges as described in RFC2616 Refs #3914 --- lib/Cake/Network/CakeResponse.php | 9 +++ .../Test/Case/Network/CakeResponseTest.php | 70 +++++++++++++++++++ 2 files changed, 79 insertions(+) diff --git a/lib/Cake/Network/CakeResponse.php b/lib/Cake/Network/CakeResponse.php index 3cc4b6356..f09212bc9 100644 --- a/lib/Cake/Network/CakeResponse.php +++ b/lib/Cake/Network/CakeResponse.php @@ -1302,6 +1302,15 @@ class CakeResponse { $fileSize = $file->size(); $lastByte = $fileSize - 1; + + if ($start === '') { + $start = $fileSize - $end; + $end = $lastByte; + } + if ($end === '') { + $end = $lastByte; + } + if ($start > $end || $end > $lastByte || $start > $lastByte) { $this->statusCode(416); $this->header(array( diff --git a/lib/Cake/Test/Case/Network/CakeResponseTest.php b/lib/Cake/Test/Case/Network/CakeResponseTest.php index e69e39fec..f92750390 100644 --- a/lib/Cake/Test/Case/Network/CakeResponseTest.php +++ b/lib/Cake/Test/Case/Network/CakeResponseTest.php @@ -1387,6 +1387,76 @@ class CakeResponseTest extends CakeTestCase { $response->file(CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS . 'img' . DS . 'test_2.JPG'); } +/** + * A data provider for testing various ranges + * + * @return array + */ + public static function rangeProvider() { + return array( + // suffix-byte-range + array( + 'bytes=-25', 25, 'bytes 13-37/38' + ), + + array( + 'bytes=0-', 38, 'bytes 0-37/38' + ), + array( + 'bytes=10-', 28, 'bytes 10-37/38' + ), + array( + 'bytes=10-20', 11, 'bytes 10-20/38' + ), + ); + } + +/** + * Test the various range offset types. + * + * @dataProvider rangeProvider + * @return void + */ + public function testFileRangeOffsets($range, $length, $offsetResponse) { + $_SERVER['HTTP_RANGE'] = $range; + $response = $this->getMock('CakeResponse', array( + 'header', + 'type', + '_sendHeader', + '_isActive', + '_clearBuffer', + '_flushBuffer' + )); + + $response->expects($this->at(1)) + ->method('header') + ->with('Content-Disposition', 'attachment; filename="test_asset.css"'); + + $response->expects($this->at(2)) + ->method('header') + ->with('Accept-Ranges', 'bytes'); + + $response->expects($this->at(3)) + ->method('header') + ->with(array( + 'Content-Length' => $length, + 'Content-Range' => $offsetResponse, + )); + + $response->expects($this->any()) + ->method('_isActive') + ->will($this->returnValue(true)); + + $response->file( + CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS . 'css' . DS . 'test_asset.css', + array('download' => true) + ); + + ob_start(); + $result = $response->send(); + ob_get_clean(); + } + /** * Test fetching ranges from a file. * From 36cac116d081e380368e068d40a7e6da339d867e Mon Sep 17 00:00:00 2001 From: Phally Date: Fri, 19 Jul 2013 16:50:46 +0200 Subject: [PATCH 3/9] Fixes errors in tests with APC installed but not enabled in CLI. --- lib/Cake/Test/Case/Cache/Engine/ApcEngineTest.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/Cake/Test/Case/Cache/Engine/ApcEngineTest.php b/lib/Cake/Test/Case/Cache/Engine/ApcEngineTest.php index 9e9c5fdfd..62b46b3b7 100644 --- a/lib/Cake/Test/Case/Cache/Engine/ApcEngineTest.php +++ b/lib/Cake/Test/Case/Cache/Engine/ApcEngineTest.php @@ -36,6 +36,10 @@ class ApcEngineTest extends CakeTestCase { parent::setUp(); $this->skipIf(!function_exists('apc_store'), 'Apc is not installed or configured properly.'); + if (php_sapi_name() === 'cli') { + $this->skipIf(!ini_get('apc.enable_cli'), 'APC is not enabled for the CLI.'); + } + $this->_cacheDisable = Configure::read('Cache.disable'); Configure::write('Cache.disable', false); Cache::config('apc', array('engine' => 'Apc', 'prefix' => 'cake_')); From da8e50a48a162cbdb840087394afdd2bb3843b21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=BCrth?= Date: Sat, 20 Jul 2013 01:06:27 +0200 Subject: [PATCH 4/9] Added missing test + minor cleanup of ViewTests.php Added missing block reset test through assign(). Also made some minor cleanup in ViewTests.php. Mostly docblocks (params, returns) but also some unused variables. --- lib/Cake/Test/Case/View/ViewTest.php | 49 ++++++++++++++++++---------- 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/lib/Cake/Test/Case/View/ViewTest.php b/lib/Cake/Test/Case/View/ViewTest.php index ea3aedd5c..fb20bc1b9 100644 --- a/lib/Cake/Test/Case/View/ViewTest.php +++ b/lib/Cake/Test/Case/View/ViewTest.php @@ -106,7 +106,7 @@ class TestThemeView extends View { * * @param string $name * @param array $params - * @return void + * @return string The given name */ public function renderElement($name, $params = array()) { return $name; @@ -115,8 +115,8 @@ class TestThemeView extends View { /** * getViewFileName method * - * @param string $name - * @return void + * @param string $name Controller action to find template filename for + * @return string Template filename */ public function getViewFileName($name = null) { return $this->_getViewFileName($name); @@ -125,8 +125,8 @@ class TestThemeView extends View { /** * getLayoutFileName method * - * @param string $name - * @return void + * @param string $name The name of the layout to find. + * @return string Filename for layout file (.ctp). */ public function getLayoutFileName($name = null) { return $this->_getLayoutFileName($name); @@ -144,8 +144,8 @@ class TestView extends View { /** * getViewFileName method * - * @param string $name - * @return void + * @param string $name Controller action to find template filename for + * @return string Template filename */ public function getViewFileName($name = null) { return $this->_getViewFileName($name); @@ -154,8 +154,8 @@ class TestView extends View { /** * getLayoutFileName method * - * @param string $name - * @return void + * @param string $name The name of the layout to find. + * @return string Filename for layout file (.ctp). */ public function getLayoutFileName($name = null) { return $this->_getLayoutFileName($name); @@ -164,9 +164,9 @@ class TestView extends View { /** * paths method * - * @param string $plugin - * @param boolean $cached - * @return void + * @param string $plugin Optional plugin name to scan for view files. + * @param boolean $cached Set to true to force a refresh of view paths. + * @return array paths */ public function paths($plugin = null, $cached = true) { return $this->_paths($plugin, $cached); @@ -200,6 +200,7 @@ class TestAfterHelper extends Helper { /** * beforeLayout method * + * @param string $viewFile * @return void */ public function beforeLayout($viewFile) { @@ -209,6 +210,7 @@ class TestAfterHelper extends Helper { /** * afterLayout method * + * @param string $layoutFile * @return void */ public function afterLayout($layoutFile) { @@ -529,7 +531,7 @@ class ViewTest extends CakeTestCase { $View = new TestView($this->Controller); ob_start(); - $result = $View->getViewFileName('does_not_exist'); + $View->getViewFileName('does_not_exist'); $this->ThemeController->plugin = null; $this->ThemeController->name = 'Pages'; @@ -557,8 +559,8 @@ class ViewTest extends CakeTestCase { $View = new TestView($this->Controller); ob_start(); - $result = $View->getLayoutFileName(); - $expected = ob_get_clean(); + $View->getLayoutFileName(); + ob_get_clean(); $this->ThemeController->plugin = null; $this->ThemeController->name = 'Posts'; @@ -567,7 +569,7 @@ class ViewTest extends CakeTestCase { $this->ThemeController->theme = 'my_theme'; $View = new TestThemeView($this->ThemeController); - $result = $View->getLayoutFileName(); + $View->getLayoutFileName(); } /** @@ -762,7 +764,7 @@ class ViewTest extends CakeTestCase { $result = Cache::read('element__test_element_cache_callbacks_param_foo', 'test_view'); $this->assertEquals($expected, $result); - $result = $View->element('test_element', array( + $View->element('test_element', array( 'param' => 'one', 'foo' => 'two' ), array( @@ -772,7 +774,7 @@ class ViewTest extends CakeTestCase { $this->assertEquals($expected, $result); $View->elementCache = 'default'; - $result = $View->element('test_element', array( + $View->element('test_element', array( 'param' => 'one', 'foo' => 'two' ), array( @@ -1310,6 +1312,17 @@ class ViewTest extends CakeTestCase { $this->assertEquals('Block content', $result); } +/** + * Test resetting a block's content. + * + * @return void + */ + public function testBlockReset() { + $this->View->assign('test', ''); + $result = $this->View->fetch('test', 'This should not be returned'); + $this->assertSame('', $result); + } + /** * Test appending to a block with append. * From 6d6be87f8ffcf1a86b1ebfde434b104d60dc41f7 Mon Sep 17 00:00:00 2001 From: Phally Date: Sat, 20 Jul 2013 16:59:39 +0200 Subject: [PATCH 5/9] Replaces deprecated paginate() calls in controller bake templates. Fixes #3895. --- lib/Cake/Console/Command/Task/ControllerTask.php | 7 ++++--- .../Templates/default/actions/controller_actions.ctp | 2 +- .../Case/Console/Command/Task/ControllerTaskTest.php | 10 +++++----- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/Cake/Console/Command/Task/ControllerTask.php b/lib/Cake/Console/Command/Task/ControllerTask.php index cd401c487..cb1a76857 100644 --- a/lib/Cake/Console/Command/Task/ControllerTask.php +++ b/lib/Cake/Console/Command/Task/ControllerTask.php @@ -370,10 +370,11 @@ class ControllerTask extends BakeTask { * @return array Components the user wants to use. */ public function doComponents() { - return $this->_doPropertyChoices( - __d('cake_console', "Would you like this controller to use any components?"), + $components = array('Paginator'); + return array_merge($components, $this->_doPropertyChoices( + __d('cake_console', "Would you like this controller to use other components\nbesides PaginatorComponent?"), __d('cake_console', "Please provide a comma separated list of the component names you'd like to use.\nExample: 'Acl, Security, RequestHandler'") - ); + )); } /** diff --git a/lib/Cake/Console/Templates/default/actions/controller_actions.ctp b/lib/Cake/Console/Templates/default/actions/controller_actions.ctp index 02249c1b0..928ec94af 100644 --- a/lib/Cake/Console/Templates/default/actions/controller_actions.ctp +++ b/lib/Cake/Console/Templates/default/actions/controller_actions.ctp @@ -26,7 +26,7 @@ */ public function index() { $this->->recursive = 0; - $this->set('', $this->paginate()); + $this->set('', $this->Paginator->paginate()); } /** diff --git a/lib/Cake/Test/Case/Console/Command/Task/ControllerTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/ControllerTaskTest.php index 5d85aa569..2047314d6 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/ControllerTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/ControllerTaskTest.php @@ -224,7 +224,7 @@ class ControllerTaskTest extends CakeTestCase { public function testDoComponentsNo() { $this->Task->expects($this->any())->method('in')->will($this->returnValue('n')); $result = $this->Task->doComponents(); - $this->assertSame(array(), $result); + $this->assertSame(array('Paginator'), $result); } /** @@ -237,7 +237,7 @@ class ControllerTaskTest extends CakeTestCase { $this->Task->expects($this->at(1))->method('in')->will($this->returnValue(' RequestHandler, Security ')); $result = $this->Task->doComponents(); - $expected = array('RequestHandler', 'Security'); + $expected = array('Paginator', 'RequestHandler', 'Security'); $this->assertEquals($expected, $result); } @@ -251,7 +251,7 @@ class ControllerTaskTest extends CakeTestCase { $this->Task->expects($this->at(1))->method('in')->will($this->returnValue(' RequestHandler, Security, , ')); $result = $this->Task->doComponents(); - $expected = array('RequestHandler', 'Security'); + $expected = array('Paginator', 'RequestHandler', 'Security'); $this->assertEquals($expected, $result); } @@ -350,7 +350,7 @@ class ControllerTaskTest extends CakeTestCase { $this->assertContains('function index() {', $result); $this->assertContains('$this->BakeArticle->recursive = 0;', $result); - $this->assertContains("\$this->set('bakeArticles', \$this->paginate());", $result); + $this->assertContains("\$this->set('bakeArticles', \$this->Paginator->paginate());", $result); $this->assertContains('function view($id = null)', $result); $this->assertContains("throw new NotFoundException(__('Invalid bake article'));", $result); @@ -388,7 +388,7 @@ class ControllerTaskTest extends CakeTestCase { $this->assertContains('function index() {', $result); $this->assertContains('$this->BakeArticle->recursive = 0;', $result); - $this->assertContains("\$this->set('bakeArticles', \$this->paginate());", $result); + $this->assertContains("\$this->set('bakeArticles', \$this->Paginator->paginate());", $result); $this->assertContains('function view($id = null)', $result); $this->assertContains("throw new NotFoundException(__('Invalid bake article'));", $result); From 5953171c7bd14205814bc34b1d12398f4b68ca05 Mon Sep 17 00:00:00 2001 From: Phally Date: Sat, 20 Jul 2013 20:21:35 +0200 Subject: [PATCH 6/9] Fixes cake bake all. Refs #1443. --- lib/Cake/Console/Command/Task/ControllerTask.php | 5 +++++ .../Test/Case/Console/Command/Task/ControllerTaskTest.php | 7 ++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Console/Command/Task/ControllerTask.php b/lib/Cake/Console/Command/Task/ControllerTask.php index cb1a76857..bea789f25 100644 --- a/lib/Cake/Console/Command/Task/ControllerTask.php +++ b/lib/Cake/Console/Command/Task/ControllerTask.php @@ -328,6 +328,11 @@ class ControllerTask extends BakeTask { 'plugin' => $this->plugin, 'pluginPath' => empty($this->plugin) ? '' : $this->plugin . '.' )); + + if (!in_array('Paginator', (array)$components)) { + $components[] = 'Paginator'; + } + $this->Template->set(compact('controllerName', 'actions', 'helpers', 'components', 'isScaffold')); $contents = $this->Template->generate('classes', 'controller'); diff --git a/lib/Cake/Test/Case/Console/Command/Task/ControllerTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/ControllerTaskTest.php index 2047314d6..fcf86204b 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/ControllerTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/ControllerTaskTest.php @@ -286,8 +286,9 @@ class ControllerTaskTest extends CakeTestCase { $this->assertContains(' * @property Article $Article', $result); $this->assertContains(' * @property AclComponent $Acl', $result); $this->assertContains(' * @property AuthComponent $Auth', $result); + $this->assertContains(' * @property PaginatorComponent $Paginator', $result); $this->assertContains('class ArticlesController extends AppController', $result); - $this->assertContains("public \$components = array('Acl', 'Auth')", $result); + $this->assertContains("public \$components = array('Acl', 'Auth', 'Paginator')", $result); $this->assertContains("public \$helpers = array('Js', 'Time')", $result); $this->assertContains("--actions--", $result); @@ -300,8 +301,8 @@ class ControllerTaskTest extends CakeTestCase { $result = $this->Task->bake('Articles', '--actions--', array(), array()); $this->assertContains('class ArticlesController extends AppController', $result); - $this->assertSame(substr_count($result, '@property'), 1); - $this->assertNotContains('components', $result); + $this->assertSame(substr_count($result, '@property'), 2); + $this->assertContains("public \$components = array('Paginator')", $result); $this->assertNotContains('helpers', $result); $this->assertContains('--actions--', $result); } From 881e757a1e4ea62fca9eafd11567d395f710dc98 Mon Sep 17 00:00:00 2001 From: Phally Date: Mon, 22 Jul 2013 13:51:09 +0200 Subject: [PATCH 7/9] Paths for App::build() require trailing /. --- app/Config/bootstrap.php | 36 +++++++++---------- .../Templates/skel/Config/bootstrap.php | 36 +++++++++---------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/app/Config/bootstrap.php b/app/Config/bootstrap.php index aaa7effcb..bc7e8edf6 100644 --- a/app/Config/bootstrap.php +++ b/app/Config/bootstrap.php @@ -31,24 +31,24 @@ Cache::config('default', array('engine' => 'File')); * The settings below can be used to set additional paths to models, views and controllers. * * App::build(array( - * 'Model' => array('/path/to/models', '/next/path/to/models'), - * 'Model/Behavior' => array('/path/to/behaviors', '/next/path/to/behaviors'), - * 'Model/Datasource' => array('/path/to/datasources', '/next/path/to/datasources'), - * 'Model/Datasource/Database' => array('/path/to/databases', '/next/path/to/database'), - * 'Model/Datasource/Session' => array('/path/to/sessions', '/next/path/to/sessions'), - * 'Controller' => array('/path/to/controllers', '/next/path/to/controllers'), - * 'Controller/Component' => array('/path/to/components', '/next/path/to/components'), - * 'Controller/Component/Auth' => array('/path/to/auths', '/next/path/to/auths'), - * 'Controller/Component/Acl' => array('/path/to/acls', '/next/path/to/acls'), - * 'View' => array('/path/to/views', '/next/path/to/views'), - * 'View/Helper' => array('/path/to/helpers', '/next/path/to/helpers'), - * 'Console' => array('/path/to/consoles', '/next/path/to/consoles'), - * 'Console/Command' => array('/path/to/commands', '/next/path/to/commands'), - * 'Console/Command/Task' => array('/path/to/tasks', '/next/path/to/tasks'), - * 'Lib' => array('/path/to/libs', '/next/path/to/libs'), - * 'Locale' => array('/path/to/locales', '/next/path/to/locales'), - * 'Vendor' => array('/path/to/vendors', '/next/path/to/vendors'), - * 'Plugin' => array('/path/to/plugins', '/next/path/to/plugins'), + * 'Model' => array('/path/to/models/', '/next/path/to/models/'), + * 'Model/Behavior' => array('/path/to/behaviors/', '/next/path/to/behaviors/'), + * 'Model/Datasource' => array('/path/to/datasources/', '/next/path/to/datasources/'), + * 'Model/Datasource/Database' => array('/path/to/databases/', '/next/path/to/database/'), + * 'Model/Datasource/Session' => array('/path/to/sessions/', '/next/path/to/sessions/'), + * 'Controller' => array('/path/to/controllers/', '/next/path/to/controllers/'), + * 'Controller/Component' => array('/path/to/components/', '/next/path/to/components/'), + * 'Controller/Component/Auth' => array('/path/to/auths/', '/next/path/to/auths/'), + * 'Controller/Component/Acl' => array('/path/to/acls/', '/next/path/to/acls/'), + * 'View' => array('/path/to/views/', '/next/path/to/views/'), + * 'View/Helper' => array('/path/to/helpers/', '/next/path/to/helpers/'), + * 'Console' => array('/path/to/consoles/', '/next/path/to/consoles/'), + * 'Console/Command' => array('/path/to/commands/', '/next/path/to/commands/'), + * 'Console/Command/Task' => array('/path/to/tasks/', '/next/path/to/tasks/'), + * 'Lib' => array('/path/to/libs/', '/next/path/to/libs/'), + * 'Locale' => array('/path/to/locales/', '/next/path/to/locales/'), + * 'Vendor' => array('/path/to/vendors/', '/next/path/to/vendors/'), + * 'Plugin' => array('/path/to/plugins/', '/next/path/to/plugins/'), * )); * */ diff --git a/lib/Cake/Console/Templates/skel/Config/bootstrap.php b/lib/Cake/Console/Templates/skel/Config/bootstrap.php index aaa7effcb..bc7e8edf6 100644 --- a/lib/Cake/Console/Templates/skel/Config/bootstrap.php +++ b/lib/Cake/Console/Templates/skel/Config/bootstrap.php @@ -31,24 +31,24 @@ Cache::config('default', array('engine' => 'File')); * The settings below can be used to set additional paths to models, views and controllers. * * App::build(array( - * 'Model' => array('/path/to/models', '/next/path/to/models'), - * 'Model/Behavior' => array('/path/to/behaviors', '/next/path/to/behaviors'), - * 'Model/Datasource' => array('/path/to/datasources', '/next/path/to/datasources'), - * 'Model/Datasource/Database' => array('/path/to/databases', '/next/path/to/database'), - * 'Model/Datasource/Session' => array('/path/to/sessions', '/next/path/to/sessions'), - * 'Controller' => array('/path/to/controllers', '/next/path/to/controllers'), - * 'Controller/Component' => array('/path/to/components', '/next/path/to/components'), - * 'Controller/Component/Auth' => array('/path/to/auths', '/next/path/to/auths'), - * 'Controller/Component/Acl' => array('/path/to/acls', '/next/path/to/acls'), - * 'View' => array('/path/to/views', '/next/path/to/views'), - * 'View/Helper' => array('/path/to/helpers', '/next/path/to/helpers'), - * 'Console' => array('/path/to/consoles', '/next/path/to/consoles'), - * 'Console/Command' => array('/path/to/commands', '/next/path/to/commands'), - * 'Console/Command/Task' => array('/path/to/tasks', '/next/path/to/tasks'), - * 'Lib' => array('/path/to/libs', '/next/path/to/libs'), - * 'Locale' => array('/path/to/locales', '/next/path/to/locales'), - * 'Vendor' => array('/path/to/vendors', '/next/path/to/vendors'), - * 'Plugin' => array('/path/to/plugins', '/next/path/to/plugins'), + * 'Model' => array('/path/to/models/', '/next/path/to/models/'), + * 'Model/Behavior' => array('/path/to/behaviors/', '/next/path/to/behaviors/'), + * 'Model/Datasource' => array('/path/to/datasources/', '/next/path/to/datasources/'), + * 'Model/Datasource/Database' => array('/path/to/databases/', '/next/path/to/database/'), + * 'Model/Datasource/Session' => array('/path/to/sessions/', '/next/path/to/sessions/'), + * 'Controller' => array('/path/to/controllers/', '/next/path/to/controllers/'), + * 'Controller/Component' => array('/path/to/components/', '/next/path/to/components/'), + * 'Controller/Component/Auth' => array('/path/to/auths/', '/next/path/to/auths/'), + * 'Controller/Component/Acl' => array('/path/to/acls/', '/next/path/to/acls/'), + * 'View' => array('/path/to/views/', '/next/path/to/views/'), + * 'View/Helper' => array('/path/to/helpers/', '/next/path/to/helpers/'), + * 'Console' => array('/path/to/consoles/', '/next/path/to/consoles/'), + * 'Console/Command' => array('/path/to/commands/', '/next/path/to/commands/'), + * 'Console/Command/Task' => array('/path/to/tasks/', '/next/path/to/tasks/'), + * 'Lib' => array('/path/to/libs/', '/next/path/to/libs/'), + * 'Locale' => array('/path/to/locales/', '/next/path/to/locales/'), + * 'Vendor' => array('/path/to/vendors/', '/next/path/to/vendors/'), + * 'Plugin' => array('/path/to/plugins/', '/next/path/to/plugins/'), * )); * */ From 8b21710c95274c977ef9db35bed973a13facce2f Mon Sep 17 00:00:00 2001 From: euromark Date: Thu, 25 Jul 2013 13:26:21 +0200 Subject: [PATCH 8/9] whitespace correction --- lib/Cake/Controller/Component/PaginatorComponent.php | 2 +- lib/Cake/Test/test_app/View/Posts/test_nocache_tags.ctp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Controller/Component/PaginatorComponent.php b/lib/Cake/Controller/Component/PaginatorComponent.php index e5d5fb425..0acba7bdf 100644 --- a/lib/Cake/Controller/Component/PaginatorComponent.php +++ b/lib/Cake/Controller/Component/PaginatorComponent.php @@ -121,7 +121,7 @@ class PaginatorComponent extends Component { * @param Model|string $object Model to paginate (e.g: model instance, or 'Model', or 'Model.InnerModel') * @param string|array $scope Additional find conditions to use while paginating * @param array $whitelist List of allowed fields for ordering. This allows you to prevent ordering - * on non-indexed, or undesirable columns. See PaginatorComponent::validateSort() for additional details + * on non-indexed, or undesirable columns. See PaginatorComponent::validateSort() for additional details * on how the whitelisting and sort field validation works. * @return array Model query results * @throws MissingModelException diff --git a/lib/Cake/Test/test_app/View/Posts/test_nocache_tags.ctp b/lib/Cake/Test/test_app/View/Posts/test_nocache_tags.ctp index d91db313d..1b1815e44 100644 --- a/lib/Cake/Test/test_app/View/Posts/test_nocache_tags.ctp +++ b/lib/Cake/Test/test_app/View/Posts/test_nocache_tags.ctp @@ -61,7 +61,7 @@

From f7eab23a5c03b4f323e1445e3129b54da56793d3 Mon Sep 17 00:00:00 2001 From: Phally Date: Fri, 26 Jul 2013 12:05:45 +0200 Subject: [PATCH 9/9] Strips the base off the generated URL from the AuthComponent. Fixes #3922. --- .../Controller/Component/AuthComponent.php | 2 +- .../Component/AuthComponentTest.php | 35 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Controller/Component/AuthComponent.php b/lib/Cake/Controller/Component/AuthComponent.php index 833b5f40f..621c97fc5 100644 --- a/lib/Cake/Controller/Component/AuthComponent.php +++ b/lib/Cake/Controller/Component/AuthComponent.php @@ -677,7 +677,7 @@ class AuthComponent extends Component { $redir = '/'; } if (is_array($redir)) { - return Router::url($redir); + return Router::url($redir + array('base' => false)); } return $redir; } diff --git a/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php b/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php index 4855928f5..73e70704a 100644 --- a/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php @@ -1268,6 +1268,41 @@ class AuthComponentTest extends CakeTestCase { $this->assertFalse($this->Auth->Session->check('Auth.redirect')); } +/** + * test that the returned URL doesn't contain the base URL. + * + * @see https://cakephp.lighthouseapp.com/projects/42648/tickets/3922-authcomponentredirecturl-prepends-appbaseurl + * + * @return void This test method doesn't return anything. + */ + public function testRedirectUrlWithBaseSet() { + $App = Configure::read('App'); + + Configure::write('App', array( + 'dir' => APP_DIR, + 'webroot' => WEBROOT_DIR, + 'base' => false, + 'baseUrl' => '/cake/index.php' + )); + + $url = '/users/login'; + $this->Auth->request = $this->Controller->request = new CakeRequest($url); + $this->Auth->request->addParams(Router::parse($url)); + $this->Auth->request->url = Router::normalize($url); + + Router::setRequestInfo($this->Auth->request); + + $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login'); + $this->Auth->loginRedirect = array('controller' => 'users', 'action' => 'home'); + + $result = $this->Auth->redirectUrl(); + $this->assertEquals('/users/home', $result); + $this->assertFalse($this->Auth->Session->check('Auth.redirect')); + + Configure::write('App', $App); + Router::reload(); + } + /** * test password hashing *