ExternalReferenceSpec   A
last analyzed

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
declare(strict_types=1);
4
5
/*
6
 * This file is part of the CrossContainerExtension package.
7
 *
8
 * (c) Kamil Kokot <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace spec\FriendsOfBehat\CrossContainerExtension;
15
16
use PhpSpec\ObjectBehavior;
17
18
final class ExternalReferenceSpec extends ObjectBehavior
19
{
20
    function let(): void
21
    {
22
        $this->beConstructedWith('__container_identifier__.service_identifier');
23
    }
24
25
    function it_returns_whether_it_is_valid(): void
26
    {
27
        static::isValid('not_valid')->shouldReturn(false);
28
        static::isValid('__not.valid')->shouldReturn(false);
29
        static::isValid('_not_.valid')->shouldReturn(false);
30
        static::isValid('__not.valid__')->shouldReturn(false);
31
        static::isValid('__not_valid__')->shouldReturn(false);
32
33
        static::isValid('__valid__.indeed')->shouldReturn(true);
34
        static::isValid('__still__valid__.indeed')->shouldReturn(true);
35
    }
36
37
    function it_returns_container_and_service_identifiers(): void
38
    {
39
        $this->containerIdentifier()->shouldReturn('container_identifier');
40
        $this->serviceIdentifier()->shouldReturn('service_identifier');
41
    }
42
43
    function it_throws_an_exception_if_trying_to_create_with_invalid_identifier(): void
44
    {
45
        $this->beConstructedWith('__not.valid__');
46
47
        $this->shouldThrow(\InvalidArgumentException::class)->duringInstantiation();
48
    }
49
}
50