/**
* @dataProvider provideDetectServer
+ * @covers WebRequest::detectServer
*/
- function testDetectServer( $expected, $input, $description ) {
+ public function testDetectServer( $expected, $input, $description ) {
$_SERVER = $input;
$result = WebRequest::detectServer();
$this->assertEquals( $expected, $result, $description );
/**
* @dataProvider provideGetIP
+ * @covers WebRequest::getIP
*/
- function testGetIP( $expected, $input, $squid, $xffList, $private, $description ) {
+ public function testGetIP( $expected, $input, $squid, $xffList, $private, $description ) {
$_SERVER = $input;
$this->setMwGlobals( array(
'wgSquidServersNoPurge' => $squid,
false,
'With X-Forwaded-For and private IP and hook (disallowed)'
),
+ array(
+ '12.0.0.1',
+ array(
+ 'REMOTE_ADDR' => 'abcd:0001:002:03:4:555:6666:7777',
+ 'HTTP_X_FORWARDED_FOR' => '12.0.0.1, abcd:0001:002:03:4:555:6666:7777',
+ ),
+ array( 'ABCD:1:2:3::/64' ),
+ array(),
+ false,
+ 'IPv6 CIDR'
+ ),
+ array(
+ '12.0.0.3',
+ array(
+ 'REMOTE_ADDR' => '12.0.0.1',
+ 'HTTP_X_FORWARDED_FOR' => '12.0.0.3, 12.0.0.2'
+ ),
+ array( '12.0.0.0/24' ),
+ array(),
+ false,
+ 'IPv4 CIDR'
+ ),
);
}
/**
* @expectedException MWException
+ * @covers WebRequest::getIP
*/
- function testGetIpLackOfRemoteAddrThrowAnException() {
+ public function testGetIpLackOfRemoteAddrThrowAnException() {
+ // ensure that local install state doesn't interfere with test
+ $this->setMwGlobals( array(
+ 'wgSquidServersNoPurge' => array(),
+ 'wgSquidServers' => array(),
+ 'wgUsePrivateIPs' => false,
+ 'wgHooks' => array(),
+ ) );
+
$request = new WebRequest();
# Next call throw an exception about lacking an IP
$request->getIP();
/**
* @dataProvider provideLanguageData
+ * @covers WebRequest::getAcceptLang
*/
- function testAcceptLang( $acceptLanguageHeader, $expectedLanguages, $description ) {
+ public function testAcceptLang( $acceptLanguageHeader, $expectedLanguages, $description ) {
$_SERVER = array( 'HTTP_ACCEPT_LANGUAGE' => $acceptLanguageHeader );
$request = new WebRequest();
$this->assertSame( $request->getAcceptLang(), $expectedLanguages, $description );