2020-07-21 07:30:55 +02:00
< ? php
namespace SilverStripe\UserForms\Tests\FormField ;
use SilverStripe\Dev\SapphireTest ;
use SilverStripe\UserForms\FormField\UserFormsOptionSetField ;
use SilverStripe\UserForms\Model\EditableFormField\EditableRadioField ;
class UserFormsOptionSetFieldTest extends SapphireTest
{
protected static $fixture_file = '../UserFormsTest.yml' ;
public function testCustomErrorMessageValidationAttributesHTML ()
{
/** @var UserFormsOptionSetField $userFormsOptionSetField */
$radio = $this -> objFromFixture ( EditableRadioField :: class , 'radio-field' );
$radio -> Required = true ;
$radio -> CustomErrorMessage = 'My custom error message with \'single\' and "double" quotes' ;
$userFormsOptionSetField = $radio -> getFormField ();
$html = $userFormsOptionSetField -> renderWith ( UserFormsOptionSetField :: class ) -> getValue ();
$attributesHTML = 'data-rule-required="true" data-msg-required="My custom error message with &#039;single&#039; and &quot;double&quot; quotes"' ;
2022-04-13 03:52:56 +02:00
$this -> assertTrue ( strpos ( $html ? ? '' , $attributesHTML ? ? '' ) > 0 );
2020-07-21 07:30:55 +02:00
}
}