ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Sabre\HTTP\URLUtilTest Class Reference
+ Inheritance diagram for Sabre\HTTP\URLUtilTest:
+ Collaboration diagram for Sabre\HTTP\URLUtilTest:

Public Member Functions

 testEncodePath ()
 
 testEncodePathSegment ()
 
 testDecode ()
 
 testDecodeUmlaut ()
 testDecode More...
 
 testDecodeUmlautLatin1 ()
 testDecodeUmlaut More...
 
 testDecodeAccentsWindows7 ()
 This testcase was sent by a bug reporter. More...
 
 testSplitPath ()
 
 testResolve ($base, $update, $expected)
 resolveData More...
 
 resolveData ()
 

Detailed Description

Definition at line 5 of file URLUtilTest.php.

Member Function Documentation

◆ resolveData()

Sabre\HTTP\URLUtilTest::resolveData ( )

Definition at line 142 of file URLUtilTest.php.

142  {
143 
144  return [
145  [
146  'http://example.org/foo/baz',
147  '/bar',
148  'http://example.org/bar',
149  ],
150  [
151  'https://example.org/foo',
152  '//example.net/',
153  'https://example.net/',
154  ],
155  [
156  'https://example.org/foo',
157  '?a=b',
158  'https://example.org/foo?a=b',
159  ],
160  [
161  '//example.org/foo',
162  '?a=b',
163  '//example.org/foo?a=b',
164  ],
165  // Ports and fragments
166  [
167  'https://example.org:81/foo#hey',
168  '?a=b#c=d',
169  'https://example.org:81/foo?a=b#c=d',
170  ],
171  // Relative.. in-directory paths
172  [
173  'http://example.org/foo/bar',
174  'bar2',
175  'http://example.org/foo/bar2',
176  ],
177  // Now the base path ended with a slash
178  [
179  'http://example.org/foo/bar/',
180  'bar2/bar3',
181  'http://example.org/foo/bar/bar2/bar3',
182  ],
183  ];
184 
185  }

◆ testDecode()

Sabre\HTTP\URLUtilTest::testDecode ( )

Definition at line 53 of file URLUtilTest.php.

References Sabre\HTTP\URLUtil\decodePath().

53  {
54 
55  $str = 'Hello%20Test+Test2.txt';
56  $newStr = URLUtil::decodePath($str);
57  $this->assertEquals('Hello Test+Test2.txt', $newStr);
58 
59  }
static decodePath($path)
Decodes a url-encoded path.
Definition: URLUtil.php:57
+ Here is the call graph for this function:

◆ testDecodeAccentsWindows7()

Sabre\HTTP\URLUtilTest::testDecodeAccentsWindows7 ( )

This testcase was sent by a bug reporter.

testDecode

Definition at line 88 of file URLUtilTest.php.

References Sabre\HTTP\URLUtil\decodePath(), and Sabre\HTTP\URLUtil\encodePath().

88  {
89 
90  $str = '/webdav/%C3%A0fo%C3%B3';
91  $newStr = URLUtil::decodePath($str);
92  $this->assertEquals(strtolower($str), URLUtil::encodePath($newStr));
93 
94  }
static decodePath($path)
Decodes a url-encoded path.
Definition: URLUtil.php:57
static encodePath($path)
Encodes the path of a url.
Definition: URLUtil.php:29
+ Here is the call graph for this function:

◆ testDecodeUmlaut()

Sabre\HTTP\URLUtilTest::testDecodeUmlaut ( )

testDecode

Definition at line 64 of file URLUtilTest.php.

References Sabre\HTTP\URLUtil\decodePath().

64  {
65 
66  $str = 'Hello%C3%BC.txt';
67  $newStr = URLUtil::decodePath($str);
68  $this->assertEquals("Hello\xC3\xBC.txt", $newStr);
69 
70  }
static decodePath($path)
Decodes a url-encoded path.
Definition: URLUtil.php:57
+ Here is the call graph for this function:

◆ testDecodeUmlautLatin1()

Sabre\HTTP\URLUtilTest::testDecodeUmlautLatin1 ( )

testDecodeUmlaut

Definition at line 75 of file URLUtilTest.php.

References Sabre\HTTP\URLUtil\decodePath().

75  {
76 
77  $str = 'Hello%FC.txt';
78  $newStr = URLUtil::decodePath($str);
79  $this->assertEquals("Hello\xC3\xBC.txt", $newStr);
80 
81  }
static decodePath($path)
Decodes a url-encoded path.
Definition: URLUtil.php:57
+ Here is the call graph for this function:

◆ testEncodePath()

Sabre\HTTP\URLUtilTest::testEncodePath ( )

Definition at line 7 of file URLUtilTest.php.

References $i, Sabre\HTTP\URLUtil\decodePath(), and Sabre\HTTP\URLUtil\encodePath().

7  {
8 
9  $str = '';
10  for ($i = 0;$i < 128;$i++) $str .= chr($i);
11 
12  $newStr = URLUtil::encodePath($str);
13 
14  $this->assertEquals(
15  '%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f' .
16  '%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f' .
17  '%20%21%22%23%24%25%26%27()%2a%2b%2c-./' .
18  '0123456789:%3b%3c%3d%3e%3f' .
19  '@ABCDEFGHIJKLMNO' .
20  'PQRSTUVWXYZ%5b%5c%5d%5e_' .
21  '%60abcdefghijklmno' .
22  'pqrstuvwxyz%7b%7c%7d~%7f',
23  $newStr);
24 
25  $this->assertEquals($str, URLUtil::decodePath($newStr));
26 
27  }
static decodePath($path)
Decodes a url-encoded path.
Definition: URLUtil.php:57
$i
Definition: disco.tpl.php:19
static encodePath($path)
Encodes the path of a url.
Definition: URLUtil.php:29
+ Here is the call graph for this function:

◆ testEncodePathSegment()

Sabre\HTTP\URLUtilTest::testEncodePathSegment ( )

Definition at line 29 of file URLUtilTest.php.

References $i, Sabre\HTTP\URLUtil\decodePathSegment(), and Sabre\HTTP\URLUtil\encodePathSegment().

29  {
30 
31  $str = '';
32  for ($i = 0;$i < 128;$i++) $str .= chr($i);
33 
34  $newStr = URLUtil::encodePathSegment($str);
35 
36  // Note: almost exactly the same as the last test, with the
37  // exception of the encoding of / (ascii code 2f)
38  $this->assertEquals(
39  '%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f' .
40  '%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f' .
41  '%20%21%22%23%24%25%26%27()%2a%2b%2c-.%2f' .
42  '0123456789:%3b%3c%3d%3e%3f' .
43  '@ABCDEFGHIJKLMNO' .
44  'PQRSTUVWXYZ%5b%5c%5d%5e_' .
45  '%60abcdefghijklmno' .
46  'pqrstuvwxyz%7b%7c%7d~%7f',
47  $newStr);
48 
49  $this->assertEquals($str, URLUtil::decodePathSegment($newStr));
50 
51  }
static encodePathSegment($pathSegment)
Encodes a 1 segment of a path.
Definition: URLUtil.php:44
$i
Definition: disco.tpl.php:19
static decodePathSegment($path)
Decodes a url-encoded path segment.
Definition: URLUtil.php:70
+ Here is the call graph for this function:

◆ testResolve()

Sabre\HTTP\URLUtilTest::testResolve (   $base,
  $update,
  $expected 
)

resolveData

Definition at line 133 of file URLUtilTest.php.

133  {
134 
135  $this->assertEquals(
136  $expected,
137  URLUtil::resolve($base, $update)
138  );
139 
140  }
static resolve($basePath, $newPath)
Resolves relative urls, like a browser would.
Definition: URLUtil.php:97
$base
Definition: index.php:4

◆ testSplitPath()

Sabre\HTTP\URLUtilTest::testSplitPath ( )

Definition at line 96 of file URLUtilTest.php.

References $input, Sabre\VObject\$output, and Sabre\HTTP\URLUtil\splitPath().

96  {
97 
98  $strings = [
99 
100  // input // expected result
101  '/foo/bar' => ['/foo','bar'],
102  '/foo/bar/' => ['/foo','bar'],
103  'foo/bar/' => ['foo','bar'],
104  'foo/bar' => ['foo','bar'],
105  'foo/bar/baz' => ['foo/bar','baz'],
106  'foo/bar/baz/' => ['foo/bar','baz'],
107  'foo' => ['','foo'],
108  'foo/' => ['','foo'],
109  '/foo/' => ['','foo'],
110  '/foo' => ['','foo'],
111  '' => [null,null],
112 
113  // UTF-8
114  "/\xC3\xA0fo\xC3\xB3/bar" => ["/\xC3\xA0fo\xC3\xB3",'bar'],
115  "/\xC3\xA0foo/b\xC3\xBCr/" => ["/\xC3\xA0foo","b\xC3\xBCr"],
116  "foo/\xC3\xA0\xC3\xBCr" => ["foo","\xC3\xA0\xC3\xBCr"],
117 
118  ];
119 
120  foreach ($strings as $input => $expected) {
121 
123  $this->assertEquals($expected, $output, 'The expected output for \'' . $input . '\' was incorrect');
124 
125 
126  }
127 
128  }
static splitPath($path)
Returns the &#39;dirname&#39; and &#39;basename&#39; for a path.
Definition: URLUtil.php:83
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: