7 use MediaWikiCoversValidator;
8 use PHPUnit4And6Compat;
14 $this->setExpectedException( MWException::class,
'bogus data' );
22 $this->setExpectedException( MWException::class,
'bogus session' );
30 $session = SessionManager::singleton()->getEmptySession(
new FauxRequest( [] ) );
31 $this->assertInstanceOf(
42 $this->assertEquals(
'Value',
$req->getText(
'x' ) );
43 $this->assertEquals(
'',
$req->getText(
'z' ) );
52 $this->assertSame(
"A\r\nb",
$req->getVal(
'crlf' ),
'CRLF' );
65 $this->assertSame(
'Value',
$req->getRawVal(
'x' ) );
66 $this->assertSame(
null,
$req->getRawVal(
'z' ),
'Not found' );
67 $this->assertSame(
null,
$req->getRawVal(
'y' ),
'Array is ignored' );
68 $this->assertSame(
"A\r\nb",
$req->getRawVal(
'crlf' ),
'CRLF' );
75 $values = [
'x' =>
'Value',
'y' =>
'' ];
77 $this->assertEquals( $values,
$req->getValues() );
84 $values = [
'x' =>
'Value',
'y' =>
'' ];
87 $this->assertEquals( $values,
$req->getQueryValues() );
89 $this->assertEquals( [],
$req->getQueryValues() );
97 $this->assertEquals(
'GET',
$req->getMethod() );
99 $this->assertEquals(
'POST',
$req->getMethod() );
107 $this->assertFalse(
$req->wasPosted() );
109 $this->assertTrue(
$req->wasPosted() );
119 $this->assertSame(
null,
$req->getCookie(
'z',
'' ) );
121 $req->setCookie(
'x',
'Value',
'' );
122 $this->assertEquals(
'Value',
$req->getCookie(
'x',
'' ) );
124 $req->setCookies( [
'x' =>
'One',
'y' =>
'Two' ],
'' );
125 $this->assertEquals(
'One',
$req->getCookie(
'x',
'' ) );
126 $this->assertEquals(
'Two',
$req->getCookie(
'y',
'' ) );
140 $this->assertSame(
null,
$req->getCookie(
'z' ) );
142 $req->setCookie(
'x',
'Value' );
143 $this->assertEquals(
'Value',
$req->getCookie(
'x' ) );
153 $this->setExpectedException( MWException::class );
154 $req->getRequestURL();
163 $req->setRequestURL(
'https://example.org' );
164 $this->assertEquals(
'https://example.org',
$req->getRequestURL() );
173 $this->assertEquals(
'http',
$req->getProtocol() );
175 $this->assertEquals(
'http',
$req->getProtocol() );
177 $this->assertEquals(
'https',
$req->getProtocol() );
186 $value =
'text/plain, text/html';
191 $this->assertEquals(
$request->getHeader(
'Nonexistent' ),
false );
196 $request->getHeader(
'Accept', WebRequest::GETHEADER_LIST ),
197 [
'text/plain',
'text/html' ]
205 $_SERVER[
'HTTP_TEST'] =
'Example';
225 $values = [
'x' =>
'Value',
'y' =>
'' ];
228 $this->assertEquals( $values,
$req->getSessionArray() );
231 $this->assertSame(
null,
$req->getSessionArray() );
241 $this->assertEquals(
'',
$req->getRawQueryString() );
242 $this->assertEquals(
'',
$req->getRawPostString() );
243 $this->assertEquals(
'',
$req->getRawInput() );
$wgCookiePrefix
Cookies generated by MediaWiki have names starting with this prefix.
testGetRequestURL()
FauxRequest::getRequestURL.
testDummies()
FauxRequest::getRawQueryString FauxRequest::getRawPostString FauxRequest::getRawInput.
testConstructInvalidSession()
FauxRequest::__construct.
testSetRequestURL()
FauxRequest::setRequestURL FauxRequest::getRequestURL.
testWasPosted()
FauxRequest::wasPosted.
testProtocol()
FauxRequest::__construct FauxRequest::getProtocol.
testGetText()
FauxRequest::getText.
testConstructInvalidData()
FauxRequest::__construct.
testSessionData()
FauxRequest::__construct FauxRequest::getSessionArray.
testCookies()
FauxRequest::getCookie FauxRequest::setCookie FauxRequest::setCookies.
testGetVal()
Integration test for parent method FauxRequest::getVal.
testCookiesDefaultPrefix()
FauxRequest::getCookie FauxRequest::setCookie FauxRequest::setCookies.
testConstructWithSession()
FauxRequest::__construct.
testGetMethod()
FauxRequest::getMethod.
testGetSetHeader()
FauxRequest::setHeader FauxRequest::setHeaders FauxRequest::getHeader.
testGetValues()
FauxRequest::getValues.
testGetRawVal()
Integration test for parent method FauxRequest::getRawVal.
testGetQueryValues()
FauxRequest::getQueryValues.
testGetAllHeaders()
FauxRequest::initHeaders.
WebRequest clone which takes values from a provided array.
this hook is for auditing only $req
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on $request