Debian Codegraph @

tests/phpunit/includes/filerepo/FileRepoTest.php

raw symbols SCIP
1 <?php
2
3 use MediaWiki\MainConfigNames;
4 use Wikimedia\FileBackend\FSFileBackend;
5
6 /**
7 * @covers \FileRepo
8 */
9 class FileRepoTest extends MediaWikiIntegrationTestCase {
10
11 public function testFileRepoConstructionOptionCanNotBeNull() {
12 $this->expectException( InvalidArgumentException::class );
13 new FileRepo();
14 }
15
16 public function testFileRepoConstructionOptionCanNotBeAnEmptyArray() {
17 $this->expectException( InvalidArgumentException::class );
18 new FileRepo( [] );
19 }
20
21 public function testFileRepoConstructionOptionNeedNameKey() {
22 $this->expectException( InvalidArgumentException::class );
23 new FileRepo( [
24 'backend' => 'foobar'
25 ] );
26 }
27
28 public function testFileRepoConstructionOptionNeedBackendKey() {
29 $this->expectException( InvalidArgumentException::class );
30 new FileRepo( [
31 'name' => 'foobar'
32 ] );
33 }
34
35 public function testFileRepoConstructionWithRequiredOptions() {
36 $f = new FileRepo( [
37 'name' => 'FileRepoTestRepository',
38 'backend' => new FSFileBackend( [
39 'name' => 'local-testing',
40 'wikiId' => 'test_wiki',
41 'containerPaths' => []
42 ] )
43 ] );
44 $this->assertInstanceOf( FileRepo::class, $f );
45 }
46
47 public function testFileRepoConstructionWithInvalidCasing() {
48 $this->expectException( InvalidArgumentException::class );
49 $this->expectExceptionMessage( 'File repos with initial capital false' );
50
51 $this->overrideConfigValue( MainConfigNames::CapitalLinks, true );
52
53 new FileRepo( [
54 'name' => 'foobar',
55 'backend' => 'local-backend',
56 'initialCapital' => false,
57 ] );
58 }
59 }