Completed
Pull Request — master (#10)
by Helpful
14:43
created

EditableFieldTest::testModifyingFieldSettings()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 11
rs 9.4285
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
3
/**
4
 * EditableFieldTest contains test cases for test EditableField classes
5
 *
6
 * @author  Mohamed Alsharaf <[email protected]>
7
 * @package editablefield
8
 */
9
class EditableFieldTest extends FunctionalTest
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
10
{
11
    protected static $fixture_file = 'EditableFieldTest.yml';
12
    protected $fields = [
13
        'radio-field'         => [
14
            'class' => 'EditableFieldRadio',
15
            'field' => 'OptionsetField'
16
        ],
17
        'html-field'          => [
18
            'class' => 'EditableFieldLiteral',
19
            'field' => 'LiteralField'
20
        ],
21
        'numeric-field'       => [
22
            'class' => 'EditableFieldNumeric',
23
            'field' => 'NumericField'
24
        ],
25
        'email-field'         => [
26
            'class' => 'EditableFieldEmail',
27
            'field' => 'EmailField'
28
        ],
29
        'checkbox-1'          => [
30
            'class' => 'EditableFieldCheckbox',
31
            'field' => 'CheckboxField'
32
        ],
33
        'department-dropdown' => [
34
            'class' => 'EditableFieldDropdown',
35
            'field' => 'DropdownField'
36
        ],
37
        'heading-field'       => [
38
            'class' => 'EditableFieldHeading',
39
            'field' => 'HeaderField'
40
        ],
41
        'dob-field'           => [
42
            'class' => 'EditableFieldDate',
43
            'field' => 'DateField'
44
        ],
45
        'country-field'       => [
46
            'class' => 'EditableFieldCountryDropdown',
47
            'field' => 'CountryDropdownField'
48
        ],
49
        'member-field'        => [
50
            'class' => 'EditableFieldMemberList',
51
            'field' => 'DropdownField'
52
        ],
53
        'pagetype-field'      => [
54
            'class' => 'EditableFieldPageTypeList',
55
            'field' => 'DropdownField'
56
        ],
57
        'basic-text'          => [
58
            'class' => 'EditableFieldText',
59
            'field' => 'TextField'
60
        ],
61
        'text-area'           => [
62
            'class' => 'EditableFieldText',
63
            'field' => 'TextareaField'
64
        ],
65
        'checkbox-group'      => [
66
            'class' => 'EditableFieldCheckboxGroup',
67
            'field' => 'CheckboxSetField'
68
        ],
69
    ];
70
71
    public function testGetFormField()
72
    {
73
        foreach ($this->fields as $name => $field) {
74
            $object = $this->objFromFixture($field['class'], $name);
75
            $this->assertInstanceOf($field['field'], $object->getFormField());
0 ignored issues
show
Bug introduced by
The method assertInstanceOf() does not seem to exist on object<EditableFieldTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
76
        }
77
    }
78
79
    public function testModifyingFieldSettings()
80
    {
81
        $content = 'html content 1...';
82
        $field = $this->fields['html-field'];
83
84
        $htmlField = $this->objFromFixture($field['class'], 'html-field');
85
        $htmlField->setSetting('Content', $content);
86
        $htmlField->write();
87
88
        $this->assertEquals($htmlField->getSetting('Content'), $content);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<EditableFieldTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
89
    }
90
91
    public function testMultipleOptionDuplication()
92
    {
93
        $field = $this->fields['department-dropdown'];
94
        $dropdown = $this->objFromFixture($field['class'], 'department-dropdown');
95
96
        $clone = $dropdown->duplicate();
97
98
        $this->assertEquals($clone->Options()->Count(), $dropdown->Options()->Count());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<EditableFieldTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
99
100
        foreach ($clone->Options() as $option) {
101
            $orginal = $dropdown->Options()->find('Title', $option->Title);
102
103
            $this->assertEquals($orginal->Sort, $option->Sort);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<EditableFieldTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
104
        }
105
    }
106
}
107