[Form] fixed a maxlength overring on a guessing
This commit is contained in:
parent
5284b59fb9
commit
7248680eba
@ -113,11 +113,11 @@ class FormFactory implements FormFactoryInterface
|
||||
$pattern = $patternGuess ? $patternGuess->getValue() : null;
|
||||
|
||||
if (null !== $pattern) {
|
||||
$options = array_merge(array('attr' => array('pattern' => $pattern)), $options);
|
||||
$options = array_replace_recursive(array('attr' => array('pattern' => $pattern)), $options);
|
||||
}
|
||||
|
||||
if (null !== $maxLength) {
|
||||
$options = array_merge(array('attr' => array('maxlength' => $maxLength)), $options);
|
||||
$options = array_replace_recursive(array('attr' => array('maxlength' => $maxLength)), $options);
|
||||
}
|
||||
|
||||
if ($requiredGuess) {
|
||||
|
@ -504,6 +504,41 @@ class FormFactoryTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('builderInstance', $this->builder);
|
||||
}
|
||||
|
||||
public function testCreateBuilderUsesMaxLengthAndPattern()
|
||||
{
|
||||
$this->guesser1->expects($this->once())
|
||||
->method('guessMaxLength')
|
||||
->with('Application\Author', 'firstName')
|
||||
->will($this->returnValue(new ValueGuess(
|
||||
20,
|
||||
Guess::HIGH_CONFIDENCE
|
||||
)));
|
||||
|
||||
$this->guesser2->expects($this->once())
|
||||
->method('guessPattern')
|
||||
->with('Application\Author', 'firstName')
|
||||
->will($this->returnValue(new ValueGuess(
|
||||
'.{5,}',
|
||||
Guess::HIGH_CONFIDENCE
|
||||
)));
|
||||
|
||||
$factory = $this->getMockFactory(array('createNamedBuilder'));
|
||||
|
||||
$factory->expects($this->once())
|
||||
->method('createNamedBuilder')
|
||||
->with('firstName', 'text', null, array('attr' => array('maxlength' => 20, 'pattern' => '.{5,}', 'class' => 'tinymce')))
|
||||
->will($this->returnValue('builderInstance'));
|
||||
|
||||
$this->builder = $factory->createBuilderForProperty(
|
||||
'Application\Author',
|
||||
'firstName',
|
||||
null,
|
||||
array('attr' => array('class' => 'tinymce'))
|
||||
);
|
||||
|
||||
$this->assertEquals('builderInstance', $this->builder);
|
||||
}
|
||||
|
||||
public function testCreateBuilderUsesRequiredSettingWithHighestConfidence()
|
||||
{
|
||||
$this->guesser1->expects($this->once())
|
||||
|
Reference in New Issue
Block a user