From edc9a45e53b303128973a61ffbf3662acc2eddef Mon Sep 17 00:00:00 2001 From: Joe Cohen Date: Tue, 3 Jul 2018 13:29:16 -0500 Subject: [PATCH] Set test now and use config date --- tests/Api/MetricPointTest.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/Api/MetricPointTest.php b/tests/Api/MetricPointTest.php index ed19fb47..c9f4ffdf 100644 --- a/tests/Api/MetricPointTest.php +++ b/tests/Api/MetricPointTest.php @@ -100,6 +100,9 @@ class MetricPointTest extends AbstractApiTestCase { $this->beUser(); + // prevent tests breaking due to rolling into the next second + Carbon::setTestNow(Carbon::now()); + $metric = factory(Metric::class)->create(); $createdAt = Carbon::now(); $metricPoint = factory(MetricPoint::class)->make([ @@ -116,7 +119,7 @@ class MetricPointTest extends AbstractApiTestCase $response->assertStatus(200); $response->assertJsonFragment([ 'value' => $metricPoint->value, - 'created_at' => Carbon::createFromFormat('U', $timestamp)->setTimezone('Europe/London')->toDateTimeString(), + 'created_at' => Carbon::createFromFormat('U', $timestamp)->setTimezone(config('cachet.timezone'))->toDateTimeString(), ]); }