| 1 |
<?php |
| 2 |
|
| 3 |
use MediaWiki\MainConfigNames; |
| 4 |
use MediaWiki\WikiMap\WikiMap; |
| 5 |
use Wikimedia\FileBackend\SwiftFileBackend; |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
class SwiftFileBackendIntegrationTest extends FileBackendIntegrationTestBase { |
| 12 |
|
| 13 |
private static $backendToUse; |
| 14 |
|
| 15 |
private function getBackendConfig(): ?array { |
| 16 |
$backends = $this->getServiceContainer()->getMainConfig()->get( MainConfigNames::FileBackends ); |
| 17 |
foreach ( $backends as $conf ) { |
| 18 |
if ( $conf['class'] === SwiftFileBackend::class ) { |
| 19 |
return $conf; |
| 20 |
} |
| 21 |
} |
| 22 |
return null; |
| 23 |
} |
| 24 |
|
| 25 |
protected function getBackend() { |
| 26 |
if ( !self::$backendToUse ) { |
| 27 |
$conf = $this->getBackendConfig(); |
| 28 |
if ( $conf === null ) { |
| 29 |
$this->markTestSkipped( 'Configure a Swift file backend in $wgFileBackends to enable this test' ); |
| 30 |
} |
| 31 |
$conf['name'] = 'localtesting'; |
| 32 |
$conf['shardViaHashLevels'] = [ |
| 33 |
'unittest-cont1' => [ 'levels' => 1, 'base' => 16, 'repeat' => 1 ] |
| 34 |
]; |
| 35 |
$lockManagerGroup = $this->getServiceContainer() |
| 36 |
->getLockManagerGroupFactory()->getLockManagerGroup(); |
| 37 |
$conf['lockManager'] = $lockManagerGroup->get( $conf['lockManager'] ); |
| 38 |
$conf['domainId'] = WikiMap::getCurrentWikiId(); |
| 39 |
self::$backendToUse = new SwiftFileBackend( $conf ); |
| 40 |
} |
| 41 |
return self::$backendToUse; |
| 42 |
} |
| 43 |
} |