mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-11 09:42:15 +01:00
Fixed test case and travelTo function in test cases
This commit is contained in:
committed by
Constantin Graf
parent
86555664c5
commit
b0cdeb3e33
@@ -5,8 +5,10 @@ declare(strict_types=1);
|
||||
namespace Tests;
|
||||
|
||||
use App\Service\PermissionStore;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use TiMacDonald\Log\LogFake;
|
||||
|
||||
@@ -32,4 +34,17 @@ abstract class TestCase extends BaseTestCase
|
||||
{
|
||||
$this->assertEqualsCanonicalizing($ids, $models->pluck('id')->toArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current time to the given time.
|
||||
* This method fixes a bug, that setting the test now with Carbon::setTestNow() with a Carbon instance that has a timezone set, will not work as expected.
|
||||
* IT will also set the timezone for model casts with type "datetime" to the timezone and not use the timezone configured in the configuration "app.timezone".
|
||||
*
|
||||
* @param Carbon|CarbonImmutable $date
|
||||
* @param callable|null $callback
|
||||
*/
|
||||
public function travelTo($date, $callback = null): void
|
||||
{
|
||||
parent::travelTo($date->utc());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user