Passed
Pull Request — 4.3 (#9305)
by Damian
11:59
created

FormActionTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetField() 0 7 1
A testGetTitle() 0 11 1
1
<?php
2
3
namespace SilverStripe\Forms\Tests;
4
5
use SilverStripe\Dev\SapphireTest;
6
use SilverStripe\Forms\FormAction;
7
8
class FormActionTest extends SapphireTest
9
{
10
11
    public function testGetField()
12
    {
13
        $formAction = new FormAction('test');
14
        $this->assertContains('type="submit"', $formAction->getAttributesHTML());
15
16
        $formAction->setAttribute('src', 'file.png');
17
        $this->assertContains('type="image"', $formAction->getAttributesHTML());
18
    }
19
20
    public function testGetTitle()
21
    {
22
        // Test that description overrides title attribute, but doesn't prevent it from
23
        // working if blank.
24
        $action = new FormAction('test');
25
        $action->setAttribute('title', 'this is the title');
26
        $this->assertEquals('this is the title', $action->getAttribute('title'));
27
        $action->setDescription('this is a better title');
28
        $this->assertEquals('this is a better title', $action->getAttribute('title'));
29
        $action->setDescription(null);
30
        $this->assertEquals('this is the title', $action->getAttribute('title'));
31
    }
32
}
33