KnockoutTextFieldTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 18
c 2
b 0
f 0
dl 0
loc 25
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testKnockoutTextField() 0 23 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
            ->setHasFocus(true);
18
19
        $this->assertEquals(
20
            "spaceship",
21
            $field->getObservable(),
22
            "observable is set"
23
        );
24
        $this->assertEquals(
25
            "textInput",
26
            $field->getBindingType(),
27
            "Binding Type is set"
28
        );
29
        $this->assertTrue(
30
            $field->getHasFocus(),
31
            "Focus is set to True"
32
        );
33
        $this->assertStringContainsString(
34
            '<input data-bind="textInput: spaceship, hasFocus: true"',
35
            $field->Field()->getValue()
36
        );
37
    }
38
}
39