|
1 | 1 | <?php
|
2 | 2 |
|
| 3 | +use Carbon\Carbon; |
| 4 | +use Carbon\CarbonImmutable; |
3 | 5 | use Laravel\SerializableClosure\SerializableClosure;
|
4 | 6 | use Laravel\SerializableClosure\Serializers\Signed;
|
5 | 7 | use Laravel\SerializableClosure\Support\ReflectionClosure;
|
@@ -401,31 +403,40 @@ function () {
|
401 | 403 | expect($f(new Model))->toBeInstanceOf(Model::class);
|
402 | 404 | })->with('serializers');
|
403 | 405 |
|
404 |
| -test('serializes carbon objects', function () { |
405 |
| - $carbon = new \Carbon\Carbon('now'); |
406 |
| - |
407 |
| - $closure = function () use ($carbon) { |
408 |
| - return $carbon; |
| 406 | +test('serializes used dates', function ($_, $date) { |
| 407 | + $closure = function () use ($date) { |
| 408 | + return $date; |
409 | 409 | };
|
410 | 410 |
|
411 | 411 | $u = s($closure);
|
412 | 412 | $r = $u();
|
413 | 413 |
|
414 |
| - expect($r)->toEqual($carbon); |
415 |
| -})->with('serializers'); |
| 414 | + expect($r)->toEqual($date); |
| 415 | +})->with('serializers')->with([ |
| 416 | + new DateTime, |
| 417 | + new DateTimeImmutable, |
| 418 | + new Carbon, |
| 419 | + new CarbonImmutable, |
| 420 | +]); |
416 | 421 |
|
417 |
| -test('serializes carbon immutable objects', function () { |
418 |
| - $carbon = new \Carbon\CarbonImmutable('now'); |
| 422 | +test('serializes with used object date properties', function ($_, $date) { |
| 423 | + $obj = new ObjSelf; |
| 424 | + $obj->o = $date; |
419 | 425 |
|
420 |
| - $closure = function () use ($carbon) { |
421 |
| - return $carbon; |
| 426 | + $closure = function () use ($obj) { |
| 427 | + return $obj; |
422 | 428 | };
|
423 | 429 |
|
424 | 430 | $u = s($closure);
|
425 | 431 | $r = $u();
|
426 | 432 |
|
427 |
| - expect($r)->toEqual($carbon); |
428 |
| -})->with('serializers'); |
| 433 | + expect($r->o)->toEqual($date); |
| 434 | +})->with('serializers')->with([ |
| 435 | + new DateTime, |
| 436 | + new DateTimeImmutable, |
| 437 | + new Carbon, |
| 438 | + new CarbonImmutable, |
| 439 | +]); |
429 | 440 |
|
430 | 441 | class A
|
431 | 442 | {
|
|
0 commit comments