Fix typo for OldChangesList
[lhc/web/wiklou.git] / tests / LocalFileTest.php
1 <?php
2
3 /**
4 * These tests should work regardless of $wgCapitalLinks
5 */
6
7 class LocalFileTest extends PHPUnit_Framework_TestCase {
8 function setUp() {
9 $info = array(
10 'name' => 'test',
11 'directory' => '/testdir',
12 'url' => '/testurl',
13 'hashLevels' => 2,
14 'transformVia404' => false,
15 );
16 $this->repo_hl0 = new LocalRepo( array( 'hashLevels' => 0 ) + $info );
17 $this->repo_hl2 = new LocalRepo( array( 'hashLevels' => 2 ) + $info );
18 $this->repo_lc = new LocalRepo( array( 'initialCapital' => false ) + $info );
19 $this->file_hl0 = $this->repo_hl0->newFile( 'test!' );
20 $this->file_hl2 = $this->repo_hl2->newFile( 'test!' );
21 $this->file_lc = $this->repo_lc->newFile( 'test!' );
22 }
23
24 function testGetHashPath() {
25 $this->assertEquals( '', $this->file_hl0->getHashPath() );
26 $this->assertEquals( 'a/a2/', $this->file_hl2->getHashPath() );
27 $this->assertEquals( 'c/c4/', $this->file_lc->getHashPath() );
28 }
29
30 function testGetRel() {
31 $this->assertEquals( 'Test!', $this->file_hl0->getRel() );
32 $this->assertEquals( 'a/a2/Test!', $this->file_hl2->getRel() );
33 $this->assertEquals( 'c/c4/test!', $this->file_lc->getRel() );
34 }
35
36 function testGetUrlRel() {
37 $this->assertEquals( 'Test%21', $this->file_hl0->getUrlRel() );
38 $this->assertEquals( 'a/a2/Test%21', $this->file_hl2->getUrlRel() );
39 $this->assertEquals( 'c/c4/test%21', $this->file_lc->getUrlRel() );
40 }
41
42 function testGetArchivePath() {
43 $this->assertEquals( '/testdir/archive', $this->file_hl0->getArchivePath() );
44 $this->assertEquals( '/testdir/archive/a/a2', $this->file_hl2->getArchivePath() );
45 $this->assertEquals( '/testdir/archive/!', $this->file_hl0->getArchivePath( '!' ) );
46 $this->assertEquals( '/testdir/archive/a/a2/!', $this->file_hl2->getArchivePath( '!' ) );
47 }
48
49 function testGetThumbPath() {
50 $this->assertEquals( '/testdir/thumb/Test!', $this->file_hl0->getThumbPath() );
51 $this->assertEquals( '/testdir/thumb/a/a2/Test!', $this->file_hl2->getThumbPath() );
52 $this->assertEquals( '/testdir/thumb/Test!/x', $this->file_hl0->getThumbPath( 'x' ) );
53 $this->assertEquals( '/testdir/thumb/a/a2/Test!/x', $this->file_hl2->getThumbPath( 'x' ) );
54 }
55
56 function testGetArchiveUrl() {
57 $this->assertEquals( '/testurl/archive', $this->file_hl0->getArchiveUrl() );
58 $this->assertEquals( '/testurl/archive/a/a2', $this->file_hl2->getArchiveUrl() );
59 $this->assertEquals( '/testurl/archive/%21', $this->file_hl0->getArchiveUrl( '!' ) );
60 $this->assertEquals( '/testurl/archive/a/a2/%21', $this->file_hl2->getArchiveUrl( '!' ) );
61 }
62
63 function testGetThumbUrl() {
64 $this->assertEquals( '/testurl/thumb/Test%21', $this->file_hl0->getThumbUrl() );
65 $this->assertEquals( '/testurl/thumb/a/a2/Test%21', $this->file_hl2->getThumbUrl() );
66 $this->assertEquals( '/testurl/thumb/Test%21/x', $this->file_hl0->getThumbUrl( 'x' ) );
67 $this->assertEquals( '/testurl/thumb/a/a2/Test%21/x', $this->file_hl2->getThumbUrl( 'x' ) );
68 }
69
70 function testGetArchiveVirtualUrl() {
71 $this->assertEquals( 'mwrepo://test/public/archive', $this->file_hl0->getArchiveVirtualUrl() );
72 $this->assertEquals( 'mwrepo://test/public/archive/a/a2', $this->file_hl2->getArchiveVirtualUrl() );
73 $this->assertEquals( 'mwrepo://test/public/archive/%21', $this->file_hl0->getArchiveVirtualUrl( '!' ) );
74 $this->assertEquals( 'mwrepo://test/public/archive/a/a2/%21', $this->file_hl2->getArchiveVirtualUrl( '!' ) );
75 }
76
77 function testGetThumbVirtualUrl() {
78 $this->assertEquals( 'mwrepo://test/public/thumb/Test%21', $this->file_hl0->getThumbVirtualUrl() );
79 $this->assertEquals( 'mwrepo://test/public/thumb/a/a2/Test%21', $this->file_hl2->getThumbVirtualUrl() );
80 $this->assertEquals( 'mwrepo://test/public/thumb/Test%21/%21', $this->file_hl0->getThumbVirtualUrl( '!' ) );
81 $this->assertEquals( 'mwrepo://test/public/thumb/a/a2/Test%21/%21', $this->file_hl2->getThumbVirtualUrl( '!' ) );
82 }
83
84 function testGetUrl() {
85 $this->assertEquals( '/testurl/Test%21', $this->file_hl0->getUrl() );
86 $this->assertEquals( '/testurl/a/a2/Test%21', $this->file_hl2->getUrl() );
87 }
88 }
89
90