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 ( 48aa34...e9e817 )
by Mario
29:19 queued 01:50
created

FormBuilderTest::testFormBuildUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 23
rs 9.0856
cc 1
eloc 14
nc 1
nop 0
1
<?php
2
3
namespace Netgen\Bundle\InformationCollectionBundle\Tests\FieldHandler;
4
5
use eZ\Publish\API\Repository\Values\Content\ContentInfo;
6
use eZ\Publish\Core\Repository\ContentTypeService;
7
use eZ\Publish\Core\Repository\Values\Content\Location;
8
use Netgen\Bundle\InformationCollectionBundle\Form\Builder\FormBuilder;
9
use PHPUnit\Framework\TestCase;
10
use Symfony\Component\Form\FormBuilder as SymfonyFormBuilder;
11
use Symfony\Component\Form\FormFactory;
12
use Symfony\Component\Routing\Router;
13
14
class FormBuilderTest extends TestCase
15
{
16
    /**
17
     * @var FormBuilder
18
     */
19
    protected $formBuilder;
20
21
    /**
22
     * @var \PHPUnit_Framework_MockObject_MockObject
23
     */
24
    protected $formFactory;
25
26
    /**
27
     * @var \PHPUnit_Framework_MockObject_MockObject
28
     */
29
    protected $contentTypeService;
30
31
    /**
32
     * @var \PHPUnit_Framework_MockObject_MockObject
33
     */
34
    protected $router;
35
36
    /**
37
     * @var \PHPUnit_Framework_MockObject_MockObject
38
     */
39
    protected $innerFormBuilder;
40
41
    public function setUp()
42
    {
43
        $this->formFactory = $this->getMockBuilder(FormFactory::class)
44
            ->disableOriginalConstructor()
45
            ->setMethods(array('createBuilder', 'setAction'))
46
            ->getMock();
47
48
        $this->contentTypeService = $this->getMockBuilder(ContentTypeService::class)
49
            ->disableOriginalConstructor()
50
            ->setMethods(array('loadContentType'))
51
            ->getMock();
52
53
        $this->router = $this->getMockBuilder(Router::class)
54
            ->disableOriginalConstructor()
55
            ->setMethods(array('generate'))
56
            ->getMock();
57
58
        $this->formBuilder = new FormBuilder($this->formFactory, $this->contentTypeService, $this->router, true);
59
        $this->innerFormBuilder = $this->getMockBuilder(SymfonyFormBuilder::class)
60
            ->disableOriginalConstructor()
61
            ->setMethods(array())
62
            ->getMock();
63
64
        parent::setUp();
65
    }
66
67
    public function testFormBuildUp()
68
    {
69
        $location = new Location(array(
70
            'contentInfo' => new ContentInfo(array(
71
                'contentTypeId' => 123,
72
            )),
73
        ));
74
75
        $this->contentTypeService->expects($this->once())
76
            ->method('loadContentType')
77
            ->with(123);
78
79
        $this->formFactory->expects($this->once())
80
            ->method('createBuilder')
81
            ->willReturn($this->innerFormBuilder);
82
83
        $this->innerFormBuilder->expects($this->never())
84
            ->method('setAction');
85
86
        $builder = $this->formBuilder->createFormForLocation($location, false);
87
88
        $this->assertSame($this->innerFormBuilder, $builder);
89
    }
90
91
    public function testFormBuildUpWithCustomURL()
92
    {
93
        $location = new Location(array(
94
            'contentInfo' => new ContentInfo(array(
95
                'contentTypeId' => 123,
96
            )),
97
        ));
98
99
        $this->contentTypeService->expects($this->once())
100
            ->method('loadContentType')
101
            ->with(123);
102
103
        $this->formFactory->expects($this->once())
104
            ->method('createBuilder')
105
            ->willReturn($this->innerFormBuilder);
106
107
        $this->innerFormBuilder->expects($this->once())
108
            ->method('setAction');
109
110
        $this->router->expects($this->once())
111
            ->method('generate');
112
113
        $builder = $this->formBuilder->createFormForLocation($location, true);
114
115
        $this->assertSame($this->innerFormBuilder, $builder);
116
    }
117
}
118