Skip to content

Instantly share code, notes, and snippets.

@skurfuerst
Created May 16, 2011 08:28
Show Gist options
  • Save skurfuerst/974095 to your computer and use it in GitHub Desktop.
Save skurfuerst/974095 to your computer and use it in GitHub Desktop.
/**
* @test
* @author Bastian Waidelich <bastian@typo3.org>
*/
public function packageKeyCanBeOverwrittenByRequest() {
$packageKey = NULL;
$setControllerPackageKeyCallback = function() use (&$packageKey) {
$args = func_get_args();
$packageKey = $args[0];
};
$router = $this->getRouter();
$router->expects($this->once())->method('findMatchResults')->with('foo')->will($this->returnValue(array('@package' => 'MyPackage')));
$mockRequest = $this->getMock('F3\FLOW3\MVC\Web\Request', array(), array(), '', FALSE);
$mockRequest->expects($this->once())->method('getRoutePath')->will($this->returnValue('foo'));
$mockRequest->expects($this->any())->method('getArguments')->will($this->returnValue(array('@package' => 'OverwrittenPackage')));
$mockRequest->expects($this->exactly(2))->method('setControllerPackageKey')->will($this->returnCallback($setControllerPackageKeyCallback));
$router->route($mockRequest);
$this->assertEquals('OverwrittenPackage', $packageKey);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment