public function testHttpAuthentication() { $app = $this->createApplication('http'); $client = new Client($app); $client->request('get', '/'); $this->assertEquals(401, $client->getResponse()->getStatusCode()); $this->assertEquals('Basic realm="Secured"', $client->getResponse()->headers->get('www-authenticate')); $client->request('get', '/', array(), array(), array('PHP_AUTH_USER' => 'dennis', 'PHP_AUTH_PW' => 'foo')); $this->assertEquals('dennisAUTHENTICATED', $client->getResponse()->getContent()); $client->request('get', '/admin'); $this->assertEquals(403, $client->getResponse()->getStatusCode()); $client->restart(); $client->request('get', '/'); $this->assertEquals(401, $client->getResponse()->getStatusCode()); $this->assertEquals('Basic realm="Secured"', $client->getResponse()->headers->get('www-authenticate')); $client->request('get', '/', array(), array(), array('PHP_AUTH_USER' => 'admin', 'PHP_AUTH_PW' => 'foo')); $this->assertEquals('adminAUTHENTICATEDADMIN', $client->getResponse()->getContent()); $client->request('get', '/admin'); $this->assertEquals('admin', $client->getResponse()->getContent()); }