From eda0bc578e37807a7cacd97591568cd232ef8331 Mon Sep 17 00:00:00 2001 From: webchick Date: Tue, 5 Aug 2014 21:55:48 -0700 Subject: [PATCH] Issue #2316153 by Berdir: Fixed PHP 5.4.30/5.5.15+ changed json_encode() of DateTime objects to include microseconds, breaks tests. --- .../form_test/src/Form/FormTestDisabledElementsForm.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestDisabledElementsForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestDisabledElementsForm.php index da3b8a2de31..d768de689ec 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestDisabledElementsForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestDisabledElementsForm.php @@ -128,7 +128,11 @@ class FormTestDisabledElementsForm extends FormBase { // Date. $date = new DrupalDateTime('1978-11-01 10:30:00', 'Europe/Berlin'); - $expected = array('date' => '1978-11-01 10:30:00', 'timezone_type' => 3, 'timezone' => 'Europe/Berlin',); + // Starting with PHP 5.4.30, 5.5.15, JSON encoded DateTime objects include + // microsends. Make sure that the expected value is correct for all versions + // by encoding and decoding it again instead of hardcoding it. + // See https://github.com/php/php-src/commit/fdb2709dd27c5987c2d2c8aaf0cdbebf9f17f643 + $expected = json_decode(json_encode($date), TRUE); $form['disabled_container']['disabled_container_datetime'] = array( '#type' => 'datetime', '#title' => 'datetime',