Merge branch '2.4'
* 2.4: [Form] Automatically add step attribute to HTML5 time widgets to display seconds if needed Fixed incorrect regular plural for -ves words [HttpKernel] Replace sha1 with sha256 in recently added tests.
This commit is contained in:
commit
be1b917d21
@ -140,6 +140,14 @@ class TimeType extends AbstractType
|
|||||||
|
|
||||||
if ('single_text' === $options['widget']) {
|
if ('single_text' === $options['widget']) {
|
||||||
$view->vars['type'] = 'time';
|
$view->vars['type'] = 'time';
|
||||||
|
|
||||||
|
// we need to force the browser to display the seconds by
|
||||||
|
// adding the HTML attribute step if not already defined.
|
||||||
|
// Otherwise the browser will not display and so not send the seconds
|
||||||
|
// therefore the value will always be considered as invalid.
|
||||||
|
if ($options['with_seconds'] && !isset($view->vars['attr']['step'])) {
|
||||||
|
$view->vars['attr']['step'] = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -492,6 +492,33 @@ class TimeTypeTest extends TypeTestCase
|
|||||||
$this->assertEquals('time', $view->vars['type']);
|
$this->assertEquals('time', $view->vars['type']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testSingleTextWidgetWithSecondsShouldHaveRightStepAttribute()
|
||||||
|
{
|
||||||
|
$form = $this->factory->create('time', null, array(
|
||||||
|
'widget' => 'single_text',
|
||||||
|
'with_seconds' => true,
|
||||||
|
));
|
||||||
|
|
||||||
|
$view = $form->createView();
|
||||||
|
$this->assertArrayHasKey('step', $view->vars['attr']);
|
||||||
|
$this->assertEquals(1, $view->vars['attr']['step']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testSingleTextWidgetWithSecondsShouldNotOverrideStepAttribute()
|
||||||
|
{
|
||||||
|
$form = $this->factory->create('time', null, array(
|
||||||
|
'widget' => 'single_text',
|
||||||
|
'with_seconds' => true,
|
||||||
|
'attr' => array(
|
||||||
|
'step' => 30
|
||||||
|
)
|
||||||
|
));
|
||||||
|
|
||||||
|
$view = $form->createView();
|
||||||
|
$this->assertArrayHasKey('step', $view->vars['attr']);
|
||||||
|
$this->assertEquals(30, $view->vars['attr']['step']);
|
||||||
|
}
|
||||||
|
|
||||||
public function testPassDefaultEmptyValueToViewIfNotRequired()
|
public function testPassDefaultEmptyValueToViewIfNotRequired()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('time', null, array(
|
||||||
|
@ -609,12 +609,11 @@ class HttpCacheTest extends HttpCacheTestCase
|
|||||||
$values = $this->getMetaStorageValues();
|
$values = $this->getMetaStorageValues();
|
||||||
$this->assertCount(1, $values);
|
$this->assertCount(1, $values);
|
||||||
$tmp = unserialize($values[0]);
|
$tmp = unserialize($values[0]);
|
||||||
$time = \DateTime::createFromFormat('U', time());
|
|
||||||
$tmp[0][1]['date'] = \DateTime::createFromFormat('U', time() - 5)->format(DATE_RFC2822);
|
$tmp[0][1]['date'] = \DateTime::createFromFormat('U', time() - 5)->format(DATE_RFC2822);
|
||||||
$r = new \ReflectionObject($this->store);
|
$r = new \ReflectionObject($this->store);
|
||||||
$m = $r->getMethod('save');
|
$m = $r->getMethod('save');
|
||||||
$m->setAccessible(true);
|
$m->setAccessible(true);
|
||||||
$m->invoke($this->store, 'md'.sha1('http://localhost/'), serialize($tmp));
|
$m->invoke($this->store, 'md'.hash('sha256', 'http://localhost/'), serialize($tmp));
|
||||||
|
|
||||||
$this->request('GET', '/');
|
$this->request('GET', '/');
|
||||||
$this->assertHttpKernelIsCalled();
|
$this->assertHttpKernelIsCalled();
|
||||||
@ -659,12 +658,11 @@ class HttpCacheTest extends HttpCacheTestCase
|
|||||||
$values = $this->getMetaStorageValues();
|
$values = $this->getMetaStorageValues();
|
||||||
$this->assertCount(1, $values);
|
$this->assertCount(1, $values);
|
||||||
$tmp = unserialize($values[0]);
|
$tmp = unserialize($values[0]);
|
||||||
$time = \DateTime::createFromFormat('U', time());
|
|
||||||
$tmp[0][1]['date'] = \DateTime::createFromFormat('U', time() - 5)->format(DATE_RFC2822);
|
$tmp[0][1]['date'] = \DateTime::createFromFormat('U', time() - 5)->format(DATE_RFC2822);
|
||||||
$r = new \ReflectionObject($this->store);
|
$r = new \ReflectionObject($this->store);
|
||||||
$m = $r->getMethod('save');
|
$m = $r->getMethod('save');
|
||||||
$m->setAccessible(true);
|
$m->setAccessible(true);
|
||||||
$m->invoke($this->store, 'md'.sha1('http://localhost/'), serialize($tmp));
|
$m->invoke($this->store, 'md'.hash('sha256', 'http://localhost/'), serialize($tmp));
|
||||||
|
|
||||||
$this->request('GET', '/');
|
$this->request('GET', '/');
|
||||||
$this->assertHttpKernelIsCalled();
|
$this->assertHttpKernelIsCalled();
|
||||||
|
@ -81,8 +81,8 @@ class StringUtil
|
|||||||
// moves (move)
|
// moves (move)
|
||||||
array('sevom', 5, true, true, 'move'),
|
array('sevom', 5, true, true, 'move'),
|
||||||
|
|
||||||
// hooves (hoof), dwarves (dwarf), elves (elf), leaves (leaf)
|
// hooves (hoof), dwarves (dwarf), elves (elf), leaves (leaf), caves (cave), staves (staff)
|
||||||
array('sev', 3, true, true, 'f'),
|
array('sev', 3, true, true, array('f', 've', 'ff')),
|
||||||
|
|
||||||
// axes (axis), axes (ax), axes (axe)
|
// axes (axis), axes (ax), axes (axe)
|
||||||
array('sexa', 4, false, false, array('ax', 'axe', 'axis')),
|
array('sexa', 4, false, false, array('ax', 'axe', 'axis')),
|
||||||
|
@ -38,7 +38,7 @@ class StringUtilTest extends \PHPUnit_Framework_TestCase
|
|||||||
array('feet', 'foot'),
|
array('feet', 'foot'),
|
||||||
array('nebulae', 'nebula'),
|
array('nebulae', 'nebula'),
|
||||||
array('babies', 'baby'),
|
array('babies', 'baby'),
|
||||||
array('hooves', 'hoof'),
|
array('hooves', array('hoof', 'hoove', 'hooff')),
|
||||||
array('chateaux', 'chateau'),
|
array('chateaux', 'chateau'),
|
||||||
array('echoes', array('echo', 'echoe')),
|
array('echoes', array('echo', 'echoe')),
|
||||||
array('analyses', array('analys', 'analyse', 'analysis')),
|
array('analyses', array('analys', 'analyse', 'analysis')),
|
||||||
@ -64,14 +64,14 @@ class StringUtilTest extends \PHPUnit_Framework_TestCase
|
|||||||
array('batches', array('batch', 'batche')),
|
array('batches', array('batch', 'batche')),
|
||||||
array('bushes', array('bush', 'bushe')),
|
array('bushes', array('bush', 'bushe')),
|
||||||
array('buses', array('bus', 'buse', 'busis')),
|
array('buses', array('bus', 'buse', 'busis')),
|
||||||
array('calves', 'calf'),
|
array('calves', array('calf', 'calve', 'calff')),
|
||||||
array('circuses', array('circus', 'circuse', 'circusis')),
|
array('circuses', array('circus', 'circuse', 'circusis')),
|
||||||
array('crises', array('cris', 'crise', 'crisis')),
|
array('crises', array('cris', 'crise', 'crisis')),
|
||||||
array('dwarves', 'dwarf'),
|
array('dwarves', array('dwarf', 'dwarve', 'dwarff')),
|
||||||
array('elves', 'elf'),
|
array('elves', array('elf', 'elve', 'elff')),
|
||||||
array('emphases', array('emphas', 'emphase', 'emphasis')),
|
array('emphases', array('emphas', 'emphase', 'emphasis')),
|
||||||
array('faxes', 'fax'),
|
array('faxes', 'fax'),
|
||||||
array('halves', 'half'),
|
array('halves', array('half', 'halve', 'halff')),
|
||||||
array('heroes', array('hero', 'heroe')),
|
array('heroes', array('hero', 'heroe')),
|
||||||
array('hoaxes', 'hoax'),
|
array('hoaxes', 'hoax'),
|
||||||
array('irises', array('iris', 'irise', 'irisis')),
|
array('irises', array('iris', 'irise', 'irisis')),
|
||||||
@ -86,13 +86,15 @@ class StringUtilTest extends \PHPUnit_Framework_TestCase
|
|||||||
array('plateaux', 'plateau'),
|
array('plateaux', 'plateau'),
|
||||||
array('poppies', 'poppy'),
|
array('poppies', 'poppy'),
|
||||||
array('quizzes', 'quiz'),
|
array('quizzes', 'quiz'),
|
||||||
array('scarves', 'scarf'),
|
array('scarves', array('scarf', 'scarve', 'scarff')),
|
||||||
array('spies', 'spy'),
|
array('spies', 'spy'),
|
||||||
array('stories', 'story'),
|
array('stories', 'story'),
|
||||||
array('syllabi', 'syllabus'),
|
array('syllabi', 'syllabus'),
|
||||||
array('thieves', 'thief'),
|
array('thieves', array('thief', 'thieve', 'thieff')),
|
||||||
array('waltzes', array('waltz', 'waltze')),
|
array('waltzes', array('waltz', 'waltze')),
|
||||||
array('wharves', 'wharf'),
|
array('wharves', array('wharf', 'wharve', 'wharff')),
|
||||||
|
array('caves', array('caf', 'cave', 'caff')),
|
||||||
|
array('staves', array('staf', 'stave', 'staff')),
|
||||||
array('wives', 'wife'),
|
array('wives', 'wife'),
|
||||||
array('ions', 'ion'),
|
array('ions', 'ion'),
|
||||||
array('bases', array('bas', 'base', 'basis')),
|
array('bases', array('bas', 'base', 'basis')),
|
||||||
|
Reference in New Issue
Block a user