SetStateTest.php 982 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * This file is part of the Carbon package.
  5. *
  6. * (c) Brian Nesbitt <brian@nesbot.com>
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. namespace Tests\CarbonInterval;
  12. use Carbon\CarbonInterval;
  13. use Tests\AbstractTestCase;
  14. class SetStateTest extends AbstractTestCase
  15. {
  16. public function testEvaluatingVarExportReturnsCarbonIntervalInstance()
  17. {
  18. $export = var_export(CarbonInterval::minutes(3), true);
  19. $this->assertInstanceOfCarbonInterval(eval("return $export;"));
  20. }
  21. public function testStateIsPreserved()
  22. {
  23. $serializedInterval = CarbonInterval::minutes(3);
  24. $export = var_export($serializedInterval, true);
  25. /** @var CarbonInterval $deserializedInterval */
  26. $deserializedInterval = eval("return $export;");
  27. $this->assertTrue($deserializedInterval->eq($serializedInterval));
  28. }
  29. }