]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blob - t/inc/LocalFile.t
MediaWiki 1.15.5
[autoinstallsdev/mediawiki.git] / t / inc / LocalFile.t
1 #!/usr/bin/env php
2 <?php
3
4 define( 'MEDIAWIKI', true );
5 require 't/Test.php';
6
7 require 'includes/Defines.php';
8 require 'includes/ProfilerStub.php';
9 require 'LocalSettings.php';
10 require 'includes/Setup.php';
11
12 /**
13  * These tests should work regardless of $wgCapitalLinks
14  */
15
16 $info = array(
17         'name' => 'test',
18         'directory' => '/testdir',
19         'url' => '/testurl',
20         'hashLevels' => 2,
21         'transformVia404' => false,
22 );
23
24 plan( 35 );
25
26 $repo_hl0 = new LocalRepo( array( 'hashLevels' => 0 ) + $info );
27 $repo_hl2 = new LocalRepo( array( 'hashLevels' => 2 ) + $info );
28 $repo_lc = new LocalRepo( array( 'initialCapital' => false ) + $info );
29
30 $file_hl0 = $repo_hl0->newFile( 'test!' );
31 $file_hl2 = $repo_hl2->newFile( 'test!' );
32 $file_lc = $repo_lc->newFile( 'test!' );
33
34 is( $file_hl0->getHashPath(), '', 'Get hash path, hasLev 0' );
35 is( $file_hl2->getHashPath(), 'a/a2/', 'Get hash path, hasLev 2' );
36 is( $file_lc->getHashPath(), 'c/c4/', 'Get hash path, lc first' );
37
38 is( $file_hl0->getRel(), 'Test!', 'Get rel path, hasLev 0' );
39 is( $file_hl2->getRel(), 'a/a2/Test!', 'Get rel path, hasLev 2' );
40 is( $file_lc->getRel(), 'c/c4/test!', 'Get rel path, lc first' );
41
42 is( $file_hl0->getUrlRel(), 'Test%21', 'Get rel url, hasLev 0' );
43 is( $file_hl2->getUrlRel(), 'a/a2/Test%21', 'Get rel url, hasLev 2' );
44 is( $file_lc->getUrlRel(), 'c/c4/test%21', 'Get rel url, lc first' );
45
46 is( $file_hl0->getArchivePath(), '/testdir/archive', 'Get archive path, hasLev 0' );
47 is( $file_hl2->getArchivePath(), '/testdir/archive/a/a2', 'Get archive path, hasLev 2' );
48 is( $file_hl0->getArchivePath( '!' ), '/testdir/archive/!', 'Get archive path, hasLev 0' );
49 is( $file_hl2->getArchivePath( '!' ), '/testdir/archive/a/a2/!', 'Get archive path, hasLev 2' );
50
51 is( $file_hl0->getThumbPath(), '/testdir/thumb/Test!', 'Get thumb path, hasLev 0' );
52 is( $file_hl2->getThumbPath(), '/testdir/thumb/a/a2/Test!', 'Get thumb path, hasLev 2' );
53 is( $file_hl0->getThumbPath( 'x' ), '/testdir/thumb/Test!/x', 'Get thumb path, hasLev 0' );
54 is( $file_hl2->getThumbPath( 'x' ), '/testdir/thumb/a/a2/Test!/x', 'Get thumb path, hasLev 2' );
55
56 is( $file_hl0->getArchiveUrl(), '/testurl/archive', 'Get archive url, hasLev 0' );
57 is( $file_hl2->getArchiveUrl(), '/testurl/archive/a/a2', 'Get archive url, hasLev 2' );
58 is( $file_hl0->getArchiveUrl( '!' ), '/testurl/archive/%21', 'Get archive url, hasLev 0' );
59 is( $file_hl2->getArchiveUrl( '!' ), '/testurl/archive/a/a2/%21', 'Get archive url, hasLev 2' );
60
61 is( $file_hl0->getThumbUrl(), '/testurl/thumb/Test%21', 'Get thumb url, hasLev 0' );
62 is( $file_hl2->getThumbUrl(), '/testurl/thumb/a/a2/Test%21', 'Get thumb url, hasLev 2' );
63 is( $file_hl0->getThumbUrl( 'x' ), '/testurl/thumb/Test%21/x', 'Get thumb url, hasLev 0' );
64 is( $file_hl2->getThumbUrl( 'x' ), '/testurl/thumb/a/a2/Test%21/x', 'Get thumb url, hasLev 2' );
65
66 is( $file_hl0->getArchiveVirtualUrl(), 'mwrepo://test/public/archive', 'Get archive virtual url, hasLev 0' );
67 is( $file_hl2->getArchiveVirtualUrl(), 'mwrepo://test/public/archive/a/a2', 'Get archive virtual url, hasLev 2' );
68 is( $file_hl0->getArchiveVirtualUrl( '!' ), 'mwrepo://test/public/archive/%21', 'Get archive virtual url, hasLev 0' );
69 is( $file_hl2->getArchiveVirtualUrl( '!' ), 'mwrepo://test/public/archive/a/a2/%21', 'Get archive virtual url, hasLev 2' );
70
71 is( $file_hl0->getThumbVirtualUrl(), 'mwrepo://test/public/thumb/Test%21', 'Get thumb virtual url, hasLev 0' );
72 is( $file_hl2->getThumbVirtualUrl(), 'mwrepo://test/public/thumb/a/a2/Test%21', 'Get thumb virtual url, hasLev 2' );
73 is( $file_hl0->getThumbVirtualUrl( '!' ), 'mwrepo://test/public/thumb/Test%21/%21', 'Get thumb virtual url, hasLev 0' );
74 is( $file_hl2->getThumbVirtualUrl( '!' ), 'mwrepo://test/public/thumb/a/a2/Test%21/%21', 'Get thumb virtual url, hasLev 2' );
75
76 is( $file_hl0->getUrl(), '/testurl/Test%21', 'Get url, hasLev 0' );
77 is( $file_hl2->getUrl(), '/testurl/a/a2/Test%21', 'Get url, hasLev 2' );