Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved the bus test coverage #2004

Merged
merged 6 commits into from
Jul 29, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/Foundation/Providers/EventServiceProvider.php
Original file line number Diff line number Diff line change
@@ -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' => [
//
],
];
}
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 <graham@alt-three.com>
*/
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 <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;
}
}
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 <graham@alt-three.com>
*/
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 <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');
}
}
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 <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');
}
}
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 <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');
}
}
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 <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');
}
}
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 <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');
}
}
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 <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');
}
}
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 <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');
}
}
36 changes: 36 additions & 0 deletions tests/Bus/Events/User/UserWasInvitedEventTest.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\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');
}
}
36 changes: 36 additions & 0 deletions tests/Bus/Events/User/UserWasRemovedEventTest.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\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');
}
}