From bb691ec4272b3ad9ca94e731f75abfc63ed13643 Mon Sep 17 00:00:00 2001 From: Joseph Cohen Date: Sat, 7 Nov 2015 13:20:06 +0000 Subject: [PATCH] Test setting timezone on the api for metric points Signed-off-by: Graham Campbell --- tests/Api/MetricPointTest.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/Api/MetricPointTest.php b/tests/Api/MetricPointTest.php index 2c7bb81a..39569d7a 100644 --- a/tests/Api/MetricPointTest.php +++ b/tests/Api/MetricPointTest.php @@ -11,6 +11,7 @@ namespace CachetHQ\Tests\Cachet\Api; +use Carbon\Carbon; use CachetHQ\Tests\Cachet\AbstractTestCase; use Illuminate\Foundation\Testing\DatabaseMigrations; @@ -72,6 +73,24 @@ class MetricPointTest extends AbstractTestCase $this->seeJson(['value' => $metricPoint->value, 'created_at' => $datetime]); } + public function testPostMetricPointTimestampTimezone() + { + $this->beUser(); + + $timezone = 'America/Mexico_City'; + $metric = factory('CachetHQ\Cachet\Models\Metric')->create(); + $timestamp = Carbon::now()->timezone($timezone)->timestamp; + $datetime = Carbon::now()->toDateTimeString(); + $metricPoint = factory('CachetHQ\Cachet\Models\MetricPoint')->make([ + 'metric_id' => $metric->id, + ]); + $postData = $metricPoint->toArray(); + $postData['timestamp'] = $timestamp; + + $this->post("/api/v1/metrics/{$metric->id}/points", $postData, ['Time-Zone' => $timezone]); + $this->seeJson(['value' => $metricPoint->value, 'created_at' => $datetime]); + } + public function testPutMetricPoint() { $this->beUser();