public function testGetAuth() { $request = new \Phalcon\Http\Request(); $_SERVER = array('PHP_AUTH_USER' => 'myleft', 'PHP_AUTH_PW' => '123456'); $data = array('username' => 'myleft', 'password' => '123456'); $auth = $request->getBasicAuth(); $this->assertEquals($auth, $data); $_SERVER = array('PHP_AUTH_DIGEST' => 'Digest username="******", realm="myleft", qop="auth", algorithm="MD5", uri="http://localhost:81/", nonce="nonce", nc=nc, cnonce="cnonce", opaque="opaque", response="response"'); $data = array('username' => 'myleft', 'realm' => 'myleft', 'qop' => 'auth', 'algorithm' => 'MD5', 'uri' => 'http://localhost:81/', 'nonce' => 'nonce', 'nc' => 'nc', 'cnonce' => 'cnonce', 'opaque' => 'opaque', 'response' => 'response'); $auth = $request->getDigestAuth(); $this->assertEquals($auth, $data); $_SERVER = array('PHP_AUTH_DIGEST' => 'Digest username=myleft, realm=myleft, qop=auth, algorithm=MD5, uri=http://localhost:81/, nonce=nonce, nc=nc, cnonce=cnonce, opaque=opaque, response=response'); $auth = $request->getDigestAuth(); $this->assertEquals($auth, $data); $_SERVER = array('PHP_AUTH_DIGEST' => 'Digest username=myleft realm=myleft qop=auth algorithm=MD5 uri=http://localhost:81/ nonce=nonce nc=nc cnonce=cnonce opaque=opaque response=response'); $auth = $request->getDigestAuth(); $this->assertEquals($auth, $data); }