Passed
Push — fix-9163 ( 4cfde3...07a516 )
by Ingo
17:14
created

GridStateTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
dl 0
loc 21
rs 10
c 1
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testValue() 0 18 1
1
<?php
2
3
namespace SilverStripe\Forms\Tests\GridField;
4
5
use SilverStripe\Dev\SapphireTest;
6
use SilverStripe\Forms\GridField\GridField;
7
use SilverStripe\Forms\GridField\GridState;
8
9
class GridStateTest extends SapphireTest
10
{
11
12
    public function testValue()
13
    {
14
        $gridfield = new GridField('Test');
15
16
        $state = new GridState($gridfield);
17
        $this->assertEquals('{}', $state->Value(), 'GridState without any data has empty JSON object for Value');
18
19
        $data = $state->getData();
20
        $data->initDefaults(['Foo' => 'Bar']);
21
22
        $this->assertEquals('{}', $state->Value(), 'GridState without change has empty JSON object for Value');
23
24
        $data->Foo = 'Barrr';
0 ignored issues
show
Bug Best Practice introduced by
The property Foo does not exist on SilverStripe\Forms\GridField\GridState_Data. Since you implemented __set, consider adding a @property annotation.
Loading history...
25
26
        $this->assertEquals(
27
            '{"Foo":"Barrr"}',
28
            $state->Value(),
29
            'GridState with changes returns has a JSON object string for Value.'
30
        );
31
    }
32
}
33