ProjectSpec::it_can_be_created()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 14

Duplication

Lines 18
Ratio 100 %

Importance

Changes 0
Metric Value
dl 18
loc 18
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 14
nc 1
nop 4
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;
16
17
use Kreta\SharedKernel\Domain\Model\Identity\Slug;
18
use Kreta\TaskManager\Domain\Model\Organization\OrganizationId;
19
use Kreta\TaskManager\Domain\Model\Project\Project;
20
use Kreta\TaskManager\Domain\Model\Project\ProjectCreated;
21
use Kreta\TaskManager\Domain\Model\Project\ProjectEdited;
22
use Kreta\TaskManager\Domain\Model\Project\ProjectId;
23
use Kreta\TaskManager\Domain\Model\Project\ProjectName;
24
use PhpSpec\ObjectBehavior;
25
26
class ProjectSpec extends ObjectBehavior
27
{
28
    function let(ProjectId $projectId, ProjectName $projectName, Slug $projectSlug, OrganizationId $organizationId)
29
    {
30
        $projectId->id()->willReturn('project-id');
31
        $this->beConstructedWith($projectId, $projectName, $projectSlug, $organizationId);
32
    }
33
34 View Code Duplication
    function it_can_be_created(
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
35
        ProjectId $projectId,
36
        ProjectName $projectName,
37
        Slug $projectSlug,
38
        OrganizationId $organizationId)
39
    {
40
        $this->shouldHaveType(Project::class);
41
42
        $this->id()->shouldReturn($projectId);
43
        $this->createdOn()->shouldReturnAnInstanceOf(\DateTimeImmutable::class);
44
        $this->updatedOn()->shouldReturnAnInstanceOf(\DateTimeImmutable::class);
45
        $this->name()->shouldReturn($projectName);
46
        $this->slug()->shouldReturn($projectSlug);
47
        $this->organizationId()->shouldReturn($organizationId);
48
        $this->__toString()->shouldReturn('project-id');
49
50
        $this->shouldHavePublished(ProjectCreated::class);
51
    }
52
53
    function it_can_be_edited(ProjectName $projectName, Slug $projectSlug)
54
    {
55
        $oldUpdatedOn = $this->updatedOn();
56
57
        $this->edit($projectName, $projectSlug);
58
59
        $this->name()->shouldReturn($projectName);
60
        $this->slug()->shouldReturn($projectSlug);
61
        $this->updatedOn()->shouldNotEqual($oldUpdatedOn);
62
63
        $this->shouldHavePublished(ProjectEdited::class);
64
    }
65
}
66