These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Kunstmaan\FormBundle\Tests\Entity\PageParts; |
||
4 | |||
5 | use ArrayObject; |
||
6 | use Kunstmaan\FormBundle\Entity\PageParts\ChoicePagePart; |
||
7 | use Kunstmaan\FormBundle\Form\ChoicePagePartAdminType; |
||
8 | use Symfony\Component\Form\FormBuilderInterface; |
||
9 | |||
10 | /** |
||
11 | * Tests for ChoicePagePart |
||
12 | */ |
||
13 | class ChoicePagePartTest extends \PHPUnit_Framework_TestCase |
||
14 | { |
||
15 | /** |
||
16 | * @var ChoicePagePart |
||
17 | */ |
||
18 | protected $object; |
||
19 | |||
20 | /** |
||
21 | * Sets up the fixture, for example, opens a network connection. |
||
22 | * This method is called before a test is executed. |
||
23 | */ |
||
24 | protected function setUp() |
||
25 | { |
||
26 | $this->object = new ChoicePagePart(); |
||
27 | } |
||
28 | |||
29 | public function testGetDefaultView() |
||
30 | { |
||
31 | $stringValue = $this->object->getDefaultView(); |
||
32 | $this->assertNotNull($stringValue); |
||
33 | $this->assertTrue(is_string($stringValue)); |
||
34 | } |
||
35 | |||
36 | View Code Duplication | public function testAdaptForm() |
|
37 | { |
||
38 | $object = $this->object; |
||
39 | $object->setRequired(true); |
||
40 | |||
41 | $formBuilder = $this->getMockBuilder('Symfony\Component\Form\FormBuilder') |
||
42 | ->disableOriginalConstructor() |
||
43 | ->getMock(); |
||
44 | |||
45 | $formBuilder->expects($this->any()) |
||
46 | ->method('getData') |
||
47 | ->will($this->returnValue(array())); |
||
48 | |||
49 | $fields = new ArrayObject(); |
||
50 | |||
51 | $this->assertTrue(count($fields) == 0); |
||
52 | $object->setErrorMessageRequired('invalid!'); |
||
53 | /* @var $formBuilder FormBuilderInterface */ |
||
54 | $object->adaptForm($formBuilder, $fields, 0); |
||
55 | $this->assertTrue(count($fields) > 0); |
||
56 | } |
||
57 | |||
58 | public function testGetDefaultAdminType() |
||
59 | { |
||
60 | $this->assertEquals(ChoicePagePartAdminType::class, $this->object->getDefaultAdminType()); |
||
61 | } |
||
62 | |||
63 | View Code Duplication | public function testSetGetExpanded() |
|
64 | { |
||
65 | $object = $this->object; |
||
66 | $this->assertFalse($object->getExpanded()); |
||
67 | $object->setExpanded(true); |
||
68 | $this->assertTrue($object->getExpanded()); |
||
69 | } |
||
70 | |||
71 | View Code Duplication | public function testSetGetMultiple() |
|
72 | { |
||
73 | $object = $this->object; |
||
74 | $this->assertFalse($object->getMultiple()); |
||
75 | $object->setMultiple(true); |
||
76 | $this->assertTrue($object->getMultiple()); |
||
77 | } |
||
78 | |||
79 | View Code Duplication | public function testSetGetChoices() |
|
80 | { |
||
81 | $object = $this->object; |
||
82 | $choices = array('test1' => 'test1', 'test2' => 'test2'); |
||
83 | $object->setChoices($choices); |
||
0 ignored issues
–
show
|
|||
84 | $this->assertEquals($choices, $object->getChoices()); |
||
85 | } |
||
86 | |||
87 | public function testGettersAndSetters() |
||
88 | { |
||
89 | $object = $this->object; |
||
90 | $value = 'test'; |
||
91 | $object->setEmptyValue($value); |
||
92 | $object->setRequired(true); |
||
93 | $object->setErrorMessageRequired('fix your code!'); |
||
94 | |||
95 | $this->assertEquals($value, $object->getEmptyValue()); |
||
96 | $this->assertTrue($object->getRequired()); |
||
97 | $this->assertEquals('fix your code!', $object->getErrorMessageRequired()); |
||
98 | } |
||
99 | } |
||
100 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: