Skip to content

Commit

Permalink
Merge pull request #2004 from CachetHQ/existence
Browse files Browse the repository at this point in the history
Improved the bus test coverage
  • Loading branch information
GrahamCampbell committed Jul 29, 2016
2 parents 8348f48 + 16189da commit b045028
Show file tree
Hide file tree
Showing 13 changed files with 431 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/Foundation/Providers/EventServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
],
Expand Down Expand Up @@ -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' => [
//
],
];
}
30 changes: 30 additions & 0 deletions tests/Bus/Commands/CommandExistenceTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

/*
* This file is part of Cachet.
*
* (c) Alt Three Services Limited
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace CachetHQ\Tests\Cachet\Bus\Commands;

use AltThree\TestBench\ExistenceTrait;
use PHPUnit_Framework_TestCase as TestCase;

/**
* This is the command existence test class.
*
* @author Graham Campbell <[email protected]>
*/
class CommandExistenceTest extends TestCase
{
use ExistenceTrait;

protected function getSourcePath()
{
return realpath(__DIR__.'/../../../app/Bus/Commands');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

/*
* This file is part of Cachet.
*
* (c) Alt Three Services Limited
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace CachetHQ\Tests\Cachet\Bus\Commands\Subscriber;

use AltThree\TestBench\CommandTrait;
use CachetHQ\Cachet\Bus\Commands\Subscriber\UpdateSubscriberSubscriptionCommand;
use CachetHQ\Cachet\Bus\Handlers\Commands\Subscriber\UpdateSubscriberSubscriptionCommandHandler;
use CachetHQ\Cachet\Models\Subscriber;
use CachetHQ\Tests\Cachet\AbstractTestCase;

/**
* This is the update subscriber subscription command test class.
*
* @author James Brooks <[email protected]>
*/
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;
}
}
30 changes: 30 additions & 0 deletions tests/Bus/Events/EventExistenceTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

/*
* This file is part of Cachet.
*
* (c) Alt Three Services Limited
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace CachetHQ\Tests\Cachet\Bus\Events;

use AltThree\TestBench\ExistenceTrait;
use PHPUnit_Framework_TestCase as TestCase;

/**
* This is the event existence test class.
*
* @author Graham Campbell <[email protected]>
*/
class EventExistenceTest extends TestCase
{
use ExistenceTrait;

protected function getSourcePath()
{
return realpath(__DIR__.'/../../../app/Bus/Events');
}
}
36 changes: 36 additions & 0 deletions tests/Bus/Events/Incident/IncidentWasRemovedEventTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

/*
* This file is part of Cachet.
*
* (c) Alt Three Services Limited
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace CachetHQ\Tests\Cachet\Bus\Events\Incident;

use CachetHQ\Cachet\Bus\Events\Incident\IncidentWasRemovedEvent;
use CachetHQ\Cachet\Models\Incident;

/**
* This is the incident was removed event test class.
*
* @author James Brooks <[email protected]>
*/
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');
}
}
36 changes: 36 additions & 0 deletions tests/Bus/Events/Incident/IncidentWasReportedEventTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

/*
* This file is part of Cachet.
*
* (c) Alt Three Services Limited
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace CachetHQ\Tests\Cachet\Bus\Events\Incident;

use CachetHQ\Cachet\Bus\Events\Incident\IncidentWasReportedEvent;
use CachetHQ\Cachet\Models\Incident;

/**
* This is the incident was reported event test class.
*
* @author James Brooks <[email protected]>
*/
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');
}
}
36 changes: 36 additions & 0 deletions tests/Bus/Events/Incident/IncidentWasUpdatedEventTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

/*
* This file is part of Cachet.
*
* (c) Alt Three Services Limited
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace CachetHQ\Tests\Cachet\Bus\Events\Incident;

use CachetHQ\Cachet\Bus\Events\Incident\IncidentWasUpdatedEvent;
use CachetHQ\Cachet\Models\Incident;

/**
* This is the incident was updated event test class.
*
* @author James Brooks <[email protected]>
*/
class IncidentWasUpdatedEventTest extends AbstractIncidentEventTestCase
{
protected function objectHasHandlers()
{
return false;
}

protected function getObjectAndParams()
{
$params = ['incident' => new Incident()];
$object = new IncidentWasUpdatedEvent($params['incident']);

return compact('params', 'object');
}
}
36 changes: 36 additions & 0 deletions tests/Bus/Events/Incident/MaintenanceWasScheduledEventTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

/*
* This file is part of Cachet.
*
* (c) Alt Three Services Limited
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace CachetHQ\Tests\Cachet\Bus\Events\Incident;

use CachetHQ\Cachet\Bus\Events\Incident\MaintenanceWasScheduledEvent;
use CachetHQ\Cachet\Models\Incident;

/**
* This is the maintenance was scheduled event test class.
*
* @author James Brooks <[email protected]>
*/
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');
}
}
36 changes: 36 additions & 0 deletions tests/Bus/Events/Metric/MetricPointWasAddedEventTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

/*
* This file is part of Cachet.
*
* (c) Alt Three Services Limited
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace CachetHQ\Tests\Cachet\Bus\Events\Metric;

use CachetHQ\Cachet\Bus\Events\Metric\MetricPointWasAddedEvent;
use CachetHQ\Cachet\Models\MetricPoint;

/**
* This is the metric point was added event test class.
*
* @author James Brooks <[email protected]>
*/
class MetricPointWasAddedEventTest extends AbstractMetricEventTestCase
{
protected function objectHasHandlers()
{
return false;
}

protected function getObjectAndParams()
{
$params = ['metricPoint' => new MetricPoint()];
$object = new MetricPointWasAddedEvent($params['metricPoint']);

return compact('params', 'object');
}
}
36 changes: 36 additions & 0 deletions tests/Bus/Events/Metric/MetricPointWasRemovedEventTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

/*
* This file is part of Cachet.
*
* (c) Alt Three Services Limited
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace CachetHQ\Tests\Cachet\Bus\Events\Metric;

use CachetHQ\Cachet\Bus\Events\Metric\MetricPointWasRemovedEvent;
use CachetHQ\Cachet\Models\MetricPoint;

/**
* This is the metric point was removed event test class.
*
* @author James Brooks <[email protected]>
*/
class MetricPointWasRemovedEventTest extends AbstractMetricEventTestCase
{
protected function objectHasHandlers()
{
return false;
}

protected function getObjectAndParams()
{
$params = ['metricPoint' => new MetricPoint()];
$object = new MetricPointWasRemovedEvent($params['metricPoint']);

return compact('params', 'object');
}
}
36 changes: 36 additions & 0 deletions tests/Bus/Events/Metric/MetricPointWasUpdatedEventTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

/*
* This file is part of Cachet.
*
* (c) Alt Three Services Limited
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace CachetHQ\Tests\Cachet\Bus\Events\Metric;

use CachetHQ\Cachet\Bus\Events\Metric\MetricPointWasUpdatedEvent;
use CachetHQ\Cachet\Models\MetricPoint;

/**
* This is the metric point was updated event test class.
*
* @author James Brooks <[email protected]>
*/
class MetricPointWasUpdatedEventTest extends AbstractMetricEventTestCase
{
protected function objectHasHandlers()
{
return false;
}

protected function getObjectAndParams()
{
$params = ['metricPoint' => new MetricPoint()];
$object = new MetricPointWasUpdatedEvent($params['metricPoint']);

return compact('params', 'object');
}
}
Loading

0 comments on commit b045028

Please sign in to comment.