Completed
Push — master ( e62fa2...4391c3 )
by Kristof
133:20 queued 117:59
created

ChoiceFormSubmissionFieldTest.php (3 issues)

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
8
/**
9
 * Tests for ChoiceFormSubmissionField
10
 */
11
class ChoiceFormSubmissionFieldTest extends \PHPUnit_Framework_TestCase
12
{
13
    /**
14
     * @var ChoiceFormSubmissionField
15
     */
16
    protected $object;
17
18
    /**
19
     * Sets up the fixture, for example, opens a network connection.
20
     * This method is called before a test is executed.
21
     */
22
    protected function setUp()
23
    {
24
        $this->object = new ChoiceFormSubmissionField();
25
    }
26
27
    public function testGetDefaultAdminType()
28
    {
29
        $this->assertEquals(ChoiceFormSubmissionType::class, $this->object->getDefaultAdminType());
30
    }
31
32
    public function testToString()
33
    {
34
        $stringValue = $this->object->__toString();
35
        $this->assertNotNull($stringValue);
36
        $this->assertTrue(is_string($stringValue));
37
        $object = $this->object;
38
        $object->setChoices(['delboy1978uk' => 123456789]);
39
        $object->setValue('delboy1978uk');
40
        $string = $object->__toString();
41
        $this->assertEquals('123456789', $string);
42
        $object->setValue(['delboy1978uk', 'numkil', 'sandergo90', 'dezinc']);
43
        $string = $object->__toString();
44
        $this->assertEquals('123456789, numkil, sandergo90, dezinc', $string);
45
    }
46
47
    public function testIsNull()
48
    {
49
        $object = $this->object;
50
        $this->assertTrue($object->isNull());
51
        $object->setValue(array('test' => 'test'));
52
        $this->assertFalse($object->isNull());
53
        $object->setValue('blah');
54
        $this->assertFalse($object->isNull());
55
    }
56
57
    public function testSetGetValue()
58
    {
59
        $object = $this->object;
60
        $value = array('test' => 'test');
61
        $object->setValue($value);
62
        $this->assertEquals($value, $object->getValue());
63
    }
64
65 View Code Duplication
    public function testSetGetExpanded()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
66
    {
67
        $object = $this->object;
68
        $this->assertFalse($object->getExpanded());
69
        $object->setExpanded(true);
70
        $this->assertTrue($object->getExpanded());
71
    }
72
73 View Code Duplication
    public function testSetGetMultiple()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
74
    {
75
        $object = $this->object;
76
        $this->assertFalse($object->getMultiple());
77
        $object->setMultiple(true);
78
        $this->assertTrue($object->getMultiple());
79
    }
80
81 View Code Duplication
    public function testSetGetChoices()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
82
    {
83
        $object = $this->object;
84
        $choices = array('test1' => 'test1', 'test2' => 'test2');
85
        $object->setChoices($choices);
86
        $this->assertEquals($choices, $object->getChoices());
87
    }
88
89
    public function testSetGetRequired()
90
    {
91
        $object = $this->object;
92
        $object->setRequired(true);
93
        $this->assertTrue($object->getRequired());
94
        $object->setRequired(false);
95
        $this->assertFalse($object->getRequired());
96
    }
97
}
98