withQueryParams(['ref' => '/somewhere-else']); $this->event = new Event('Controller.beforeFilter'); $this->Controller = new RefererRedirectComponentTestController($serverRequest); Configure::write('App.fullBaseUrl', 'http://localhost'); } /** * @return void */ public function tearDown(): void { parent::tearDown(); unset($this->Controller); } /** * @return void */ public function testBeforeRedirect() { $response = new Response(); $componentRegistry = new ComponentRegistry($this->Controller); $refererRedirectComponent = new RefererRedirectComponent($componentRegistry); $modifiedResponse = $refererRedirectComponent->beforeRedirect($this->event, ['action' => 'foo'], $response); $this->assertSame(['/somewhere-else'], $modifiedResponse->getHeader('Location')); } }