Completed
Push — master ( 1671b1...4e9462 )
by Kamil
23:39
created

ProductReviewContextSpec::it_is_initializable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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
namespace spec\Sylius\Behat\Context\Setup;
13
14
use Behat\Behat\Context\Context;
15
use Doctrine\Common\Persistence\ObjectManager;
16
use PhpSpec\ObjectBehavior;
17
use Sylius\Component\Core\Model\ProductInterface;
18
use Sylius\Component\Core\Test\Services\SharedStorageInterface;
19
use Sylius\Component\Resource\Factory\FactoryInterface;
20
use Sylius\Component\Resource\Repository\RepositoryInterface;
21
use Sylius\Component\Review\Model\ReviewerInterface;
22
use Sylius\Component\Review\Model\ReviewInterface;
23
24
/**
25
 * @author Magdalena Banasiak <[email protected]>
26
 */
27
class ProductReviewContextSpec extends ObjectBehavior
28
{
29
    function let(
30
        SharedStorageInterface $sharedStorage,
31
        FactoryInterface $reviewFactory,
32
        RepositoryInterface $reviewRepository
33
    ) {
34
        $this->beConstructedWith($sharedStorage, $reviewFactory, $reviewRepository);
35
    }
36
37
    function it_is_initializable()
38
    {
39
        $this->shouldHaveType('Sylius\Behat\Context\Setup\ProductReviewContext');
40
    }
41
42
    function it_implements_context_interface()
43
    {
44
        $this->shouldImplement(Context::class);
45
    }
46
47
    function it_creates_a_review_for_a_given_product(
48
        SharedStorageInterface $sharedStorage,
49
        FactoryInterface $reviewFactory,
50
        RepositoryInterface $productReviewRepository,
51
        ProductInterface $product,
52
        ReviewInterface $review
53
    ) {
54
        $sharedStorage->get('product')->willReturn($product);
55
56
        $reviewFactory->createNew()->willReturn($review);
57
        $review->setTitle('title')->shouldBeCalled();
58
        $review->setRating(5)->shouldBeCalled();
59
        $review->setReviewSubject($product)->shouldBeCalled();
60
61
        $product->addReview($review)->shouldBeCalled();
62
63
        $productReviewRepository->add($review);
64
65
        $this->productHasAReview($product);
66
    }
67
}
68