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
|
|
|
|