ExternalReferenceSpec::let()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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