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

it_should_generate_a_description_string()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 2
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