From 127d0d0d556d42dba221d2e037c27487c0c2d80c Mon Sep 17 00:00:00 2001 From: James Brooks Date: Sat, 3 Oct 2015 16:34:11 +0100 Subject: [PATCH] Added command tests --- .../Component/AddComponentCommand.php | 2 +- .../Component/RemoveComponentCommand.php | 2 +- .../Component/UpdateComponentCommand.php | 2 +- .../AddComponentGroupCommand.php | 2 +- .../RemoveComponentGroupCommand.php | 2 +- .../UpdateComponentGroupCommand.php | 2 +- .../Incident/RemoveIncidentCommand.php | 2 +- .../Incident/ReportIncidentCommand.php | 2 +- .../Incident/ReportMaintenanceCommand.php | 2 +- .../Incident/UpdateIncidentCommand.php | 2 +- app/Commands/Metric/AddMetricCommand.php | 2 +- app/Commands/Metric/AddMetricPointCommand.php | 2 +- app/Commands/Metric/RemoveMetricCommand.php | 2 +- .../Metric/RemoveMetricPointCommand.php | 2 +- app/Commands/Metric/UpdateMetricCommand.php | 2 +- .../Metric/UpdateMetricPointCommand.php | 2 +- .../Subscriber/SubscribeSubscriberCommand.php | 4 +- .../UnsubscribeSubscriberCommand.php | 4 +- .../Subscriber/VerifySubscriberCommand.php | 4 +- app/Commands/User/AddTeamMemberCommand.php | 13 +++- app/Commands/User/GenerateApiTokenCommand.php | 2 +- app/Commands/User/RemoveUserCommand.php | 2 +- tests/Commands/AbstractCommandTestCase.php | 31 +++++++++ .../Component/AddComponentCommandTest.php | 56 +++++++++++++++++ .../Component/RemoveComponentCommandTest.php | 43 +++++++++++++ .../Component/UpdateComponentCommandTest.php | 59 +++++++++++++++++ .../AddComponentGroupCommandTest.php | 48 ++++++++++++++ .../RemoveComponentGroupCommandTest.php | 43 +++++++++++++ .../UpdateComponentGroupCommandTest.php | 47 ++++++++++++++ .../Incident/RemoveIncidentCommandTest.php | 43 +++++++++++++ .../Incident/ReportIncidentCommandTest.php | 60 ++++++++++++++++++ .../Incident/ReportMaintenanceCommandTest.php | 52 +++++++++++++++ .../Incident/UpdateIncidentCommandTest.php | 63 +++++++++++++++++++ .../Commands/Metric/AddMetricCommandTest.php | 58 +++++++++++++++++ .../Metric/AddMetricPointCommandTest.php | 51 +++++++++++++++ .../Metric/RemoveMetricCommandTest.php | 43 +++++++++++++ .../Metric/RemoveMetricPointCommandTest.php | 43 +++++++++++++ .../Metric/UpdateMetricCommandTest.php | 61 ++++++++++++++++++ .../Metric/UpdateMetricPointCommandTest.php | 54 ++++++++++++++++ .../SubscribeSubscriberCommandTest.php | 48 ++++++++++++++ .../UnsubscribeSubscriberCommandTest.php | 43 +++++++++++++ .../VerifySubscriberCommandTest.php | 43 +++++++++++++ .../User/AddTeamMemberCommandTest.php | 52 +++++++++++++++ .../User/GenerateApiTokenCommandTest.php | 43 +++++++++++++ tests/Commands/User/RemoveUserCommandTest.php | 43 +++++++++++++ 45 files changed, 1163 insertions(+), 25 deletions(-) create mode 100644 tests/Commands/AbstractCommandTestCase.php create mode 100644 tests/Commands/Component/AddComponentCommandTest.php create mode 100644 tests/Commands/Component/RemoveComponentCommandTest.php create mode 100644 tests/Commands/Component/UpdateComponentCommandTest.php create mode 100644 tests/Commands/ComponentGroup/AddComponentGroupCommandTest.php create mode 100644 tests/Commands/ComponentGroup/RemoveComponentGroupCommandTest.php create mode 100644 tests/Commands/ComponentGroup/UpdateComponentGroupCommandTest.php create mode 100644 tests/Commands/Incident/RemoveIncidentCommandTest.php create mode 100644 tests/Commands/Incident/ReportIncidentCommandTest.php create mode 100644 tests/Commands/Incident/ReportMaintenanceCommandTest.php create mode 100644 tests/Commands/Incident/UpdateIncidentCommandTest.php create mode 100644 tests/Commands/Metric/AddMetricCommandTest.php create mode 100644 tests/Commands/Metric/AddMetricPointCommandTest.php create mode 100644 tests/Commands/Metric/RemoveMetricCommandTest.php create mode 100644 tests/Commands/Metric/RemoveMetricPointCommandTest.php create mode 100644 tests/Commands/Metric/UpdateMetricCommandTest.php create mode 100644 tests/Commands/Metric/UpdateMetricPointCommandTest.php create mode 100644 tests/Commands/Subscriber/SubscribeSubscriberCommandTest.php create mode 100644 tests/Commands/Subscriber/UnsubscribeSubscriberCommandTest.php create mode 100644 tests/Commands/Subscriber/VerifySubscriberCommandTest.php create mode 100644 tests/Commands/User/AddTeamMemberCommandTest.php create mode 100644 tests/Commands/User/GenerateApiTokenCommandTest.php create mode 100644 tests/Commands/User/RemoveUserCommandTest.php diff --git a/app/Commands/Component/AddComponentCommand.php b/app/Commands/Component/AddComponentCommand.php index 4f43e61e..24161911 100644 --- a/app/Commands/Component/AddComponentCommand.php +++ b/app/Commands/Component/AddComponentCommand.php @@ -11,7 +11,7 @@ namespace CachetHQ\Cachet\Commands\Component; -class AddComponentCommand +final class AddComponentCommand { /** * The component name. diff --git a/app/Commands/Component/RemoveComponentCommand.php b/app/Commands/Component/RemoveComponentCommand.php index 80dbe1ae..ce8383dd 100644 --- a/app/Commands/Component/RemoveComponentCommand.php +++ b/app/Commands/Component/RemoveComponentCommand.php @@ -13,7 +13,7 @@ namespace CachetHQ\Cachet\Commands\Component; use CachetHQ\Cachet\Models\Component; -class RemoveComponentCommand +final class RemoveComponentCommand { /** * The component to remove. diff --git a/app/Commands/Component/UpdateComponentCommand.php b/app/Commands/Component/UpdateComponentCommand.php index d34ee4d9..c48ddeaa 100644 --- a/app/Commands/Component/UpdateComponentCommand.php +++ b/app/Commands/Component/UpdateComponentCommand.php @@ -13,7 +13,7 @@ namespace CachetHQ\Cachet\Commands\Component; use CachetHQ\Cachet\Models\Component; -class UpdateComponentCommand +final class UpdateComponentCommand { /** * The component to update. diff --git a/app/Commands/ComponentGroup/AddComponentGroupCommand.php b/app/Commands/ComponentGroup/AddComponentGroupCommand.php index 1ca433d2..90d74150 100644 --- a/app/Commands/ComponentGroup/AddComponentGroupCommand.php +++ b/app/Commands/ComponentGroup/AddComponentGroupCommand.php @@ -11,7 +11,7 @@ namespace CachetHQ\Cachet\Commands\ComponentGroup; -class AddComponentGroupCommand +final class AddComponentGroupCommand { /** * The component group name. diff --git a/app/Commands/ComponentGroup/RemoveComponentGroupCommand.php b/app/Commands/ComponentGroup/RemoveComponentGroupCommand.php index 54a212de..5cdc59f4 100644 --- a/app/Commands/ComponentGroup/RemoveComponentGroupCommand.php +++ b/app/Commands/ComponentGroup/RemoveComponentGroupCommand.php @@ -13,7 +13,7 @@ namespace CachetHQ\Cachet\Commands\ComponentGroup; use CachetHQ\Cachet\Models\ComponentGroup; -class RemoveComponentGroupCommand +final class RemoveComponentGroupCommand { /** * The component group to remove. diff --git a/app/Commands/ComponentGroup/UpdateComponentGroupCommand.php b/app/Commands/ComponentGroup/UpdateComponentGroupCommand.php index 5f81c7ad..d9b6ce87 100644 --- a/app/Commands/ComponentGroup/UpdateComponentGroupCommand.php +++ b/app/Commands/ComponentGroup/UpdateComponentGroupCommand.php @@ -13,7 +13,7 @@ namespace CachetHQ\Cachet\Commands\ComponentGroup; use CachetHQ\Cachet\Models\ComponentGroup; -class UpdateComponentGroupCommand +final class UpdateComponentGroupCommand { /** * The component group. diff --git a/app/Commands/Incident/RemoveIncidentCommand.php b/app/Commands/Incident/RemoveIncidentCommand.php index ca095b51..7742afee 100644 --- a/app/Commands/Incident/RemoveIncidentCommand.php +++ b/app/Commands/Incident/RemoveIncidentCommand.php @@ -13,7 +13,7 @@ namespace CachetHQ\Cachet\Commands\Incident; use CachetHQ\Cachet\Models\Incident; -class RemoveIncidentCommand +final class RemoveIncidentCommand { /** * The incident to remove. diff --git a/app/Commands/Incident/ReportIncidentCommand.php b/app/Commands/Incident/ReportIncidentCommand.php index 988eb653..da99e773 100644 --- a/app/Commands/Incident/ReportIncidentCommand.php +++ b/app/Commands/Incident/ReportIncidentCommand.php @@ -11,7 +11,7 @@ namespace CachetHQ\Cachet\Commands\Incident; -class ReportIncidentCommand +final class ReportIncidentCommand { /** * The incident name. diff --git a/app/Commands/Incident/ReportMaintenanceCommand.php b/app/Commands/Incident/ReportMaintenanceCommand.php index 2f0a6405..80de430b 100644 --- a/app/Commands/Incident/ReportMaintenanceCommand.php +++ b/app/Commands/Incident/ReportMaintenanceCommand.php @@ -11,7 +11,7 @@ namespace CachetHQ\Cachet\Commands\Incident; -class ReportMaintenanceCommand +final class ReportMaintenanceCommand { /** * The maintenance name. diff --git a/app/Commands/Incident/UpdateIncidentCommand.php b/app/Commands/Incident/UpdateIncidentCommand.php index 4e9c493b..0a60618f 100644 --- a/app/Commands/Incident/UpdateIncidentCommand.php +++ b/app/Commands/Incident/UpdateIncidentCommand.php @@ -13,7 +13,7 @@ namespace CachetHQ\Cachet\Commands\Incident; use CachetHQ\Cachet\Models\Incident; -class UpdateIncidentCommand +final class UpdateIncidentCommand { /** * The incident to update. diff --git a/app/Commands/Metric/AddMetricCommand.php b/app/Commands/Metric/AddMetricCommand.php index e67df2d8..e5147a76 100644 --- a/app/Commands/Metric/AddMetricCommand.php +++ b/app/Commands/Metric/AddMetricCommand.php @@ -11,7 +11,7 @@ namespace CachetHQ\Cachet\Commands\Metric; -class AddMetricCommand +final class AddMetricCommand { /** * The metric name. diff --git a/app/Commands/Metric/AddMetricPointCommand.php b/app/Commands/Metric/AddMetricPointCommand.php index 9ecdad1a..3f42a544 100644 --- a/app/Commands/Metric/AddMetricPointCommand.php +++ b/app/Commands/Metric/AddMetricPointCommand.php @@ -13,7 +13,7 @@ namespace CachetHQ\Cachet\Commands\Metric; use CachetHQ\Cachet\Models\Metric; -class AddMetricPointCommand +final class AddMetricPointCommand { /** * The metric to add. diff --git a/app/Commands/Metric/RemoveMetricCommand.php b/app/Commands/Metric/RemoveMetricCommand.php index a893551f..41d9d048 100644 --- a/app/Commands/Metric/RemoveMetricCommand.php +++ b/app/Commands/Metric/RemoveMetricCommand.php @@ -13,7 +13,7 @@ namespace CachetHQ\Cachet\Commands\Metric; use CachetHQ\Cachet\Models\Metric; -class RemoveMetricCommand +final class RemoveMetricCommand { /** * The metric to remove. diff --git a/app/Commands/Metric/RemoveMetricPointCommand.php b/app/Commands/Metric/RemoveMetricPointCommand.php index c305b238..88ed7fd4 100644 --- a/app/Commands/Metric/RemoveMetricPointCommand.php +++ b/app/Commands/Metric/RemoveMetricPointCommand.php @@ -13,7 +13,7 @@ namespace CachetHQ\Cachet\Commands\Metric; use CachetHQ\Cachet\Models\MetricPoint; -class RemoveMetricPointCommand +final class RemoveMetricPointCommand { /** * The metric point to remove. diff --git a/app/Commands/Metric/UpdateMetricCommand.php b/app/Commands/Metric/UpdateMetricCommand.php index a858b055..1b123918 100644 --- a/app/Commands/Metric/UpdateMetricCommand.php +++ b/app/Commands/Metric/UpdateMetricCommand.php @@ -13,7 +13,7 @@ namespace CachetHQ\Cachet\Commands\Metric; use CachetHQ\Cachet\Models\Metric; -class UpdateMetricCommand +final class UpdateMetricCommand { /** * The metric. diff --git a/app/Commands/Metric/UpdateMetricPointCommand.php b/app/Commands/Metric/UpdateMetricPointCommand.php index 420a41e4..bb4024de 100644 --- a/app/Commands/Metric/UpdateMetricPointCommand.php +++ b/app/Commands/Metric/UpdateMetricPointCommand.php @@ -14,7 +14,7 @@ namespace CachetHQ\Cachet\Commands\Metric; use CachetHQ\Cachet\Models\Metric; use CachetHQ\Cachet\Models\MetricPoint; -class UpdateMetricPointCommand +final class UpdateMetricPointCommand { /** * The metric point. diff --git a/app/Commands/Subscriber/SubscribeSubscriberCommand.php b/app/Commands/Subscriber/SubscribeSubscriberCommand.php index d409d18f..270674b8 100644 --- a/app/Commands/Subscriber/SubscribeSubscriberCommand.php +++ b/app/Commands/Subscriber/SubscribeSubscriberCommand.php @@ -11,7 +11,7 @@ namespace CachetHQ\Cachet\Commands\Subscriber; -class SubscribeSubscriberCommand +final class SubscribeSubscriberCommand { /** * The subscriber email. @@ -23,7 +23,7 @@ class SubscribeSubscriberCommand /** * The subscriber auto verification. * - * @var string + * @var bool */ public $verified; diff --git a/app/Commands/Subscriber/UnsubscribeSubscriberCommand.php b/app/Commands/Subscriber/UnsubscribeSubscriberCommand.php index e49c0ffe..b46e2b0b 100644 --- a/app/Commands/Subscriber/UnsubscribeSubscriberCommand.php +++ b/app/Commands/Subscriber/UnsubscribeSubscriberCommand.php @@ -13,12 +13,12 @@ namespace CachetHQ\Cachet\Commands\Subscriber; use CachetHQ\Cachet\Models\Subscriber; -class UnsubscribeSubscriberCommand +final class UnsubscribeSubscriberCommand { /** * The subscriber to unsubscribe. * - * @var string + * @var \CachetHQ\Cachet\Models\Subscriber */ public $subscriber; diff --git a/app/Commands/Subscriber/VerifySubscriberCommand.php b/app/Commands/Subscriber/VerifySubscriberCommand.php index 91bf6414..51ca7fa3 100644 --- a/app/Commands/Subscriber/VerifySubscriberCommand.php +++ b/app/Commands/Subscriber/VerifySubscriberCommand.php @@ -13,12 +13,12 @@ namespace CachetHQ\Cachet\Commands\Subscriber; use CachetHQ\Cachet\Models\Subscriber; -class VerifySubscriberCommand +final class VerifySubscriberCommand { /** * The subscriber to verify. * - * @var string + * @var \CachetHQ\Cachet\Models\Subscriber */ public $subscriber; diff --git a/app/Commands/User/AddTeamMemberCommand.php b/app/Commands/User/AddTeamMemberCommand.php index 07be0219..c55a8499 100644 --- a/app/Commands/User/AddTeamMemberCommand.php +++ b/app/Commands/User/AddTeamMemberCommand.php @@ -11,7 +11,7 @@ namespace CachetHQ\Cachet\Commands\User; -class AddTeamMemberCommand +final class AddTeamMemberCommand { /** * The user username. @@ -41,6 +41,17 @@ class AddTeamMemberCommand */ public $level; + /** + * The validation rules. + * + * @var string[] + */ + public $rules = [ + 'name' => 'required|string', + 'password' => 'string', + 'level' => 'integer', + ]; + /** * Create a new add team member command instance. * diff --git a/app/Commands/User/GenerateApiTokenCommand.php b/app/Commands/User/GenerateApiTokenCommand.php index 71a75fdc..5b79428b 100644 --- a/app/Commands/User/GenerateApiTokenCommand.php +++ b/app/Commands/User/GenerateApiTokenCommand.php @@ -11,7 +11,7 @@ namespace CachetHQ\Cachet\Commands\User; -class GenerateApiTokenCommand +final class GenerateApiTokenCommand { /** * The user to generate the token. diff --git a/app/Commands/User/RemoveUserCommand.php b/app/Commands/User/RemoveUserCommand.php index c5998249..2d4b0acd 100644 --- a/app/Commands/User/RemoveUserCommand.php +++ b/app/Commands/User/RemoveUserCommand.php @@ -13,7 +13,7 @@ namespace CachetHQ\Cachet\Commands\User; use CachetHQ\Cachet\Models\User; -class RemoveUserCommand +final class RemoveUserCommand { /** * The user to remove. diff --git a/tests/Commands/AbstractCommandTestCase.php b/tests/Commands/AbstractCommandTestCase.php new file mode 100644 index 00000000..7884bb5f --- /dev/null +++ b/tests/Commands/AbstractCommandTestCase.php @@ -0,0 +1,31 @@ + + */ +abstract class AbstractCommandTestCase extends AbstractAnemicTestCase +{ + public function testHandlerCanBeResolved() + { + $command = $this->getObjectAndParams()['object']; + $dispatcher = $this->app->make(Dispatcher::class); + + $this->assertInstanceOf($this->getHandlerClass(), $dispatcher->resolveHandler($command)); + } +} diff --git a/tests/Commands/Component/AddComponentCommandTest.php b/tests/Commands/Component/AddComponentCommandTest.php new file mode 100644 index 00000000..92897303 --- /dev/null +++ b/tests/Commands/Component/AddComponentCommandTest.php @@ -0,0 +1,56 @@ + + */ +class AddComponentCommandTest extends AbstractCommandTestCase +{ + protected function getObjectAndParams() + { + $params = [ + 'name' => 'Test', + 'description' => 'Foo', + 'status' => 1, + 'link' => 'https://cachethq.io', + 'order' => 0, + 'group_id' => 0, + ]; + $object = new AddComponentCommand( + $params['name'], + $params['description'], + $params['status'], + $params['link'], + $params['order'], + $params['group_id'] + ); + + return compact('params', 'object'); + } + + protected function objectHasRules() + { + return true; + } + + protected function getHandlerClass() + { + return AddComponentCommandHandler::class; + } +} diff --git a/tests/Commands/Component/RemoveComponentCommandTest.php b/tests/Commands/Component/RemoveComponentCommandTest.php new file mode 100644 index 00000000..8c2663a8 --- /dev/null +++ b/tests/Commands/Component/RemoveComponentCommandTest.php @@ -0,0 +1,43 @@ + + */ +class RemoveComponentCommandTest extends AbstractCommandTestCase +{ + protected function getObjectAndParams() + { + $params = ['component' => new Component()]; + $object = new RemoveComponentCommand($params['component']); + + return compact('params', 'object'); + } + + protected function objectHasRules() + { + return false; + } + + protected function getHandlerClass() + { + return RemoveComponentCommandHandler::class; + } +} diff --git a/tests/Commands/Component/UpdateComponentCommandTest.php b/tests/Commands/Component/UpdateComponentCommandTest.php new file mode 100644 index 00000000..db158a4f --- /dev/null +++ b/tests/Commands/Component/UpdateComponentCommandTest.php @@ -0,0 +1,59 @@ + + */ +class UpdateComponentCommandTest extends AbstractCommandTestCase +{ + protected function getObjectAndParams() + { + $params = [ + 'component' => new Component(), + 'name' => 'Test', + 'description' => 'Foo', + 'status' => 1, + 'link' => 'https://cachethq.io', + 'order' => 0, + 'group_id' => 0, + ]; + $object = new UpdateComponentCommand( + $params['component'], + $params['name'], + $params['description'], + $params['status'], + $params['link'], + $params['order'], + $params['group_id'] + ); + + return compact('params', 'object'); + } + + protected function objectHasRules() + { + return true; + } + + protected function getHandlerClass() + { + return UpdateComponentCommandHandler::class; + } +} diff --git a/tests/Commands/ComponentGroup/AddComponentGroupCommandTest.php b/tests/Commands/ComponentGroup/AddComponentGroupCommandTest.php new file mode 100644 index 00000000..5765f9d0 --- /dev/null +++ b/tests/Commands/ComponentGroup/AddComponentGroupCommandTest.php @@ -0,0 +1,48 @@ + + */ +class AddComponentGroupCommandTest extends AbstractCommandTestCase +{ + protected function getObjectAndParams() + { + $params = [ + 'name' => 'Test', + 'order' => 0, + ]; + $object = new AddComponentGroupCommand( + $params['name'], + $params['order'] + ); + + return compact('params', 'object'); + } + + protected function objectHasRules() + { + return true; + } + + protected function getHandlerClass() + { + return AddComponentGroupCommandHandler::class; + } +} diff --git a/tests/Commands/ComponentGroup/RemoveComponentGroupCommandTest.php b/tests/Commands/ComponentGroup/RemoveComponentGroupCommandTest.php new file mode 100644 index 00000000..650951c6 --- /dev/null +++ b/tests/Commands/ComponentGroup/RemoveComponentGroupCommandTest.php @@ -0,0 +1,43 @@ + + */ +class RemoveComponentGroupCommandTest extends AbstractCommandTestCase +{ + protected function getObjectAndParams() + { + $params = ['group' => new ComponentGroup()]; + $object = new RemoveComponentGroupCommand($params['group']); + + return compact('params', 'object'); + } + + protected function objectHasRules() + { + return false; + } + + protected function getHandlerClass() + { + return RemoveComponentGroupCommandHandler::class; + } +} diff --git a/tests/Commands/ComponentGroup/UpdateComponentGroupCommandTest.php b/tests/Commands/ComponentGroup/UpdateComponentGroupCommandTest.php new file mode 100644 index 00000000..3ac8fad4 --- /dev/null +++ b/tests/Commands/ComponentGroup/UpdateComponentGroupCommandTest.php @@ -0,0 +1,47 @@ + + */ +class UpdateComponentGroupCommandTest extends AbstractCommandTestCase +{ + protected function getObjectAndParams() + { + $params = [ + 'group' => new ComponentGroup(), + 'name' => 'Foo', + 'order' => 1, + ]; + $object = new UpdateComponentGroupCommand($params['group'], $params['name'], $params['order']); + + return compact('params', 'object'); + } + + protected function objectHasRules() + { + return true; + } + + protected function getHandlerClass() + { + return UpdateComponentGroupCommandHandler::class; + } +} diff --git a/tests/Commands/Incident/RemoveIncidentCommandTest.php b/tests/Commands/Incident/RemoveIncidentCommandTest.php new file mode 100644 index 00000000..5e05283e --- /dev/null +++ b/tests/Commands/Incident/RemoveIncidentCommandTest.php @@ -0,0 +1,43 @@ + + */ +class RemoveIncidentCommandTest extends AbstractCommandTestCase +{ + protected function getObjectAndParams() + { + $params = ['incident' => new Incident()]; + $object = new RemoveIncidentCommand($params['incident']); + + return compact('params', 'object'); + } + + protected function objectHasRules() + { + return false; + } + + protected function getHandlerClass() + { + return RemoveIncidentCommandHandler::class; + } +} diff --git a/tests/Commands/Incident/ReportIncidentCommandTest.php b/tests/Commands/Incident/ReportIncidentCommandTest.php new file mode 100644 index 00000000..c6e4bcf7 --- /dev/null +++ b/tests/Commands/Incident/ReportIncidentCommandTest.php @@ -0,0 +1,60 @@ + + */ +class ReportIncidentCommandTest extends AbstractCommandTestCase +{ + protected function getObjectAndParams() + { + $params = [ + 'name' => 'Test', + 'status' => 1, + 'message' => 'Foo bar baz', + 'visible' => 1, + 'component_id' => 1, + 'component_status' => 1, + 'notify' => false, + 'incident_date' => null, + ]; + $object = new ReportIncidentCommand( + $params['name'], + $params['status'], + $params['message'], + $params['visible'], + $params['component_id'], + $params['component_status'], + $params['notify'], + $params['incident_date'] + ); + + return compact('params', 'object'); + } + + protected function objectHasRules() + { + return true; + } + + protected function getHandlerClass() + { + return ReportIncidentCommandHandler::class; + } +} diff --git a/tests/Commands/Incident/ReportMaintenanceCommandTest.php b/tests/Commands/Incident/ReportMaintenanceCommandTest.php new file mode 100644 index 00000000..cff0a809 --- /dev/null +++ b/tests/Commands/Incident/ReportMaintenanceCommandTest.php @@ -0,0 +1,52 @@ + + */ +class ReportMaintenanceCommandTest extends AbstractCommandTestCase +{ + protected function getObjectAndParams() + { + $params = [ + 'name' => 'Test', + 'message' => 'Foo bar baz', + 'notify' => false, + 'timestamp' => '2020-12-30 00:00:01', + ]; + $object = new ReportMaintenanceCommand( + $params['name'], + $params['message'], + $params['notify'], + $params['timestamp'] + ); + + return compact('params', 'object'); + } + + protected function objectHasRules() + { + return true; + } + + protected function getHandlerClass() + { + return ReportMaintenanceCommandHandler::class; + } +} diff --git a/tests/Commands/Incident/UpdateIncidentCommandTest.php b/tests/Commands/Incident/UpdateIncidentCommandTest.php new file mode 100644 index 00000000..fe3eceb7 --- /dev/null +++ b/tests/Commands/Incident/UpdateIncidentCommandTest.php @@ -0,0 +1,63 @@ + + */ +class UpdateIncidentCommandTest extends AbstractCommandTestCase +{ + protected function getObjectAndParams() + { + $params = [ + 'incident' => new Incident(), + 'name' => 'Test', + 'status' => 1, + 'message' => 'Foo bar baz', + 'visible' => 1, + 'component_id' => 1, + 'component_status' => 1, + 'notify' => false, + 'incident_date' => null, + ]; + $object = new UpdateIncidentCommand( + $params['incident'], + $params['name'], + $params['status'], + $params['message'], + $params['visible'], + $params['component_id'], + $params['component_status'], + $params['notify'], + $params['incident_date'] + ); + + return compact('params', 'object'); + } + + protected function objectHasRules() + { + return true; + } + + protected function getHandlerClass() + { + return UpdateIncidentCommandHandler::class; + } +} diff --git a/tests/Commands/Metric/AddMetricCommandTest.php b/tests/Commands/Metric/AddMetricCommandTest.php new file mode 100644 index 00000000..d03eaf61 --- /dev/null +++ b/tests/Commands/Metric/AddMetricCommandTest.php @@ -0,0 +1,58 @@ + + */ +class AddMetricCommandTest extends AbstractCommandTestCase +{ + protected function getObjectAndParams() + { + $params = [ + 'name' => 'Coffee', + 'suffix' => 'cups', + 'description' => 'Cups of coffee consumed', + 'default_value' => 0, + 'calc_type' => 0, + 'display_chart' => 1, + 'places' => 0, + ]; + $object = new AddMetricCommand( + $params['name'], + $params['suffix'], + $params['description'], + $params['default_value'], + $params['calc_type'], + $params['display_chart'], + $params['places'] + ); + + return compact('params', 'object'); + } + + protected function objectHasRules() + { + return true; + } + + protected function getHandlerClass() + { + return AddMetricCommandHandler::class; + } +} diff --git a/tests/Commands/Metric/AddMetricPointCommandTest.php b/tests/Commands/Metric/AddMetricPointCommandTest.php new file mode 100644 index 00000000..9d1c8f29 --- /dev/null +++ b/tests/Commands/Metric/AddMetricPointCommandTest.php @@ -0,0 +1,51 @@ + + */ +class AddMetricPointCommandTest extends AbstractCommandTestCase +{ + protected function getObjectAndParams() + { + $params = [ + 'metric' => new Metric(), + 'value' => 1, + 'created_at' => '2020-12-30 12:00:00', + ]; + $object = new AddMetricPointCommand( + $params['metric'], + $params['value'], + $params['created_at'] + ); + + return compact('params', 'object'); + } + + protected function objectHasRules() + { + return true; + } + + protected function getHandlerClass() + { + return AddMetricPointCommandHandler::class; + } +} diff --git a/tests/Commands/Metric/RemoveMetricCommandTest.php b/tests/Commands/Metric/RemoveMetricCommandTest.php new file mode 100644 index 00000000..8092cb56 --- /dev/null +++ b/tests/Commands/Metric/RemoveMetricCommandTest.php @@ -0,0 +1,43 @@ + + */ +class RemoveMetricCommandTest extends AbstractCommandTestCase +{ + protected function getObjectAndParams() + { + $params = ['metric' => new Metric()]; + $object = new RemoveMetricCommand($params['metric']); + + return compact('params', 'object'); + } + + protected function objectHasRules() + { + return false; + } + + protected function getHandlerClass() + { + return RemoveMetricCommandHandler::class; + } +} diff --git a/tests/Commands/Metric/RemoveMetricPointCommandTest.php b/tests/Commands/Metric/RemoveMetricPointCommandTest.php new file mode 100644 index 00000000..ef0631e6 --- /dev/null +++ b/tests/Commands/Metric/RemoveMetricPointCommandTest.php @@ -0,0 +1,43 @@ + + */ +class RemoveMetricPointCommandTest extends AbstractCommandTestCase +{ + protected function getObjectAndParams() + { + $params = ['metricPoint' => new MetricPoint()]; + $object = new RemoveMetricPointCommand($params['metricPoint']); + + return compact('params', 'object'); + } + + protected function objectHasRules() + { + return false; + } + + protected function getHandlerClass() + { + return RemoveMetricPointCommandHandler::class; + } +} diff --git a/tests/Commands/Metric/UpdateMetricCommandTest.php b/tests/Commands/Metric/UpdateMetricCommandTest.php new file mode 100644 index 00000000..395bc613 --- /dev/null +++ b/tests/Commands/Metric/UpdateMetricCommandTest.php @@ -0,0 +1,61 @@ + + */ +class UpdateMetricCommandTest extends AbstractCommandTestCase +{ + protected function getObjectAndParams() + { + $params = [ + 'metric' => new Metric(), + 'name' => 'Coffee', + 'suffix' => 'cups', + 'description' => 'Cups of coffee consumed', + 'default_value' => 0, + 'calc_type' => 0, + 'display_chart' => 1, + 'places' => 0, + ]; + $object = new UpdateMetricCommand( + $params['metric'], + $params['name'], + $params['suffix'], + $params['description'], + $params['default_value'], + $params['calc_type'], + $params['display_chart'], + $params['places'] + ); + + return compact('params', 'object'); + } + + protected function objectHasRules() + { + return true; + } + + protected function getHandlerClass() + { + return UpdateMetricCommandHandler::class; + } +} diff --git a/tests/Commands/Metric/UpdateMetricPointCommandTest.php b/tests/Commands/Metric/UpdateMetricPointCommandTest.php new file mode 100644 index 00000000..029427d9 --- /dev/null +++ b/tests/Commands/Metric/UpdateMetricPointCommandTest.php @@ -0,0 +1,54 @@ + + */ +class UpdateMetricPointCommandTest extends AbstractCommandTestCase +{ + protected function getObjectAndParams() + { + $params = [ + 'point' => new MetricPoint(), + 'metric' => new Metric(), + 'value' => 1, + 'created_at' => '2012-12-30 12:00:00', + ]; + $object = new UpdateMetricPointCommand( + $params['point'], + $params['metric'], + $params['value'], + $params['created_at'] + ); + + return compact('params', 'object'); + } + + protected function objectHasRules() + { + return true; + } + + protected function getHandlerClass() + { + return UpdateMetricPointCommandHandler::class; + } +} diff --git a/tests/Commands/Subscriber/SubscribeSubscriberCommandTest.php b/tests/Commands/Subscriber/SubscribeSubscriberCommandTest.php new file mode 100644 index 00000000..34d60c9e --- /dev/null +++ b/tests/Commands/Subscriber/SubscribeSubscriberCommandTest.php @@ -0,0 +1,48 @@ + + */ +class SubscribeSubscriberCommandTest extends AbstractCommandTestCase +{ + protected function getObjectAndParams() + { + $params = [ + 'email' => 'support@cachethq.io', + 'verified' => true, + ]; + $object = new SubscribeSubscriberCommand( + $params['email'], + $params['verified'] + ); + + return compact('params', 'object'); + } + + protected function objectHasRules() + { + return true; + } + + protected function getHandlerClass() + { + return SubscribeSubscriberCommandHandler::class; + } +} diff --git a/tests/Commands/Subscriber/UnsubscribeSubscriberCommandTest.php b/tests/Commands/Subscriber/UnsubscribeSubscriberCommandTest.php new file mode 100644 index 00000000..26af0f31 --- /dev/null +++ b/tests/Commands/Subscriber/UnsubscribeSubscriberCommandTest.php @@ -0,0 +1,43 @@ + + */ +class UnsubscribeSubscriberCommandTest extends AbstractCommandTestCase +{ + protected function getObjectAndParams() + { + $params = ['subscriber' => new Subscriber()]; + $object = new UnsubscribeSubscriberCommand($params['subscriber']); + + return compact('params', 'object'); + } + + protected function objectHasRules() + { + return false; + } + + protected function getHandlerClass() + { + return UnsubscribeSubscriberCommandHandler::class; + } +} diff --git a/tests/Commands/Subscriber/VerifySubscriberCommandTest.php b/tests/Commands/Subscriber/VerifySubscriberCommandTest.php new file mode 100644 index 00000000..19a69b87 --- /dev/null +++ b/tests/Commands/Subscriber/VerifySubscriberCommandTest.php @@ -0,0 +1,43 @@ + + */ +class VerifySubscriberCommandTest extends AbstractCommandTestCase +{ + protected function getObjectAndParams() + { + $params = ['subscriber' => new Subscriber()]; + $object = new VerifySubscriberCommand($params['subscriber']); + + return compact('params', 'object'); + } + + protected function objectHasRules() + { + return false; + } + + protected function getHandlerClass() + { + return VerifySubscriberCommandHandler::class; + } +} diff --git a/tests/Commands/User/AddTeamMemberCommandTest.php b/tests/Commands/User/AddTeamMemberCommandTest.php new file mode 100644 index 00000000..22ef6229 --- /dev/null +++ b/tests/Commands/User/AddTeamMemberCommandTest.php @@ -0,0 +1,52 @@ + + */ +class AddTeamMemberCommandTest extends AbstractCommandTestCase +{ + protected function getObjectAndParams() + { + $params = [ + 'username' => 'Test', + 'password' => 'fooey', + 'email' => 'test@test.com', + 'level' => 1, + ]; + $object = new AddTeamMemberCommand( + $params['username'], + $params['password'], + $params['email'], + $params['level'] + ); + + return compact('params', 'object'); + } + + protected function objectHasRules() + { + return true; + } + + protected function getHandlerClass() + { + return AddTeamMemberCommandHandler::class; + } +} diff --git a/tests/Commands/User/GenerateApiTokenCommandTest.php b/tests/Commands/User/GenerateApiTokenCommandTest.php new file mode 100644 index 00000000..29f06b68 --- /dev/null +++ b/tests/Commands/User/GenerateApiTokenCommandTest.php @@ -0,0 +1,43 @@ + + */ +class GenerateApiTokenCommandTest extends AbstractCommandTestCase +{ + protected function getObjectAndParams() + { + $params = ['user' => new User()]; + $object = new GenerateApiTokenCommand($params['user']); + + return compact('params', 'object'); + } + + protected function objectHasRules() + { + return false; + } + + protected function getHandlerClass() + { + return GenerateApiTokenCommandHandler::class; + } +} diff --git a/tests/Commands/User/RemoveUserCommandTest.php b/tests/Commands/User/RemoveUserCommandTest.php new file mode 100644 index 00000000..ef35d7d3 --- /dev/null +++ b/tests/Commands/User/RemoveUserCommandTest.php @@ -0,0 +1,43 @@ + + */ +class RemoveUserCommandTest extends AbstractCommandTestCase +{ + protected function getObjectAndParams() + { + $params = ['user' => new User()]; + $object = new RemoveUserCommand($params['user']); + + return compact('params', 'object'); + } + + protected function objectHasRules() + { + return false; + } + + protected function getHandlerClass() + { + return RemoveUserCommandHandler::class; + } +}