test: coverage recording now needs to be explicit
[mediawiki.git] / tests / phpunit / includes / GlobalFunctions / wfAssembleUrlTest.php
blob4184d1524fb76298da04ba543682c21c73aabf34
1 <?php
2 /**
3 * Tests for wfAssembleUrl()
4 */
5 class WfAssembleUrlTest extends MediaWikiTestCase {
6 /** @dataProvider provideURLParts */
7 public function testWfAssembleUrl( $parts, $output ) {
8 $partsDump = print_r( $parts, true );
9 $this->assertEquals(
10 $output,
11 wfAssembleUrl( $parts ),
12 "Testing $partsDump assembles to $output"
16 /**
17 * Provider of URL parts for testing wfAssembleUrl()
19 * @return array
21 public static function provideURLParts() {
22 $schemes = array(
23 '' => array(),
24 '//' => array(
25 'delimiter' => '//',
27 'http://' => array(
28 'scheme' => 'http',
29 'delimiter' => '://',
33 $hosts = array(
34 '' => array(),
35 'example.com' => array(
36 'host' => 'example.com',
38 'example.com:123' => array(
39 'host' => 'example.com',
40 'port' => 123,
42 'id@example.com' => array(
43 'user' => 'id',
44 'host' => 'example.com',
46 'id@example.com:123' => array(
47 'user' => 'id',
48 'host' => 'example.com',
49 'port' => 123,
51 'id:key@example.com' => array(
52 'user' => 'id',
53 'pass' => 'key',
54 'host' => 'example.com',
56 'id:key@example.com:123' => array(
57 'user' => 'id',
58 'pass' => 'key',
59 'host' => 'example.com',
60 'port' => 123,
64 $cases = array();
65 foreach ( $schemes as $scheme => $schemeParts ) {
66 foreach ( $hosts as $host => $hostParts ) {
67 foreach ( array( '', '/path' ) as $path ) {
68 foreach ( array( '', 'query' ) as $query ) {
69 foreach ( array( '', 'fragment' ) as $fragment ) {
70 $parts = array_merge(
71 $schemeParts,
72 $hostParts
74 $url = $scheme .
75 $host .
76 $path;
78 if ( $path ) {
79 $parts['path'] = $path;
81 if ( $query ) {
82 $parts['query'] = $query;
83 $url .= '?' . $query;
85 if ( $fragment ) {
86 $parts['fragment'] = $fragment;
87 $url .= '#' . $fragment;
90 $cases[] = array(
91 $parts,
92 $url,
100 $complexURL = 'http://id:key@example.org:321' .
101 '/over/there?name=ferret&foo=bar#nose';
102 $cases[] = array(
103 wfParseUrl( $complexURL ),
104 $complexURL,
107 return $cases;