Merge pull request #2004 from CachetHQ/existence

Improved the bus test coverage
This commit is contained in:
Graham Campbell
2016-07-29 13:12:29 -04:00
committed by GitHub
13 changed files with 431 additions and 0 deletions

View File

@@ -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' => [
//
],
];
}

View File

@@ -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 <graham@alt-three.com>
*/
class CommandExistenceTest extends TestCase
{
use ExistenceTrait;
protected function getSourcePath()
{
return realpath(__DIR__.'/../../../app/Bus/Commands');
}
}

View File

@@ -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 <james@alt-three.com>
*/
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;
}
}

View File

@@ -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 <graham@alt-three.com>
*/
class EventExistenceTest extends TestCase
{
use ExistenceTrait;
protected function getSourcePath()
{
return realpath(__DIR__.'/../../../app/Bus/Events');
}
}

View File

@@ -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 <james@alt-three.com>
*/
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');
}
}

View File

@@ -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 <james@alt-three.com>
*/
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');
}
}

View File

@@ -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 <james@alt-three.com>
*/
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');
}
}

View File

@@ -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 <james@alt-three.com>
*/
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');
}
}

View File

@@ -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 <james@alt-three.com>
*/
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');
}
}

View File

@@ -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 <james@alt-three.com>
*/
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');
}
}

View File

@@ -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 <james@alt-three.com>
*/
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');
}
}

View File

@@ -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\User;
use CachetHQ\Cachet\Bus\Events\User\UserWasInvitedEvent;
use CachetHQ\Cachet\Models\Invite;
/**
* This is the user was invited event test class.
*
* @author James Brooks <james@alt-three.com>
*/
class UserWasInvitedEventTest extends AbstractUserEventTestCase
{
protected function objectHasHandlers()
{
return true;
}
protected function getObjectAndParams()
{
$params = ['invite' => new Invite()];
$object = new UserWasInvitedEvent($params['invite']);
return compact('params', 'object');
}
}

View File

@@ -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\User;
use CachetHQ\Cachet\Bus\Events\User\UserWasRemovedEvent;
use CachetHQ\Cachet\Models\User;
/**
* This is the user was removed event test class.
*
* @author James Brooks <james@alt-three.com>
*/
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');
}
}