assertInstanceOf(ServerRequest::class, $request); $this->assertIsArray($options); return '/my/custom/url/'; }); $this->configRequest([ 'headers' => [ 'REFERER' => 'http://localhost/profile', ], ]); $this->get('/users/index'); $this->assertRedirect('/my/custom/url/'); } /** * Test unathorize redirect when user is NOT logged * * @return void */ public function testUnauthorizedRedirectNotLogged() { $this->configRequest([ 'headers' => [ 'REFERER' => 'http://localhost/profile', ], ]); $this->get('/users/index'); $this->assertRedirect('/login?redirect=http%3A%2F%2Flocalhost%2Fusers%2Findex'); } /** * Test unathorize redirect when user is logged * * @return void */ public function testUnauthorizedRedirectLogged() { $userId = '00000000-0000-0000-0000-000000000004'; $user = TableRegistry::getTableLocator() ->get('CakeDC/Users.Users') ->get($userId); $this->session(['Auth' => $user]); $this->configRequest([ 'headers' => [ 'REFERER' => 'http://localhost/profile', ], ]); $this->get('/users/index'); $this->assertRedirect('/profile'); } }