Skip to content

Commit d715a63

Browse files
authored
[1.x] Adds tests regarding carbon instances (#82)
* Adds tests regarding carbon instances * Fixes matrix laravel name * Uses setTestNow
1 parent ebe4d98 commit d715a63

File tree

3 files changed

+34
-4
lines changed

3 files changed

+34
-4
lines changed

.github/workflows/tests.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,22 @@ jobs:
1717
fail-fast: true
1818
matrix:
1919
php: [7.3, 7.4, '8.0', 8.1, 8.2, 8.3]
20-
21-
name: PHP ${{ matrix.php }}
20+
laravel: [8, 9, 10, 11]
21+
exclude:
22+
- php: 7.3
23+
laravel: [9, 10, 11]
24+
- php: 7.4
25+
laravel: [9, 10, 11]
26+
- php: 8.0
27+
laravel: [10, 11]
28+
- php: 8.1
29+
laravel: [8, 11]
30+
- php: 8.2
31+
laravel: 8
32+
- php: 8.3
33+
laravel: 8
34+
35+
name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }}
2236

2337
steps:
2438
- name: Checkout code

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@
2121
"php": "^7.3|^8.0"
2222
},
2323
"require-dev": {
24-
"nesbot/carbon": "^2.61",
24+
"illuminate/support": "^8.0|^9.0|^10.0|^11.0",
25+
"nesbot/carbon": "^2.61|^3.0",
2526
"pestphp/pest": "^1.21.3",
2627
"phpstan/phpstan": "^1.8.2",
27-
"symfony/var-dumper": "^5.4.11"
28+
"symfony/var-dumper": "^5.4.11|^6.2.0|^7.0.0"
2829
},
2930
"autoload": {
3031
"psr-4": {

tests/SerializerPhp81Test.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
use Illuminate\Support\Carbon;
34
use Tests\Fixtures\Model;
45
use Tests\Fixtures\ModelAttribute;
56
use Tests\Fixtures\RegularClass;
@@ -681,6 +682,20 @@ public function getClosure()
681682
expect(s($f1)())->toBeInstanceOf(RegularClass::class);
682683
})->with('serializers');
683684

685+
test('carbon serialization', function () {
686+
$now = Carbon::createFromDate(2011, 1, 1);
687+
688+
Carbon::setTestNow($now);
689+
690+
$startDate = Carbon::now();
691+
692+
$f1 = fn () => $startDate;
693+
694+
expect(s($f1)())
695+
->toBeInstanceOf(Carbon::class)
696+
->format('Y-m-d')->toBe('2011-01-01');
697+
})->with('serializers');
698+
684699
class ClassWithBackedEnumProperty
685700
{
686701
public SerializerGlobalBackedEnum $enum = SerializerGlobalBackedEnum::Admin;

0 commit comments

Comments
 (0)