Passed
Push — master ( 1dd2b2...edeeac )
by Antony
01:40
created

testKnockoutCheckboxField()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 29
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 22
nc 1
nop 0
dl 0
loc 29
rs 9.568
c 0
b 0
f 0
1
<?php
2
3
namespace AntonyThorpe\Knockout\Tests;
4
5
use SilverStripe\Dev\SapphireTest;
6
use AntonyThorpe\Knockout\KnockoutCheckboxField;
7
8
/**
9
 * KnockoutCheckboxFieldTest
10
 */
11
class KnockoutCheckboxFieldTest extends SapphireTest
12
{
13
    public function testKnockoutCheckboxField()
14
    {
15
        $field = KnockoutCheckboxField::create("MyField", "This is a checkbox")
16
            ->setObservable('checkboxField')
17
            ->setOtherBindings("blah: anotherFunction")
18
            ->setHasFocus(true);
19
20
        $this->assertEquals(
21
            "checkboxField",
22
            $field->getObservable(),
23
            "observable is set"
24
        );
25
        $this->assertEquals(
26
            "blah: anotherFunction",
27
            $field->getOtherBindings(),
28
            "other bindings are set"
29
        );
30
        $this->assertEquals(
31
            "checked",
32
            $field->getBindingType(),
33
            "Default Binding Type is set"
34
        );
35
        $this->assertTrue(
36
            $field->getHasFocus(),
37
            "Focus is set to True"
38
        );
39
        $this->assertContains(
40
            '<input data-bind="checked: checkboxField, blah: anotherFunction',
41
            $field->Field()->getValue()
42
        );
43
    }
44
}
45