SetStateTest.php 950 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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\CarbonImmutable;
  12. use Carbon\Traits\Serialization;
  13. use stdClass;
  14. use Tests\AbstractTestCase;
  15. class SetStateTest extends AbstractTestCase
  16. {
  17. public function testSteState()
  18. {
  19. $obj = new class() {
  20. use Serialization;
  21. public static function instance($value)
  22. {
  23. return $value;
  24. }
  25. public function callSetState($value)
  26. {
  27. return static::__set_state($value);
  28. }
  29. };
  30. $data = $obj->callSetState(['foo' => 'bar']);
  31. $this->assertInstanceOf(stdClass::class, $data);
  32. $this->assertSame(['foo' => 'bar'], (array) $data);
  33. }
  34. }