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

GridStateTest::testValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 11
nc 1
nop 0
dl 0
loc 18
rs 9.9
c 1
b 0
f 0
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