Completed
Push — master ( 50c1b3...460dcb )
by Gorka
14s
created

NumericIdSpec::it_constructs()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Kreta package.
5
 *
6
 * (c) Beñat Espiña <[email protected]>
7
 * (c) Gorka Laucirica <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
declare(strict_types=1);
14
15
namespace Spec\Kreta\TaskManager\Domain\Model\Project\Task;
16
17
use Kreta\TaskManager\Domain\Model\Project\Task\NumericId;
18
use Kreta\TaskManager\Domain\Model\Project\Task\NumericIdInvalidException;
19
use PhpSpec\ObjectBehavior;
20
21
class NumericIdSpec extends ObjectBehavior
22
{
23
    function it_constructs()
24
    {
25
        $this->beConstructedWith(2);
26
        $this->shouldHaveType(NumericId::class);
27
        $this->id()->shouldReturn(2);
28
        $this->__toString()->shouldReturn('2');
29
    }
30
31
    function it_constructs_from_previous_id()
32
    {
33
        $this->beConstructedFromPrevious(0);
34
        $this->shouldHaveType(NumericId::class);
35
        $this->id()->shouldReturn(1);
36
        $this->__toString()->shouldReturn('1');
37
38
        $this::fromPrevious(1)->shouldReturnAnInstanceOf(NumericId::class);
39
    }
40
41
    function it_cannot_construct_with_invalid_id()
42
    {
43
        $this->beConstructedWith(0);
44
45
        $this->shouldThrow(NumericIdInvalidException::class)->duringInstantiation();
46
    }
47
}
48