These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
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\DomainModel; |
||
14 | |||
15 | use PHPUnit\Framework\TestCase; |
||
16 | |||
17 | /** |
||
18 | * Test case for Uri |
||
19 | * |
||
20 | * @coversDefaultClass phpDocumentor\DomainModel\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 | public function testItShouldReturnTrueIfUrisAreEqual() |
||
57 | { |
||
58 | $uri1 = new Uri('foo'); |
||
59 | $uri2 = new Uri('foo'); |
||
60 | |||
61 | $this->assertTrue($uri1->equals($uri2)); |
||
0 ignored issues
–
show
|
|||
62 | } |
||
63 | |||
64 | public function testItShouldReturnTrueIfUrisAreNotEqual() |
||
65 | { |
||
66 | $uri1 = new Uri('foo'); |
||
67 | $uri2 = new Uri('bar'); |
||
68 | |||
69 | $this->assertFalse($uri1->equals($uri2)); |
||
0 ignored issues
–
show
$uri2 is of type object<phpDocumentor\DomainModel\Uri> , but the function expects a object<self> .
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: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
70 | } |
||
71 | } |
||
72 |
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: