Completed
Push — master ( 4f4b30...79d213 )
by Kamil
49:20 queued 33s
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\Setup;
13
14
use Behat\Behat\Context\Context;
15
use PhpSpec\ObjectBehavior;
16
use Prophecy\Argument;
17
use Sylius\Bundle\CoreBundle\Test\Services\PaymentMethodNameToGatewayConverterInterface;
18
use Sylius\Component\Core\Test\Services\SharedStorageInterface;
19
use Sylius\Component\Payment\Model\PaymentMethod;
20
use Sylius\Component\Resource\Factory\FactoryInterface;
21
use Sylius\Component\Resource\Repository\RepositoryInterface;
22
23
/**
24
 * @author Łukasz Chruściel <[email protected]>
25
 */
26
class PaymentContextSpec extends ObjectBehavior
27
{
28
    function let(
29
        RepositoryInterface $paymentMethodRepository,
30
        SharedStorageInterface $sharedStorage,
31
        FactoryInterface $paymentMethodFactory,
32
        PaymentMethodNameToGatewayConverterInterface $paymentMethodNameToGatewayConverter
33
    ) {
34
        $this->beConstructedWith($paymentMethodRepository, $sharedStorage, $paymentMethodFactory, $paymentMethodNameToGatewayConverter);
35
    }
36
37
    function it_is_initializable()
38
    {
39
        $this->shouldHaveType('Sylius\Behat\Context\Setup\PaymentContext');
40
    }
41
42
    function it_implements_context_interface()
43
    {
44
        $this->shouldImplement(Context::class);
45
    }
46
47
    function it_converts_payment_method_name_into_payment_method_object(
48
        RepositoryInterface $paymentMethodRepository,
49
        PaymentMethod $paymentMethod
50
    ) {
51
        $paymentMethodRepository->findOneBy(['name' => 'Offline'])->willReturn($paymentMethod);
52
53
        $this->getPaymentMethodByName('Offline')->shouldReturn($paymentMethod);
54
    }
55
56
    function it_throws_element_not_found_exception_if_payment_method_has_not_been_found (
57
        RepositoryInterface $paymentMethodRepository
58
    ) {
59
        $paymentMethodRepository->findOneBy(['name' => 'Free'])->willReturn(null);
60
61
        $this->shouldThrow(\InvalidArgumentException::class)->during('getPaymentMethodByName', ['Free']);
62
    }
63
}
64