public function testProvideSessionInfo() { $provider = $this->getProvider(); $request = new \FauxRequest(); $request->setCookie('_BPsession', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'wgCookiePrefix'); if (!defined('MW_API')) { $this->assertNull($provider->provideSessionInfo($request)); define('MW_API', 1); } $info = $provider->provideSessionInfo($request); $this->assertInstanceOf('MediaWiki\\Session\\SessionInfo', $info); $this->assertSame('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', $info->getId()); $this->config->set('EnableBotPasswords', false); $this->assertNull($provider->provideSessionInfo($request)); $this->config->set('EnableBotPasswords', true); $this->assertNull($provider->provideSessionInfo(new \FauxRequest())); }
/** * @covers FauxRequest::getCookie * @covers FauxRequest::setCookie * @covers FauxRequest::setCookies */ public function testCookiesDefaultPrefix() { global $wgCookiePrefix; $oldPrefix = $wgCookiePrefix; $wgCookiePrefix = '_'; $req = new FauxRequest(); $this->assertSame(null, $req->getCookie('z')); $req->setCookie('x', 'Value'); $this->assertEquals('Value', $req->getCookie('x')); $wgCookiePrefix = $oldPrefix; }