mirror of
https://github.com/CachetHQ/Cachet.git
synced 2025-01-17 21:49:01 +01:00
Added beacon events
This commit is contained in:
parent
1559e5945d
commit
9da17e7c15
24
app/Bus/Events/Beacon/BeaconEventInterface.php
Normal file
24
app/Bus/Events/Beacon/BeaconEventInterface.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?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\Cachet\Bus\Events\Beacon;
|
||||
|
||||
use CachetHQ\Cachet\Bus\Events\EventInterface;
|
||||
|
||||
/**
|
||||
* This is the beacon event interface.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
interface BeaconEventInterface extends EventInterface
|
||||
{
|
||||
//
|
||||
}
|
22
app/Bus/Events/Beacon/BeaconFailedToSendEvent.php
Normal file
22
app/Bus/Events/Beacon/BeaconFailedToSendEvent.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?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\Cachet\Bus\Events\Beacon;
|
||||
|
||||
/**
|
||||
* This is the beacon failed to send event.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
final class BeaconFailedToSendEvent implements BeaconEventInterface
|
||||
{
|
||||
//
|
||||
}
|
22
app/Bus/Events/Beacon/BeaconWasSentEvent.php
Normal file
22
app/Bus/Events/Beacon/BeaconWasSentEvent.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?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\Cachet\Bus\Events\Beacon;
|
||||
|
||||
/**
|
||||
* This is the beacon was sent event.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
final class BeaconWasSentEvent implements BeaconEventInterface
|
||||
{
|
||||
//
|
||||
}
|
@ -21,6 +21,12 @@ class EventServiceProvider extends ServiceProvider
|
||||
* @var array
|
||||
*/
|
||||
protected $listen = [
|
||||
'CachetHQ\Cachet\Bus\Events\Beacon\BeaconFailedToSendEvent' => [
|
||||
//
|
||||
],
|
||||
'CachetHQ\Cachet\Bus\Events\Beacon\BeaconWasSentEvent' => [
|
||||
//
|
||||
],
|
||||
'CachetHQ\Cachet\Bus\Events\ComponentGroup\ComponentGroupWasAddedEvent' => [
|
||||
//
|
||||
],
|
||||
|
@ -17,6 +17,8 @@ use CachetHQ\Cachet\Models\Incident;
|
||||
use CachetHQ\Cachet\Models\Metric;
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
use CachetHQ\Cachet\Settings\Repository as Setting;
|
||||
use CachetHQ\Cachet\Bus\Events\Beacon\BeaconWasSentEvent;
|
||||
use CachetHQ\Cachet\Bus\Events\Beacon\BeaconFailedToSendEvent;
|
||||
use Exception;
|
||||
use GuzzleHttp\Client;
|
||||
use Illuminate\Contracts\Config\Repository;
|
||||
@ -110,6 +112,11 @@ class Beacon implements BeaconContract
|
||||
]);
|
||||
} catch (Exception $e) {
|
||||
// TODO: Log a warning that the beacon could not be sent.
|
||||
event(new BeaconFailedToSendEvent());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
event(new BeaconWasSentEvent());
|
||||
}
|
||||
}
|
||||
|
31
tests/Bus/Events/Beacon/AbstractBeaconEventTestCase.php
Normal file
31
tests/Bus/Events/Beacon/AbstractBeaconEventTestCase.php
Normal 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\Bus\Events\Beacon;
|
||||
|
||||
use AltThree\TestBench\EventTrait;
|
||||
use CachetHQ\Cachet\Bus\Events\Beacon\BeaconEventInterface;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
|
||||
/**
|
||||
* This is the abstract beacon event test case.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
abstract class AbstractBeaconEventTestCase extends AbstractTestCase
|
||||
{
|
||||
use EventTrait;
|
||||
|
||||
protected function getEventInterfaces()
|
||||
{
|
||||
return [BeaconEventInterface::class];
|
||||
}
|
||||
}
|
35
tests/Bus/Events/Beacon/BeaconFailedToSendEventTest.php
Normal file
35
tests/Bus/Events/Beacon/BeaconFailedToSendEventTest.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?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\Beacon;
|
||||
|
||||
use CachetHQ\Cachet\Bus\Events\Beacon\BeaconFailedToSendEvent;
|
||||
|
||||
/**
|
||||
* This is the beacon was sent event test.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class BeaconFailedToSendEventTest extends AbstractBeaconEventTestCase
|
||||
{
|
||||
protected function objectHasHandlers()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getObjectAndParams()
|
||||
{
|
||||
$params = [];
|
||||
$object = new BeaconFailedToSendEvent();
|
||||
|
||||
return compact('params', 'object');
|
||||
}
|
||||
}
|
35
tests/Bus/Events/Beacon/BeaconWasSentEventTest.php
Normal file
35
tests/Bus/Events/Beacon/BeaconWasSentEventTest.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?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\Beacon;
|
||||
|
||||
use CachetHQ\Cachet\Bus\Events\Beacon\BeaconWasSentEvent;
|
||||
|
||||
/**
|
||||
* This is the beacon was sent event test.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class BeaconWasSentEventTest extends AbstractBeaconEventTestCase
|
||||
{
|
||||
protected function objectHasHandlers()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getObjectAndParams()
|
||||
{
|
||||
$params = [];
|
||||
$object = new BeaconWasSentEvent();
|
||||
|
||||
return compact('params', 'object');
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user