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

FormActionTest::testGetTitle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
nc 1
nop 0
dl 0
loc 11
rs 10
c 1
b 0
f 0
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