1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of phpDocumentor. |
4
|
|
|
* |
5
|
|
|
* For the full copyright and license information, please view the LICENSE |
6
|
|
|
* file that was distributed with this source code. |
7
|
|
|
* |
8
|
|
|
* @copyright 2010-2015 Mike van Riel<[email protected]> |
9
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php MIT |
10
|
|
|
* @link http://phpdoc.org |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
namespace phpDocumentor; |
14
|
|
|
|
15
|
|
|
use PHPUnit\Framework\TestCase; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Test case for Uri |
19
|
|
|
* |
20
|
|
|
* @coversDefaultClass \phpDocumentor\Uri |
21
|
|
|
*/ |
22
|
|
|
final class UriTest extends TestCase |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* @covers ::__construct |
26
|
|
|
* @covers ::__toString |
27
|
|
|
* @covers ::<private> |
28
|
|
|
*/ |
29
|
|
|
public function testItShouldReturnTheUriAsAString() |
30
|
|
|
{ |
31
|
|
|
$uri = new Uri('http://foo.bar/phpdoc.xml'); |
32
|
|
|
|
33
|
|
|
$this->assertSame('http://foo.bar/phpdoc.xml', (string) $uri); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @covers ::<private> |
38
|
|
|
* @expectedException \InvalidArgumentException |
39
|
|
|
* @expectedExceptionMessage http://foo,bar is not a valid uri |
40
|
|
|
*/ |
41
|
|
|
public function testItShouldDiscardAnInvalidUri() |
42
|
|
|
{ |
43
|
|
|
new Uri('http://foo,bar'); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @covers ::<private> |
48
|
|
|
*/ |
49
|
|
|
public function testItShouldAddAFileSchemeWhenSchemeIsAbsent() |
50
|
|
|
{ |
51
|
|
|
$uri = new Uri('foo/phpdoc.xml'); |
52
|
|
|
|
53
|
|
|
$this->assertSame('file://foo/phpdoc.xml', (string) $uri); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @covers ::<private> |
58
|
|
|
*/ |
59
|
|
|
public function testItShouldAddAFileSchemeWhenAWindowsDriveLetterIsGiven() |
60
|
|
|
{ |
61
|
|
|
$uri = new Uri('c:\foo\phpdoc.xml'); |
62
|
|
|
|
63
|
|
|
$this->assertSame('file:///c:\foo\phpdoc.xml', (string) $uri); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function testItShouldReturnTrueIfUrisAreEqual() |
67
|
|
|
{ |
68
|
|
|
$uri1 = new Uri('foo'); |
69
|
|
|
$uri2 = new Uri('foo'); |
70
|
|
|
|
71
|
|
|
$this->assertTrue($uri1->equals($uri2)); |
|
|
|
|
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
public function testItShouldReturnTrueIfUrisAreNotEqual() |
75
|
|
|
{ |
76
|
|
|
$uri1 = new Uri('foo'); |
77
|
|
|
$uri2 = new Uri('bar'); |
78
|
|
|
|
79
|
|
|
$this->assertFalse($uri1->equals($uri2)); |
|
|
|
|
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: