CategoryPatchMessageSpec::it_should_build()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 24

Duplication

Lines 24
Ratio 100 %

Importance

Changes 0
Metric Value
dl 24
loc 24
rs 9.536
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace spec\Yproximite\Api\Message\Article;
4
5
use PhpSpec\ObjectBehavior;
6
7
use Yproximite\Api\Model\Article\Category;
8
use Yproximite\Api\Model\Article\CategoryTranslation;
9
use Yproximite\Api\Message\Article\CategoryPatchMessage;
10
use Yproximite\Api\Message\Article\CategoryTranslationMessage;
11
12
class CategoryPatchMessageSpec extends ObjectBehavior
13
{
14
    function it_is_initializable()
15
    {
16
        $this->shouldHaveType(CategoryPatchMessage::class);
17
    }
18
19 View Code Duplication
    function it_should_build()
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...
20
    {
21
        $translation = new CategoryTranslationMessage();
22
        $translation->setLocale('en');
23
        $translation->setTitle('English title');
24
        $translation->setDescription('English description');
25
26
        $this->setParentRootId(11);
27
        $this->setEnabled(true);
28
        $this->addTranslation($translation);
29
30
        $transData = [
31
            'title'       => 'English title',
32
            'description' => 'English description',
33
        ];
34
35
        $data = [
36
            'parentRootId' => 11,
37
            'enabled'      => true,
38
            'translations' => ['en' => $transData],
39
        ];
40
41
        $this->build()->shouldReturn($data);
42
    }
43
44
    function it_should_create_from_category(
45
        Category $category,
46
        CategoryTranslation $translation
47
    ) {
48
        $translation->getLocale()->willReturn('en');
49
        $translation->getTitle()->willReturn('English title');
50
        $translation->getDescription()->willReturn('English description');
51
52
        $category->getId()->willReturn(1);
53
        $category->isEnabled()->willReturn(true);
54
        $category->getTranslations()->willReturn([$translation]);
55
56
        $transMessage = new CategoryTranslationMessage();
57
        $transMessage->setLocale('en');
58
        $transMessage->setTitle('English title');
59
        $transMessage->setDescription('English description');
60
61
        $message = new CategoryPatchMessage();
62
        $message->setId(1);
63
        $message->setEnabled(true);
64
        $message->addTranslation($transMessage);
65
66
        $this::createFromCategory($category)->shouldBeLike($message);
67
    }
68
}
69