Clean up test names and remove laravel/browser-kit-testing
This commit is contained in:
@@ -11,6 +11,9 @@
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Api;
|
||||
|
||||
use CachetHQ\Cachet\Models\Incident;
|
||||
use CachetHQ\Cachet\Models\IncidentUpdate;
|
||||
|
||||
/**
|
||||
* This is the incident update test class.
|
||||
*
|
||||
@@ -18,85 +21,84 @@ namespace CachetHQ\Tests\Cachet\Api;
|
||||
*/
|
||||
class IncidentUpdateTest extends AbstractApiTestCase
|
||||
{
|
||||
public function testGetIncidentUpdates()
|
||||
public function test_can_get_all_incident_updates()
|
||||
{
|
||||
$incident = factory('CachetHQ\Cachet\Models\Incident')->create();
|
||||
$updates = factory('CachetHQ\Cachet\Models\IncidentUpdate', 3)->create([
|
||||
$incident = factory(Incident::class)->create();
|
||||
$updates = factory(IncidentUpdate::class, 3)->create([
|
||||
'incident_id' => $incident->id,
|
||||
]);
|
||||
|
||||
$this->get("/api/v1/incidents/{$incident->id}/updates");
|
||||
$response = $this->json('GET', "/api/v1/incidents/{$incident->id}/updates");
|
||||
|
||||
$this->assertResponseOk();
|
||||
$response->assertStatus(200);
|
||||
|
||||
$this->seeJsonContains(['id' => $updates[0]->id]);
|
||||
$this->seeJsonContains(['id' => $updates[1]->id]);
|
||||
$this->seeJsonContains(['id' => $updates[2]->id]);
|
||||
$response->assertJsonFragment(['id' => $updates[0]->id]);
|
||||
$response->assertJsonFragment(['id' => $updates[1]->id]);
|
||||
$response->assertJsonFragment(['id' => $updates[2]->id]);
|
||||
}
|
||||
|
||||
public function testGetInvalidIncidentUpdate()
|
||||
public function test_cannot_get_invalid_incident_update()
|
||||
{
|
||||
$this->get('/api/v1/incidents/1/updates/1');
|
||||
$response = $this->json('GET', '/api/v1/incidents/1/updates/1');
|
||||
|
||||
$this->assertResponseStatus(404);
|
||||
$response->assertStatus(404);
|
||||
}
|
||||
|
||||
public function testPostIncidentUpdateUnauthorized()
|
||||
public function test_cannot_create_incident_update_without_authorization()
|
||||
{
|
||||
$incident = factory('CachetHQ\Cachet\Models\Incident')->create();
|
||||
$this->post("/api/v1/incidents/{$incident->id}/updates");
|
||||
$incident = factory(Incident::class)->create();
|
||||
|
||||
$this->assertResponseStatus(401);
|
||||
$response = $this->json('POST', "/api/v1/incidents/{$incident->id}/updates");
|
||||
|
||||
$response->assertStatus(401);
|
||||
}
|
||||
|
||||
public function testPostIncidentUpdateNoData()
|
||||
public function test_cannot_create_incident_update_without_data()
|
||||
{
|
||||
$this->beUser();
|
||||
$incident = factory('CachetHQ\Cachet\Models\Incident')->create();
|
||||
$incident = factory(Incident::class)->create();
|
||||
|
||||
$this->post("/api/v1/incidents/{$incident->id}/updates");
|
||||
$response = $this->json('POST', "/api/v1/incidents/{$incident->id}/updates");
|
||||
|
||||
$this->assertResponseStatus(400);
|
||||
$response->assertStatus(400);
|
||||
}
|
||||
|
||||
public function testPostIncidentUpdate()
|
||||
public function test_can_create_incident_update()
|
||||
{
|
||||
$this->beUser();
|
||||
$incident = factory('CachetHQ\Cachet\Models\Incident')->create();
|
||||
$incident = factory(Incident::class)->create();
|
||||
|
||||
$this->post("/api/v1/incidents/{$incident->id}/updates", [
|
||||
$response = $this->json('POST', "/api/v1/incidents/{$incident->id}/updates", [
|
||||
'status' => 4,
|
||||
'message' => 'Incident fixed!',
|
||||
]);
|
||||
|
||||
$this->assertResponseOk();
|
||||
|
||||
$this->seeJsonContains(['incident_id' => $incident->id]);
|
||||
$response->assertStatus(200);
|
||||
$response->assertJsonFragment(['incident_id' => $incident->id]);
|
||||
}
|
||||
|
||||
public function testPutIncidentUpdate()
|
||||
public function test_can_update_incident_update()
|
||||
{
|
||||
$this->beUser();
|
||||
$incident = factory('CachetHQ\Cachet\Models\Incident')->create();
|
||||
$update = factory('CachetHQ\Cachet\Models\IncidentUpdate')->create();
|
||||
$incident = factory(Incident::class)->create();
|
||||
$update = factory(IncidentUpdate::class)->create();
|
||||
|
||||
$this->put("/api/v1/incidents/{$incident->id}/updates/{$update->id}", [
|
||||
$response = $this->json('PUT', "/api/v1/incidents/{$incident->id}/updates/{$update->id}", [
|
||||
'message' => 'Message updated :smile:',
|
||||
]);
|
||||
|
||||
$this->assertResponseOk();
|
||||
|
||||
$this->seeJsonContains(['message' => 'Message updated :smile:']);
|
||||
$response->assertStatus(200);
|
||||
$response->assertJsonFragment(['message' => 'Message updated :smile:']);
|
||||
}
|
||||
|
||||
public function testDeleteIncidentUpdate()
|
||||
public function test_can_delete_incident_update()
|
||||
{
|
||||
$this->beUser();
|
||||
$incident = factory('CachetHQ\Cachet\Models\Incident')->create();
|
||||
$update = factory('CachetHQ\Cachet\Models\IncidentUpdate')->create();
|
||||
$incident = factory(Incident::class)->create();
|
||||
$update = factory(IncidentUpdate::class)->create();
|
||||
|
||||
$this->delete("/api/v1/incidents/{$incident->id}/updates/{$update->id}");
|
||||
$response = $this->json('DELETE', "/api/v1/incidents/{$incident->id}/updates/{$update->id}");
|
||||
|
||||
$this->assertResponseStatus(204);
|
||||
$response->assertStatus(204);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user