Backport Incident Updates from v3.0.0
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
<?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\Api;
|
||||
|
||||
/**
|
||||
* This is the incident update test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class IncidentUpdateTest extends AbstractApiTestCase
|
||||
{
|
||||
public function testGetIncidentUpdates()
|
||||
{
|
||||
$incident = factory('CachetHQ\Cachet\Models\Incident')->create();
|
||||
$updates = factory('CachetHQ\Cachet\Models\IncidentUpdate', 3)->create([
|
||||
'incident_id' => $incident->id,
|
||||
]);
|
||||
|
||||
$this->get("/api/v1/incidents/{$incident->id}/updates");
|
||||
|
||||
$this->assertResponseOk();
|
||||
|
||||
$this->seeJson(['id' => $updates[0]->id]);
|
||||
$this->seeJson(['id' => $updates[1]->id]);
|
||||
$this->seeJson(['id' => $updates[2]->id]);
|
||||
}
|
||||
|
||||
public function testGetInvalidIncidentUpdate()
|
||||
{
|
||||
$this->get('/api/v1/incidents/1/updates/1');
|
||||
|
||||
$this->assertResponseStatus(404);
|
||||
}
|
||||
|
||||
public function testPostIncidentUpdateUnauthorized()
|
||||
{
|
||||
$incident = factory('CachetHQ\Cachet\Models\Incident')->create();
|
||||
$this->post("/api/v1/incidents/{$incident->id}/updates");
|
||||
|
||||
$this->assertResponseStatus(401);
|
||||
}
|
||||
|
||||
public function testPostIncidentUpdateNoData()
|
||||
{
|
||||
$this->beUser();
|
||||
$incident = factory('CachetHQ\Cachet\Models\Incident')->create();
|
||||
|
||||
$this->post("/api/v1/incidents/{$incident->id}/updates");
|
||||
|
||||
$this->assertResponseStatus(400);
|
||||
}
|
||||
|
||||
public function testPostIncidentUpdate()
|
||||
{
|
||||
$this->beUser();
|
||||
$incident = factory('CachetHQ\Cachet\Models\Incident')->create();
|
||||
|
||||
$this->post("/api/v1/incidents/{$incident->id}/updates", [
|
||||
'status' => 4,
|
||||
'message' => 'Incident fixed!',
|
||||
]);
|
||||
|
||||
$this->assertResponseOk();
|
||||
|
||||
$this->seeJson(['incident_id' => $incident->id]);
|
||||
}
|
||||
|
||||
public function testPutIncidentUpdate()
|
||||
{
|
||||
$this->beUser();
|
||||
$incident = factory('CachetHQ\Cachet\Models\Incident')->create();
|
||||
$update = factory('CachetHQ\Cachet\Models\IncidentUpdate')->create();
|
||||
|
||||
$this->put("/api/v1/incidents/{$incident->id}/updates/{$update->id}", [
|
||||
'message' => 'Message updated :smile:',
|
||||
]);
|
||||
|
||||
$this->assertResponseOk();
|
||||
|
||||
$this->seeJson(['message' => 'Message updated :smile:']);
|
||||
}
|
||||
|
||||
public function testDeleteIncidentUpdate()
|
||||
{
|
||||
$this->beUser();
|
||||
$incident = factory('CachetHQ\Cachet\Models\Incident')->create();
|
||||
$update = factory('CachetHQ\Cachet\Models\IncidentUpdate')->create();
|
||||
|
||||
$this->delete("/api/v1/incidents/{$incident->id}/updates/{$update->id}");
|
||||
|
||||
$this->assertResponseStatus(204);
|
||||
}
|
||||
}
|
||||
@@ -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\IncidentUpdate;
|
||||
|
||||
use AltThree\TestBench\EventTrait;
|
||||
use CachetHQ\Cachet\Bus\Events\IncidentUpdate\IncidentUpdateEventInterface;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
|
||||
/**
|
||||
* This is the abstract incident update event test case class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
abstract class AbstractIncidentUpdateCommandTest extends AbstractTestCase
|
||||
{
|
||||
use EventTrait;
|
||||
|
||||
protected function getEventInterfaces()
|
||||
{
|
||||
return [IncidentUpdateEventInterface::class];
|
||||
}
|
||||
}
|
||||
@@ -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\IncidentUpdate;
|
||||
|
||||
use AltThree\TestBench\CommandTrait;
|
||||
use CachetHQ\Cachet\Bus\Commands\IncidentUpdate\RemoveIncidentUpdateCommand;
|
||||
use CachetHQ\Cachet\Bus\Handlers\Commands\IncidentUpdate\RemoveIncidentUpdateCommandHandler;
|
||||
use CachetHQ\Cachet\Models\IncidentUpdate;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
|
||||
/**
|
||||
* This is the remove incident update command test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class RemoveIncidentUpdateCommandTest extends AbstractTestCase
|
||||
{
|
||||
use CommandTrait;
|
||||
|
||||
protected function getObjectAndParams()
|
||||
{
|
||||
$params = ['incidentUpdate' => new IncidentUpdate()];
|
||||
$object = new RemoveIncidentUpdateCommand($params['incidentUpdate']);
|
||||
|
||||
return compact('params', 'object');
|
||||
}
|
||||
|
||||
protected function getHandlerClass()
|
||||
{
|
||||
return RemoveIncidentUpdateCommandHandler::class;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?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\IncidentUpdate;
|
||||
|
||||
use AltThree\TestBench\CommandTrait;
|
||||
use CachetHQ\Cachet\Bus\Commands\IncidentUpdate\ReportIncidentUpdateCommand;
|
||||
use CachetHQ\Cachet\Bus\Handlers\Commands\IncidentUpdate\ReportIncidentUpdateCommandHandler;
|
||||
use CachetHQ\Cachet\Models\Incident;
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
|
||||
/**
|
||||
* This is the report incident update command test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class ReportIncidentUpdateCommandTest extends AbstractTestCase
|
||||
{
|
||||
use CommandTrait;
|
||||
|
||||
protected function getObjectAndParams()
|
||||
{
|
||||
$params = [
|
||||
'incident' => new Incident(),
|
||||
'status' => 1,
|
||||
'message' => 'Foo',
|
||||
'user' => new User(),
|
||||
];
|
||||
$object = new ReportIncidentUpdateCommand($params['incident'], $params['status'], $params['message'], $params['user']);
|
||||
|
||||
return compact('params', 'object');
|
||||
}
|
||||
|
||||
protected function objectHasRules()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function getHandlerClass()
|
||||
{
|
||||
return ReportIncidentUpdateCommandHandler::class;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?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\IncidentUpdate;
|
||||
|
||||
use AltThree\TestBench\CommandTrait;
|
||||
use CachetHQ\Cachet\Bus\Commands\IncidentUpdate\UpdateIncidentUpdateCommand;
|
||||
use CachetHQ\Cachet\Bus\Handlers\Commands\IncidentUpdate\UpdateIncidentUpdateCommandHandler;
|
||||
use CachetHQ\Cachet\Models\IncidentUpdate;
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
|
||||
/**
|
||||
* This is the update incident update command test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class UpdateIncidentUpdateCommandTest extends AbstractTestCase
|
||||
{
|
||||
use CommandTrait;
|
||||
|
||||
protected function getObjectAndParams()
|
||||
{
|
||||
$params = ['update' => new IncidentUpdate(), 'status' => 1, 'message' => 'Updating!', 'user' => new User()];
|
||||
$object = new UpdateIncidentUpdateCommand(
|
||||
$params['update'],
|
||||
$params['status'],
|
||||
$params['message'],
|
||||
$params['user']
|
||||
);
|
||||
|
||||
return compact('params', 'object');
|
||||
}
|
||||
|
||||
protected function objectHasRules()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function getHandlerClass()
|
||||
{
|
||||
return UpdateIncidentUpdateCommandHandler::class;
|
||||
}
|
||||
}
|
||||
@@ -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\Bus\Events\IncidentUpdate;
|
||||
|
||||
use AltThree\TestBench\EventTrait;
|
||||
use CachetHQ\Cachet\Bus\Events\IncidentUpdate\IncidentUpdateEventInterface;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
|
||||
abstract class AbstractIncidentUpdateEventTestCase extends AbstractTestCase
|
||||
{
|
||||
use EventTrait;
|
||||
|
||||
protected function getEventInterfaces()
|
||||
{
|
||||
return [IncidentUpdateEventInterface::class];
|
||||
}
|
||||
}
|
||||
@@ -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\IncidentUpdate;
|
||||
|
||||
use CachetHQ\Cachet\Bus\Events\IncidentUpdate\IncidentUpdateWasRemovedEvent;
|
||||
use CachetHQ\Cachet\Models\IncidentUpdate;
|
||||
|
||||
class IncidentUpdateWasRemovedEventTest extends AbstractIncidentUpdateEventTestCase
|
||||
{
|
||||
protected function objectHasHandlers()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getObjectAndParams()
|
||||
{
|
||||
$params = ['update' => new IncidentUpdate()];
|
||||
$object = new IncidentUpdateWasRemovedEvent($params['update']);
|
||||
|
||||
return compact('params', 'object');
|
||||
}
|
||||
}
|
||||
@@ -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\IncidentUpdate;
|
||||
|
||||
use CachetHQ\Cachet\Bus\Events\IncidentUpdate\IncidentUpdateWasReportedEvent;
|
||||
use CachetHQ\Cachet\Models\IncidentUpdate;
|
||||
|
||||
class IncidentUpdateWasReportedEventTest extends AbstractIncidentUpdateEventTestCase
|
||||
{
|
||||
protected function objectHasHandlers()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getObjectAndParams()
|
||||
{
|
||||
$params = ['update' => new IncidentUpdate()];
|
||||
$object = new IncidentUpdateWasReportedEvent($params['update']);
|
||||
|
||||
return compact('params', 'object');
|
||||
}
|
||||
}
|
||||
@@ -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\IncidentUpdate;
|
||||
|
||||
use CachetHQ\Cachet\Bus\Events\IncidentUpdate\IncidentUpdateWasUpdatedEvent;
|
||||
use CachetHQ\Cachet\Models\IncidentUpdate;
|
||||
|
||||
class IncidentUpdateWasUpdatedEventTest extends AbstractIncidentUpdateEventTestCase
|
||||
{
|
||||
protected function objectHasHandlers()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getObjectAndParams()
|
||||
{
|
||||
$params = ['update' => new IncidentUpdate()];
|
||||
$object = new IncidentUpdateWasUpdatedEvent($params['update']);
|
||||
|
||||
return compact('params', 'object');
|
||||
}
|
||||
}
|
||||
@@ -38,16 +38,14 @@ class StatusPageControllerTest extends AbstractTestCase
|
||||
->setupConfig();
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function on_index_only_public_component_groups_are_shown_to_a_guest()
|
||||
public function testIndexShowsOnlyPublicComponentGroupsToGues()
|
||||
{
|
||||
$this->visit('/')
|
||||
->see(self::COMPONENT_GROUP_1_NAME)
|
||||
->dontSee(self::COMPONENT_GROUP_2_NAME);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function on_index_all_component_groups_are_displayed_to_logged_in_users()
|
||||
public function testIndexShowsAllComponentGroupsToLoggedInUsers()
|
||||
{
|
||||
$this->signIn();
|
||||
|
||||
|
||||
@@ -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\Models;
|
||||
|
||||
use AltThree\TestBench\ValidationTrait;
|
||||
use CachetHQ\Cachet\Models\IncidentUpdate;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
|
||||
/**
|
||||
* This is the incident model test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class IncidentUpdateTest extends AbstractTestCase
|
||||
{
|
||||
use ValidationTrait;
|
||||
|
||||
public function testValidation()
|
||||
{
|
||||
$this->checkRules(new IncidentUpdate());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user