Remove messages.inc, rebuildLanguage.php, writeMessagesArray.inc
[mediawiki.git] / tests / phpunit / includes / GlobalFunctions / wfAssembleUrlTest.php
blob9bb74873380053956406f2fb5841f08fa65bb98d
1 <?php
2 /**
3 * @covers ::wfAssembleUrl
4 */
5 class WfAssembleUrlTest extends MediaWikiTestCase {
6 /**
7 * @dataProvider provideURLParts
8 */
9 public function testWfAssembleUrl( $parts, $output ) {
10 $partsDump = print_r( $parts, true );
11 $this->assertEquals(
12 $output,
13 wfAssembleUrl( $parts ),
14 "Testing $partsDump assembles to $output"
18 /**
19 * Provider of URL parts for testing wfAssembleUrl()
21 * @return array
23 public static function provideURLParts() {
24 $schemes = array(
25 '' => array(),
26 '//' => array(
27 'delimiter' => '//',
29 'http://' => array(
30 'scheme' => 'http',
31 'delimiter' => '://',
35 $hosts = array(
36 '' => array(),
37 'example.com' => array(
38 'host' => 'example.com',
40 'example.com:123' => array(
41 'host' => 'example.com',
42 'port' => 123,
44 'id@example.com' => array(
45 'user' => 'id',
46 'host' => 'example.com',
48 'id@example.com:123' => array(
49 'user' => 'id',
50 'host' => 'example.com',
51 'port' => 123,
53 'id:key@example.com' => array(
54 'user' => 'id',
55 'pass' => 'key',
56 'host' => 'example.com',
58 'id:key@example.com:123' => array(
59 'user' => 'id',
60 'pass' => 'key',
61 'host' => 'example.com',
62 'port' => 123,
66 $cases = array();
67 foreach ( $schemes as $scheme => $schemeParts ) {
68 foreach ( $hosts as $host => $hostParts ) {
69 foreach ( array( '', '/path' ) as $path ) {
70 foreach ( array( '', 'query' ) as $query ) {
71 foreach ( array( '', 'fragment' ) as $fragment ) {
72 $parts = array_merge(
73 $schemeParts,
74 $hostParts
76 $url = $scheme .
77 $host .
78 $path;
80 if ( $path ) {
81 $parts['path'] = $path;
83 if ( $query ) {
84 $parts['query'] = $query;
85 $url .= '?' . $query;
87 if ( $fragment ) {
88 $parts['fragment'] = $fragment;
89 $url .= '#' . $fragment;
92 $cases[] = array(
93 $parts,
94 $url,
102 $complexURL = 'http://id:key@example.org:321' .
103 '/over/there?name=ferret&foo=bar#nose';
104 $cases[] = array(
105 wfParseUrl( $complexURL ),
106 $complexURL,
109 return $cases;