3 * Tests for wfParseUrl()
5 * Copyright © 2013 Alexandre Emsenhuber
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * http://www.gnu.org/copyleft/gpl.html
25 class WfParseUrlTest
extends MediaWikiTestCase
{
26 protected function setUp() {
29 $this->setMwGlobals( 'wgUrlProtocols', array(
30 '//', 'http://', 'file://', 'mailto:',
34 /** @dataProvider provideURLs */
35 public function testWfParseUrl( $url, $parts ) {
36 $partsDump = var_export( $parts, true );
40 "Testing $url parses to $partsDump"
45 * Provider of URLs for testing wfParseUrl()
49 public static function provideURLs() {
56 'host' => 'example.org',
64 'host' => 'example.org',
68 'http://id:key@example.org:123/path?foo=bar#baz',
74 'host' => 'example.org',
82 'file://example.org/etc/php.ini',
86 'host' => 'example.org',
87 'path' => '/etc/php.ini',
91 'file:///etc/php.ini',
96 'path' => '/etc/php.ini',
103 'delimiter' => '://',
109 'mailto:id@example.org',
111 'scheme' => 'mailto',
113 'host' => 'id@example.org',
118 'mailto:id@example.org?subject=Foo',
120 'scheme' => 'mailto',
122 'host' => 'id@example.org',
124 'query' => 'subject=Foo',
128 'mailto:?subject=Foo',
130 'scheme' => 'mailto',
134 'query' => 'subject=Foo',