Skip to content

Commit

Permalink
Fixing some issues with parameter handling. Adding test cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Apr 29, 2010
1 parent f17eebe commit 15a4607
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
8 changes: 6 additions & 2 deletions cake/libs/cake_request.php
Expand Up @@ -79,6 +79,10 @@ protected function _processPost() {
}
unset($this->params['form']['_method']);
}
if (isset($this->params['form']['data'])) {
$this->data = $this->params['form']['data'];
unset($this->params['form']['data']);
}
}

/**
Expand All @@ -93,9 +97,9 @@ protected function _processGet() {
$url = $_GET;
}
if (isset($this->params['url'])) {
$this->params['url'] = array_merge($this->params['url'], $url);
$this->url = array_merge($this->url, $url);
} else {
$this->params['url'] = $url;
$this->url = $url;
}
}

Expand Down
19 changes: 18 additions & 1 deletion cake/tests/cases/libs/cake_request.test.php
Expand Up @@ -38,6 +38,23 @@ function testConstructionGetParsing() {
'two' => 'banana'
);
$request = new CakeRequest();
$this->assertEqual($request->params['url'], $_GET);
$this->assertEqual($request->url, $_GET);
}

/**
* test parsing POST data into the object.
*
* @return void
*/
function testPostParsing() {
$_POST = array('data' => array(
'Article' => array('title')
));
$request = new CakeRequest();
$this->assertEqual($request->data, $_POST['data']);

$_POST = array('one' => 1, 'two' => 'three');
$request = new CakeRequest();
$this->assertEqual($request->params['form'], $_POST);
}
}

0 comments on commit 15a4607

Please sign in to comment.