|
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
|
|
|
|