diff --git a/app/Bus/Commands/Component/CreateComponentCommand.php b/app/Bus/Commands/Component/CreateComponentCommand.php index d2305fa9..56aa6a7a 100644 --- a/app/Bus/Commands/Component/CreateComponentCommand.php +++ b/app/Bus/Commands/Component/CreateComponentCommand.php @@ -70,7 +70,7 @@ final class CreateComponentCommand /** * JSON meta data for the component. * - * @var string|null + * @var array|null */ public $meta; @@ -87,7 +87,7 @@ final class CreateComponentCommand 'order' => 'nullable|int', 'group_id' => 'nullable|int', 'enabled' => 'nullable|bool', - 'meta' => 'nullable|string', + 'meta' => 'nullable|array', ]; /** @@ -100,7 +100,7 @@ final class CreateComponentCommand * @param int $order * @param int $group_id * @param bool $enabled - * @param string|null $meta + * @param array|null $meta * * @return void */ diff --git a/app/Bus/Commands/Component/UpdateComponentCommand.php b/app/Bus/Commands/Component/UpdateComponentCommand.php index d5b1b01a..52503094 100644 --- a/app/Bus/Commands/Component/UpdateComponentCommand.php +++ b/app/Bus/Commands/Component/UpdateComponentCommand.php @@ -74,7 +74,7 @@ final class UpdateComponentCommand /** * JSON meta data for the component. * - * @var string|null + * @var array|null */ public $meta; @@ -98,7 +98,7 @@ final class UpdateComponentCommand 'order' => 'nullable|int', 'group_id' => 'nullable|int', 'enabled' => 'nullable|bool', - 'meta' => 'nullable|string', + 'meta' => 'nullable|array', 'silent' => 'nullable|bool', ]; @@ -113,7 +113,7 @@ final class UpdateComponentCommand * @param int $order * @param int $group_id * @param bool $enabled - * @param string|null $meta + * @param array|null $meta * @param bool $silent * * @return void diff --git a/app/Bus/Commands/Incident/CreateIncidentCommand.php b/app/Bus/Commands/Incident/CreateIncidentCommand.php index 5ed21694..dde666b7 100644 --- a/app/Bus/Commands/Incident/CreateIncidentCommand.php +++ b/app/Bus/Commands/Incident/CreateIncidentCommand.php @@ -111,7 +111,7 @@ final class CreateIncidentCommand public $rules = [ 'name' => 'required|string', 'status' => 'required|int|min:0|max:4', - 'message' => 'required|string', + 'message' => 'nullable|string', 'visible' => 'nullable|bool', 'component_id' => 'nullable|required_with:component_status|int', 'component_status' => 'nullable|required_with:component_id|int|min:0|max:4', @@ -119,7 +119,7 @@ final class CreateIncidentCommand 'stickied' => 'required|bool', 'occurred_at' => 'nullable|string', 'template' => 'nullable|string', - 'meta' => 'required|array', + 'meta' => 'nullable|array', ]; /** diff --git a/app/Bus/Commands/Metric/CreateMetricPointCommand.php b/app/Bus/Commands/Metric/CreateMetricPointCommand.php index a6b7e0a1..8f33f4a4 100644 --- a/app/Bus/Commands/Metric/CreateMetricPointCommand.php +++ b/app/Bus/Commands/Metric/CreateMetricPointCommand.php @@ -38,7 +38,7 @@ final class CreateMetricPointCommand /** * The metric point created at. * - * @var string + * @var int */ public $created_at; @@ -49,7 +49,7 @@ final class CreateMetricPointCommand */ public $rules = [ 'value' => 'required|numeric', - 'created_at' => 'required|string', + 'created_at' => 'nullable|int', ]; /** @@ -57,7 +57,7 @@ final class CreateMetricPointCommand * * @param \CachetHQ\Cachet\Models\Metric $metric * @param int $value - * @param string $created_at + * @param int $created_at * * @return void */ diff --git a/app/Bus/Commands/Metric/UpdateMetricCommand.php b/app/Bus/Commands/Metric/UpdateMetricCommand.php index 9ef77011..aa713408 100644 --- a/app/Bus/Commands/Metric/UpdateMetricCommand.php +++ b/app/Bus/Commands/Metric/UpdateMetricCommand.php @@ -116,7 +116,7 @@ final class UpdateMetricCommand 'default_view' => 'nullable|numeric|between:0,4', 'threshold' => 'nullable|int', 'order' => 'nullable|int', - 'visible' => 'required|int|between:0,2', + 'visible' => 'nullable|int|between:0,2', ]; /** diff --git a/app/Bus/Commands/Schedule/CreateScheduleCommand.php b/app/Bus/Commands/Schedule/CreateScheduleCommand.php index 4268e68d..ebeec0d8 100644 --- a/app/Bus/Commands/Schedule/CreateScheduleCommand.php +++ b/app/Bus/Commands/Schedule/CreateScheduleCommand.php @@ -71,7 +71,7 @@ final class CreateScheduleCommand 'status' => 'required|int|min:0|max:2', 'scheduled_at' => 'required|string', 'completed_at' => 'nullable|string', - 'components' => 'required|array', + 'components' => 'nullable|array', ]; /** @@ -86,7 +86,7 @@ final class CreateScheduleCommand * * @return void */ - public function __construct($name, $message, $status, $scheduled_at, $completed_at, array $components) + public function __construct($name, $message, $status, $scheduled_at, $completed_at, array $components = []) { $this->name = $name; $this->message = $message; diff --git a/app/Foundation/Providers/AppServiceProvider.php b/app/Foundation/Providers/AppServiceProvider.php index 08cbe5bd..c652b039 100644 --- a/app/Foundation/Providers/AppServiceProvider.php +++ b/app/Foundation/Providers/AppServiceProvider.php @@ -12,6 +12,7 @@ namespace CachetHQ\Cachet\Foundation\Providers; use AltThree\Bus\Dispatcher; +use AltThree\Validator\ValidatingMiddleware; use CachetHQ\Cachet\Bus\Middleware\UseDatabaseTransactions; use CachetHQ\Cachet\Services\Dates\DateFactory; use Illuminate\Database\Eloquent\Relations\Relation; @@ -41,7 +42,7 @@ class AppServiceProvider extends ServiceProvider return Dispatcher::simpleMapping($command, 'CachetHQ\Cachet\Bus', 'CachetHQ\Cachet\Bus\Handlers'); }); - $dispatcher->pipeThrough([UseDatabaseTransactions::class]); + $dispatcher->pipeThrough([UseDatabaseTransactions::class, ValidatingMiddleware::class]); Str::macro('canonicalize', function ($url) { return preg_replace('/([^\/])$/', '$1/', $url); diff --git a/tests/Api/MetricPointTest.php b/tests/Api/MetricPointTest.php index 7e12c9f7..c2a88f42 100644 --- a/tests/Api/MetricPointTest.php +++ b/tests/Api/MetricPointTest.php @@ -70,7 +70,6 @@ class MetricPointTest extends AbstractApiTestCase $metric = factory('CachetHQ\Cachet\Models\Metric')->create(); $timestamp = 1434369116; - $datetime = '2015-06-15 11:51:56'; $metricPoint = factory('CachetHQ\Cachet\Models\MetricPoint')->make([ 'metric_id' => $metric->id, ]); @@ -79,7 +78,10 @@ class MetricPointTest extends AbstractApiTestCase $this->post("/api/v1/metrics/{$metric->id}/points", $postData); - $this->seeJsonContains(['value' => $metricPoint->value, 'created_at' => $datetime]); + $this->seeJsonContains([ + 'value' => $metricPoint->value, + 'created_at' => date('Y-m-d H:i:s', 1434369116), + ]); $this->assertResponseOk(); }