Passed
Push — master ( bf3235...abf80a )
by Antony
02:59
created

KnockoutTextFieldTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 26
dl 0
loc 35
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testKnockoutTextField() 0 33 1
1
<?php
2
3
namespace AntonyThorpe\Knockout\Tests;
4
5
use SilverStripe\Dev\SapphireTest;
6
use AntonyThorpe\Knockout\KnockoutTextField;
7
8
/**
9
 * KnockoutTextFieldTest
10
 */
11
class KnockoutTextFieldTest extends SapphireTest
12
{
13
    public function testKnockoutTextField()
14
    {
15
        $field = KnockoutTextField::create("MyField", "My Field", null, 50)
16
            ->setObservable('spaceship')
17
            ->setBindingType('value')
18
            ->setOtherBindings("valueUpdate: 'input'")
19
            ->setHasFocus(true);
20
21
        $this->assertEquals(
22
            "spaceship",
23
            $field->getObservable(),
24
            "observable is set"
25
        );
26
        $this->assertEquals(
27
            "valueUpdate: 'input'",
28
            $field->getOtherBindings(),
29
            "other bindings are set"
30
        );
31
        $this->assertEquals(
32
            "value",
33
            $field->getBindingType(),
34
            "Binding Type is set"
35
        );
36
37
        $field->setBindingType('textInput');
38
        $this->assertEquals(
39
            "textInput",
40
            $field->getBindingType(),
41
            "Binding Type is reset"
42
        );
43
        $this->assertTrue(
44
            $field->getHasFocus(),
45
            "Focus is set to True"
46
        );
47
    }
48
}
49