Go to the documentation of this file.
7 use MediaWikiCoversValidator;
8 use PHPUnit4And6Compat;
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' ) );
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 );
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() );
WebRequest clone which takes values from a provided array.
processing should stop and the error should be shown to the user * false
this hook is for auditing only $req
testProtocol()
FauxRequest::__construct FauxRequest::getProtocol.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
testConstructInvalidSession()
FauxRequest::__construct.
testGetText()
FauxRequest::getText.
testGetVal()
Integration test for parent method FauxRequest::getVal.
testGetRequestURL()
FauxRequest::getRequestURL.
testGetSetHeader()
FauxRequest::setHeader FauxRequest::setHeaders FauxRequest::getHeader.
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
testConstructInvalidData()
FauxRequest::__construct.
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
testCookies()
FauxRequest::getCookie FauxRequest::setCookie FauxRequest::setCookies.
testWasPosted()
FauxRequest::wasPosted.
testSessionData()
FauxRequest::__construct FauxRequest::getSessionArray.
testGetMethod()
FauxRequest::getMethod.
const GETHEADER_LIST
Flag to make WebRequest::getHeader return an array of values.
testGetRawVal()
Integration test for parent method FauxRequest::getRawVal.
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
testConstructWithSession()
FauxRequest::__construct.
testGetAllHeaders()
FauxRequest::initHeaders.
testCookiesDefaultPrefix()
FauxRequest::getCookie FauxRequest::setCookie FauxRequest::setCookies.
testGetQueryValues()
FauxRequest::getQueryValues.
$wgCookiePrefix
Cookies generated by MediaWiki have names starting with this prefix.
testSetRequestURL()
FauxRequest::setRequestURL FauxRequest::getRequestURL.
testDummies()
FauxRequest::getRawQueryString FauxRequest::getRawPostString FauxRequest::getRawInput.
testGetValues()
FauxRequest::getValues.