8000 [Form] Support \DateTimeImmutable by vudaltsov · Pull Request #25582 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Added instanceof assertions.
  • Loading branch information
vudaltsov committed Feb 6, 2018
commit 1eff2b5963e0c7875b1d45012b801a5a71ef3af8
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ public function testTransform()
$transformer = new DateTimeImmutableToDateTimeTransformer();

$input = new \DateTimeImmutable('2010-02-03 04:05:06 UTC');
$output = new \DateTime('2010-02-03 04:05:06 UTC');
$expectedOutput = new \DateTime('2010-02-03 04:05:06 UTC');
$actualOutput = $transformer->transform($input);

$this->assertEquals($output, $transformer->transform($input));
$this->assertInstanceOf(\DateTime::class, $actualOutput);
$this->assertEquals($expectedOutput, $actualOutput);
}

public function testTransformEmpty()
Expand All @@ -48,9 +50,11 @@ public function testReverseTransform()
$transformer = new DateTimeImmutableToDateTimeTransformer();

$input = new \DateTime('2010-02-03 04:05:06 UTC');
$output = new \DateTimeImmutable('2010-02-03 04:05:06 UTC');
$expectedOutput = new \DateTimeImmutable('2010-02-03 04:05:06 UTC');
$actualOutput = $transformer->reverseTransform($input);

$this->assertEquals($output, $transformer->reverseTransform($input));
$this->assertInstanceOf(\DateTimeImmutable::class, $actualOutput);
$this->assertEquals($expectedOutput, $actualOutput);
}

public function testReverseTransformEmpty()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ public function testSubmitDifferentTimezonesDateTimeImmutable()

$outputTime = $outputTime->setTimezone(new \DateTimeZone('America/New_York'));

$this->assertInstanceOf(\DateTimeImmutable::class, $form->getData());
$this->assertEquals($outputTime, $form->getData());
$this->assertEquals('2010-06-02T03:04:00-10:00', $form->getViewData());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ public function testSubmitFromSingleTextDateTimeImmutable()

$form->submit('2.6.2010');

$this->assertInstanceOf(\DateTimeImmutable::class, $form->getData());
$this->assertEquals(new \DateTimeImmutable('2010-06-02 UTC'), $form->getData());
$this->assertEquals('02.06.2010', $form->getViewData());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public function testSubmitDateTimeImmutable()

$dateTime = new \DateTimeImmutable('1970-01-01 03:04:00 UTC');

$this->assertInstanceOf(\DateTimeImmutable::class, $form->getData());
$this->assertEquals($dateTime, $form->getData());
$this->assertEquals($input, $form->getViewData());
}
Expand Down
0