Passed
Branch master (e5ff15)
by Antony
01:18
created

KnockoutOptionsetFieldTest::testKnockoutOptionsetField()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 29

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 29
rs 9.456
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace AntonyThorpe\Knockout\Tests;
4
5
use SilverStripe\Dev\SapphireTest;
6
use AntonyThorpe\Knockout\KnockoutOptionsetField;
7
8
/**
9
 * KnockoutOptionsetFieldTest
10
 */
11
class KnockoutOptionsetFieldTest extends SapphireTest
12
{
13
    public function testKnockoutOptionsetField()
14
    {
15
        $field = KnockoutOptionsetField::create(
16
            "MyField",
17
            "My Field",
18
            array(
19
                'Flying High DVD' => 'Flying High DVD',
20
                'Zero Gravity Pillow' => 'Zero Gravity Pillow',
21
                'Rocket Replica' => 'Rocket Replica'
22
            ),
23
            'Zero Gravity Pillow'
24
        )->setObservable('accessories')
25
            ->setOtherBindings("blah: console.log('blast-off')")
26
            ->setHasFocus(true);
27
28
        $this->assertEquals(
29
            "accessories",
30
            $field->getObservable(),
31
            "observable is set"
32
        );
33
        $this->assertEquals(
34
            "blah: console.log('blast-off')",
35
            $field->getOtherBindings(),
36
            "other bindings are set"
37
        );
38
        $this->assertEquals(
39
            "checked",
40
            $field->getBindingType(),
41
            "Default Binding Type is set"
42
        );
43
        $this->assertTrue(
44
            $field->getHasFocus(),
45
            "Focus is set to True"
46
        );
47
    }
48
}
49