Completed
Push — master ( 59db0f...abafe8 )
by Kamil
18:55
created

PaymentContextSpec   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 5
c 2
b 0
f 0
lcom 0
cbo 3
dl 0
loc 36
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_is_initializable() 0 4 1
A it_implements_context_interface() 0 4 1
A it_checks_if_a_payment_exists_in_repository() 0 8 1
A it_throws_an_exception_if_payment_still_exist() 0 9 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
namespace spec\Sylius\Behat\Context\Domain;
13
14
use Behat\Behat\Context\Context;
15
use PhpSpec\Exception\Example\NotEqualException;
16
use PhpSpec\ObjectBehavior;
17
use Sylius\Component\Core\Model\PaymentInterface;
18
use Sylius\Component\Core\Repository\PaymentRepositoryInterface;
19
use Sylius\Component\Payment\Model\PaymentMethodInterface;
20
use Sylius\Component\Resource\Repository\RepositoryInterface;
21
22
/**
23
 * @author Łukasz Chruściel <[email protected]>
24
 */
25
class PaymentContextSpec extends ObjectBehavior
26
{
27
    function let(PaymentRepositoryInterface $paymentRepository)
28
    {
29
        $this->beConstructedWith($paymentRepository);
30
    }
31
32
    function it_is_initializable()
33
    {
34
        $this->shouldHaveType('Sylius\Behat\Context\Domain\PaymentContext');
35
    }
36
37
    function it_implements_context_interface()
38
    {
39
        $this->shouldImplement(Context::class);
40
    }
41
42
    function it_checks_if_a_payment_exists_in_repository(
43
        PaymentRepositoryInterface $paymentRepository,
44
        PaymentMethodInterface $cashOnDeliveryPaymentMethod
45
    ) {
46
        $paymentRepository->findBy(['method' => $cashOnDeliveryPaymentMethod])->willReturn([]);
47
48
        $this->paymentShouldNotExistInTheRegistry($cashOnDeliveryPaymentMethod);
49
    }
50
51
    function it_throws_an_exception_if_payment_still_exist(
52
        PaymentRepositoryInterface $paymentRepository,
53
        PaymentMethodInterface $paypalPaymentMethod,
54
        PaymentInterface $payment
55
    ) {
56
        $paymentRepository->findBy(['method' => $paypalPaymentMethod])->willReturn([$payment]);
57
58
        $this->shouldThrow(NotEqualException::class)->during('paymentShouldNotExistInTheRegistry', [$paypalPaymentMethod]);
59
    }
60
}
61