Completed
Push — master ( f72deb...78ed9f )
by Derek
04:03
created

UriSpec   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 104
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 104
rs 10
c 1
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_is_initializable() 0 4 1
A it_throws_an_exception_when_constructed_with_a_non_string() 0 4 1
A its_properties_are_constructed_from_a_string_during_construction() 0 13 1
1
<?php
2
namespace spec\Subreality\Dilmun\Anshar\Http;
3
4
use Subreality\Dilmun\Anshar\Http\Uri;
5
use PhpSpec\ObjectBehavior;
6
use Prophecy\Argument;
7
8
class UriSpec extends ObjectBehavior
9
{
10
    function let()
11
    {
12
        $this->beConstructedWith("foo://bar:[email protected]:8042/over/there?name=ferret#nose");
13
    }
14
15
    function it_is_initializable()
16
    {
17
        $this->shouldHaveType(Uri::class);
18
    }
19
20
    function it_throws_an_exception_when_constructed_with_a_non_string()
21
    {
22
        $this->shouldThrow('\InvalidArgumentException')->during('__construct', array(123));
23
    }
24
25
    function its_properties_are_constructed_from_a_string_during_construction()
26
    {
27
        $this->getScheme()->shouldReturn("foo");
28
        /*
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
29
        $this->getAuthority()->shouldReturn("bar:[email protected]:8042");
30
        $this->getUserInfo()->shouldReturn("bar:baz");
31
        $this->getHost()->shouldReturn("example.com");
32
        $this->getPort()->shouldReturn(8042);
33
        $this->getPath()->shouldReturn("/over/there");
34
        $this->getQuery()->shouldReturn("name=ferret");
35
        $this->getFragment()->shouldReturn("nose");
36
        */
37
    }
38
39
/*    function it_returns_an_empty_string_when_it_has_no_scheme()
0 ignored issues
show
Unused Code Comprehensibility introduced by
53% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
40
    {
41
        $this->getScheme()->shouldReturn("");
42
    }
43
44
    function it_returns_a_lowercase_string_when_it_has_a_scheme()
45
    {
46
        $mixed_case = "HtTp";
47
48
        $lower_case = "http";
49
50
        $this->getScheme()->shouldReturn($lower_case);
51
    }
52
53
    function it_does_not_return_a_scheme_that_ends_in_a_colon()
54
    {
55
        $this->getScheme()->shouldNotEndWith(":");
56
    }
57
58
    function it_returns_an_empty_string_when_it_has_no_authority()
59
    {
60
        $this->getAuthority()->shouldReturn("");
61
    }
62
63
    function it_returns_authority_data_including_user_info_when_it_has_user_info()
64
    {
65
        $user_info  = "baz";
66
        $host       = "www.foo.bar";
67
        $port       = 8080;
68
69
        $authority_syntax = "{$user_info}@{$host}:{$port}";
70
71
        $this->getAuthority()->shouldReturn($authority_syntax);
72
    }
73
74
    function it_returns_authority_data_without_user_info_when_it_has_no_user_info()
75
    {
76
        $host = "www.foo.bar";
77
        $port = 8080;
78
79
        $authority_syntax = "{$host}:{$port}";
80
81
        $this->getAuthority()->shouldReturn($authority_syntax);
82
    }
83
84
    function it_returns_authority_data_including_port_when_it_has_nonstandard_port()
85
    {
86
        $host = "www.foo.bar";
87
        $port = 8080;
88
89
        $authority_syntax = "{$host}:{$port}";
90
91
        $this->getAuthority()->shouldReturn($authority_syntax);
92
    }
93
94
    function it_returns_authority_data_excluding_port_when_it_has_standard_port()
95
    {
96
        $host = "www.foo.bar";
97
98
        $authority_syntax = $host;
99
100
        $this->getAuthority()->shouldReturn($authority_syntax);
101
    }
102
103
    function it_returns_authority_data_without_port_when_it_has_no_port()
104
    {
105
        $host = "www.foo.bar";
106
107
        $authority_syntax = $host;
108
109
        $this->getAuthority()->shouldReturn($authority_syntax);
110
    }*/
111
}
112