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