Unbreak geolocation tests

The freegeoip.net service is shutdown since... a while.

There's currently no alternative, apart from ones where you need an API
key. As I don't want to provide an API key in the CI, and this is a
release branch, I simply remove the tests. The same will most likely be
done in master, but I need to think about removing this feature
altogether, if untested.

Change-Id: I1c5783aae290af5fdcb39f44ac1e832fa5edb6db
This commit is contained in:
Florian Schmidt 2021-01-05 19:39:32 +01:00
parent 8ab2dfc20f
commit 2fa9bb87b0

View file

@ -117,62 +117,4 @@ class CookieWarningHooksTest extends MediaWikiLangTestCase {
],
];
}
/**
* @dataProvider providerOnSkinTemplateOutputPageBeforeExecGeoLocation
*/
public function testOnSkinTemplateOutputPageBeforeExecGeoLocation( $ipAddress, $countryCodes,
$expected
) {
$this->resetCookieWarningHooks();
$this->setMwGlobals( [
'wgCookieWarningEnabled' => true,
'wgCookieWarningGeoIPLookup' => is_array( $countryCodes ) ? 'php' : 'none',
'wgCookieWarningForCountryCodes' => $countryCodes,
] );
$request = new FauxRequest();
$request->setIP( $ipAddress );
$context = new DerivativeContext( RequestContext::getMain() );
$context->setRequest( $request );
$sk = new SkinTemplate();
$sk->setContext( $context );
$tpl = new CookieWarningTestTemplate();
CookieWarningHooks::onSkinTemplateOutputPageBeforeExec( $sk, $tpl );
$this->assertEquals(
$expected,
isset( $tpl->data['headelement'] ) && (bool)$tpl->data['headelement']
);
}
public function providerOnSkinTemplateOutputPageBeforeExecGeoLocation() {
return [
[
'8.8.8.8',
[ 'US' => 'United States of America' ],
true,
],
[
'8.8.8.8',
[ 'EU' => 'European Union' ],
false,
],
[
'8.8.8.8',
false,
true,
],
];
}
private function resetCookieWarningHooks() {
// reset the inConfiguredRegion value to retrigger a location lookup, if called again
$singleton = CookieWarningHooks::class;
$reflection = new ReflectionClass( $singleton );
$instance = $reflection->getProperty( 'inConfiguredRegion' );
$instance->setAccessible( true );
$instance->setValue( null, null );
$instance->setAccessible( false );
}
}