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