Completed
Push — develop ( 2993ce...48a3ec )
by Mike
09:32
created

testItShouldAddAFileSchemeWhenAWindowsDriveLetterIsGiven()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 6
rs 10
c 0
b 0
f 0
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));
0 ignored issues
show
Documentation introduced by Jaapio
$uri2 is of type object<phpDocumentor\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...
72
    }
73
74
    public function testItShouldReturnTrueIfUrisAreNotEqual()
75
    {
76
        $uri1 = new Uri('foo');
77
        $uri2 = new Uri('bar');
78
79
        $this->assertFalse($uri1->equals($uri2));
0 ignored issues
show
Documentation introduced by Jaapio
$uri2 is of type object<phpDocumentor\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...
80
    }
81
}
82