Completed
Push — master ( fcb59d...326ddf )
by Ruud
299:19 queued 288:03
created

ChoiceFormSubmissionFieldTest.php (1 issue)

Upgrade to new PHP Analysis Engine

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\FormSubmissionFieldTypes;
4
5
use Kunstmaan\FormBundle\Entity\FormSubmissionFieldTypes\ChoiceFormSubmissionField;
6
use Kunstmaan\FormBundle\Form\ChoiceFormSubmissionType;
7
use PHPUnit\Framework\TestCase;
8
9
/**
10
 * Tests for ChoiceFormSubmissionField
11
 */
12
class ChoiceFormSubmissionFieldTest extends TestCase
13
{
14
    /**
15
     * @var ChoiceFormSubmissionField
16
     */
17
    protected $object;
18
19
    /**
20
     * Sets up the fixture, for example, opens a network connection.
21
     * This method is called before a test is executed.
22
     */
23
    protected function setUp()
24
    {
25
        $this->object = new ChoiceFormSubmissionField();
26
    }
27
28
    public function testGetDefaultAdminType()
29
    {
30
        $this->assertEquals(ChoiceFormSubmissionType::class, $this->object->getDefaultAdminType());
31
    }
32
33
    public function testToString()
34
    {
35
        $stringValue = $this->object->__toString();
36
        $this->assertNotNull($stringValue);
37
        $this->assertInternalType('string', $stringValue);
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit\Framework\Assert::assertInternalType() has been deprecated with message: https://github.com/sebastianbergmann/phpunit/issues/3369

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
38
        $object = $this->object;
39
        $object->setChoices(['delboy1978uk' => 123456789]);
40
        $object->setValue('delboy1978uk');
41
        $string = $object->__toString();
42
        $this->assertEquals('123456789', $string);
43
        $object->setValue(['delboy1978uk', 'numkil', 'sandergo90', 'dezinc']);
44
        $string = $object->__toString();
45
        $this->assertEquals('123456789, numkil, sandergo90, dezinc', $string);
46
    }
47
48
    public function testIsNull()
49
    {
50
        $object = $this->object;
51
        $this->assertTrue($object->isNull());
52
        $object->setValue(array('test' => 'test'));
53
        $this->assertFalse($object->isNull());
54
        $object->setValue('blah');
55
        $this->assertFalse($object->isNull());
56
    }
57
58
    public function testSetGetValue()
59
    {
60
        $object = $this->object;
61
        $value = array('test' => 'test');
62
        $object->setValue($value);
63
        $this->assertEquals($value, $object->getValue());
64
    }
65
66 View Code Duplication
    public function testSetGetExpanded()
67
    {
68
        $object = $this->object;
69
        $this->assertFalse($object->getExpanded());
70
        $object->setExpanded(true);
71
        $this->assertTrue($object->getExpanded());
72
    }
73
74 View Code Duplication
    public function testSetGetMultiple()
75
    {
76
        $object = $this->object;
77
        $this->assertFalse($object->getMultiple());
78
        $object->setMultiple(true);
79
        $this->assertTrue($object->getMultiple());
80
    }
81
82 View Code Duplication
    public function testSetGetChoices()
83
    {
84
        $object = $this->object;
85
        $choices = array('test1' => 'test1', 'test2' => 'test2');
86
        $object->setChoices($choices);
87
        $this->assertEquals($choices, $object->getChoices());
88
    }
89
90
    public function testSetGetRequired()
91
    {
92
        $object = $this->object;
93
        $object->setRequired(true);
94
        $this->assertTrue($object->getRequired());
95
        $object->setRequired(false);
96
        $this->assertFalse($object->getRequired());
97
    }
98
}
99