From 4031c429589cdb7e988287d6e2ee06675dfe0e59 Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Sun, 24 Jul 2016 15:15:18 +0100 Subject: [PATCH 1/6] Added test existence tests --- tests/Bus/Commands/CommandExistenceTest.php | 30 +++++++++++++++++++++ tests/Bus/Events/EventExistenceTest.php | 30 +++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 tests/Bus/Commands/CommandExistenceTest.php create mode 100644 tests/Bus/Events/EventExistenceTest.php diff --git a/tests/Bus/Commands/CommandExistenceTest.php b/tests/Bus/Commands/CommandExistenceTest.php new file mode 100644 index 000000000000..62106fbac303 --- /dev/null +++ b/tests/Bus/Commands/CommandExistenceTest.php @@ -0,0 +1,30 @@ + + */ +class CommandExistenceTest extends TestCase +{ + use ExistenceTrait; + + protected function getSourcePath() + { + return realpath(__DIR__.'/../../../app/Bus/Commands'); + } +} diff --git a/tests/Bus/Events/EventExistenceTest.php b/tests/Bus/Events/EventExistenceTest.php new file mode 100644 index 000000000000..47983a7f3bf7 --- /dev/null +++ b/tests/Bus/Events/EventExistenceTest.php @@ -0,0 +1,30 @@ + + */ +class EventExistenceTest extends TestCase +{ + use ExistenceTrait; + + protected function getSourcePath() + { + return realpath(__DIR__.'/../../../app/Bus/Events'); + } +} From a2f8f4540e74ab5b0435a9ce124af04415f0edc7 Mon Sep 17 00:00:00 2001 From: James Brooks Date: Tue, 26 Jul 2016 10:22:04 +0100 Subject: [PATCH 2/6] Added missing event tests --- .../Incident/IncidentWasRemovedEventTest.php | 36 +++++++++++++++++++ .../Incident/IncidentWasReportedEventTest.php | 36 +++++++++++++++++++ .../Incident/IncidentWasUpdatedEventTest.php | 36 +++++++++++++++++++ .../MaintenanceWasScheduledEventTest.php | 36 +++++++++++++++++++ .../Metric/MetricPointWasAddedEventTest.php | 36 +++++++++++++++++++ .../Metric/MetricPointWasRemovedEventTest.php | 36 +++++++++++++++++++ .../Metric/MetricPointWasUpdatedEventTest.php | 36 +++++++++++++++++++ .../Events/User/UserWasInvitedEventTest.php | 36 +++++++++++++++++++ .../Events/User/UserWasRemovedEventTest.php | 36 +++++++++++++++++++ 9 files changed, 324 insertions(+) create mode 100644 tests/Bus/Events/Incident/IncidentWasRemovedEventTest.php create mode 100644 tests/Bus/Events/Incident/IncidentWasReportedEventTest.php create mode 100644 tests/Bus/Events/Incident/IncidentWasUpdatedEventTest.php create mode 100644 tests/Bus/Events/Incident/MaintenanceWasScheduledEventTest.php create mode 100644 tests/Bus/Events/Metric/MetricPointWasAddedEventTest.php create mode 100644 tests/Bus/Events/Metric/MetricPointWasRemovedEventTest.php create mode 100644 tests/Bus/Events/Metric/MetricPointWasUpdatedEventTest.php create mode 100644 tests/Bus/Events/User/UserWasInvitedEventTest.php create mode 100644 tests/Bus/Events/User/UserWasRemovedEventTest.php diff --git a/tests/Bus/Events/Incident/IncidentWasRemovedEventTest.php b/tests/Bus/Events/Incident/IncidentWasRemovedEventTest.php new file mode 100644 index 000000000000..aadb73985816 --- /dev/null +++ b/tests/Bus/Events/Incident/IncidentWasRemovedEventTest.php @@ -0,0 +1,36 @@ + + */ +class IncidentWasRemovedEventTest extends AbstractIncidentEventTestCase +{ + protected function objectHasHandlers() + { + return false; + } + + protected function getObjectAndParams() + { + $params = ['incident' => new Incident()]; + $object = new IncidentWasRemovedEvent($params['incident']); + + return compact('params', 'object'); + } +} diff --git a/tests/Bus/Events/Incident/IncidentWasReportedEventTest.php b/tests/Bus/Events/Incident/IncidentWasReportedEventTest.php new file mode 100644 index 000000000000..c6f880f6e680 --- /dev/null +++ b/tests/Bus/Events/Incident/IncidentWasReportedEventTest.php @@ -0,0 +1,36 @@ + + */ +class IncidentWasReportedEventTest extends AbstractIncidentEventTestCase +{ + protected function objectHasHandlers() + { + return true; + } + + protected function getObjectAndParams() + { + $params = ['incident' => new Incident()]; + $object = new IncidentWasReportedEvent($params['incident']); + + return compact('params', 'object'); + } +} diff --git a/tests/Bus/Events/Incident/IncidentWasUpdatedEventTest.php b/tests/Bus/Events/Incident/IncidentWasUpdatedEventTest.php new file mode 100644 index 000000000000..b2ccf5977b1b --- /dev/null +++ b/tests/Bus/Events/Incident/IncidentWasUpdatedEventTest.php @@ -0,0 +1,36 @@ + + */ +class IncidentWasUpdatedEventTest extends AbstractIncidentEventTestCase +{ + protected function objectHasHandlers() + { + return true; + } + + protected function getObjectAndParams() + { + $params = ['incident' => new Incident()]; + $object = new IncidentWasUpdatedEvent($params['incident']); + + return compact('params', 'object'); + } +} diff --git a/tests/Bus/Events/Incident/MaintenanceWasScheduledEventTest.php b/tests/Bus/Events/Incident/MaintenanceWasScheduledEventTest.php new file mode 100644 index 000000000000..bf273cf06510 --- /dev/null +++ b/tests/Bus/Events/Incident/MaintenanceWasScheduledEventTest.php @@ -0,0 +1,36 @@ + + */ +class MaintenanceWasScheduledEventTest extends AbstractIncidentEventTestCase +{ + protected function objectHasHandlers() + { + return true; + } + + protected function getObjectAndParams() + { + $params = ['incident' => new Incident()]; + $object = new MaintenanceWasScheduledEvent($params['incident']); + + return compact('params', 'object'); + } +} diff --git a/tests/Bus/Events/Metric/MetricPointWasAddedEventTest.php b/tests/Bus/Events/Metric/MetricPointWasAddedEventTest.php new file mode 100644 index 000000000000..15b09a0180aa --- /dev/null +++ b/tests/Bus/Events/Metric/MetricPointWasAddedEventTest.php @@ -0,0 +1,36 @@ + + */ +class MetricPointWasAddedEventTest extends AbstractMetricEventTestCase +{ + protected function objectHasHandlers() + { + return false; + } + + protected function getObjectAndParams() + { + $params = ['metric' => new Metric()]; + $object = new MetricPointWasAddedEvent($params['metric']); + + return compact('params', 'object'); + } +} diff --git a/tests/Bus/Events/Metric/MetricPointWasRemovedEventTest.php b/tests/Bus/Events/Metric/MetricPointWasRemovedEventTest.php new file mode 100644 index 000000000000..97eb9ba1ccaf --- /dev/null +++ b/tests/Bus/Events/Metric/MetricPointWasRemovedEventTest.php @@ -0,0 +1,36 @@ + + */ +class MetricPointWasRemovedEventTest extends AbstractMetricEventTestCase +{ + protected function objectHasHandlers() + { + return false; + } + + protected function getObjectAndParams() + { + $params = ['metric' => new Metric()]; + $object = new MetricPointWasRemovedEvent($params['metric']); + + return compact('params', 'object'); + } +} diff --git a/tests/Bus/Events/Metric/MetricPointWasUpdatedEventTest.php b/tests/Bus/Events/Metric/MetricPointWasUpdatedEventTest.php new file mode 100644 index 000000000000..d10da3af8317 --- /dev/null +++ b/tests/Bus/Events/Metric/MetricPointWasUpdatedEventTest.php @@ -0,0 +1,36 @@ + + */ +class MetricPointWasUpdatedEventTest extends AbstractMetricEventTestCase +{ + protected function objectHasHandlers() + { + return false; + } + + protected function getObjectAndParams() + { + $params = ['metric' => new Metric()]; + $object = new MetricPointWasUpdatedEvent($params['metric']); + + return compact('params', 'object'); + } +} diff --git a/tests/Bus/Events/User/UserWasInvitedEventTest.php b/tests/Bus/Events/User/UserWasInvitedEventTest.php new file mode 100644 index 000000000000..f0e5a4b44b03 --- /dev/null +++ b/tests/Bus/Events/User/UserWasInvitedEventTest.php @@ -0,0 +1,36 @@ + + */ +class UserWasInvitedEventTest extends AbstractUserEventTestCase +{ + protected function objectHasHandlers() + { + return false; + } + + protected function getObjectAndParams() + { + $params = ['user' => new User()]; + $object = new UserWasInvitedEvent($params['user']); + + return compact('params', 'object'); + } +} diff --git a/tests/Bus/Events/User/UserWasRemovedEventTest.php b/tests/Bus/Events/User/UserWasRemovedEventTest.php new file mode 100644 index 000000000000..a6b72cff952c --- /dev/null +++ b/tests/Bus/Events/User/UserWasRemovedEventTest.php @@ -0,0 +1,36 @@ + + */ +class UserWasRemovedEventTest extends AbstractUserEventTestCase +{ + protected function objectHasHandlers() + { + return false; + } + + protected function getObjectAndParams() + { + $params = ['user' => new User()]; + $object = new UserWasRemovedEvent($params['user']); + + return compact('params', 'object'); + } +} From d8ea3c59e3a449bcb19b3604701182e445e591c3 Mon Sep 17 00:00:00 2001 From: James Brooks Date: Tue, 26 Jul 2016 11:10:50 +0100 Subject: [PATCH 3/6] Added update subscriber subscription command test --- ...pdateSubscriberSubscriptionCommandTest.php | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 tests/Bus/Commands/Subscriber/UpdateSubscriberSubscriptionCommandTest.php diff --git a/tests/Bus/Commands/Subscriber/UpdateSubscriberSubscriptionCommandTest.php b/tests/Bus/Commands/Subscriber/UpdateSubscriberSubscriptionCommandTest.php new file mode 100644 index 000000000000..86cb0a11d517 --- /dev/null +++ b/tests/Bus/Commands/Subscriber/UpdateSubscriberSubscriptionCommandTest.php @@ -0,0 +1,41 @@ + + */ +class UpdateSubscriberSubscriptionCommandTest extends AbstractTestCase +{ + use CommandTrait; + + protected function getObjectAndParams() + { + $params = ['subscriber' => new Subscriber(), 'subscriptions' => null]; + $object = new UpdateSubscriberSubscriptionCommand($params['subscriber'], $params['subscriptions']); + + return compact('params', 'object'); + } + + protected function getHandlerClass() + { + return UpdateSubscriberSubscriptionCommandHandler::class; + } +} From dcea94797384ddbc59b0fc94221c51f8fe58332f Mon Sep 17 00:00:00 2001 From: James Brooks Date: Tue, 26 Jul 2016 11:10:58 +0100 Subject: [PATCH 4/6] Fix metric point tests --- tests/Bus/Events/Metric/MetricPointWasAddedEventTest.php | 6 +++--- tests/Bus/Events/Metric/MetricPointWasRemovedEventTest.php | 6 +++--- tests/Bus/Events/Metric/MetricPointWasUpdatedEventTest.php | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/Bus/Events/Metric/MetricPointWasAddedEventTest.php b/tests/Bus/Events/Metric/MetricPointWasAddedEventTest.php index 15b09a0180aa..99fe8be33593 100644 --- a/tests/Bus/Events/Metric/MetricPointWasAddedEventTest.php +++ b/tests/Bus/Events/Metric/MetricPointWasAddedEventTest.php @@ -12,7 +12,7 @@ namespace CachetHQ\Tests\Cachet\Bus\Events\Metric; use CachetHQ\Cachet\Bus\Events\Metric\MetricPointWasAddedEvent; -use CachetHQ\Cachet\Models\Metric; +use CachetHQ\Cachet\Models\MetricPoint; /** * This is the metric point was added event test class. @@ -28,8 +28,8 @@ protected function objectHasHandlers() protected function getObjectAndParams() { - $params = ['metric' => new Metric()]; - $object = new MetricPointWasAddedEvent($params['metric']); + $params = ['metricPoint' => new MetricPoint()]; + $object = new MetricPointWasAddedEvent($params['metricPoint']); return compact('params', 'object'); } diff --git a/tests/Bus/Events/Metric/MetricPointWasRemovedEventTest.php b/tests/Bus/Events/Metric/MetricPointWasRemovedEventTest.php index 97eb9ba1ccaf..4c2a8c4f2ee2 100644 --- a/tests/Bus/Events/Metric/MetricPointWasRemovedEventTest.php +++ b/tests/Bus/Events/Metric/MetricPointWasRemovedEventTest.php @@ -12,7 +12,7 @@ namespace CachetHQ\Tests\Cachet\Bus\Events\Metric; use CachetHQ\Cachet\Bus\Events\Metric\MetricPointWasRemovedEvent; -use CachetHQ\Cachet\Models\Metric; +use CachetHQ\Cachet\Models\MetricPoint; /** * This is the metric point was removed event test class. @@ -28,8 +28,8 @@ protected function objectHasHandlers() protected function getObjectAndParams() { - $params = ['metric' => new Metric()]; - $object = new MetricPointWasRemovedEvent($params['metric']); + $params = ['metricPoint' => new MetricPoint()]; + $object = new MetricPointWasRemovedEvent($params['metricPoint']); return compact('params', 'object'); } diff --git a/tests/Bus/Events/Metric/MetricPointWasUpdatedEventTest.php b/tests/Bus/Events/Metric/MetricPointWasUpdatedEventTest.php index d10da3af8317..fd5b30997c40 100644 --- a/tests/Bus/Events/Metric/MetricPointWasUpdatedEventTest.php +++ b/tests/Bus/Events/Metric/MetricPointWasUpdatedEventTest.php @@ -12,7 +12,7 @@ namespace CachetHQ\Tests\Cachet\Bus\Events\Metric; use CachetHQ\Cachet\Bus\Events\Metric\MetricPointWasUpdatedEvent; -use CachetHQ\Cachet\Models\Metric; +use CachetHQ\Cachet\Models\MetricPoint; /** * This is the metric point was updated event test class. @@ -28,8 +28,8 @@ protected function objectHasHandlers() protected function getObjectAndParams() { - $params = ['metric' => new Metric()]; - $object = new MetricPointWasUpdatedEvent($params['metric']); + $params = ['metricPoint' => new MetricPoint()]; + $object = new MetricPointWasUpdatedEvent($params['metricPoint']); return compact('params', 'object'); } From 7596966e6ce16ff2acfa6a71fe94eb8e7919080a Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Fri, 29 Jul 2016 13:05:18 -0400 Subject: [PATCH 5/6] Added missing listener definitions --- app/Foundation/Providers/EventServiceProvider.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/Foundation/Providers/EventServiceProvider.php b/app/Foundation/Providers/EventServiceProvider.php index b8f18b9bcc3b..aaff317e9703 100644 --- a/app/Foundation/Providers/EventServiceProvider.php +++ b/app/Foundation/Providers/EventServiceProvider.php @@ -48,6 +48,9 @@ class EventServiceProvider extends ServiceProvider 'CachetHQ\Cachet\Bus\Events\Incident\IncidentWasUpdatedEvent' => [ // ], + 'CachetHQ\Cachet\Bus\Events\Incident\IncidentWasRemovedEvent' => [ + // + ], 'CachetHQ\Cachet\Bus\Events\Incident\MaintenanceWasScheduledEvent' => [ 'CachetHQ\Cachet\Bus\Handlers\Events\Incident\SendMaintenanceEmailNotificationHandler', ], @@ -90,5 +93,8 @@ class EventServiceProvider extends ServiceProvider 'CachetHQ\Cachet\Bus\Events\User\UserWasInvitedEvent' => [ 'CachetHQ\Cachet\Bus\Handlers\Events\User\SendInviteUserEmailHandler', ], + 'CachetHQ\Cachet\Bus\Events\User\UserWasRemovedEvent' => [ + // + ], ]; } From 16189da222da81df26cf02395a0f33beed717717 Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Fri, 29 Jul 2016 13:05:30 -0400 Subject: [PATCH 6/6] Finished off tests --- tests/Bus/Events/Incident/IncidentWasUpdatedEventTest.php | 2 +- tests/Bus/Events/User/UserWasInvitedEventTest.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/Bus/Events/Incident/IncidentWasUpdatedEventTest.php b/tests/Bus/Events/Incident/IncidentWasUpdatedEventTest.php index b2ccf5977b1b..732de05c6f30 100644 --- a/tests/Bus/Events/Incident/IncidentWasUpdatedEventTest.php +++ b/tests/Bus/Events/Incident/IncidentWasUpdatedEventTest.php @@ -23,7 +23,7 @@ class IncidentWasUpdatedEventTest extends AbstractIncidentEventTestCase { protected function objectHasHandlers() { - return true; + return false; } protected function getObjectAndParams() diff --git a/tests/Bus/Events/User/UserWasInvitedEventTest.php b/tests/Bus/Events/User/UserWasInvitedEventTest.php index f0e5a4b44b03..acdfbd71e053 100644 --- a/tests/Bus/Events/User/UserWasInvitedEventTest.php +++ b/tests/Bus/Events/User/UserWasInvitedEventTest.php @@ -12,7 +12,7 @@ namespace CachetHQ\Tests\Cachet\Bus\Events\User; use CachetHQ\Cachet\Bus\Events\User\UserWasInvitedEvent; -use CachetHQ\Cachet\Models\User; +use CachetHQ\Cachet\Models\Invite; /** * This is the user was invited event test class. @@ -23,13 +23,13 @@ class UserWasInvitedEventTest extends AbstractUserEventTestCase { protected function objectHasHandlers() { - return false; + return true; } protected function getObjectAndParams() { - $params = ['user' => new User()]; - $object = new UserWasInvitedEvent($params['user']); + $params = ['invite' => new Invite()]; + $object = new UserWasInvitedEvent($params['invite']); return compact('params', 'object'); }