Test Failed
Push — master ( 06fcec...ff7c45 )
by Martin
07:58
created

TaskNameIsUniqueSpecificationSpec   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A it_is_initializable() 0 4 1
A let() 0 16 1
A it_is_satisfied() 0 7 1
1
<?php
2
3
namespace spec\Todo\Domain\Specification;
4
5
use Todo\Domain\Exception\TaskNotFoundException;
6
use Todo\Domain\Factory\TaskFactory;
7
use Todo\Domain\Repository\TaskRepositoryInterface;
8
use Todo\Domain\Specification\TaskNameIsUniqueSpecification;
9
use Todo\Domain\Task;
10
use PhpSpec\ObjectBehavior;
11
use Prophecy\Argument;
12
13
class TaskNameIsUniqueSpecificationSpec extends ObjectBehavior
14
{
15
    protected $taskRepository;
16
17
    protected $taskNameExists = 'Buying milk';
18
    protected $taskNameNonExists = 'Buying sugar';
19
    protected $task;
20
21
    function it_is_initializable()
22
    {
23
        $this->shouldHaveType(TaskNameIsUniqueSpecification::class);
24
    }
25
26
    function let(TaskRepositoryInterface $taskRepository)
27
    {
28
        $this->task = new Task;
29
        $this->task->setId(1);
30
        $this->task->setName($this->taskNameExists);
31
32
        $this->taskRepository = $taskRepository;
33
        $this->taskRepository
0 ignored issues
show
Bug introduced by
The method willReturn() does not seem to exist on object<Todo\Domain\Task>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
34
            ->findByName($this->taskNameExists)
35
            ->willReturn($this->task);
36
        $this->taskRepository
0 ignored issues
show
Bug introduced by
The method willThrow() does not seem to exist on object<Todo\Domain\Task>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
37
            ->findByName($this->taskNameNonExists)
38
            ->willThrow(TaskNotFoundException::class);
39
40
        $this->beConstructedWith($this->taskRepository);
41
    }
42
43
    function it_is_satisfied()
44
    {
45
        $this->isSatisfiedBy($this->taskNameExists)->shouldBe(false);
46
        $this->isSatisfiedBy($this->taskNameNonExists)->shouldBe(true);
47
48
        $this->isSatisfiedBy($this->taskNameExists, 1)->shouldBe(true);
49
    }
50
}
51