/** * Instantiate a mock request to the given operation. * @param $requestedOp string the requested operation * @param $context mixed a request context to be returned * by the router. * @param $user User a user to be put into the registry. * @return PKPRequest */ protected function getMockRequest($requestedOp, $context = null, $user = null) { // Mock a request to the permitted operation. $request = new PKPRequest(); // Mock a router. $router = $this->getMock('PKPRouter', array('getRequestedOp', 'getContext')); // Mock the getRequestedOp() method. $router->expects($this->any())->method('getRequestedOp')->will($this->returnValue($requestedOp)); // Mock the getContext() method. $router->expects($this->any())->method('getContext')->will($this->returnValue($context)); // Put a user into the registry if one has been // passed in. if ($user instanceof User) { Registry::set('user', $user); } $request->setRouter($router); return $request; }