MediaWiki REL1_33
WikiReferenceTest.php
Go to the documentation of this file.
1<?php
2
6class WikiReferenceTest extends PHPUnit\Framework\TestCase {
7
8 use MediaWikiCoversValidator;
9
10 public function provideGetDisplayName() {
11 return [
12 'http' => [ 'foo.bar', 'http://foo.bar' ],
13 'https' => [ 'foo.bar', 'http://foo.bar' ],
14
15 // apparently, this is the expected behavior
16 'invalid' => [ 'purple kittens', 'purple kittens' ],
17 ];
18 }
19
23 public function testGetDisplayName( $expected, $canonicalServer ) {
24 $reference = new WikiReference( $canonicalServer, '/wiki/$1' );
25 $this->assertEquals( $expected, $reference->getDisplayName() );
26 }
27
28 public function testGetCanonicalServer() {
29 $reference = new WikiReference( 'https://acme.com', '/wiki/$1', '//acme.com' );
30 $this->assertEquals( 'https://acme.com', $reference->getCanonicalServer() );
31 }
32
33 public function provideGetCanonicalUrl() {
34 return [
35 'no fragment' => [
36 'https://acme.com/wiki/Foo',
37 'https://acme.com',
38 '//acme.com',
39 '/wiki/$1',
40 'Foo',
41 null
42 ],
43 'empty fragment' => [
44 'https://acme.com/wiki/Foo',
45 'https://acme.com',
46 '//acme.com',
47 '/wiki/$1',
48 'Foo',
49 ''
50 ],
51 'fragment' => [
52 'https://acme.com/wiki/Foo#Bar',
53 'https://acme.com',
54 '//acme.com',
55 '/wiki/$1',
56 'Foo',
57 'Bar'
58 ],
59 'double fragment' => [
60 'https://acme.com/wiki/Foo#Bar%23Xus',
61 'https://acme.com',
62 '//acme.com',
63 '/wiki/$1',
64 'Foo',
65 'Bar#Xus'
66 ],
67 'escaped fragment' => [
68 'https://acme.com/wiki/Foo%23Bar',
69 'https://acme.com',
70 '//acme.com',
71 '/wiki/$1',
72 'Foo#Bar',
73 null
74 ],
75 'empty path' => [
76 'https://acme.com/Foo',
77 'https://acme.com',
78 '//acme.com',
79 '/$1',
80 'Foo',
81 null
82 ],
83 ];
84 }
85
89 public function testGetCanonicalUrl(
90 $expected, $canonicalServer, $server, $path, $page, $fragmentId
91 ) {
92 $reference = new WikiReference( $canonicalServer, $path, $server );
93 $this->assertEquals( $expected, $reference->getCanonicalUrl( $page, $fragmentId ) );
94 }
95
100 public function testGetUrl( $expected, $canonicalServer, $server, $path, $page, $fragmentId ) {
101 $reference = new WikiReference( $canonicalServer, $path, $server );
102 $this->assertEquals( $expected, $reference->getUrl( $page, $fragmentId ) );
103 }
104
105 public function provideGetFullUrl() {
106 return [
107 'no fragment' => [
108 '//acme.com/wiki/Foo',
109 'https://acme.com',
110 '//acme.com',
111 '/wiki/$1',
112 'Foo',
113 null
114 ],
115 'empty fragment' => [
116 '//acme.com/wiki/Foo',
117 'https://acme.com',
118 '//acme.com',
119 '/wiki/$1',
120 'Foo',
121 ''
122 ],
123 'fragment' => [
124 '//acme.com/wiki/Foo#Bar',
125 'https://acme.com',
126 '//acme.com',
127 '/wiki/$1',
128 'Foo',
129 'Bar'
130 ],
131 'double fragment' => [
132 '//acme.com/wiki/Foo#Bar%23Xus',
133 'https://acme.com',
134 '//acme.com',
135 '/wiki/$1',
136 'Foo',
137 'Bar#Xus'
138 ],
139 'escaped fragment' => [
140 '//acme.com/wiki/Foo%23Bar',
141 'https://acme.com',
142 '//acme.com',
143 '/wiki/$1',
144 'Foo#Bar',
145 null
146 ],
147 'empty path' => [
148 '//acme.com/Foo',
149 'https://acme.com',
150 '//acme.com',
151 '/$1',
152 'Foo',
153 null
154 ],
155 ];
156 }
157
161 public function testGetFullUrl( $expected, $canonicalServer, $server, $path, $page, $fragmentId ) {
162 $reference = new WikiReference( $canonicalServer, $path, $server );
163 $this->assertEquals( $expected, $reference->getFullUrl( $page, $fragmentId ) );
164 }
165
166}
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
testGetUrl( $expected, $canonicalServer, $server, $path, $page, $fragmentId)
provideGetCanonicalUrl
testGetFullUrl( $expected, $canonicalServer, $server, $path, $page, $fragmentId)
provideGetFullUrl
testGetCanonicalUrl( $expected, $canonicalServer, $server, $path, $page, $fragmentId)
provideGetCanonicalUrl
testGetDisplayName( $expected, $canonicalServer)
provideGetDisplayName
Reference to a locally-hosted wiki.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not null
Definition hooks.txt:783