KnockoutPasswordFieldTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 19
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testKnockoutPasswordField() 0 17 1
1
<?php
2
3
namespace AntonyThorpe\Knockout\Tests;
4
5
use SilverStripe\Dev\SapphireTest;
6
use AntonyThorpe\Knockout\KnockoutPasswordField;
7
8
/**
9
 * KnockoutPasswordFieldTest
10
 */
11
class KnockoutPasswordFieldTest extends SapphireTest
12
{
13
    public function testKnockoutPasswordField()
14
    {
15
        $field = KnockoutPasswordField::create("MyField", "My Field")
16
            ->setHasFocus(true);
17
18
        $this->assertEquals(
19
            "password",
20
            $field->getObservable(),
21
            "observable is set to password by default"
22
        );
23
        $this->assertTrue(
24
            $field->getHasFocus(),
25
            "Focus is set to True"
26
        );
27
        $this->assertStringContainsString(
28
            '<input data-bind="textInput: password, hasFocus: true"',
29
            $field->Field()->getValue()
30
        );
31
    }
32
}
33