From f9659719198f278943dd5401e8a260dd840f86c2 Mon Sep 17 00:00:00 2001 From: Makdessi Alex Date: Thu, 13 Feb 2020 15:34:42 +0100 Subject: [PATCH] [VarDumper] fixed DateCaster not displaying additional fields --- .../Component/VarDumper/Caster/DateCaster.php | 6 ++- .../VarDumper/Tests/Caster/DateCasterTest.php | 37 ++++++++++++++++++- .../Tests/Fixtures/DateTimeChild.php | 8 ++++ 3 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 src/Symfony/Component/VarDumper/Tests/Fixtures/DateTimeChild.php diff --git a/src/Symfony/Component/VarDumper/Caster/DateCaster.php b/src/Symfony/Component/VarDumper/Caster/DateCaster.php index f3258b19a6f28..70f229a0d8b7d 100644 --- a/src/Symfony/Component/VarDumper/Caster/DateCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/DateCaster.php @@ -31,7 +31,11 @@ public static function castDateTime(\DateTimeInterface $d, array $a, Stub $stub, .($location ? ($d->format('I') ? "\nDST On" : "\nDST Off") : '') ; - $a = []; + unset( + $a[Caster::PREFIX_DYNAMIC.'date'], + $a[Caster::PREFIX_DYNAMIC.'timezone'], + $a[Caster::PREFIX_DYNAMIC.'timezone_type'] + ); $a[$prefix.'date'] = new ConstStub(self::formatDateTime($d, $location ? ' e (P)' : ' P'), $title); $stub->class .= $d->format(' @U'); diff --git a/src/Symfony/Component/VarDumper/Tests/Caster/DateCasterTest.php b/src/Symfony/Component/VarDumper/Tests/Caster/DateCasterTest.php index da8b4d0fa5c38..87485448dcc90 100644 --- a/src/Symfony/Component/VarDumper/Tests/Caster/DateCasterTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Caster/DateCasterTest.php @@ -16,6 +16,7 @@ use Symfony\Component\VarDumper\Caster\DateCaster; use Symfony\Component\VarDumper\Cloner\Stub; use Symfony\Component\VarDumper\Test\VarDumperTestTrait; +use Symfony\Component\VarDumper\Tests\Fixtures\DateTimeChild; /** * @author Dany Maillard @@ -55,7 +56,7 @@ public function testCastDateTime($time, $timezone, $xDate, $xTimestamp, $xInfos) $stub = new Stub(); $date = new \DateTime($time, new \DateTimeZone($timezone)); - $cast = DateCaster::castDateTime($date, ['foo' => 'bar'], $stub, false, 0); + $cast = DateCaster::castDateTime($date, Caster::castObject($date, \DateTime::class), $stub, false, 0); $xDump = << "foo" + "\\x00~\\x00date" => $xDate +] +EODUMP; + + $this->assertDumpEquals($xDump, $dateCast); + + $xDump = <<assertDumpMatchesFormat($xDump, $dateCast["\0~\0date"]); + } + /** * @dataProvider provideIntervals */ diff --git a/src/Symfony/Component/VarDumper/Tests/Fixtures/DateTimeChild.php b/src/Symfony/Component/VarDumper/Tests/Fixtures/DateTimeChild.php new file mode 100644 index 0000000000000..2ea2df6514ae0 --- /dev/null +++ b/src/Symfony/Component/VarDumper/Tests/Fixtures/DateTimeChild.php @@ -0,0 +1,8 @@ + pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy