Completed
Push — master ( 4c7b9c...e919dc )
by Kamil
21:11
created

AddPaymentMethodsFormSubscriberSpec   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
lcom 0
cbo 4
dl 0
loc 37
rs 10
c 1
b 0
f 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A it_is_initializable() 0 4 1
A it_is_an_event_subscriber() 0 4 1
A it_listens_on_pre_set_data_event() 0 4 1
A it_adds_payment_methods_choice_to_the_form() 0 19 1
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\Bundle\CoreBundle\Form\EventSubscriber;
13
14
use PhpSpec\ObjectBehavior;
15
use Prophecy\Argument;
16
use spec\Sylius\Bundle\ArchetypeBundle\Form\Type\ArchetypeTypeSpec;
17
use Sylius\Component\Payment\Model\PaymentInterface;
18
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
19
use Symfony\Component\Form\FormEvent;
20
use Symfony\Component\Form\FormEvents;
21
use Symfony\Component\Form\FormInterface;
22
23
/**
24
 * @author Anna Walasek <[email protected]>
25
 */
26
class AddPaymentMethodsFormSubscriberSpec extends ObjectBehavior
27
{
28
    function it_is_initializable()
29
    {
30
        $this->shouldHaveType('Sylius\Bundle\CoreBundle\Form\EventSubscriber\AddPaymentMethodsFormSubscriber');
31
    }
32
33
    function it_is_an_event_subscriber()
34
    {
35
        $this->shouldImplement(EventSubscriberInterface::class);
36
    }
37
38
    function it_listens_on_pre_set_data_event()
39
    {
40
        $this->getSubscribedEvents()->shouldReturn([FormEvents::PRE_SET_DATA => 'preSetData']);
41
    }
42
43
    function it_adds_payment_methods_choice_to_the_form(
44
        FormEvent $event,
45
        FormInterface $form,
46
        PaymentInterface $payment
47
    ) {
48
        $event->getForm()->willReturn($form);
49
        $event->getData()->willReturn($payment);
50
51
        $form
52
            ->add('method', Argument::type('string'), [
53
                'label' => 'sylius.form.checkout.payment_method', 
54
                'subject' => $payment, 
55
                'expanded' => true,
56
            ])
57
            ->shouldBeCalled()
58
        ;
59
60
        $this->preSetData($event);
61
    }
62
}
63