3 * Copyright © 2013 Alexandre Emsenhuber
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
24 * @covers ::wfParseUrl
26 class WfParseUrlTest
extends MediaWikiTestCase
{
27 protected function setUp() {
30 $this->setMwGlobals( 'wgUrlProtocols', array(
31 '//', 'http://', 'file://', 'mailto:',
36 * @dataProvider provideURLs
38 public function testWfParseUrl( $url, $parts ) {
39 $partsDump = var_export( $parts, true );
43 "Testing $url parses to $partsDump"
48 * Provider of URLs for testing wfParseUrl()
52 public static function provideURLs() {
59 'host' => 'example.org',
67 'host' => 'example.org',
71 'http://id:key@example.org:123/path?foo=bar#baz',
77 'host' => 'example.org',
85 'file://example.org/etc/php.ini',
89 'host' => 'example.org',
90 'path' => '/etc/php.ini',
94 'file:///etc/php.ini',
99 'path' => '/etc/php.ini',
106 'delimiter' => '://',
112 'mailto:id@example.org',
114 'scheme' => 'mailto',
116 'host' => 'id@example.org',
121 'mailto:id@example.org?subject=Foo',
123 'scheme' => 'mailto',
125 'host' => 'id@example.org',
127 'query' => 'subject=Foo',
131 'mailto:?subject=Foo',
133 'scheme' => 'mailto',
137 'query' => 'subject=Foo',