diff --git a/cake/tests/cases/libs/cake_test_case.test.php b/cake/tests/cases/libs/cake_test_case.test.php index 14fd9a751..974f41b9b 100644 --- a/cake/tests/cases/libs/cake_test_case.test.php +++ b/cake/tests/cases/libs/cake_test_case.test.php @@ -250,6 +250,39 @@ class CakeTestCaseTest extends CakeTestCase { $result = $this->Case->testAction('/tests_apps_posts/add', array('return' => 'vars')); $this->assertTrue(array_key_exists('posts', $result)); $this->assertEqual(count($result['posts']), 1); + + $result = $this->Case->testAction('/tests_apps_posts/url_var/var1:value1/var2:val2', array( + 'return' => 'vars', + 'method' => 'get', + )); + $this->assertEqual(array_keys($result['params']['url']), array('case', 'output', 'url')); + $this->assertEqual(array_keys($result['params']['named']), array('var1', 'var2')); + + $result = $this->Case->testAction('/tests_apps_posts/url_var/gogo/val2', array( + 'return' => 'vars', + 'method' => 'get', + )); + $this->assertEqual($result['params']['pass'], array('gogo', 'val2')); + + $result = $this->Case->testAction('/tests_apps_posts/url_var', array( + 'return' => 'vars', + 'method' => 'get', + 'data' => array( + 'red' => 'health', + 'blue' => 'mana' + ) + )); + $this->assertEqual(array_keys($result['params']['url']), array('case', 'output', 'red', 'blue', 'url')); + + $result = $this->Case->testAction('/tests_apps_posts/post_var', array( + 'return' => 'vars', + 'method' => 'post', + 'data' => array( + 'name' => 'is jonas', + 'pork' => 'and beans', + ) + )); + $this->assertEqual(array_keys($result['data']), array('name', 'pork')); Configure::write('controllerPaths', $_back['controller']); Configure::write('viewPaths', $_back['view']); diff --git a/cake/tests/lib/cake_test_case.php b/cake/tests/lib/cake_test_case.php index 3c88deea5..1ccd0b67a 100644 --- a/cake/tests/lib/cake_test_case.php +++ b/cake/tests/lib/cake_test_case.php @@ -265,14 +265,14 @@ class CakeTestCase extends UnitTestCase { : $this->__savedGetData; $data = (!empty($params['data'])) - ? array('data' => $params['data']) + ? $params['data'] : array(); if (strtolower($params['method']) == 'get') { $_GET = array_merge($this->__savedGetData, $data); $_POST = array(); } else { - $_POST = $data; + $_POST = array('data' => $data); $_GET = $this->__savedGetData; } diff --git a/cake/tests/test_app/controllers/tests_apps_posts_controller.php b/cake/tests/test_app/controllers/tests_apps_posts_controller.php index 2bae16450..cc2d73c80 100644 --- a/cake/tests/test_app/controllers/tests_apps_posts_controller.php +++ b/cake/tests/test_app/controllers/tests_apps_posts_controller.php @@ -43,6 +43,16 @@ class TestsAppsPostsController extends AppController { $this->set('posts', $this->Post->find('all')); $this->render('index'); } + + function url_var() { + $this->set('params', $this->params); + $this->render('index'); + } + + function post_var() { + $this->set('data', $this->data); + $this->render('index'); + } } ?> \ No newline at end of file