From: Christian Flothmann <christian.flothmann@sensiolabs.de>
Date: Sun, 1 Jan 2017 13:18:05 +0100
X-Dgit-Generated: 2.8.7+dfsg-1.1 804ee09c5a98f4ff4ed1132b68bf4c4afa17facc
Subject: Do not depend on a fixed date in layout tests

By default, the `DateType` as well as the `DateTimeType` set the choices
being available for the year to a range starting five years in the past.
After some time, this will make tests fail when the year of the fixed
date being used as the initial data is before the first year being part
of the choices.

Origin: backport, https://github.com/symfony/symfony/commit/97b7fabf519b48333b772924b141f84efdb44c1e

---

--- symfony-2.8.7+dfsg.orig/src/Symfony/Component/Form/Tests/AbstractBootstrap3LayoutTest.php
+++ symfony-2.8.7+dfsg/src/Symfony/Component/Form/Tests/AbstractBootstrap3LayoutTest.php
@@ -1346,7 +1346,7 @@ abstract class AbstractBootstrap3LayoutT
 
     public function testDateTime()
     {
-        $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', '2011-02-03 04:05:06', array(
+        $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', date('Y').'-02-03 04:05:06', array(
             'input' => 'string',
             'with_seconds' => false,
         ));
@@ -1365,7 +1365,7 @@ abstract class AbstractBootstrap3LayoutT
         /following-sibling::select
             [@id="name_date_year"]
             [@class="form-control"]
-            [./option[@value="2011"][@selected="selected"]]
+            [./option[@value="'.date('Y').'"][@selected="selected"]]
         /following-sibling::select
             [@id="name_time_hour"]
             [@class="form-control"]
@@ -1420,7 +1420,7 @@ abstract class AbstractBootstrap3LayoutT
 
     public function testDateTimeWithHourAndMinute()
     {
-        $data = array('year' => '2011', 'month' => '2', 'day' => '3', 'hour' => '4', 'minute' => '5');
+        $data = array('year' => date('Y'), 'month' => '2', 'day' => '3', 'hour' => '4', 'minute' => '5');
 
         $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', $data, array(
             'input' => 'array',
@@ -1442,7 +1442,7 @@ abstract class AbstractBootstrap3LayoutT
         /following-sibling::select
             [@id="name_date_year"]
             [@class="form-control"]
-            [./option[@value="2011"][@selected="selected"]]
+            [./option[@value="'.date('Y').'"][@selected="selected"]]
         /following-sibling::select
             [@id="name_time_hour"]
             [@class="form-control"]
@@ -1459,7 +1459,7 @@ abstract class AbstractBootstrap3LayoutT
 
     public function testDateTimeWithSeconds()
     {
-        $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', '2011-02-03 04:05:06', array(
+        $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', date('Y').'-02-03 04:05:06', array(
             'input' => 'string',
             'with_seconds' => true,
         ));
@@ -1479,7 +1479,7 @@ abstract class AbstractBootstrap3LayoutT
         /following-sibling::select
             [@id="name_date_year"]
             [@class="form-control"]
-            [./option[@value="2011"][@selected="selected"]]
+            [./option[@value="'.date('Y').'"][@selected="selected"]]
         /following-sibling::select
             [@id="name_time_hour"]
             [@class="form-control"]
@@ -1569,7 +1569,7 @@ abstract class AbstractBootstrap3LayoutT
 
     public function testDateChoice()
     {
-        $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType', '2011-02-03', array(
+        $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType', date('Y').'-02-03', array(
             'input' => 'string',
             'widget' => 'choice',
         ));
@@ -1589,7 +1589,7 @@ abstract class AbstractBootstrap3LayoutT
         /following-sibling::select
             [@id="name_year"]
             [@class="form-control"]
-            [./option[@value="2011"][@selected="selected"]]
+            [./option[@value="'.date('Y').'"][@selected="selected"]]
     ]
     [count(./select)=3]
 '
--- symfony-2.8.7+dfsg.orig/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php
+++ symfony-2.8.7+dfsg/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php
@@ -1251,7 +1251,7 @@ abstract class AbstractLayoutTest extend
 
     public function testDateTime()
     {
-        $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', '2011-02-03 04:05:06', array(
+        $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', date('Y').'-02-03 04:05:06', array(
             'input' => 'string',
             'with_seconds' => false,
         ));
@@ -1270,7 +1270,7 @@ abstract class AbstractLayoutTest extend
                     [./option[@value="3"][@selected="selected"]]
                 /following-sibling::select
                     [@id="name_date_year"]
-                    [./option[@value="2011"][@selected="selected"]]
+                    [./option[@value="'.date('Y').'"][@selected="selected"]]
             ]
         /following-sibling::div
             [@id="name_time"]
@@ -1330,7 +1330,7 @@ abstract class AbstractLayoutTest extend
 
     public function testDateTimeWithHourAndMinute()
     {
-        $data = array('year' => '2011', 'month' => '2', 'day' => '3', 'hour' => '4', 'minute' => '5');
+        $data = array('year' => date('Y'), 'month' => '2', 'day' => '3', 'hour' => '4', 'minute' => '5');
 
         $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', $data, array(
             'input' => 'array',
@@ -1351,7 +1351,7 @@ abstract class AbstractLayoutTest extend
                     [./option[@value="3"][@selected="selected"]]
                 /following-sibling::select
                     [@id="name_date_year"]
-                    [./option[@value="2011"][@selected="selected"]]
+                    [./option[@value="'.date('Y').'"][@selected="selected"]]
             ]
         /following-sibling::div
             [@id="name_time"]
@@ -1371,7 +1371,7 @@ abstract class AbstractLayoutTest extend
 
     public function testDateTimeWithSeconds()
     {
-        $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', '2011-02-03 04:05:06', array(
+        $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', date('Y').'-02-03 04:05:06', array(
             'input' => 'string',
             'with_seconds' => true,
         ));
@@ -1390,7 +1390,7 @@ abstract class AbstractLayoutTest extend
                     [./option[@value="3"][@selected="selected"]]
                 /following-sibling::select
                     [@id="name_date_year"]
-                    [./option[@value="2011"][@selected="selected"]]
+                    [./option[@value="'.date('Y').'"][@selected="selected"]]
             ]
         /following-sibling::div
             [@id="name_time"]
@@ -1477,7 +1477,7 @@ abstract class AbstractLayoutTest extend
 
     public function testDateChoice()
     {
-        $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType', '2011-02-03', array(
+        $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType', date('Y').'-02-03', array(
             'input' => 'string',
             'widget' => 'choice',
         ));
@@ -1493,7 +1493,7 @@ abstract class AbstractLayoutTest extend
             [./option[@value="3"][@selected="selected"]]
         /following-sibling::select
             [@id="name_year"]
-            [./option[@value="2011"][@selected="selected"]]
+            [./option[@value="'.date('Y').'"][@selected="selected"]]
     ]
     [count(./select)=3]
 '
