From 255544f19481978d62be254191372e128ead8b9b Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Thu, 15 May 2014 08:35:53 +0100 Subject: [PATCH 1/3] [HttpKernel] Replace sha1 with sha256 in recently added tests. --- .../Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php index d2342aac40..f1c467d76b 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php @@ -609,12 +609,11 @@ class HttpCacheTest extends HttpCacheTestCase $values = $this->getMetaStorageValues(); $this->assertCount(1, $values); $tmp = unserialize($values[0]); - $time = \DateTime::createFromFormat('U', time()); $tmp[0][1]['date'] = \DateTime::createFromFormat('U', time() - 5)->format(DATE_RFC2822); $r = new \ReflectionObject($this->store); $m = $r->getMethod('save'); $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->assertHttpKernelIsCalled(); @@ -659,12 +658,11 @@ class HttpCacheTest extends HttpCacheTestCase $values = $this->getMetaStorageValues(); $this->assertCount(1, $values); $tmp = unserialize($values[0]); - $time = \DateTime::createFromFormat('U', time()); $tmp[0][1]['date'] = \DateTime::createFromFormat('U', time() - 5)->format(DATE_RFC2822); $r = new \ReflectionObject($this->store); $m = $r->getMethod('save'); $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->assertHttpKernelIsCalled(); From c7a77c55b74a078f3c2f1ff55e7e876f6315936e Mon Sep 17 00:00:00 2001 From: Charles Sarrazin Date: Fri, 16 May 2014 11:21:11 +0200 Subject: [PATCH 2/3] Fixed incorrect regular plural for -ves words Fixes singularization for words like caves (cave), staves (staff). --- .../Component/PropertyAccess/StringUtil.php | 4 ++-- .../PropertyAccess/Tests/StringUtilTest.php | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/Symfony/Component/PropertyAccess/StringUtil.php b/src/Symfony/Component/PropertyAccess/StringUtil.php index 509bce4b92..50a8eb4092 100644 --- a/src/Symfony/Component/PropertyAccess/StringUtil.php +++ b/src/Symfony/Component/PropertyAccess/StringUtil.php @@ -81,8 +81,8 @@ class StringUtil // moves (move) array('sevom', 5, true, true, 'move'), - // hooves (hoof), dwarves (dwarf), elves (elf), leaves (leaf) - array('sev', 3, true, true, 'f'), + // hooves (hoof), dwarves (dwarf), elves (elf), leaves (leaf), caves (cave), staves (staff) + array('sev', 3, true, true, array('f', 've', 'ff')), // axes (axis), axes (ax), axes (axe) array('sexa', 4, false, false, array('ax', 'axe', 'axis')), diff --git a/src/Symfony/Component/PropertyAccess/Tests/StringUtilTest.php b/src/Symfony/Component/PropertyAccess/Tests/StringUtilTest.php index e33f01dd9c..92df8f1f73 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/StringUtilTest.php +++ b/src/Symfony/Component/PropertyAccess/Tests/StringUtilTest.php @@ -38,7 +38,7 @@ class StringUtilTest extends \PHPUnit_Framework_TestCase array('feet', 'foot'), array('nebulae', 'nebula'), array('babies', 'baby'), - array('hooves', 'hoof'), + array('hooves', array('hoof', 'hoove', 'hooff')), array('chateaux', 'chateau'), array('echoes', array('echo', 'echoe')), array('analyses', array('analys', 'analyse', 'analysis')), @@ -64,14 +64,14 @@ class StringUtilTest extends \PHPUnit_Framework_TestCase array('batches', array('batch', 'batche')), array('bushes', array('bush', 'bushe')), array('buses', array('bus', 'buse', 'busis')), - array('calves', 'calf'), + array('calves', array('calf', 'calve', 'calff')), array('circuses', array('circus', 'circuse', 'circusis')), array('crises', array('cris', 'crise', 'crisis')), - array('dwarves', 'dwarf'), - array('elves', 'elf'), + array('dwarves', array('dwarf', 'dwarve', 'dwarff')), + array('elves', array('elf', 'elve', 'elff')), array('emphases', array('emphas', 'emphase', 'emphasis')), array('faxes', 'fax'), - array('halves', 'half'), + array('halves', array('half', 'halve', 'halff')), array('heroes', array('hero', 'heroe')), array('hoaxes', 'hoax'), array('irises', array('iris', 'irise', 'irisis')), @@ -86,13 +86,15 @@ class StringUtilTest extends \PHPUnit_Framework_TestCase array('plateaux', 'plateau'), array('poppies', 'poppy'), array('quizzes', 'quiz'), - array('scarves', 'scarf'), + array('scarves', array('scarf', 'scarve', 'scarff')), array('spies', 'spy'), array('stories', 'story'), array('syllabi', 'syllabus'), - array('thieves', 'thief'), + array('thieves', array('thief', 'thieve', 'thieff')), 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('ions', 'ion'), array('bases', array('bas', 'base', 'basis')), From a379298db9c7323780e45b7e80e84f94f0c41c59 Mon Sep 17 00:00:00 2001 From: Tugdual Saunier Date: Tue, 4 Mar 2014 11:12:50 +0000 Subject: [PATCH 3/3] [Form] Automatically add step attribute to HTML5 time widgets to display seconds if needed --- .../Form/Extension/Core/Type/TimeType.php | 8 ++++++ .../Extension/Core/Type/TimeTypeTest.php | 27 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php b/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php index d7a2a9efba..6bf41517ac 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php @@ -140,6 +140,14 @@ class TimeType extends AbstractType if ('single_text' === $options['widget']) { $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; + } } } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php index 9bdfe1567b..ca186207ac 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php @@ -492,6 +492,33 @@ class TimeTypeTest extends TypeTestCase $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() { $form = $this->factory->create('time', null, array(