From 485116b5cede924c4511876e3fe340daba1cb405 Mon Sep 17 00:00:00 2001 From: James Brooks Date: Sat, 18 Mar 2017 09:41:33 +0000 Subject: [PATCH] Rename incident bus --- ...tCommand.php => CreateIncidentCommand.php} | 6 ++--- ...nd.php => CreateIncidentUpdateCommand.php} | 2 +- ...dEvent.php => IncidentWasCreatedEvent.php} | 2 +- ...r.php => CreateIncidentCommandHandler.php} | 22 +++++++++---------- ...=> CreateIncidentUpdateCommandHandler.php} | 8 +++---- .../SendIncidentEmailNotificationHandler.php | 6 ++--- .../Providers/EventServiceProvider.php | 6 ++--- .../Controllers/Api/IncidentController.php | 4 ++-- .../Api/IncidentUpdateController.php | 4 ++-- .../Dashboard/IncidentController.php | 8 +++---- ...Test.php => CreateIncidentCommandTest.php} | 12 +++++----- ...hp => CreateIncidentUpdateCommandTest.php} | 12 +++++----- ...st.php => IncidentWasCreatedEventTest.php} | 8 +++---- 13 files changed, 50 insertions(+), 50 deletions(-) rename app/Bus/Commands/Incident/{ReportIncidentCommand.php => CreateIncidentCommand.php} (96%) rename app/Bus/Commands/IncidentUpdate/{ReportIncidentUpdateCommand.php => CreateIncidentUpdateCommand.php} (97%) rename app/Bus/Events/Incident/{IncidentWasReportedEvent.php => IncidentWasCreatedEvent.php} (94%) rename app/Bus/Handlers/Commands/Incident/{ReportIncidentCommandHandler.php => CreateIncidentCommandHandler.php} (86%) rename app/Bus/Handlers/Commands/IncidentUpdate/{ReportIncidentUpdateCommandHandler.php => CreateIncidentUpdateCommandHandler.php} (87%) rename tests/Bus/Commands/Incident/{ReportIncidentCommandTest.php => CreateIncidentCommandTest.php} (82%) rename tests/Bus/Commands/IncidentUpdate/{ReportIncidentUpdateCommandTest.php => CreateIncidentUpdateCommandTest.php} (73%) rename tests/Bus/Events/Incident/{IncidentWasReportedEventTest.php => IncidentWasCreatedEventTest.php} (70%) diff --git a/app/Bus/Commands/Incident/ReportIncidentCommand.php b/app/Bus/Commands/Incident/CreateIncidentCommand.php similarity index 96% rename from app/Bus/Commands/Incident/ReportIncidentCommand.php rename to app/Bus/Commands/Incident/CreateIncidentCommand.php index 979cc0cdc..ae8f5f97a 100644 --- a/app/Bus/Commands/Incident/ReportIncidentCommand.php +++ b/app/Bus/Commands/Incident/CreateIncidentCommand.php @@ -12,12 +12,12 @@ namespace CachetHQ\Cachet\Bus\Commands\Incident; /** - * This is the report incident command. + * This is the create incident command. * * @author Joseph Cohen * @author James Brooks */ -final class ReportIncidentCommand +final class CreateIncidentCommand { /** * The incident name. @@ -115,7 +115,7 @@ final class ReportIncidentCommand ]; /** - * Create a new report incident command instance. + * Create a new create incident command instance. * * @param string $name * @param int $status diff --git a/app/Bus/Commands/IncidentUpdate/ReportIncidentUpdateCommand.php b/app/Bus/Commands/IncidentUpdate/CreateIncidentUpdateCommand.php similarity index 97% rename from app/Bus/Commands/IncidentUpdate/ReportIncidentUpdateCommand.php rename to app/Bus/Commands/IncidentUpdate/CreateIncidentUpdateCommand.php index d88e51401..048465b8f 100644 --- a/app/Bus/Commands/IncidentUpdate/ReportIncidentUpdateCommand.php +++ b/app/Bus/Commands/IncidentUpdate/CreateIncidentUpdateCommand.php @@ -19,7 +19,7 @@ use CachetHQ\Cachet\Models\User; * * @author James Brooks */ -final class ReportIncidentUpdateCommand +final class CreateIncidentUpdateCommand { /** * The incident. diff --git a/app/Bus/Events/Incident/IncidentWasReportedEvent.php b/app/Bus/Events/Incident/IncidentWasCreatedEvent.php similarity index 94% rename from app/Bus/Events/Incident/IncidentWasReportedEvent.php rename to app/Bus/Events/Incident/IncidentWasCreatedEvent.php index 141fccb7f..c43d672b0 100644 --- a/app/Bus/Events/Incident/IncidentWasReportedEvent.php +++ b/app/Bus/Events/Incident/IncidentWasCreatedEvent.php @@ -15,7 +15,7 @@ use CachetHQ\Cachet\Bus\Events\ActionInterface; use CachetHQ\Cachet\Models\Incident; use CachetHQ\Cachet\Models\User; -final class IncidentWasReportedEvent implements ActionInterface, IncidentEventInterface +final class IncidentWasCreatedEvent implements ActionInterface, IncidentEventInterface { /** * The user who reported the event. diff --git a/app/Bus/Handlers/Commands/Incident/ReportIncidentCommandHandler.php b/app/Bus/Handlers/Commands/Incident/CreateIncidentCommandHandler.php similarity index 86% rename from app/Bus/Handlers/Commands/Incident/ReportIncidentCommandHandler.php rename to app/Bus/Handlers/Commands/Incident/CreateIncidentCommandHandler.php index 85fcd6484..d8b36af2b 100644 --- a/app/Bus/Handlers/Commands/Incident/ReportIncidentCommandHandler.php +++ b/app/Bus/Handlers/Commands/Incident/CreateIncidentCommandHandler.php @@ -12,8 +12,8 @@ namespace CachetHQ\Cachet\Bus\Handlers\Commands\Incident; use CachetHQ\Cachet\Bus\Commands\Component\UpdateComponentCommand; -use CachetHQ\Cachet\Bus\Commands\Incident\ReportIncidentCommand; -use CachetHQ\Cachet\Bus\Events\Incident\IncidentWasReportedEvent; +use CachetHQ\Cachet\Bus\Commands\Incident\CreateIncidentCommand; +use CachetHQ\Cachet\Bus\Events\Incident\IncidentWasCreatedEvent; use CachetHQ\Cachet\Bus\Exceptions\Incident\InvalidIncidentTimestampException; use CachetHQ\Cachet\Models\Component; use CachetHQ\Cachet\Models\Incident; @@ -25,11 +25,11 @@ use Twig_Environment; use Twig_Loader_Array; /** - * This is the report incident command handler. + * This is the create incident command handler. * * @author James Brooks */ -class ReportIncidentCommandHandler +class CreateIncidentCommandHandler { /** * The authentication guard instance. @@ -46,7 +46,7 @@ class ReportIncidentCommandHandler protected $dates; /** - * Create a new report incident command handler instance. + * Create a new create incident command handler instance. * * @param \Illuminate\Contracts\Auth\Guard $auth * @param \CachetHQ\Cachet\Services\Dates\DateFactory $dates @@ -60,13 +60,13 @@ class ReportIncidentCommandHandler } /** - * Handle the report incident command. + * Handle the create incident command. * - * @param \CachetHQ\Cachet\Bus\Commands\Incident\ReportIncidentCommand $command + * @param \CachetHQ\Cachet\Bus\Commands\Incident\CreateIncidentCommand $command * * @return \CachetHQ\Cachet\Models\Incident */ - public function handle(ReportIncidentCommand $command) + public function handle(CreateIncidentCommand $command) { $data = [ 'name' => $command->name, @@ -116,7 +116,7 @@ class ReportIncidentCommandHandler )); } - event(new IncidentWasReportedEvent($this->auth->user(), $incident, (bool) $command->notify)); + event(new IncidentWasCreatedEvent($this->auth->user(), $incident, (bool) $command->notify)); return $incident; } @@ -125,11 +125,11 @@ class ReportIncidentCommandHandler * Compiles an incident template into an incident message. * * @param \CachetHQ\Cachet\Models\IncidentTemplate $template - * @param \CachetHQ\Cachet\Bus\Commands\Incident\ReportIncidentCommand $command + * @param \CachetHQ\Cachet\Bus\Commands\Incident\CreateIncidentCommand $command * * @return string */ - protected function parseTemplate(IncidentTemplate $template, ReportIncidentCommand $command) + protected function parseTemplate(IncidentTemplate $template, CreateIncidentCommand $command) { $env = new Twig_Environment(new Twig_Loader_Array([])); $template = $env->createTemplate($template->template); diff --git a/app/Bus/Handlers/Commands/IncidentUpdate/ReportIncidentUpdateCommandHandler.php b/app/Bus/Handlers/Commands/IncidentUpdate/CreateIncidentUpdateCommandHandler.php similarity index 87% rename from app/Bus/Handlers/Commands/IncidentUpdate/ReportIncidentUpdateCommandHandler.php rename to app/Bus/Handlers/Commands/IncidentUpdate/CreateIncidentUpdateCommandHandler.php index fba3c3e53..09fe9d9b1 100644 --- a/app/Bus/Handlers/Commands/IncidentUpdate/ReportIncidentUpdateCommandHandler.php +++ b/app/Bus/Handlers/Commands/IncidentUpdate/CreateIncidentUpdateCommandHandler.php @@ -12,7 +12,7 @@ namespace CachetHQ\Cachet\Bus\Handlers\Commands\IncidentUpdate; use CachetHQ\Cachet\Bus\Commands\Incident\UpdateIncidentCommand; -use CachetHQ\Cachet\Bus\Commands\IncidentUpdate\ReportIncidentUpdateCommand; +use CachetHQ\Cachet\Bus\Commands\IncidentUpdate\CreateIncidentUpdateCommand; use CachetHQ\Cachet\Bus\Events\IncidentUpdate\IncidentUpdateWasReportedEvent; use CachetHQ\Cachet\Models\IncidentUpdate; use Illuminate\Contracts\Auth\Guard; @@ -22,7 +22,7 @@ use Illuminate\Contracts\Auth\Guard; * * @author James Brooks */ -class ReportIncidentUpdateCommandHandler +class CreateIncidentUpdateCommandHandler { /** * The authentication guard instance. @@ -46,11 +46,11 @@ class ReportIncidentUpdateCommandHandler /** * Handle the report incident command. * - * @param \CachetHQ\Cachet\Bus\Commands\IncidentUpdate\ReportIncidentUpdateCommand $command + * @param \CachetHQ\Cachet\Bus\Commands\IncidentUpdate\CreateIncidentUpdateCommand $command * * @return \CachetHQ\Cachet\Models\IncidentUpdate */ - public function handle(ReportIncidentUpdateCommand $command) + public function handle(CreateIncidentUpdateCommand $command) { $data = [ 'incident_id' => $command->incident->id, diff --git a/app/Bus/Handlers/Events/Incident/SendIncidentEmailNotificationHandler.php b/app/Bus/Handlers/Events/Incident/SendIncidentEmailNotificationHandler.php index 82bddcda7..b85b8fc86 100644 --- a/app/Bus/Handlers/Events/Incident/SendIncidentEmailNotificationHandler.php +++ b/app/Bus/Handlers/Events/Incident/SendIncidentEmailNotificationHandler.php @@ -11,7 +11,7 @@ namespace CachetHQ\Cachet\Bus\Handlers\Events\Incident; -use CachetHQ\Cachet\Bus\Events\Incident\IncidentWasReportedEvent; +use CachetHQ\Cachet\Bus\Events\Incident\IncidentWasCreatedEvent; use CachetHQ\Cachet\Models\Subscriber; use CachetHQ\Cachet\Notifications\Incident\NewIncidentNotification; @@ -39,11 +39,11 @@ class SendIncidentEmailNotificationHandler /** * Handle the event. * - * @param \CachetHQ\Cachet\Bus\Events\Incident\IncidentWasReportedEvent $event + * @param \CachetHQ\Cachet\Bus\Events\Incident\IncidentWasCreatedEvent $event * * @return void */ - public function handle(IncidentWasReportedEvent $event) + public function handle(IncidentWasCreatedEvent $event) { $incident = $event->incident; diff --git a/app/Foundation/Providers/EventServiceProvider.php b/app/Foundation/Providers/EventServiceProvider.php index ac289226b..2543300b0 100644 --- a/app/Foundation/Providers/EventServiceProvider.php +++ b/app/Foundation/Providers/EventServiceProvider.php @@ -60,12 +60,12 @@ class EventServiceProvider extends ServiceProvider 'CachetHQ\Cachet\Bus\Events\IncidentUpdate\IncidentUpdateWasUpdatedEvent' => [ // ], + 'CachetHQ\Cachet\Bus\Events\Incident\IncidentWasCreatedEvent' => [ + 'CachetHQ\Cachet\Bus\Handlers\Events\Incident\SendIncidentEmailNotificationHandler', + ], 'CachetHQ\Cachet\Bus\Events\Incident\IncidentWasRemovedEvent' => [ // ], - 'CachetHQ\Cachet\Bus\Events\Incident\IncidentWasReportedEvent' => [ - 'CachetHQ\Cachet\Bus\Handlers\Events\Incident\SendIncidentEmailNotificationHandler', - ], 'CachetHQ\Cachet\Bus\Events\Incident\IncidentWasUpdatedEvent' => [ // ], diff --git a/app/Http/Controllers/Api/IncidentController.php b/app/Http/Controllers/Api/IncidentController.php index 1c6226f92..98b66cc2f 100644 --- a/app/Http/Controllers/Api/IncidentController.php +++ b/app/Http/Controllers/Api/IncidentController.php @@ -11,8 +11,8 @@ namespace CachetHQ\Cachet\Http\Controllers\Api; +use CachetHQ\Cachet\Bus\Commands\Incident\CreateIncidentCommand; use CachetHQ\Cachet\Bus\Commands\Incident\RemoveIncidentCommand; -use CachetHQ\Cachet\Bus\Commands\Incident\ReportIncidentCommand; use CachetHQ\Cachet\Bus\Commands\Incident\UpdateIncidentCommand; use CachetHQ\Cachet\Models\Incident; use GrahamCampbell\Binput\Facades\Binput; @@ -67,7 +67,7 @@ class IncidentController extends AbstractApiController public function postIncidents() { try { - $incident = dispatch(new ReportIncidentCommand( + $incident = dispatch(new CreateIncidentCommand( Binput::get('name'), Binput::get('status'), Binput::get('message', null, false, false), diff --git a/app/Http/Controllers/Api/IncidentUpdateController.php b/app/Http/Controllers/Api/IncidentUpdateController.php index 84a01d7ab..73faf3794 100644 --- a/app/Http/Controllers/Api/IncidentUpdateController.php +++ b/app/Http/Controllers/Api/IncidentUpdateController.php @@ -11,8 +11,8 @@ namespace CachetHQ\Cachet\Http\Controllers\Api; +use CachetHQ\Cachet\Bus\Commands\IncidentUpdate\CreateIncidentUpdateCommand; use CachetHQ\Cachet\Bus\Commands\IncidentUpdate\RemoveIncidentUpdateCommand; -use CachetHQ\Cachet\Bus\Commands\IncidentUpdate\ReportIncidentUpdateCommand; use CachetHQ\Cachet\Bus\Commands\IncidentUpdate\UpdateIncidentUpdateCommand; use CachetHQ\Cachet\Models\Incident; use CachetHQ\Cachet\Models\IncidentUpdate; @@ -74,7 +74,7 @@ class IncidentUpdateController extends AbstractApiController public function postIncidentUpdate(Incident $incident) { try { - $update = dispatch(new ReportIncidentUpdateCommand( + $update = dispatch(new CreateIncidentUpdateCommand( $incident, Binput::get('status'), Binput::get('message'), diff --git a/app/Http/Controllers/Dashboard/IncidentController.php b/app/Http/Controllers/Dashboard/IncidentController.php index 376f8a357..c1aa9a05f 100644 --- a/app/Http/Controllers/Dashboard/IncidentController.php +++ b/app/Http/Controllers/Dashboard/IncidentController.php @@ -12,10 +12,10 @@ namespace CachetHQ\Cachet\Http\Controllers\Dashboard; use AltThree\Validator\ValidationException; +use CachetHQ\Cachet\Bus\Commands\Incident\CreateIncidentCommand; use CachetHQ\Cachet\Bus\Commands\Incident\RemoveIncidentCommand; -use CachetHQ\Cachet\Bus\Commands\Incident\ReportIncidentCommand; use CachetHQ\Cachet\Bus\Commands\Incident\UpdateIncidentCommand; -use CachetHQ\Cachet\Bus\Commands\IncidentUpdate\ReportIncidentUpdateCommand; +use CachetHQ\Cachet\Bus\Commands\IncidentUpdate\CreateIncidentUpdateCommand; use CachetHQ\Cachet\Models\Component; use CachetHQ\Cachet\Models\ComponentGroup; use CachetHQ\Cachet\Models\Incident; @@ -108,7 +108,7 @@ class IncidentController extends Controller public function createIncidentAction() { try { - $incident = dispatch(new ReportIncidentCommand( + $incident = dispatch(new CreateIncidentCommand( Binput::get('name'), Binput::get('status'), Binput::get('message', null, false, false), @@ -308,7 +308,7 @@ class IncidentController extends Controller public function createIncidentUpdateAction(Incident $incident) { try { - $incident = dispatch(new ReportIncidentUpdateCommand( + $incident = dispatch(new CreateIncidentUpdateCommand( $incident, Binput::get('status'), Binput::get('message'), diff --git a/tests/Bus/Commands/Incident/ReportIncidentCommandTest.php b/tests/Bus/Commands/Incident/CreateIncidentCommandTest.php similarity index 82% rename from tests/Bus/Commands/Incident/ReportIncidentCommandTest.php rename to tests/Bus/Commands/Incident/CreateIncidentCommandTest.php index 3c135c078..e52796c3f 100644 --- a/tests/Bus/Commands/Incident/ReportIncidentCommandTest.php +++ b/tests/Bus/Commands/Incident/CreateIncidentCommandTest.php @@ -12,17 +12,17 @@ namespace CachetHQ\Tests\Cachet\Bus\Commands\Incident; use AltThree\TestBench\CommandTrait; -use CachetHQ\Cachet\Bus\Commands\Incident\ReportIncidentCommand; -use CachetHQ\Cachet\Bus\Handlers\Commands\Incident\ReportIncidentCommandHandler; +use CachetHQ\Cachet\Bus\Commands\Incident\CreateIncidentCommand; +use CachetHQ\Cachet\Bus\Handlers\Commands\Incident\CreateIncidentCommandHandler; use CachetHQ\Tests\Cachet\AbstractTestCase; /** - * This is the add incident command test class. + * This is the create incident command test class. * * @author James Brooks * @author Graham Campbell */ -class ReportIncidentCommandTest extends AbstractTestCase +class CreateIncidentCommandTest extends AbstractTestCase { use CommandTrait; @@ -42,7 +42,7 @@ class ReportIncidentCommandTest extends AbstractTestCase 'template_vars' => [], ]; - $object = new ReportIncidentCommand( + $object = new CreateIncidentCommand( $params['name'], $params['status'], $params['message'], @@ -66,6 +66,6 @@ class ReportIncidentCommandTest extends AbstractTestCase protected function getHandlerClass() { - return ReportIncidentCommandHandler::class; + return CreateIncidentCommandHandler::class; } } diff --git a/tests/Bus/Commands/IncidentUpdate/ReportIncidentUpdateCommandTest.php b/tests/Bus/Commands/IncidentUpdate/CreateIncidentUpdateCommandTest.php similarity index 73% rename from tests/Bus/Commands/IncidentUpdate/ReportIncidentUpdateCommandTest.php rename to tests/Bus/Commands/IncidentUpdate/CreateIncidentUpdateCommandTest.php index 3a81fd188..ef715e113 100644 --- a/tests/Bus/Commands/IncidentUpdate/ReportIncidentUpdateCommandTest.php +++ b/tests/Bus/Commands/IncidentUpdate/CreateIncidentUpdateCommandTest.php @@ -12,18 +12,18 @@ namespace CachetHQ\Tests\Cachet\Bus\Commands\IncidentUpdate; use AltThree\TestBench\CommandTrait; -use CachetHQ\Cachet\Bus\Commands\IncidentUpdate\ReportIncidentUpdateCommand; -use CachetHQ\Cachet\Bus\Handlers\Commands\IncidentUpdate\ReportIncidentUpdateCommandHandler; +use CachetHQ\Cachet\Bus\Commands\IncidentUpdate\CreateIncidentUpdateCommand; +use CachetHQ\Cachet\Bus\Handlers\Commands\IncidentUpdate\CreateIncidentUpdateCommandHandler; use CachetHQ\Cachet\Models\Incident; use CachetHQ\Cachet\Models\User; use CachetHQ\Tests\Cachet\AbstractTestCase; /** - * This is the report incident update command test class. + * This is the create incident update command test class. * * @author James Brooks */ -class ReportIncidentUpdateCommandTest extends AbstractTestCase +class CreateIncidentUpdateCommandTest extends AbstractTestCase { use CommandTrait; @@ -35,7 +35,7 @@ class ReportIncidentUpdateCommandTest extends AbstractTestCase 'message' => 'Foo', 'user' => new User(), ]; - $object = new ReportIncidentUpdateCommand($params['incident'], $params['status'], $params['message'], $params['user']); + $object = new CreateIncidentUpdateCommand($params['incident'], $params['status'], $params['message'], $params['user']); return compact('params', 'object'); } @@ -47,6 +47,6 @@ class ReportIncidentUpdateCommandTest extends AbstractTestCase protected function getHandlerClass() { - return ReportIncidentUpdateCommandHandler::class; + return CreateIncidentUpdateCommandHandler::class; } } diff --git a/tests/Bus/Events/Incident/IncidentWasReportedEventTest.php b/tests/Bus/Events/Incident/IncidentWasCreatedEventTest.php similarity index 70% rename from tests/Bus/Events/Incident/IncidentWasReportedEventTest.php rename to tests/Bus/Events/Incident/IncidentWasCreatedEventTest.php index cb4445d95..5fd7d7202 100644 --- a/tests/Bus/Events/Incident/IncidentWasReportedEventTest.php +++ b/tests/Bus/Events/Incident/IncidentWasCreatedEventTest.php @@ -11,16 +11,16 @@ namespace CachetHQ\Tests\Cachet\Bus\Events\Incident; -use CachetHQ\Cachet\Bus\Events\Incident\IncidentWasReportedEvent; +use CachetHQ\Cachet\Bus\Events\Incident\IncidentWasCreatedEvent; use CachetHQ\Cachet\Models\Incident; use CachetHQ\Cachet\Models\User; /** - * This is the incident was reported event test class. + * This is the incident was created event test class. * * @author James Brooks */ -class IncidentWasReportedEventTest extends AbstractIncidentEventTestCase +class IncidentWasCreatedEventTest extends AbstractIncidentEventTestCase { protected function objectHasHandlers() { @@ -34,7 +34,7 @@ class IncidentWasReportedEventTest extends AbstractIncidentEventTestCase 'incident' => new Incident(), 'notify' => true, ]; - $object = new IncidentWasReportedEvent($params['user'], $params['incident'], $params['notify']); + $object = new IncidentWasCreatedEvent($params['user'], $params['incident'], $params['notify']); return compact('params', 'object'); }