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. class ValueExporterTest extends TestCase
  14. {
  15. /**
  16. * @var ValueExporter
  17. */
  18. private $valueExporter;
  19. protected function setUp()
  20. {
  21. $this->valueExporter = new ValueExporter();
  22. }
  23. public function testDateTime()
  24. {
  25. $dateTime = new \DateTime('2014-06-10 07:35:40', new \DateTimeZone('UTC'));
  26. $this->assertSame('Object(DateTime) - 2014-06-10T07:35:40+00:00', $this->valueExporter->exportValue($dateTime));
  27. }
  28. /**
  29. * @requires PHP 5.5
  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. }