wiki.techinc.nl/tests/phpunit/includes/filebackend/FileBackendGroupIntegrationTest.php
Aryeh Gregor 0fdb213fe5 Fix FileBackendGroup test for some configurations
The expected value of FileBackendGroup::config()['srvCache'] was being
obtained from MediaWikiServices::getLocalServerObjectCache(), but the
class actually used ObjectCache::getLocalServerInstance( 'hash' ). It
happens these are often the same, so it passed the gate-and-submit jobs,
but it's causing failures on Travis CI.

Follow-up to bd2a439502, which added the failing test. Thanks to
Krinkle for pointing out the failures on CI.

Change-Id: I17651766f4ee2752dfcae9574d2538269dec4ebe
2019-08-29 16:32:40 +03:00

61 lines
1.6 KiB
PHP

<?php
use MediaWiki\MediaWikiServices;
/**
* @coversDefaultClass FileBackendGroup
* @covers ::singleton
* @covers ::destroySingleton
*/
class FileBackendGroupIntegrationTest extends MediaWikiIntegrationTestCase {
use FileBackendGroupTestTrait;
private static function getWikiID() {
return wfWikiID();
}
private function getLockManagerGroupFactory() {
return MediaWikiServices::getInstance()->getLockManagerGroupFactory();
}
private function newObj( array $options = [] ) : FileBackendGroup {
$globals = [ 'DirectoryMode', 'FileBackends', 'ForeignFileRepos', 'LocalFileRepo' ];
foreach ( $globals as $global ) {
$this->setMwGlobals(
"wg$global", $options[$global] ?? self::getDefaultOptions()[$global] );
}
$serviceMembers = [
'configuredROMode' => 'ConfiguredReadOnlyMode',
'srvCache' => 'LocalServerObjectCache',
'wanCache' => 'MainWANObjectCache',
'mimeAnalyzer' => 'MimeAnalyzer',
'lmgFactory' => 'LockManagerGroupFactory',
'tmpFileFactory' => 'TempFSFileFactory',
];
foreach ( $serviceMembers as $key => $name ) {
if ( isset( $options[$key] ) ) {
$this->setService( $name, $options[$key] );
}
}
$this->assertEmpty(
array_diff( array_keys( $options ), $globals, array_keys( $serviceMembers ) ) );
$this->resetServices();
FileBackendGroup::destroySingleton();
$services = MediaWikiServices::getInstance();
foreach ( $serviceMembers as $key => $name ) {
if ( $key === 'srvCache' ) {
$this->$key = ObjectCache::getLocalServerInstance( 'hash' );
} else {
$this->$key = $services->getService( $name );
}
}
return FileBackendGroup::singleton();
}
}