4 * These tests should work regardless of $wgCapitalLinks
7 require_once( 'Namespace.php' );
9 class LocalFileTest
extends PHPUnit_Framework_TestCase
{
12 $wgContLang = new Language
;
15 'directory' => '/testdir',
18 'transformVia404' => false,
20 $this->repo_hl0
= new LocalRepo( array( 'hashLevels' => 0 ) +
$info );
21 $this->repo_hl2
= new LocalRepo( array( 'hashLevels' => 2 ) +
$info );
22 $this->repo_lc
= new LocalRepo( array( 'initialCapital' => false ) +
$info );
23 $this->file_hl0
= $this->repo_hl0
->newFile( 'test!' );
24 $this->file_hl2
= $this->repo_hl2
->newFile( 'test!' );
25 $this->file_lc
= $this->repo_lc
->newFile( 'test!' );
33 function testGetHashPath() {
34 $this->assertEquals( '', $this->file_hl0
->getHashPath() );
35 $this->assertEquals( 'a/a2/', $this->file_hl2
->getHashPath() );
36 $this->assertEquals( 'c/c4/', $this->file_lc
->getHashPath() );
39 function testGetRel() {
40 $this->assertEquals( 'Test!', $this->file_hl0
->getRel() );
41 $this->assertEquals( 'a/a2/Test!', $this->file_hl2
->getRel() );
42 $this->assertEquals( 'c/c4/test!', $this->file_lc
->getRel() );
45 function testGetUrlRel() {
46 $this->assertEquals( 'Test%21', $this->file_hl0
->getUrlRel() );
47 $this->assertEquals( 'a/a2/Test%21', $this->file_hl2
->getUrlRel() );
48 $this->assertEquals( 'c/c4/test%21', $this->file_lc
->getUrlRel() );
51 function testGetArchivePath() {
52 $this->assertEquals( '/testdir/archive', $this->file_hl0
->getArchivePath() );
53 $this->assertEquals( '/testdir/archive/a/a2', $this->file_hl2
->getArchivePath() );
54 $this->assertEquals( '/testdir/archive/!', $this->file_hl0
->getArchivePath( '!' ) );
55 $this->assertEquals( '/testdir/archive/a/a2/!', $this->file_hl2
->getArchivePath( '!' ) );
58 function testGetThumbPath() {
59 $this->assertEquals( '/testdir/thumb/Test!', $this->file_hl0
->getThumbPath() );
60 $this->assertEquals( '/testdir/thumb/a/a2/Test!', $this->file_hl2
->getThumbPath() );
61 $this->assertEquals( '/testdir/thumb/Test!/x', $this->file_hl0
->getThumbPath( 'x' ) );
62 $this->assertEquals( '/testdir/thumb/a/a2/Test!/x', $this->file_hl2
->getThumbPath( 'x' ) );
65 function testGetArchiveUrl() {
66 $this->assertEquals( '/testurl/archive', $this->file_hl0
->getArchiveUrl() );
67 $this->assertEquals( '/testurl/archive/a/a2', $this->file_hl2
->getArchiveUrl() );
68 $this->assertEquals( '/testurl/archive/%21', $this->file_hl0
->getArchiveUrl( '!' ) );
69 $this->assertEquals( '/testurl/archive/a/a2/%21', $this->file_hl2
->getArchiveUrl( '!' ) );
72 function testGetThumbUrl() {
73 $this->assertEquals( '/testurl/thumb/Test%21', $this->file_hl0
->getThumbUrl() );
74 $this->assertEquals( '/testurl/thumb/a/a2/Test%21', $this->file_hl2
->getThumbUrl() );
75 $this->assertEquals( '/testurl/thumb/Test%21/x', $this->file_hl0
->getThumbUrl( 'x' ) );
76 $this->assertEquals( '/testurl/thumb/a/a2/Test%21/x', $this->file_hl2
->getThumbUrl( 'x' ) );
79 function testGetArchiveVirtualUrl() {
80 $this->assertEquals( 'mwrepo://test/public/archive', $this->file_hl0
->getArchiveVirtualUrl() );
81 $this->assertEquals( 'mwrepo://test/public/archive/a/a2', $this->file_hl2
->getArchiveVirtualUrl() );
82 $this->assertEquals( 'mwrepo://test/public/archive/%21', $this->file_hl0
->getArchiveVirtualUrl( '!' ) );
83 $this->assertEquals( 'mwrepo://test/public/archive/a/a2/%21', $this->file_hl2
->getArchiveVirtualUrl( '!' ) );
86 function testGetThumbVirtualUrl() {
87 $this->assertEquals( 'mwrepo://test/thumb/Test%21', $this->file_hl0
->getThumbVirtualUrl() );
88 $this->assertEquals( 'mwrepo://test/thumb/a/a2/Test%21', $this->file_hl2
->getThumbVirtualUrl() );
89 $this->assertEquals( 'mwrepo://test/thumb/Test%21/%21', $this->file_hl0
->getThumbVirtualUrl( '!' ) );
90 $this->assertEquals( 'mwrepo://test/thumb/a/a2/Test%21/%21', $this->file_hl2
->getThumbVirtualUrl( '!' ) );
93 function testGetUrl() {
94 $this->assertEquals( '/testurl/Test%21', $this->file_hl0
->getUrl() );
95 $this->assertEquals( '/testurl/a/a2/Test%21', $this->file_hl2
->getUrl() );