KnockoutDropdownFieldTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A testKnockoutDropdownField() 0 21 1
1
<?php
2
3
namespace AntonyThorpe\Knockout\Tests;
4
5
use SilverStripe\Dev\SapphireTest;
6
use AntonyThorpe\Knockout\KnockoutDropdownField;
7
8
/**
9
 * KnockoutDropdownFieldTest
10
 */
11
class KnockoutDropdownFieldTest extends SapphireTest
12
{
13
    public function testKnockoutDropdownField()
14
    {
15
        $field = KnockoutDropdownField::create(
16
            "SpaceExploration",
17
            "Space Exploration",
18
            array(
19
                "Rocket" => "Rocket",
20
                "Launcher" => "Launcher",
21
                "Blast Off" => "Blast Off"
22
            ),
23
            "Blast Off"
24
        )->setObservable('spaceship');
25
26
        $this->assertEquals(
27
            "spaceship",
28
            $field->getObservable(),
29
            "observable can be obtained"
30
        );
31
        $this->assertStringContainsString(
32
            '<select data-bind="value: spaceship, setKnockout:{value:\'Blast Off\'}"',
33
            $field->Field()->getValue()
34
        );
35
    }
36
}
37