xref: /plugin/davcal/vendor/sabre/uri/tests/ResolveTest.php (revision a1a3b6794e0e143a4a8b51d3185ce2d339be61ab)
1*a1a3b679SAndreas Boehler<?php
2*a1a3b679SAndreas Boehler
3*a1a3b679SAndreas Boehlernamespace Sabre\Uri;
4*a1a3b679SAndreas Boehler
5*a1a3b679SAndreas Boehlerclass ResolveTest extends \PHPUnit_Framework_TestCase{
6*a1a3b679SAndreas Boehler
7*a1a3b679SAndreas Boehler    /**
8*a1a3b679SAndreas Boehler     * @dataProvider resolveData
9*a1a3b679SAndreas Boehler     */
10*a1a3b679SAndreas Boehler    function testResolve($base, $update, $expected) {
11*a1a3b679SAndreas Boehler
12*a1a3b679SAndreas Boehler        $this->assertEquals(
13*a1a3b679SAndreas Boehler            $expected,
14*a1a3b679SAndreas Boehler            resolve($base, $update)
15*a1a3b679SAndreas Boehler        );
16*a1a3b679SAndreas Boehler
17*a1a3b679SAndreas Boehler    }
18*a1a3b679SAndreas Boehler
19*a1a3b679SAndreas Boehler    function resolveData() {
20*a1a3b679SAndreas Boehler
21*a1a3b679SAndreas Boehler        return [
22*a1a3b679SAndreas Boehler            [
23*a1a3b679SAndreas Boehler                'http://example.org/foo/baz',
24*a1a3b679SAndreas Boehler                '/bar',
25*a1a3b679SAndreas Boehler                'http://example.org/bar',
26*a1a3b679SAndreas Boehler            ],
27*a1a3b679SAndreas Boehler            [
28*a1a3b679SAndreas Boehler                'https://example.org/foo',
29*a1a3b679SAndreas Boehler                '//example.net/',
30*a1a3b679SAndreas Boehler                'https://example.net/',
31*a1a3b679SAndreas Boehler            ],
32*a1a3b679SAndreas Boehler            [
33*a1a3b679SAndreas Boehler                'https://example.org/foo',
34*a1a3b679SAndreas Boehler                '?a=b',
35*a1a3b679SAndreas Boehler                'https://example.org/foo?a=b',
36*a1a3b679SAndreas Boehler            ],
37*a1a3b679SAndreas Boehler            [
38*a1a3b679SAndreas Boehler                '//example.org/foo',
39*a1a3b679SAndreas Boehler                '?a=b',
40*a1a3b679SAndreas Boehler                '//example.org/foo?a=b',
41*a1a3b679SAndreas Boehler            ],
42*a1a3b679SAndreas Boehler            // Ports and fragments
43*a1a3b679SAndreas Boehler            [
44*a1a3b679SAndreas Boehler                'https://example.org:81/foo#hey',
45*a1a3b679SAndreas Boehler                '?a=b#c=d',
46*a1a3b679SAndreas Boehler                'https://example.org:81/foo?a=b#c=d',
47*a1a3b679SAndreas Boehler            ],
48*a1a3b679SAndreas Boehler            // Relative.. in-directory paths
49*a1a3b679SAndreas Boehler            [
50*a1a3b679SAndreas Boehler                'http://example.org/foo/bar',
51*a1a3b679SAndreas Boehler                'bar2',
52*a1a3b679SAndreas Boehler                'http://example.org/foo/bar2',
53*a1a3b679SAndreas Boehler            ],
54*a1a3b679SAndreas Boehler            // Now the base path ended with a slash
55*a1a3b679SAndreas Boehler            [
56*a1a3b679SAndreas Boehler                'http://example.org/foo/bar/',
57*a1a3b679SAndreas Boehler                'bar2/bar3',
58*a1a3b679SAndreas Boehler                'http://example.org/foo/bar/bar2/bar3',
59*a1a3b679SAndreas Boehler            ],
60*a1a3b679SAndreas Boehler            // .. and .
61*a1a3b679SAndreas Boehler            [
62*a1a3b679SAndreas Boehler                'http://example.org/foo/bar/',
63*a1a3b679SAndreas Boehler                '../bar2/.././/bar3/',
64*a1a3b679SAndreas Boehler                'http://example.org/foo//bar3/',
65*a1a3b679SAndreas Boehler            ],
66*a1a3b679SAndreas Boehler            // Only updating the fragment
67*a1a3b679SAndreas Boehler            [
68*a1a3b679SAndreas Boehler                'https://example.org/foo?a=b',
69*a1a3b679SAndreas Boehler                '#comments',
70*a1a3b679SAndreas Boehler                'https://example.org/foo?a=b#comments',
71*a1a3b679SAndreas Boehler            ],
72*a1a3b679SAndreas Boehler            // Switching to mailto!
73*a1a3b679SAndreas Boehler            [
74*a1a3b679SAndreas Boehler                'https://example.org/foo?a=b',
75*a1a3b679SAndreas Boehler                'mailto:foo@example.org',
76*a1a3b679SAndreas Boehler                'mailto:foo@example.org',
77*a1a3b679SAndreas Boehler            ],
78*a1a3b679SAndreas Boehler
79*a1a3b679SAndreas Boehler        ];
80*a1a3b679SAndreas Boehler
81*a1a3b679SAndreas Boehler    }
82*a1a3b679SAndreas Boehler
83*a1a3b679SAndreas Boehler}
84