KnockoutOptionsetFieldTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A testKnockoutOptionsetField() 0 37 1
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: someFunction")
26
            ->setHasFocus(true);
27
28
        $this->assertEquals(
29
            "accessories",
30
            $field->getObservable(),
31
            "observable is set"
32
        );
33
        $this->assertEquals(
34
            "blah: someFunction",
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
        $this->assertStringContainsString(
48
            '<input data-bind="checked: accessories, blah: someFunction"',
49
            $field->Field()->getValue()
50
        );
51
    }
52
}
53