forked from mongodb/laravel-mongodb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDateTimeImmutableTest.php
43 lines (32 loc) · 965 Bytes
/
DateTimeImmutableTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
declare(strict_types=1);
namespace MongoDB\Laravel\Tests\Eloquent;
use Carbon\CarbonImmutable;
use Illuminate\Support\Facades\Date;
use MongoDB\Laravel\Tests\Models\Anniversary;
use MongoDB\Laravel\Tests\TestCase;
use function assert;
final class DateTimeImmutableTest extends TestCase
{
protected function setUp(): void
{
parent::setUp();
Anniversary::truncate();
}
protected function tearDown(): void
{
Date::useDefault();
parent::tearDown();
}
public function testCanReturnCarbonImmutableObject(): void
{
Date::use(CarbonImmutable::class);
Anniversary::create([
'name' => 'John',
'anniversary' => new CarbonImmutable('2020-01-01 00:00:00'),
]);
$anniversary = Anniversary::sole();
assert($anniversary instanceof Anniversary);
self::assertInstanceOf(CarbonImmutable::class, $anniversary->anniversary);
}
}