2012-06-13 09:57:54 +02:00
|
|
|
<?php
|
|
|
|
|
2016-10-14 03:30:05 +02:00
|
|
|
namespace SilverStripe\Forms\Tests;
|
|
|
|
|
2016-08-19 00:51:35 +02:00
|
|
|
use SilverStripe\Dev\SapphireTest;
|
|
|
|
use SilverStripe\Forms\FormAction;
|
|
|
|
|
2016-12-16 05:34:21 +01:00
|
|
|
class FormActionTest extends SapphireTest
|
|
|
|
{
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2016-12-16 05:34:21 +01:00
|
|
|
public function testGetField()
|
|
|
|
{
|
|
|
|
$formAction = new FormAction('test');
|
2021-10-27 04:39:47 +02:00
|
|
|
$this->assertStringContainsString('type="submit"', $formAction->getAttributesHTML());
|
2012-06-13 09:57:54 +02:00
|
|
|
|
2016-12-16 05:34:21 +01:00
|
|
|
$formAction->setAttribute('src', 'file.png');
|
2021-10-27 04:39:47 +02:00
|
|
|
$this->assertStringContainsString('type="image"', $formAction->getAttributesHTML());
|
2016-12-16 05:34:21 +01:00
|
|
|
}
|
2019-10-29 05:19:22 +01:00
|
|
|
|
|
|
|
public function testGetTitle()
|
|
|
|
{
|
|
|
|
// Test that description overrides title attribute, but doesn't prevent it from
|
|
|
|
// working if blank.
|
|
|
|
$action = new FormAction('test');
|
|
|
|
$action->setAttribute('title', 'this is the title');
|
|
|
|
$this->assertEquals('this is the title', $action->getAttribute('title'));
|
|
|
|
$action->setDescription('this is a better title');
|
|
|
|
$this->assertEquals('this is a better title', $action->getAttribute('title'));
|
|
|
|
$action->setDescription(null);
|
|
|
|
$this->assertEquals('this is the title', $action->getAttribute('title'));
|
|
|
|
}
|
2014-08-15 08:53:05 +02:00
|
|
|
}
|