Merge pull request #1305 from cachethq/event-tests

Event tests
This commit is contained in:
James Brooks
2015-12-26 10:10:35 +00:00
41 changed files with 625 additions and 21 deletions

View File

@@ -13,7 +13,7 @@ namespace CachetHQ\Cachet\Events\Component;
use CachetHQ\Cachet\Models\Component;
class ComponentWasAddedEvent implements ComponentEventInterface
final class ComponentWasAddedEvent implements ComponentEventInterface
{
/**
* The component that was added.

View File

@@ -13,7 +13,7 @@ namespace CachetHQ\Cachet\Events\Component;
use CachetHQ\Cachet\Models\Component;
class ComponentWasRemovedEvent implements ComponentEventInterface
final class ComponentWasRemovedEvent implements ComponentEventInterface
{
/**
* The component that was removed.

View File

@@ -13,7 +13,7 @@ namespace CachetHQ\Cachet\Events\Component;
use CachetHQ\Cachet\Models\Component;
class ComponentWasUpdatedEvent implements ComponentEventInterface
final class ComponentWasUpdatedEvent implements ComponentEventInterface
{
/**
* The component that was updated.

View File

@@ -13,7 +13,7 @@ namespace CachetHQ\Cachet\Events\ComponentGroup;
use CachetHQ\Cachet\Models\ComponentGroup;
class ComponentGroupWasAddedEvent implements ComponentGroupEventInterface
final class ComponentGroupWasAddedEvent implements ComponentGroupEventInterface
{
/**
* The component group that was added.

View File

@@ -13,7 +13,7 @@ namespace CachetHQ\Cachet\Events\ComponentGroup;
use CachetHQ\Cachet\Models\ComponentGroup;
class ComponentGroupWasRemovedEvent implements ComponentGroupEventInterface
final class ComponentGroupWasRemovedEvent implements ComponentGroupEventInterface
{
/**
* The component group that was removed.

View File

@@ -13,7 +13,7 @@ namespace CachetHQ\Cachet\Events\ComponentGroup;
use CachetHQ\Cachet\Models\ComponentGroup;
class ComponentGroupWasUpdatedEvent implements ComponentGroupEventInterface
final class ComponentGroupWasUpdatedEvent implements ComponentGroupEventInterface
{
/**
* The component group that was updated.

View File

@@ -13,7 +13,7 @@ namespace CachetHQ\Cachet\Events\Incident;
use CachetHQ\Cachet\Models\Incident;
class IncidentWasRemovedEvent implements IncidentEventInterface
final class IncidentWasRemovedEvent implements IncidentEventInterface
{
/**
* The incident that has been removed.

View File

@@ -13,7 +13,7 @@ namespace CachetHQ\Cachet\Events\Incident;
use CachetHQ\Cachet\Models\Incident;
class IncidentWasReportedEvent implements IncidentEventInterface
final class IncidentWasReportedEvent implements IncidentEventInterface
{
/**
* The incident that has been reported.

View File

@@ -13,7 +13,7 @@ namespace CachetHQ\Cachet\Events\Incident;
use CachetHQ\Cachet\Models\Incident;
class IncidentWasUpdatedEvent implements IncidentEventInterface
final class IncidentWasUpdatedEvent implements IncidentEventInterface
{
/**
* The incident that has been updated.

View File

@@ -13,7 +13,7 @@ namespace CachetHQ\Cachet\Events\Incident;
use CachetHQ\Cachet\Models\Incident;
class MaintenanceWasScheduledEvent implements IncidentEventInterface
final class MaintenanceWasScheduledEvent implements IncidentEventInterface
{
/**
* The incident that has been reported.

View File

@@ -13,7 +13,7 @@ namespace CachetHQ\Cachet\Events\Invite;
use CachetHQ\Cachet\Models\Invite;
final class InviteWasClaimed implements InviteEventInterface
final class InviteWasClaimedEvent implements InviteEventInterface
{
/**
* The invite that has been claimed.

View File

@@ -13,7 +13,7 @@ namespace CachetHQ\Cachet\Events\Metric;
use CachetHQ\Cachet\Models\MetricPoint;
class MetricPointWasAddedEvent implements MetricEventInterface
final class MetricPointWasAddedEvent implements MetricEventInterface
{
/**
* The metric point that was added.

View File

@@ -13,7 +13,7 @@ namespace CachetHQ\Cachet\Events\Metric;
use CachetHQ\Cachet\Models\MetricPoint;
class MetricPointWasRemovedEvent implements MetricEventInterface
final class MetricPointWasRemovedEvent implements MetricEventInterface
{
/**
* The metric point that was removed.

View File

@@ -13,7 +13,7 @@ namespace CachetHQ\Cachet\Events\Metric;
use CachetHQ\Cachet\Models\MetricPoint;
class MetricPointWasUpdatedEvent implements MetricEventInterface
final class MetricPointWasUpdatedEvent implements MetricEventInterface
{
/**
* The metric point that was updated.

View File

@@ -13,7 +13,7 @@ namespace CachetHQ\Cachet\Events\Metric;
use CachetHQ\Cachet\Models\Metric;
class MetricWasAddedEvent implements MetricEventInterface
final class MetricWasAddedEvent implements MetricEventInterface
{
/**
* The metric that was added.

View File

@@ -13,7 +13,7 @@ namespace CachetHQ\Cachet\Events\Metric;
use CachetHQ\Cachet\Models\Metric;
class MetricWasRemovedEvent implements MetricEventInterface
final class MetricWasRemovedEvent implements MetricEventInterface
{
/**
* The metric that was removed.

View File

@@ -13,7 +13,7 @@ namespace CachetHQ\Cachet\Events\Metric;
use CachetHQ\Cachet\Models\Metric;
class MetricWasUpdatedEvent implements MetricEventInterface
final class MetricWasUpdatedEvent implements MetricEventInterface
{
/**
* The metric that was updated.

View File

@@ -13,7 +13,7 @@ namespace CachetHQ\Cachet\Events\Subscriber;
use CachetHQ\Cachet\Models\Subscriber;
class SubscriberHasSubscribedEvent implements SubscriberEventInterface
final class SubscriberHasSubscribedEvent implements SubscriberEventInterface
{
/**
* The subscriber who has subscribed.

View File

@@ -13,7 +13,7 @@ namespace CachetHQ\Cachet\Events\Subscriber;
use CachetHQ\Cachet\Models\Subscriber;
class SubscriberHasUnsubscribedEvent implements SubscriberEventInterface
final class SubscriberHasUnsubscribedEvent implements SubscriberEventInterface
{
/**
* The subscriber who has unsubscribed.

View File

@@ -13,7 +13,7 @@ namespace CachetHQ\Cachet\Events\Subscriber;
use CachetHQ\Cachet\Models\Subscriber;
class SubscriberHasVerifiedEvent implements SubscriberEventInterface
final class SubscriberHasVerifiedEvent implements SubscriberEventInterface
{
/**
* The subscriber who has verified.

View File

@@ -13,7 +13,7 @@ namespace CachetHQ\Cachet\Events\User;
use CachetHQ\Cachet\Models\Invite;
final class UserWasInvitedEvent
final class UserWasInvitedEvent implements UserEventInterface
{
/**
* The invite that has been added.

View File

@@ -21,15 +21,60 @@ class EventServiceProvider extends ServiceProvider
* @var array
*/
protected $listen = [
'CachetHQ\Cachet\Events\ComponentGroup\ComponentGroupWasAddedEvent' => [
//
],
'CachetHQ\Cachet\Events\ComponentGroup\ComponentGroupWasRemovedEvent' => [
//
],
'CachetHQ\Cachet\Events\ComponentGroup\ComponentGroupWasUpdatedEvent' => [
//
],
'CachetHQ\Cachet\Events\Component\ComponentWasAddedEvent' => [
//
],
'CachetHQ\Cachet\Events\Component\ComponentWasRemovedEvent' => [
//
],
'CachetHQ\Cachet\Events\Component\ComponentWasUpdatedEvent' => [
//
],
'CachetHQ\Cachet\Events\Incident\IncidentWasReportedEvent' => [
'CachetHQ\Cachet\Handlers\Events\Incident\SendIncidentEmailNotificationHandler',
],
'CachetHQ\Cachet\Events\Incident\MaintenanceWasScheduledEvent' => [
'CachetHQ\Cachet\Handlers\Events\Incident\SendMaintenanceEmailNotificationHandler',
],
'CachetHQ\Cachet\Events\Invite\InviteWasClaimedEvent' => [
//
],
'CachetHQ\Cachet\Events\Metric\MetricPointWasAddedEvent' => [
//
],
'CachetHQ\Cachet\Events\Metric\MetricPointWasRemovedEvent' => [
//
],
'CachetHQ\Cachet\Events\Metric\MetricPointWasUpdatedEvent' => [
//
],
'CachetHQ\Cachet\Events\Metric\MetricWasAddedEvent' => [
//
],
'CachetHQ\Cachet\Events\Metric\MetricWasRemovedEvent' => [
//
],
'CachetHQ\Cachet\Events\Metric\MetricWasUpdatedEvent' => [
//
],
'CachetHQ\Cachet\Events\Subscriber\SubscriberHasSubscribedEvent' => [
'CachetHQ\Cachet\Handlers\Events\Subscriber\SendSubscriberVerificationEmailHandler',
],
'CachetHQ\Cachet\Events\Subscriber\SubscriberHasUnsubscribedEvent' => [
//
],
'CachetHQ\Cachet\Events\Subscriber\SubscriberHasVerifiedEvent' => [
//
],
'CachetHQ\Cachet\Events\User\UserWasAddedEvent' => [
//
],

View File

@@ -0,0 +1,26 @@
<?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\Events\Component;
use AltThree\TestBench\EventTrait;
use CachetHQ\Cachet\Events\Component\ComponentEventInterface;
use CachetHQ\Tests\Cachet\AbstractTestCase;
abstract class AbstractComponentEventTestCase extends AbstractTestCase
{
use EventTrait;
protected function getEventInterfaces()
{
return [ComponentEventInterface::class];
}
}

View File

@@ -0,0 +1,31 @@
<?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\Events\Component;
use CachetHQ\Cachet\Events\Component\ComponentWasAddedEvent;
use CachetHQ\Cachet\Models\Component;
class ComponentWasAddedEventTest extends AbstractComponentEventTestCase
{
protected function objectHasHandlers()
{
return false;
}
protected function getObjectAndParams()
{
$params = ['component' => new Component()];
$object = new ComponentWasAddedEvent($params['component']);
return compact('params', 'object');
}
}

View File

@@ -0,0 +1,31 @@
<?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\Events\Component;
use CachetHQ\Cachet\Events\Component\ComponentWasRemovedEvent;
use CachetHQ\Cachet\Models\Component;
class ComponentWasRemovedEventTest extends AbstractComponentEventTestCase
{
protected function objectHasHandlers()
{
return false;
}
protected function getObjectAndParams()
{
$params = ['component' => new Component()];
$object = new ComponentWasRemovedEvent($params['component']);
return compact('params', 'object');
}
}

View File

@@ -0,0 +1,31 @@
<?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\Events\Component;
use CachetHQ\Cachet\Events\Component\ComponentWasUpdatedEvent;
use CachetHQ\Cachet\Models\Component;
class ComponentWasUpdatedEventTest extends AbstractComponentEventTestCase
{
protected function objectHasHandlers()
{
return false;
}
protected function getObjectAndParams()
{
$params = ['component' => new Component()];
$object = new ComponentWasUpdatedEvent($params['component']);
return compact('params', 'object');
}
}

View File

@@ -0,0 +1,26 @@
<?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\Events\ComponentGroup;
use AltThree\TestBench\EventTrait;
use CachetHQ\Cachet\Events\ComponentGroup\ComponentGroupEventInterface;
use CachetHQ\Tests\Cachet\AbstractTestCase;
abstract class AbstractComponentGroupEventTestCase extends AbstractTestCase
{
use EventTrait;
protected function getEventInterfaces()
{
return [ComponentGroupEventInterface::class];
}
}

View File

@@ -0,0 +1,31 @@
<?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\Events\ComponentGroup;
use CachetHQ\Cachet\Events\ComponentGroup\ComponentGroupWasAddedEvent;
use CachetHQ\Cachet\Models\ComponentGroup;
class ComponentGroupWasAddedEventTest extends AbstractComponentGroupEventTestCase
{
protected function objectHasHandlers()
{
return false;
}
protected function getObjectAndParams()
{
$params = ['group' => new ComponentGroup()];
$object = new ComponentGroupWasAddedEvent($params['group']);
return compact('params', 'object');
}
}

View File

@@ -0,0 +1,31 @@
<?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\Events\ComponentGroup;
use CachetHQ\Cachet\Events\ComponentGroup\ComponentGroupWasRemovedEvent;
use CachetHQ\Cachet\Models\ComponentGroup;
class ComponentGroupWasRemovedEventTest extends AbstractComponentGroupEventTestCase
{
protected function objectHasHandlers()
{
return false;
}
protected function getObjectAndParams()
{
$params = ['group' => new ComponentGroup()];
$object = new ComponentGroupWasRemovedEvent($params['group']);
return compact('params', 'object');
}
}

View File

@@ -0,0 +1,31 @@
<?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\Events\ComponentGroup;
use CachetHQ\Cachet\Events\ComponentGroup\ComponentGroupWasUpdatedEvent;
use CachetHQ\Cachet\Models\ComponentGroup;
class ComponentGroupWasUpdatedEventTest extends AbstractComponentGroupEventTestCase
{
protected function objectHasHandlers()
{
return false;
}
protected function getObjectAndParams()
{
$params = ['group' => new ComponentGroup()];
$object = new ComponentGroupWasUpdatedEvent($params['group']);
return compact('params', 'object');
}
}

View File

@@ -0,0 +1,26 @@
<?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\Events\Incident;
use AltThree\TestBench\EventTrait;
use CachetHQ\Cachet\Events\Incident\IncidentEventInterface;
use CachetHQ\Tests\Cachet\AbstractTestCase;
abstract class AbstractIncidentEventTestCase extends AbstractTestCase
{
use EventTrait;
protected function getEventInterfaces()
{
return [IncidentEventInterface::class];
}
}

View File

@@ -0,0 +1,26 @@
<?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\Events\Invite;
use AltThree\TestBench\EventTrait;
use CachetHQ\Cachet\Events\Invite\InviteEventInterface;
use CachetHQ\Tests\Cachet\AbstractTestCase;
abstract class AbstractInviteEventTestCase extends AbstractTestCase
{
use EventTrait;
protected function getEventInterfaces()
{
return [InviteEventInterface::class];
}
}

View File

@@ -0,0 +1,31 @@
<?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\Events\Invite;
use CachetHQ\Cachet\Events\Invite\InviteWasClaimedEvent;
use CachetHQ\Cachet\Models\Invite;
class InviteWasClaimedEventTest extends AbstractInviteEventTestCase
{
protected function objectHasHandlers()
{
return false;
}
protected function getObjectAndParams()
{
$params = ['invite' => new Invite()];
$object = new InviteWasClaimedEvent($params['invite']);
return compact('params', 'object');
}
}

View File

@@ -0,0 +1,26 @@
<?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\Events\Metric;
use AltThree\TestBench\EventTrait;
use CachetHQ\Cachet\Events\Metric\MetricEventInterface;
use CachetHQ\Tests\Cachet\AbstractTestCase;
abstract class AbstractMetricEventTestCase extends AbstractTestCase
{
use EventTrait;
protected function getEventInterfaces()
{
return [MetricEventInterface::class];
}
}

View File

@@ -0,0 +1,31 @@
<?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\Events\Metric;
use CachetHQ\Cachet\Events\Metric\MetricWasAddedEvent;
use CachetHQ\Cachet\Models\Metric;
class MetricWasAddedEventTest extends AbstractMetricEventTestCase
{
protected function objectHasHandlers()
{
return false;
}
protected function getObjectAndParams()
{
$params = ['metric' => new Metric()];
$object = new MetricWasAddedEvent($params['metric']);
return compact('params', 'object');
}
}

View File

@@ -0,0 +1,31 @@
<?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\Events\Metric;
use CachetHQ\Cachet\Events\Metric\MetricWasRemovedEvent;
use CachetHQ\Cachet\Models\Metric;
class MetricWasRemovedEventTest extends AbstractMetricEventTestCase
{
protected function objectHasHandlers()
{
return false;
}
protected function getObjectAndParams()
{
$params = ['metric' => new Metric()];
$object = new MetricWasRemovedEvent($params['metric']);
return compact('params', 'object');
}
}

View File

@@ -0,0 +1,31 @@
<?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\Events\Metric;
use CachetHQ\Cachet\Events\Metric\MetricWasUpdatedEvent;
use CachetHQ\Cachet\Models\Metric;
class MetricWasUpdatedEventTest extends AbstractMetricEventTestCase
{
protected function objectHasHandlers()
{
return false;
}
protected function getObjectAndParams()
{
$params = ['metric' => new Metric()];
$object = new MetricWasUpdatedEvent($params['metric']);
return compact('params', 'object');
}
}

View File

@@ -0,0 +1,26 @@
<?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\Events\Subscriber;
use AltThree\TestBench\EventTrait;
use CachetHQ\Cachet\Events\Subscriber\SubscriberEventInterface;
use CachetHQ\Tests\Cachet\AbstractTestCase;
abstract class AbstractSubscriberEventTestCase extends AbstractTestCase
{
use EventTrait;
protected function getEventInterfaces()
{
return [SubscriberEventInterface::class];
}
}

View File

@@ -0,0 +1,31 @@
<?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\Events\Subscriber;
use CachetHQ\Cachet\Events\Subscriber\SubscriberHasSubscribedEvent;
use CachetHQ\Cachet\Models\Subscriber;
class SubscriberHasSubscribedEventTest extends AbstractSubscriberEventTestCase
{
protected function objectHasHandlers()
{
return true;
}
protected function getObjectAndParams()
{
$params = ['subscriber' => new Subscriber()];
$object = new SubscriberHasSubscribedEvent($params['subscriber']);
return compact('params', 'object');
}
}

View File

@@ -0,0 +1,31 @@
<?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\Events\Subscriber;
use CachetHQ\Cachet\Events\Subscriber\SubscriberHasUnsubscribedEvent;
use CachetHQ\Cachet\Models\Subscriber;
class SubscriberHasUnsubscribedEventTest extends AbstractSubscriberEventTestCase
{
protected function objectHasHandlers()
{
return false;
}
protected function getObjectAndParams()
{
$params = ['subscriber' => new Subscriber()];
$object = new SubscriberHasUnsubscribedEvent($params['subscriber']);
return compact('params', 'object');
}
}

View File

@@ -0,0 +1,31 @@
<?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\Events\Subscriber;
use CachetHQ\Cachet\Events\Subscriber\SubscriberHasVerifiedEvent;
use CachetHQ\Cachet\Models\Subscriber;
class SubscriberHasVerifiedEventTest extends AbstractSubscriberEventTestCase
{
protected function objectHasHandlers()
{
return false;
}
protected function getObjectAndParams()
{
$params = ['subscriber' => new Subscriber()];
$object = new SubscriberHasVerifiedEvent($params['subscriber']);
return compact('params', 'object');
}
}