ValueExporterTest.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\HttpKernel\Tests\DataCollector\Util;
  11. use PHPUnit\Framework\TestCase;
  12. use Symfony\Component\HttpKernel\DataCollector\Util\ValueExporter;
  13. /**
  14. * @group legacy
  15. */
  16. class ValueExporterTest extends TestCase
  17. {
  18. /**
  19. * @var ValueExporter
  20. */
  21. private $valueExporter;
  22. protected function setUp()
  23. {
  24. $this->valueExporter = new ValueExporter();
  25. }
  26. public function testDateTime()
  27. {
  28. $dateTime = new \DateTime('2014-06-10 07:35:40', new \DateTimeZone('UTC'));
  29. $this->assertSame('Object(DateTime) - 2014-06-10T07:35:40+00:00', $this->valueExporter->exportValue($dateTime));
  30. }
  31. public function testDateTimeImmutable()
  32. {
  33. $dateTime = new \DateTimeImmutable('2014-06-10 07:35:40', new \DateTimeZone('UTC'));
  34. $this->assertSame('Object(DateTimeImmutable) - 2014-06-10T07:35:40+00:00', $this->valueExporter->exportValue($dateTime));
  35. }
  36. public function testIncompleteClass()
  37. {
  38. $foo = new \__PHP_Incomplete_Class();
  39. $array = new \ArrayObject($foo);
  40. $array['__PHP_Incomplete_Class_Name'] = 'AppBundle/Foo';
  41. $this->assertSame('__PHP_Incomplete_Class(AppBundle/Foo)', $this->valueExporter->exportValue($foo));
  42. }
  43. }