Skip to content

Commit

Permalink
Splat operator doesn't like associative arrays.
Browse files Browse the repository at this point in the history
Fixes #10286
  • Loading branch information
ADmad committed Feb 22, 2017
1 parent 39ec5b7 commit 97cbe23
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Controller/Controller.php
Expand Up @@ -437,7 +437,7 @@ public function invokeAction()
/* @var callable $callable */
$callable = [$this, $request->getParam('action')];

return $callable(...$request->getParam('pass'));
return $callable(...array_values($request->getParam('pass')));
}

/**
Expand Down
23 changes: 23 additions & 0 deletions tests/TestCase/Controller/ControllerTest.php
Expand Up @@ -872,6 +872,29 @@ public function testInvokeActionReturnValue()
$this->assertEquals('I am from the controller.', $result);
}

/**
* test invoking controller methods with passed params
*
* @return void
*/
public function testInvokeActionWithPassedParams()
{
$url = new Request('test/index/1/2');
$url->addParams([
'controller' => 'Test',
'action' => 'index',
'pass' => ['param1' => '1', 'param2' => '2']
]);
$response = $this->getMockBuilder('Cake\Network\Response')->getMock();

$Controller = new TestController($url, $response);
$result = $Controller->invokeAction();
$this->assertEquals(
['testId' => '1', 'test2Id' => '2'],
$Controller->request->data
);
}

/**
* test that a classes namespace is used in the viewPath.
*
Expand Down

0 comments on commit 97cbe23

Please sign in to comment.