2015-11-17 17:34:17 +01: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\TextField;
|
|
|
|
use SilverStripe\Forms\EmailField;
|
|
|
|
use SilverStripe\Forms\CompositeField;
|
|
|
|
use SilverStripe\Forms\FieldGroup;
|
|
|
|
|
2016-12-16 05:34:21 +01:00
|
|
|
class FieldGroupTest extends SapphireTest
|
|
|
|
{
|
2015-11-17 17:34:17 +01:00
|
|
|
|
2016-12-16 05:34:21 +01:00
|
|
|
public function testMessagesInsideNestedCompositeFields()
|
|
|
|
{
|
|
|
|
$fieldGroup = new FieldGroup(
|
|
|
|
new CompositeField(
|
|
|
|
$textField = new TextField('TestField', 'Test Field'),
|
|
|
|
$emailField = new EmailField('TestEmailField', 'Test Email Field')
|
|
|
|
)
|
|
|
|
);
|
2015-11-17 17:34:17 +01:00
|
|
|
|
2016-12-16 05:34:21 +01:00
|
|
|
$textField->setMessage('Test error message', 'error');
|
|
|
|
$emailField->setMessage('Test error warning', 'warning');
|
2015-11-17 17:34:17 +01:00
|
|
|
|
2016-12-16 05:34:21 +01:00
|
|
|
$this->assertEquals('Test error message, Test error warning.', $fieldGroup->getMessage());
|
|
|
|
$this->assertEquals('error', $fieldGroup->getMessageType());
|
|
|
|
}
|
2015-11-17 17:34:17 +01:00
|
|
|
}
|