MediaWiki  1.23.8
LocalFileTest.php
Go to the documentation of this file.
1 <?php
2 
10 
11  protected function setUp() {
12  parent::setUp();
13 
14  $this->setMwGlobals( 'wgCapitalLinks', true );
15 
16  $info = array(
17  'name' => 'test',
18  'directory' => '/testdir',
19  'url' => '/testurl',
20  'hashLevels' => 2,
21  'transformVia404' => false,
22  'backend' => new FSFileBackend( array(
23  'name' => 'local-backend',
24  'wikiId' => wfWikiId(),
25  'containerPaths' => array(
26  'cont1' => "/testdir/local-backend/tempimages/cont1",
27  'cont2' => "/testdir/local-backend/tempimages/cont2"
28  )
29  ) )
30  );
31  $this->repo_hl0 = new LocalRepo( array( 'hashLevels' => 0 ) + $info );
32  $this->repo_hl2 = new LocalRepo( array( 'hashLevels' => 2 ) + $info );
33  $this->repo_lc = new LocalRepo( array( 'initialCapital' => false ) + $info );
34  $this->file_hl0 = $this->repo_hl0->newFile( 'test!' );
35  $this->file_hl2 = $this->repo_hl2->newFile( 'test!' );
36  $this->file_lc = $this->repo_lc->newFile( 'test!' );
37  }
38 
42  public function testGetHashPath() {
43  $this->assertEquals( '', $this->file_hl0->getHashPath() );
44  $this->assertEquals( 'a/a2/', $this->file_hl2->getHashPath() );
45  $this->assertEquals( 'c/c4/', $this->file_lc->getHashPath() );
46  }
47 
51  public function testGetRel() {
52  $this->assertEquals( 'Test!', $this->file_hl0->getRel() );
53  $this->assertEquals( 'a/a2/Test!', $this->file_hl2->getRel() );
54  $this->assertEquals( 'c/c4/test!', $this->file_lc->getRel() );
55  }
56 
60  public function testGetUrlRel() {
61  $this->assertEquals( 'Test%21', $this->file_hl0->getUrlRel() );
62  $this->assertEquals( 'a/a2/Test%21', $this->file_hl2->getUrlRel() );
63  $this->assertEquals( 'c/c4/test%21', $this->file_lc->getUrlRel() );
64  }
65 
69  public function testGetArchivePath() {
70  $this->assertEquals( 'mwstore://local-backend/test-public/archive', $this->file_hl0->getArchivePath() );
71  $this->assertEquals( 'mwstore://local-backend/test-public/archive/a/a2', $this->file_hl2->getArchivePath() );
72  $this->assertEquals( 'mwstore://local-backend/test-public/archive/!', $this->file_hl0->getArchivePath( '!' ) );
73  $this->assertEquals( 'mwstore://local-backend/test-public/archive/a/a2/!', $this->file_hl2->getArchivePath( '!' ) );
74  }
75 
79  public function testGetThumbPath() {
80  $this->assertEquals( 'mwstore://local-backend/test-thumb/Test!', $this->file_hl0->getThumbPath() );
81  $this->assertEquals( 'mwstore://local-backend/test-thumb/a/a2/Test!', $this->file_hl2->getThumbPath() );
82  $this->assertEquals( 'mwstore://local-backend/test-thumb/Test!/x', $this->file_hl0->getThumbPath( 'x' ) );
83  $this->assertEquals( 'mwstore://local-backend/test-thumb/a/a2/Test!/x', $this->file_hl2->getThumbPath( 'x' ) );
84  }
85 
89  public function testGetArchiveUrl() {
90  $this->assertEquals( '/testurl/archive', $this->file_hl0->getArchiveUrl() );
91  $this->assertEquals( '/testurl/archive/a/a2', $this->file_hl2->getArchiveUrl() );
92  $this->assertEquals( '/testurl/archive/%21', $this->file_hl0->getArchiveUrl( '!' ) );
93  $this->assertEquals( '/testurl/archive/a/a2/%21', $this->file_hl2->getArchiveUrl( '!' ) );
94  }
95 
99  public function testGetThumbUrl() {
100  $this->assertEquals( '/testurl/thumb/Test%21', $this->file_hl0->getThumbUrl() );
101  $this->assertEquals( '/testurl/thumb/a/a2/Test%21', $this->file_hl2->getThumbUrl() );
102  $this->assertEquals( '/testurl/thumb/Test%21/x', $this->file_hl0->getThumbUrl( 'x' ) );
103  $this->assertEquals( '/testurl/thumb/a/a2/Test%21/x', $this->file_hl2->getThumbUrl( 'x' ) );
104  }
105 
109  public function testGetArchiveVirtualUrl() {
110  $this->assertEquals( 'mwrepo://test/public/archive', $this->file_hl0->getArchiveVirtualUrl() );
111  $this->assertEquals( 'mwrepo://test/public/archive/a/a2', $this->file_hl2->getArchiveVirtualUrl() );
112  $this->assertEquals( 'mwrepo://test/public/archive/%21', $this->file_hl0->getArchiveVirtualUrl( '!' ) );
113  $this->assertEquals( 'mwrepo://test/public/archive/a/a2/%21', $this->file_hl2->getArchiveVirtualUrl( '!' ) );
114  }
115 
119  public function testGetThumbVirtualUrl() {
120  $this->assertEquals( 'mwrepo://test/thumb/Test%21', $this->file_hl0->getThumbVirtualUrl() );
121  $this->assertEquals( 'mwrepo://test/thumb/a/a2/Test%21', $this->file_hl2->getThumbVirtualUrl() );
122  $this->assertEquals( 'mwrepo://test/thumb/Test%21/%21', $this->file_hl0->getThumbVirtualUrl( '!' ) );
123  $this->assertEquals( 'mwrepo://test/thumb/a/a2/Test%21/%21', $this->file_hl2->getThumbVirtualUrl( '!' ) );
124  }
125 
129  public function testGetUrl() {
130  $this->assertEquals( '/testurl/Test%21', $this->file_hl0->getUrl() );
131  $this->assertEquals( '/testurl/a/a2/Test%21', $this->file_hl2->getUrl() );
132  }
133 
137  public function testWfLocalFile() {
138  $file = wfLocalFile( "File:Some_file_that_probably_doesn't exist.png" );
139  $this->assertThat( $file, $this->isInstanceOf( 'LocalFile' ), 'wfLocalFile() returns LocalFile for valid Titles' );
140  }
141 }
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
LocalFileTest\testGetArchiveVirtualUrl
testGetArchiveVirtualUrl()
@covers File::getArchiveVirtualUrl
Definition: LocalFileTest.php:109
LocalFileTest\testGetUrlRel
testGetUrlRel()
@covers File::getUrlRel
Definition: LocalFileTest.php:60
LocalFileTest\testGetRel
testGetRel()
@covers File::getRel
Definition: LocalFileTest.php:51
LocalFileTest\testGetThumbPath
testGetThumbPath()
@covers File::getThumbPath
Definition: LocalFileTest.php:79
LocalFileTest\testGetArchivePath
testGetArchivePath()
@covers File::getArchivePath
Definition: LocalFileTest.php:69
LocalFileTest\testWfLocalFile
testWfLocalFile()
@covers wfLocalFile
Definition: LocalFileTest.php:137
LocalFileTest\testGetThumbUrl
testGetThumbUrl()
@covers File::getThumbUrl
Definition: LocalFileTest.php:99
MediaWikiTestCase\setMwGlobals
setMwGlobals( $pairs, $value=null)
Definition: MediaWikiTestCase.php:302
LocalFileTest
These tests should work regardless of $wgCapitalLinks @group Database.
Definition: LocalFileTest.php:9
MediaWikiTestCase
Definition: MediaWikiTestCase.php:6
LocalFileTest\testGetUrl
testGetUrl()
@covers File::getUrl
Definition: LocalFileTest.php:129
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
LocalFileTest\setUp
setUp()
Definition: LocalFileTest.php:11
LocalFileTest\testGetArchiveUrl
testGetArchiveUrl()
@covers File::getArchiveUrl
Definition: LocalFileTest.php:89
$file
if(PHP_SAPI !='cli') $file
Definition: UtfNormalTest2.php:30
FSFileBackend
Class for a file system (FS) based file backend.
Definition: FSFileBackend.php:41
LocalFileTest\testGetHashPath
testGetHashPath()
@covers File::getHashPath
Definition: LocalFileTest.php:42
LocalFileTest\testGetThumbVirtualUrl
testGetThumbVirtualUrl()
@covers File::getThumbVirtualUrl
Definition: LocalFileTest.php:119
wfLocalFile
wfLocalFile( $title)
Get an object referring to a locally registered file.
Definition: GlobalFunctions.php:3713
LocalRepo
A repository that stores files in the local filesystem and registers them in the wiki's own database.
Definition: LocalRepo.php:31