mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CookieWarning
synced 2024-11-24 06:13:58 +00:00
5ac97cf126
MediaWikiTestCase has been renamed to MediaWikiIntegrationTestCase in 1.34. Bug: T293043 Change-Id: I92d2b29501214f00e77c92149038b19d937dcabe
45 lines
1.3 KiB
PHP
45 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace CookieWarning\Tests;
|
|
|
|
use ConfigException;
|
|
use CookieWarning\Decisions;
|
|
use CookieWarning\GeoLocation;
|
|
use HashBagOStuff;
|
|
use MediaWiki\MediaWikiServices;
|
|
use MediaWikiIntegrationTestCase;
|
|
use MWException;
|
|
use RequestContext;
|
|
use WANObjectCache;
|
|
|
|
class DecisionsTest extends MediaWikiIntegrationTestCase {
|
|
/**
|
|
* @covers \CookieWarning\Decisions::shouldShowCookieWarning()
|
|
* @throws ConfigException
|
|
* @throws MWException
|
|
*/
|
|
public function testShouldNotCallGeoLocationMultiple() {
|
|
$this->setMwGlobals( [
|
|
'wgCookieWarningEnabled' => true,
|
|
'wgCookieWarningGeoIPLookup' => 'php',
|
|
'wgCookieWarningForCountryCodes' => [ 'EU' => 'European Union' ],
|
|
] );
|
|
|
|
$geoLocation = $this->getMockBuilder( GeoLocation::class )
|
|
->disableOriginalConstructor()
|
|
->getMock();
|
|
$geoLocation->method( 'locate' )->willReturn( 'EU' );
|
|
|
|
$geoLocation->expects( $this->once() )->method( 'locate' );
|
|
$cookieWarningDecisions = new Decisions(
|
|
MediaWikiServices::getInstance()->getService( 'CookieWarning.Config' ),
|
|
$geoLocation,
|
|
new WANObjectCache( [ 'cache' => new HashBagOStuff() ] ),
|
|
MediaWikiServices::getInstance()->getUserOptionsLookup()
|
|
);
|
|
|
|
$cookieWarningDecisions->shouldShowCookieWarning( RequestContext::getMain() );
|
|
$cookieWarningDecisions->shouldShowCookieWarning( RequestContext::getMain() );
|
|
}
|
|
}
|