Completed
Push — pull-request/8055 ( ad3cfa )
by Kamil
26:24 queued 01:40
created

PaymentDescriptionProviderSpec   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 6
dl 0
loc 26
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 9 1
A it_is_initializable() 0 4 1
A it_should_generate_a_description_string() 0 8 1
1
<?php
2
3
namespace spec\Sylius\Bundle\PayumBundle\Provider;
4
5
use Doctrine\Common\Collections\ArrayCollection;
6
use Sylius\Bundle\PayumBundle\Provider\PaymentDescriptionProvider;
7
use PhpSpec\ObjectBehavior;
8
use Prophecy\Argument;
9
use Sylius\Component\Core\Model\OrderInterface;
10
use Sylius\Component\Core\Model\OrderItem;
11
use Sylius\Component\Core\Model\PaymentInterface;
12
use Symfony\Component\Translation\TranslatorInterface;
13
14
/**
15
 * @author Stefan Doorn <[email protected]>
16
 */
17
final class PaymentDescriptionProviderSpec extends ObjectBehavior
18
{
19
    function let(TranslatorInterface $translator)
20
    {
21
        $translator->transChoice('sylius.payum_action.payment.description', 2, [
22
            '%items%' => 2,
23
            '%total%' => 100.00,
24
        ])->willReturn('Payment contains 2 items for a total of 100');
25
26
        $this->beConstructedWith($translator);
27
    }
28
29
    function it_is_initializable()
30
    {
31
        $this->shouldHaveType(PaymentDescriptionProvider::class);
32
    }
33
34
    function it_should_generate_a_description_string(PaymentInterface $payment, OrderInterface $order)
35
    {
36
        $order->getItems()->willReturn(new ArrayCollection([new OrderItem(), new OrderItem()]));
37
        $order->getTotal()->willReturn(10000);
38
        $payment->getOrder()->willReturn($order);
39
40
        $this->getPaymentDescription($payment)->shouldReturn('Payment contains 2 items for a total of 100');
41
    }
42
}
43