Permalink
Browse files

Controller: Updated the set method so that data can be overwritten wh…

…en set again.

ControllerTest: Added tests for the set method.
  • Loading branch information...
1 parent 3870c61 commit 5c4f1470548904216415e4d1faa2f8f119f2e16a @Howard3 Howard3 committed with nateabele May 19, 2011
@@ -202,7 +202,7 @@ public function __invoke($request, $dispatchParams, array $options = array()) {
* @return void
*/
public function set($data = array()) {
- $this->_render['data'] += (array) $data;
+ $this->_render['data'] = (array) $data + $this->_render['data'];
}
/**
@@ -285,6 +285,24 @@ public function testManuallySettingTemplate() {
$this->assertEqual('foo', $result['template']);
}
+ public function testSetData() {
+ $postController = new MockPostsController();
+
+ $setData = array('foo' => 'bar');
+ $postController->set($setData);
+ $_render = $postController->access('_render');
+ $data = $_render['data'];
+ $expected = $setData;
+ $this->assertEqual($expected, $data);
+
+ $setData = array('foo' => 'baz');
+ $postController->set($setData);
+ $_render = $postController->access('_render');
+ $data = $_render['data'];
+ $expected = $setData;
+ $this->assertEqual($expected, $data);
+ }
+
public function testResponseTypeBasedOnRequestHeaderType() {
$request = new MockControllerRequest(array(
'env' => array('HTTP_ACCEPT' => 'application/json,*/*')

0 comments on commit 5c4f147

Please sign in to comment.