Completed
Pull Request — master (#520)
by Nic
35:50
created

EditableDropdownTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/**
4
 * Tests the {@see EditableDropdown} class
5
 */
6
class EditableDropdownTest extends SapphireTest
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...
7
{
8
9
    public static $fixture_file = 'userforms/tests/EditableFormFieldTest.yml';
10
11
    public function setUp()
12
    {
13
        parent::setUp();
14
    }
15
16
    /**
17
     * Tests that the field sets the empty string if set
18
     */
19
    public function testFormField()
20
    {
21
        if (!$dropdown = EditableDropdown::get()->filter('UseEmptyString', true)->first()) {
22
            $dropdown = $this->objFromFixture('EditableDropdown', 'basic-dropdown');
23
24
            $dropdown->UseEmptyString = true;
25
            $dropdown->EmptyString = 'My Default Empty String';
26
            $dropdown->write();
27
        }
28
29
        $field = $dropdown->getFormField();
30
        $this->assertEquals($field->getEmptyString(), 'My Default Empty String');
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<EditableDropdownTest>.

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...
31
32
        $alternateDropdown = $this->objFromFixture('EditableDropdown', 'department-dropdown');
33
        $formField = $alternateDropdown->getFormField();
34
        $this->assertFalse($formField->getHasEmptyDefault());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<EditableDropdownTest>.

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...
35
36
        $alternateDropdown->UseEmptyString = true;
37
        $alternateDropdown->write();
38
        $this->assertEquals($formField->getEmptyString(), '');
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<EditableDropdownTest>.

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...
39
40
    }
41
42
}
43