8192f01828928a54f8ed40f19ca99556e83f8489
[lhc/web/wiklou.git] / tests / phpunit / includes / libs / IEUrlExtensionTest.php
1 <?php
2
3 /**
4 * Tests for IEUrlExtension::findIE6Extension
5 * @todo tests below for findIE6Extension should be split into...
6 * ...a dataprovider and test method.
7 */
8 class IEUrlExtensionTest extends PHPUnit_Framework_TestCase {
9
10 use MediaWikiCoversValidator;
11
12 /**
13 * @covers IEUrlExtension::findIE6Extension
14 */
15 public function testSimple() {
16 $this->assertEquals(
17 'y',
18 IEUrlExtension::findIE6Extension( 'x.y' ),
19 'Simple extension'
20 );
21 }
22
23 /**
24 * @covers IEUrlExtension::findIE6Extension
25 */
26 public function testSimpleNoExt() {
27 $this->assertEquals(
28 '',
29 IEUrlExtension::findIE6Extension( 'x' ),
30 'No extension'
31 );
32 }
33
34 /**
35 * @covers IEUrlExtension::findIE6Extension
36 */
37 public function testEmpty() {
38 $this->assertEquals(
39 '',
40 IEUrlExtension::findIE6Extension( '' ),
41 'Empty string'
42 );
43 }
44
45 /**
46 * @covers IEUrlExtension::findIE6Extension
47 */
48 public function testQuestionMark() {
49 $this->assertEquals(
50 '',
51 IEUrlExtension::findIE6Extension( '?' ),
52 'Question mark only'
53 );
54 }
55
56 /**
57 * @covers IEUrlExtension::findIE6Extension
58 */
59 public function testExtQuestionMark() {
60 $this->assertEquals(
61 'x',
62 IEUrlExtension::findIE6Extension( '.x?' ),
63 'Extension then question mark'
64 );
65 }
66
67 /**
68 * @covers IEUrlExtension::findIE6Extension
69 */
70 public function testQuestionMarkExt() {
71 $this->assertEquals(
72 'x',
73 IEUrlExtension::findIE6Extension( '?.x' ),
74 'Question mark then extension'
75 );
76 }
77
78 /**
79 * @covers IEUrlExtension::findIE6Extension
80 */
81 public function testInvalidChar() {
82 $this->assertEquals(
83 '',
84 IEUrlExtension::findIE6Extension( '.x*' ),
85 'Extension with invalid character'
86 );
87 }
88
89 /**
90 * @covers IEUrlExtension::findIE6Extension
91 */
92 public function testInvalidCharThenExtension() {
93 $this->assertEquals(
94 'x',
95 IEUrlExtension::findIE6Extension( '*.x' ),
96 'Invalid character followed by an extension'
97 );
98 }
99
100 /**
101 * @covers IEUrlExtension::findIE6Extension
102 */
103 public function testMultipleQuestionMarks() {
104 $this->assertEquals(
105 'c',
106 IEUrlExtension::findIE6Extension( 'a?b?.c?.d?e?f' ),
107 'Multiple question marks'
108 );
109 }
110
111 /**
112 * @covers IEUrlExtension::findIE6Extension
113 */
114 public function testExeException() {
115 $this->assertEquals(
116 'd',
117 IEUrlExtension::findIE6Extension( 'a?b?.exe?.d?.e' ),
118 '.exe exception'
119 );
120 }
121
122 /**
123 * @covers IEUrlExtension::findIE6Extension
124 */
125 public function testExeException2() {
126 $this->assertEquals(
127 'exe',
128 IEUrlExtension::findIE6Extension( 'a?b?.exe' ),
129 '.exe exception 2'
130 );
131 }
132
133 /**
134 * @covers IEUrlExtension::findIE6Extension
135 */
136 public function testHash() {
137 $this->assertEquals(
138 '',
139 IEUrlExtension::findIE6Extension( 'a#b.c' ),
140 'Hash character preceding extension'
141 );
142 }
143
144 /**
145 * @covers IEUrlExtension::findIE6Extension
146 */
147 public function testHash2() {
148 $this->assertEquals(
149 '',
150 IEUrlExtension::findIE6Extension( 'a?#b.c' ),
151 'Hash character preceding extension 2'
152 );
153 }
154
155 /**
156 * @covers IEUrlExtension::findIE6Extension
157 */
158 public function testDotAtEnd() {
159 $this->assertEquals(
160 '',
161 IEUrlExtension::findIE6Extension( '.' ),
162 'Dot at end of string'
163 );
164 }
165
166 /**
167 * @covers IEUrlExtension::findIE6Extension
168 */
169 public function testTwoDots() {
170 $this->assertEquals(
171 'z',
172 IEUrlExtension::findIE6Extension( 'x.y.z' ),
173 'Two dots'
174 );
175 }
176
177 /**
178 * @covers IEUrlExtension::findIE6Extension
179 */
180 public function testScriptQuery() {
181 $this->assertEquals(
182 'php',
183 IEUrlExtension::findIE6Extension( 'example.php?foo=a&bar=b' ),
184 'Script with query'
185 );
186 }
187
188 /**
189 * @covers IEUrlExtension::findIE6Extension
190 */
191 public function testEscapedScriptQuery() {
192 $this->assertEquals(
193 '',
194 IEUrlExtension::findIE6Extension( 'example%2Ephp?foo=a&bar=b' ),
195 'Script with urlencoded dot and query'
196 );
197 }
198
199 /**
200 * @covers IEUrlExtension::findIE6Extension
201 */
202 public function testEscapedScriptQueryDot() {
203 $this->assertEquals(
204 'y',
205 IEUrlExtension::findIE6Extension( 'example%2Ephp?foo=a.x&bar=b.y' ),
206 'Script with urlencoded dot and query with dot'
207 );
208 }
209 }