Completed
Push — taxon-ancestor ( 0755ef )
by Kamil
119:50 queued 87:37
created

ReviewFactorySpec   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 3
dl 0
loc 48
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_is_a_resource_factory() 0 4 1
A it_implements_review_factory_interface() 0 4 1
A it_creates_a_new_review() 0 6 1
A it_creates_a_review_with_subject() 0 10 1
A it_creates_a_review_with_subject_and_reviewer() 0 12 1
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace spec\Sylius\Component\Review\Factory;
15
16
use PhpSpec\ObjectBehavior;
17
use Sylius\Component\Resource\Factory\FactoryInterface;
18
use Sylius\Component\Review\Factory\ReviewFactoryInterface;
19
use Sylius\Component\Review\Model\ReviewableInterface;
20
use Sylius\Component\Review\Model\ReviewerInterface;
21
use Sylius\Component\Review\Model\ReviewInterface;
22
23
/**
24
 * @author Grzegorz Sadowski <[email protected]>
25
 */
26
final class ReviewFactorySpec extends ObjectBehavior
27
{
28
    function let(FactoryInterface $factory): void
29
    {
30
        $this->beConstructedWith($factory);
31
    }
32
33
    function it_is_a_resource_factory(): void
34
    {
35
        $this->shouldImplement(FactoryInterface::class);
36
    }
37
38
    function it_implements_review_factory_interface(): void
39
    {
40
        $this->shouldImplement(ReviewFactoryInterface::class);
41
    }
42
43
    function it_creates_a_new_review(FactoryInterface $factory, ReviewInterface $review): void
44
    {
45
        $factory->createNew()->willReturn($review);
46
47
        $this->createNew()->shouldReturn($review);
48
    }
49
50
    function it_creates_a_review_with_subject(
51
        FactoryInterface $factory,
52
        ReviewableInterface $subject,
53
        ReviewInterface $review
54
    ): void {
55
        $factory->createNew()->willReturn($review);
56
        $review->setReviewSubject($subject)->shouldBeCalled();
57
58
        $this->createForSubject($subject)->shouldReturn($review);
59
    }
60
61
    function it_creates_a_review_with_subject_and_reviewer(
62
        FactoryInterface $factory,
63
        ReviewableInterface $subject,
64
        ReviewInterface $review,
65
        ReviewerInterface $reviewer
66
    ): void {
67
        $factory->createNew()->willReturn($review);
68
        $review->setReviewSubject($subject)->shouldBeCalled();
69
        $review->setAuthor($reviewer)->shouldBeCalled();
70
71
        $this->createForSubjectWithReviewer($subject, $reviewer);
72
    }
73
}
74