Incident API can now use incident templates with Twig templating
This commit is contained in:
@@ -63,6 +63,27 @@ class IncidentTest extends AbstractTestCase
|
||||
$this->assertResponseOk();
|
||||
}
|
||||
|
||||
public function testCreateIncidentWithTemplate()
|
||||
{
|
||||
$template = factory('CachetHQ\Cachet\Models\IncidentTemplate')->create();
|
||||
$this->beUser();
|
||||
|
||||
$this->post('/api/v1/incidents', [
|
||||
'name' => 'Foo',
|
||||
'status' => 1,
|
||||
'visible' => 1,
|
||||
'template' => $template->slug,
|
||||
'vars' => [
|
||||
'name' => 'Foo',
|
||||
'message' => 'Hello there this is a foo!',
|
||||
],
|
||||
]);
|
||||
$this->seeJson([
|
||||
'name' => 'Foo',
|
||||
'message' => "Name: Foo,\nMessage: Hello there this is a foo!",
|
||||
]);
|
||||
}
|
||||
|
||||
public function testGetNewIncident()
|
||||
{
|
||||
$incident = factory('CachetHQ\Cachet\Models\Incident')->create();
|
||||
@@ -84,6 +105,27 @@ class IncidentTest extends AbstractTestCase
|
||||
$this->assertResponseOk();
|
||||
}
|
||||
|
||||
public function testPutIncidentWithTemplate()
|
||||
{
|
||||
$this->beUser();
|
||||
$template = factory('CachetHQ\Cachet\Models\IncidentTemplate')->create();
|
||||
$component = factory('CachetHQ\Cachet\Models\Incident')->create();
|
||||
|
||||
$this->put('/api/v1/incidents/1', [
|
||||
'name' => 'Foo',
|
||||
'template' => $template->slug,
|
||||
'vars' => [
|
||||
'name' => 'Foo',
|
||||
'message' => 'Hello there this is a foo!',
|
||||
],
|
||||
]);
|
||||
$this->seeJson([
|
||||
'name' => 'Foo',
|
||||
'message' => "Name: Foo,\nMessage: Hello there this is a foo!",
|
||||
]);
|
||||
$this->assertResponseOk();
|
||||
}
|
||||
|
||||
public function testDeleteIncident()
|
||||
{
|
||||
$this->beUser();
|
||||
|
||||
@@ -33,6 +33,8 @@ class ReportIncidentCommandTest extends AbstractCommandTestCase
|
||||
'component_status' => 1,
|
||||
'notify' => false,
|
||||
'incident_date' => null,
|
||||
'template' => null,
|
||||
'template_vars' => null,
|
||||
];
|
||||
$object = new ReportIncidentCommand(
|
||||
$params['name'],
|
||||
@@ -42,7 +44,9 @@ class ReportIncidentCommandTest extends AbstractCommandTestCase
|
||||
$params['component_id'],
|
||||
$params['component_status'],
|
||||
$params['notify'],
|
||||
$params['incident_date']
|
||||
$params['incident_date'],
|
||||
$params['template'],
|
||||
$params['template_vars']
|
||||
);
|
||||
|
||||
return compact('params', 'object');
|
||||
|
||||
@@ -35,6 +35,8 @@ class UpdateIncidentCommandTest extends AbstractCommandTestCase
|
||||
'component_status' => 1,
|
||||
'notify' => false,
|
||||
'incident_date' => null,
|
||||
'template' => null,
|
||||
'template_vars' => null,
|
||||
];
|
||||
$object = new UpdateIncidentCommand(
|
||||
$params['incident'],
|
||||
@@ -45,7 +47,9 @@ class UpdateIncidentCommandTest extends AbstractCommandTestCase
|
||||
$params['component_id'],
|
||||
$params['component_status'],
|
||||
$params['notify'],
|
||||
$params['incident_date']
|
||||
$params['incident_date'],
|
||||
$params['template'],
|
||||
$params['template_vars']
|
||||
);
|
||||
|
||||
return compact('params', 'object');
|
||||
|
||||
Reference in New Issue
Block a user