From 35a1cbea2a6d744dee16a0ca0f99891eff4966da Mon Sep 17 00:00:00 2001 From: falmp Date: Wed, 16 Oct 2013 16:55:16 +0100 Subject: [PATCH 1/2] Removed unnecessary appendData(), the Slim render() already does that. --- src/SlimController/SlimController.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/SlimController/SlimController.php b/src/SlimController/SlimController.php index 9ad2eab..303d99d 100644 --- a/src/SlimController/SlimController.php +++ b/src/SlimController/SlimController.php @@ -93,17 +93,14 @@ public function __construct(\Slim\Slim &$app) * @param string $template Name of the template to be rendererd * @param array $args Args for view */ - protected function render($template, $args = null) + protected function render($template, $args = array()) { - if (!is_null($args)) { - $this->app->view()->appendData($args); - } if (!is_null($this->renderTemplateSuffix) && !preg_match('/\.' . $this->renderTemplateSuffix . '$/', $template) ) { $template .= '.' . $this->renderTemplateSuffix; } - $this->app->render($template); + $this->app->render($template, $args); } /** From c20bfe0aa988801ae6245e3e93d865c42621490f Mon Sep 17 00:00:00 2001 From: William Yaworsky Date: Wed, 16 Oct 2013 12:31:46 -0400 Subject: [PATCH 2/2] Fixed unit tests The unit test for rendering templates expected the old calls. I removed those expectations and changed the expectation on for Slim::render to reflect the new way it is called. --- tests/SlimController/Tests/SlimControllerTest.php | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/tests/SlimController/Tests/SlimControllerTest.php b/tests/SlimController/Tests/SlimControllerTest.php index c91a9d7..3fdbdb6 100644 --- a/tests/SlimController/Tests/SlimControllerTest.php +++ b/tests/SlimController/Tests/SlimControllerTest.php @@ -50,17 +50,9 @@ public function testControllerConfigParamsAreUsed() public function testRenderingWorksFine() { $this->assertDefaultConstruction(); - $view = m::mock(); - $this->slim->shouldReceive('view') - ->once() - ->withNoArgs() - ->andReturn($view); - $view->shouldReceive('appendData') - ->once() - ->with(array('foo' => 'orotound', 'bar' => 'grandios')); $this->slim->shouldReceive('render') ->once() - ->with('rendertest.Suffix'); + ->with('rendertest.Suffix', array('foo' => 'orotound', 'bar' => 'grandios')); $controller = new TestController($this->slim); $controller->renderAction(); @@ -282,4 +274,4 @@ protected function assertDefaultConstruction($suffix = 'Suffix', $paramPrefix = ->andReturn($cleanupParams); } -} \ No newline at end of file +}