Merge "Provide backwards compatibility for RevisionInsertComplete hook."
[lhc/web/wiklou.git] / tests / phpunit / includes / libs / IEUrlExtensionTest.php
1 <?php
2
3 /**
4 * Tests for IEUrlExtension::findIE6Extension
5 */
6 class IEUrlExtensionTest extends PHPUnit\Framework\TestCase {
7
8 use MediaWikiCoversValidator;
9
10 public function provideFindIE6Extension() {
11 return [
12 // url, expected, message
13 [ 'x.y', 'y', 'Simple extension' ],
14 [ 'x', '', 'No extension' ],
15 [ '', '', 'Empty string' ],
16 [ '?', '', 'Question mark only' ],
17 [ '.x?', 'x', 'Extension then question mark' ],
18 [ '?.x', 'x', 'Question mark then extension' ],
19 [ '.x*', '', 'Extension with invalid character' ],
20 [ '*.x', 'x', 'Invalid character followed by an extension' ],
21 [ 'a?b?.c?.d?e?f', 'c', 'Multiple question marks' ],
22 [ 'a?b?.exe?.d?.e', 'd', '.exe exception' ],
23 [ 'a?b?.exe', 'exe', '.exe exception 2' ],
24 [ 'a#b.c', '', 'Hash character preceding extension' ],
25 [ 'a?#b.c', '', 'Hash character preceding extension 2' ],
26 [ '.', '', 'Dot at end of string' ],
27 [ 'x.y.z', 'z', 'Two dots' ],
28 [ 'example.php?foo=a&bar=b', 'php', 'Script with query' ],
29 [ 'example%2Ephp?foo=a&bar=b', '', 'Script with urlencoded dot and query' ],
30 [ 'example%2Ephp?foo=a.x&bar=b.y', 'y', 'Script with urlencoded dot and query with dot' ],
31 ];
32 }
33
34 /**
35 * @covers IEUrlExtension::findIE6Extension
36 * @dataProvider provideFindIE6Extension
37 */
38 public function testFindIE6Extension( $url, $expected, $message ) {
39 $this->assertEquals(
40 $expected,
41 IEUrlExtension::findIE6Extension( $url ),
42 $message
43 );
44 }
45 }