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