Completed
Push — master ( b63fa9...5110b4 )
by Kamil
04:39
created

ExternalReferenceSpec   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_returns_whether_it_is_valid() 0 11 1
A it_returns_container_and_service_identifiers() 0 5 1
A it_throws_an_exception_if_trying_to_create_with_invalid_identifier() 0 6 1
1
<?php
2
3
namespace spec\FriendsOfBehat\CrossContainerExtension;
4
5
use PhpSpec\ObjectBehavior;
6
7
final class ExternalReferenceSpec extends ObjectBehavior
8
{
9
    function let()
10
    {
11
        $this->beConstructedWith('__container_identifier__.service_identifier');
12
    }
13
14
    function it_returns_whether_it_is_valid()
15
    {
16
        static::isValid('not_valid')->shouldReturn(false);
17
        static::isValid('__not.valid')->shouldReturn(false);
18
        static::isValid('_not_.valid')->shouldReturn(false);
19
        static::isValid('__not.valid__')->shouldReturn(false);
20
        static::isValid('__not_valid__')->shouldReturn(false);
21
22
        static::isValid('__valid__.indeed')->shouldReturn(true);
23
        static::isValid('__still__valid__.indeed')->shouldReturn(true);
24
    }
25
26
    function it_returns_container_and_service_identifiers()
27
    {
28
        $this->containerIdentifier()->shouldReturn('container_identifier');
29
        $this->serviceIdentifier()->shouldReturn('service_identifier');
30
    }
31
32
    function it_throws_an_exception_if_trying_to_create_with_invalid_identifier()
33
    {
34
        $this->beConstructedWith('__not.valid__');
35
36
        $this->shouldThrow(\InvalidArgumentException::class)->duringInstantiation();
37
    }
38
}
39