mirror of
https://github.com/CachetHQ/Cachet.git
synced 2025-01-17 13:38:20 +01:00
Fix tests
This commit is contained in:
parent
55002bb4b4
commit
1ac884805d
@ -92,13 +92,17 @@ class MetricPoint extends Model implements HasPresenter
|
||||
/**
|
||||
* Round the created at value into intervals of 30 seconds.
|
||||
*
|
||||
* @param string $value
|
||||
* @param string $createdAt
|
||||
*
|
||||
* @return void
|
||||
* @return string|void
|
||||
*/
|
||||
public function setCreatedAtAttribute($value)
|
||||
public function setCreatedAtAttribute($createdAt)
|
||||
{
|
||||
$timestamp = $value->format('U');
|
||||
if (!$createdAt) return;
|
||||
|
||||
$createdAt = Carbon::parse($createdAt);
|
||||
|
||||
$timestamp = $createdAt->format('U');
|
||||
$timestamp = 30 * round($timestamp / 30);
|
||||
|
||||
return Carbon::createFromFormat('U', $timestamp)->toDateTimeString();
|
||||
|
@ -78,11 +78,12 @@ class MetricPointTest extends AbstractApiTestCase
|
||||
$postData['timestamp'] = $timestamp;
|
||||
|
||||
$response = $this->json('POST', "/api/v1/metrics/{$metric->id}/points", $postData);
|
||||
$response->dump();
|
||||
|
||||
$response->assertStatus(200);
|
||||
$response->assertJsonFragment([
|
||||
'value' => $metricPoint->value,
|
||||
'created_at' => date('Y-m-d H:i:s', 1434369116),
|
||||
'created_at' => date('Y-m-d H:i:00', 1434369116),
|
||||
]);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user