Completed
Push — api ( cecea0...116a36 )
by Kamil
29:57 queued 30s
created

ProductReviewStateMachineTransitionApplicatorSpec   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 3 1
A it_accepts_product_review() 0 10 1
A it_rejects_product_review() 0 10 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\Bundle\ApiBundle\Applicator;
15
16
use PhpSpec\ObjectBehavior;
17
use SM\Factory\FactoryInterface as StateMachineFactoryInterface;
18
use SM\StateMachine\StateMachine;
19
use Sylius\Component\Core\ProductReviewTransitions;
20
use Sylius\Component\Review\Model\ReviewInterface;
21
22
final class ProductReviewStateMachineTransitionApplicatorSpec extends ObjectBehavior
23
{
24
    function let(StateMachineFactoryInterface $stateMachineFactory) {
25
        $this->beConstructedWith($stateMachineFactory);
26
    }
27
28
    public function it_accepts_product_review(
29
        StateMachineFactoryInterface $stateMachineFactory,
30
        ReviewInterface $review,
31
        StateMachine $stateMachine
32
    ): void {
33
        $stateMachineFactory->get($review, ProductReviewTransitions::GRAPH)->willReturn($stateMachine);
34
        $stateMachine->apply(ProductReviewTransitions::TRANSITION_ACCEPT)->shouldBeCalled();
35
36
        $this->accept($review);
37
    }
38
39
    public function it_rejects_product_review(
40
        StateMachineFactoryInterface $stateMachineFactory,
41
        ReviewInterface $review,
42
        StateMachine $stateMachine
43
    ): void {
44
        $stateMachineFactory->get($review, ProductReviewTransitions::GRAPH)->willReturn($stateMachine);
45
        $stateMachine->apply(ProductReviewTransitions::TRANSITION_REJECT)->shouldBeCalled();
46
47
        $this->reject($review);
48
    }
49
}
50