/** * Returns the current URL without CAS-affecting parameters. * * @return string */ public function getCurrentUrl() { $replacements = array('/\\?logout/' => '', '/&ticket=[^&]*/' => '', '/\\?ticket=[^&;]*/' => '?', '/\\?%26/' => '?', '/\\?&/' => '?', '/\\?$/' => ''); $request = $this->kernel->getRequest(); return preg_replace(array_keys($replacements), array_values($replacements), $request->getUri()); }
public function testHandleRestoresThePreviousRequestOnException() { $dispatcher = new EventDispatcher(); $resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface'); $kernel = new HttpKernel($dispatcher, $resolver); $request = new Request(); $expected = new \Exception(); $controller = function () use($expected) { throw $expected; }; $resolver->expects($this->once())->method('getController')->with($request)->will($this->returnValue($controller)); $resolver->expects($this->once())->method('getArguments')->with($request, $controller)->will($this->returnValue(array())); try { $kernel->handle($request); $this->fail('->handle() suppresses the controller exception'); } catch (\Exception $actual) { $this->assertSame($expected, $actual, '->handle() throws the controller exception'); } $this->assertNull($kernel->getRequest(), '->handle() restores the parent (null) request when the controller throws an exception'); }