MediaWiki REL1_30
RepoGroupTest.php
Go to the documentation of this file.
1<?php
3
5 $this->setMwGlobals( 'wgForeignFileRepos', [] );
8 $this->assertFalse( RepoGroup::singleton()->hasForeignRepos() );
9 }
10
12 $this->setUpForeignRepo();
13 $this->assertTrue( RepoGroup::singleton()->hasForeignRepos() );
14 }
15
17 $this->setUpForeignRepo();
18 $fakeCallback = $this->createMock( 'RepoGroupTestHelper' );
19 $fakeCallback->expects( $this->once() )->method( 'callback' );
20 RepoGroup::singleton()->forEachForeignRepo(
21 [ $fakeCallback, 'callback' ], [ [] ] );
22 }
23
25 $this->setMwGlobals( 'wgForeignFileRepos', [] );
28 $fakeCallback = $this->createMock( 'RepoGroupTestHelper' );
29 $fakeCallback->expects( $this->never() )->method( 'callback' );
30 RepoGroup::singleton()->forEachForeignRepo(
31 [ $fakeCallback, 'callback' ], [ [] ] );
32 }
33
34 private function setUpForeignRepo() {
35 global $wgUploadDirectory;
36 $this->setMwGlobals( 'wgForeignFileRepos', [ [
37 'class' => 'ForeignAPIRepo',
38 'name' => 'wikimediacommons',
39 'backend' => 'wikimediacommons-backend',
40 'apibase' => 'https://commons.wikimedia.org/w/api.php',
41 'hashLevels' => 2,
42 'fetchDescription' => true,
43 'descriptionCacheExpiry' => 43200,
44 'apiThumbCacheExpiry' => 86400,
45 'directory' => $wgUploadDirectory
46 ] ] );
49 }
50}
51
56 function callback( FileRepo $repo, array $foo ) {
57 return true;
58 }
59}
$wgUploadDirectory
The filesystem path of the images directory.
static destroySingleton()
Destroy the singleton instance.
Base class for file repositories.
Definition FileRepo.php:37
setMwGlobals( $pairs, $value=null)
Sets a global, maintaining a stashed version of the previous global to be restored in tearDown.
Quick helper class to use as a mock callback for RepoGroup::singleton()->forEachForeignRepo.
callback(FileRepo $repo, array $foo)
static singleton()
Get a RepoGroup instance.
Definition RepoGroup.php:59
static destroySingleton()
Destroy the singleton instance, so that a new one will be created next time singleton() is called.
Definition RepoGroup.php:73