Completed
Push — master ( eeff33...1702a2 )
by Kamil
41:57 queued 20:40
created

it_implements_context_interface()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
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\Transform;
13
14
use Behat\Behat\Context\Context;
15
use PhpSpec\ObjectBehavior;
16
use Prophecy\Argument;
17
use Sylius\Component\Payment\Model\PaymentMethod;
18
use Sylius\Component\Resource\Repository\RepositoryInterface;
19
20
/**
21
 * @author Łukasz Chruściel <[email protected]>
22
 */
23
class PaymentContextSpec extends ObjectBehavior
24
{
25
    function let(
26
        RepositoryInterface $paymentMethodRepository
27
    ) {
28
        $this->beConstructedWith($paymentMethodRepository);
29
    }
30
31
    function it_is_initializable()
32
    {
33
        $this->shouldHaveType('Sylius\Behat\Context\Transform\PaymentContext');
34
    }
35
36
    function it_implements_context_interface()
37
    {
38
        $this->shouldImplement(Context::class);
39
    }
40
41
    function it_converts_payment_method_name_into_payment_method_object(
42
        RepositoryInterface $paymentMethodRepository,
43
        PaymentMethod $paymentMethod
44
    ) {
45
        $paymentMethodRepository->findOneBy(['name' => 'Offline'])->willReturn($paymentMethod);
46
47
        $this->getPaymentMethodByName('Offline')->shouldReturn($paymentMethod);
48
    }
49
50
    function it_throws_element_not_found_exception_if_payment_method_has_not_been_found (
51
        RepositoryInterface $paymentMethodRepository
52
    ) {
53
        $paymentMethodRepository->findOneBy(['name' => 'Free'])->willReturn(null);
54
55
        $this->shouldThrow(\InvalidArgumentException::class)->during('getPaymentMethodByName', ['Free']);
56
    }
57
}
58