GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 9348b1...151651 )
by
unknown
04:24
created

spec/Form/Type/ReportTypeSpec.php (1 issue)

1
<?php
2
3
namespace spec\Odiseo\SyliusReportPlugin\Form\Type;
4
5
use Odiseo\SyliusReportPlugin\DataFetcher\DataFetcherInterface;
6
use Odiseo\SyliusReportPlugin\Form\Type\DataFetcher\DataFetcherChoiceType;
7
use Odiseo\SyliusReportPlugin\Form\Type\Renderer\RendererChoiceType;
8
use Odiseo\SyliusReportPlugin\Model\Report;
9
use Odiseo\SyliusReportPlugin\Renderer\RendererInterface;
10
use PhpSpec\ObjectBehavior;
11
use Prophecy\Argument;
12
use Odiseo\SyliusReportPlugin\Form\EventListener\BuildReportDataFetcherFormSubscriber;
13
use Odiseo\SyliusReportPlugin\Form\EventListener\BuildReportRendererFormSubscriber;
14
use Sylius\Bundle\ResourceBundle\Form\EventSubscriber\AddCodeFormSubscriber;
15
use Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType;
16
use Sylius\Component\Registry\ServiceRegistryInterface;
17
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
18
use Symfony\Component\Form\Extension\Core\Type\TextType;
19
use Symfony\Component\Form\Form;
20
use Symfony\Component\Form\FormBuilderInterface;
21
use Symfony\Component\Form\FormConfigInterface;
22
use Symfony\Component\Form\FormFactoryInterface;
23
use Symfony\Component\Form\FormInterface;
24
use Symfony\Component\Form\FormView;
25
26
/**
27
 * @author Mateusz Zalewski <[email protected]>
28
 * @author Diego D'amico <[email protected]>
29
 */
30
final class ReportTypeSpec extends ObjectBehavior
31
{
32
    function let(
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
33
        ServiceRegistryInterface $rendererRegistry,
34
        ServiceRegistryInterface $dataFetcherRegistry
35
    ) {
36
        $this->beConstructedWith(
37
            Report::class,
38
            ['sylius'],
39
            $rendererRegistry,
40
            $dataFetcherRegistry,
41
            '@OdiseoSyliusReportPlugin/_rendererConfiguration.html.twig',
42
            '@OdiseoSyliusReportPlugin/_dataFetcherConfiguration.html.twig'
43
        );
44
    }
45
46
    function it_is_initializable()
47
    {
48
        $this->shouldHaveType('Odiseo\SyliusReportPlugin\Form\Type\ReportType');
49
    }
50
51
    function it_should_be_abstract_resource_type_object()
52
    {
53
        $this->shouldHaveType(AbstractResourceType::class);
54
    }
55
56
    function it_build_form_with_proper_fields(
57
        FormBuilderInterface $builder,
58
        FormFactoryInterface $factory,
59
        $dataFetcherRegistry,
60
        $rendererRegistry,
61
        RendererInterface $renderer,
62
        DataFetcherInterface $dataFetcher
63
    ) {
64
        $builder->getFormFactory()->willReturn($factory);
65
66
        $builder->add('name', TextType::class, Argument::any())->shouldBeCalled()->willReturn($builder);
67
        $builder->add('description', TextareaType::class, Argument::any())->shouldBeCalled()->willReturn($builder);
68
        $builder->add('renderer', RendererChoiceType::class, Argument::any())->shouldBeCalled()->willReturn($builder);
69
        $builder->add('dataFetcher', DataFetcherChoiceType::class, Argument::any())->shouldBeCalled()->willReturn($builder);
70
71
        $builder->addEventSubscriber(Argument::type(BuildReportRendererFormSubscriber::class))->shouldBeCalled()->willReturn($builder);
72
        $builder->addEventSubscriber(Argument::type(BuildReportDataFetcherFormSubscriber::class))->shouldBeCalled()->willReturn($builder);
73
74
        $builder
75
            ->addEventSubscriber(Argument::type(AddCodeFormSubscriber::class))
76
            ->shouldBeCalled()
77
            ->willReturn($builder)
78
        ;
79
80
        $renderer->getType()->willReturn('odiseo_sylius_report_renderer_test');
81
        $rendererRegistry->all()->willReturn(['test_renderer' => $renderer]);
82
        $builder->create('rendererConfiguration', 'odiseo_sylius_report_renderer_test')->willReturn($builder);
83
        $builder->getForm()->shouldBeCalled()->willReturn(Argument::type(Form::class));
84
85
        $dataFetcher->getType()->willReturn('odiseo_sylius_report_data_fetcher_test');
86
        $dataFetcherRegistry->all()->willReturn(['test_data_fetcher' => $dataFetcher]);
87
        $builder->create('dataFetcherConfiguration', 'odiseo_sylius_report_data_fetcher_test')->willReturn($builder);
88
        $builder->getForm()->shouldBeCalled()->willReturn(Argument::type(Form::class));
89
90
        $prototypes = [
91
            'renderers' => [
92
                'test_renderer' => Argument::type(Form::class),
93
                ],
94
            'dataFetchers' => [
95
                'test_data_fetcher' => Argument::type(Form::class),
96
                ],
97
            ];
98
        $builder->setAttribute('prototypes', $prototypes)->shouldBeCalled();
99
100
        $this->buildForm($builder, []);
101
    }
102
103
    function it_builds_view(
104
        FormConfigInterface $config,
105
        FormView $view,
106
        FormInterface $form,
107
        FormInterface $formTable,
108
        FormInterface $formUserRegistration
109
    ) {
110
        $prototypes = [
111
            'dataFetchers' => ['user_registration' => $formUserRegistration],
112
            'renderers' => ['table' => $formTable],
113
        ];
114
        $config->getAttribute('prototypes')->willReturn($prototypes);
115
        $form->getConfig()->willReturn($config);
116
117
        $formTable->createView($view)->shouldBeCalled();
118
        $formUserRegistration->createView($view)->shouldBeCalled();
119
120
        $this->buildView($view, $form, []);
121
    }
122
123
    function it_has_block_prefix()
124
    {
125
        $this->getBlockPrefix()->shouldReturn('odiseo_sylius_report');
126
    }
127
}
128