Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php /* * This file is part of Cachet. * * (c) Alt Three Services Limited * * For t..
Decoded Output download
<?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;
use CachetHQ\Cachet\Models\Incident;
use CachetHQ\Cachet\Models\IncidentUpdate;
/**
* This is the incident update test class.
*
* @author James Brooks <[email protected]>
*/
class IncidentUpdateTest extends AbstractApiTestCase
{
public function test_can_get_all_incident_updates()
{
$incident = factory(Incident::class)->create();
$updates = factory(IncidentUpdate::class, 3)->create([
'incident_id' => $incident->id,
]);
$response = $this->json('GET', "/api/v1/incidents/{$incident->id}/updates");
$response->assertStatus(200);
$response->assertJsonFragment(['id' => $updates[0]->id]);
$response->assertJsonFragment(['id' => $updates[1]->id]);
$response->assertJsonFragment(['id' => $updates[2]->id]);
}
public function test_cannot_get_invalid_incident_update()
{
$response = $this->json('GET', '/api/v1/incidents/1/updates/1');
$response->assertStatus(404);
}
public function test_cannot_create_incident_update_without_authorization()
{
$incident = factory(Incident::class)->create();
$response = $this->json('POST', "/api/v1/incidents/{$incident->id}/updates");
$response->assertStatus(401);
}
public function test_cannot_create_incident_update_without_data()
{
$this->beUser();
$incident = factory(Incident::class)->create();
$response = $this->json('POST', "/api/v1/incidents/{$incident->id}/updates");
$response->assertStatus(400);
}
public function test_can_create_incident_update()
{
$this->beUser();
$incident = factory(Incident::class)->create();
$response = $this->json('POST', "/api/v1/incidents/{$incident->id}/updates", [
'status' => 4,
'message' => 'Incident fixed!',
]);
$response->assertStatus(200);
$response->assertJsonFragment(['incident_id' => $incident->id]);
}
public function test_can_update_incident_update()
{
$this->beUser();
$incident = factory(Incident::class)->create();
$update = factory(IncidentUpdate::class)->create();
$response = $this->json('PUT', "/api/v1/incidents/{$incident->id}/updates/{$update->id}", [
'message' => 'Message updated :smile:',
]);
$response->assertStatus(200);
$response->assertJsonFragment(['message' => 'Message updated :smile:']);
}
public function test_can_delete_incident_update()
{
$this->beUser();
$incident = factory(Incident::class)->create();
$update = factory(IncidentUpdate::class)->create();
$response = $this->json('DELETE', "/api/v1/incidents/{$incident->id}/updates/{$update->id}");
$response->assertStatus(204);
}
}
?>
Did this file decode correctly?
Original Code
<?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;
use CachetHQ\Cachet\Models\Incident;
use CachetHQ\Cachet\Models\IncidentUpdate;
/**
* This is the incident update test class.
*
* @author James Brooks <[email protected]>
*/
class IncidentUpdateTest extends AbstractApiTestCase
{
public function test_can_get_all_incident_updates()
{
$incident = factory(Incident::class)->create();
$updates = factory(IncidentUpdate::class, 3)->create([
'incident_id' => $incident->id,
]);
$response = $this->json('GET', "/api/v1/incidents/{$incident->id}/updates");
$response->assertStatus(200);
$response->assertJsonFragment(['id' => $updates[0]->id]);
$response->assertJsonFragment(['id' => $updates[1]->id]);
$response->assertJsonFragment(['id' => $updates[2]->id]);
}
public function test_cannot_get_invalid_incident_update()
{
$response = $this->json('GET', '/api/v1/incidents/1/updates/1');
$response->assertStatus(404);
}
public function test_cannot_create_incident_update_without_authorization()
{
$incident = factory(Incident::class)->create();
$response = $this->json('POST', "/api/v1/incidents/{$incident->id}/updates");
$response->assertStatus(401);
}
public function test_cannot_create_incident_update_without_data()
{
$this->beUser();
$incident = factory(Incident::class)->create();
$response = $this->json('POST', "/api/v1/incidents/{$incident->id}/updates");
$response->assertStatus(400);
}
public function test_can_create_incident_update()
{
$this->beUser();
$incident = factory(Incident::class)->create();
$response = $this->json('POST', "/api/v1/incidents/{$incident->id}/updates", [
'status' => 4,
'message' => 'Incident fixed!',
]);
$response->assertStatus(200);
$response->assertJsonFragment(['incident_id' => $incident->id]);
}
public function test_can_update_incident_update()
{
$this->beUser();
$incident = factory(Incident::class)->create();
$update = factory(IncidentUpdate::class)->create();
$response = $this->json('PUT', "/api/v1/incidents/{$incident->id}/updates/{$update->id}", [
'message' => 'Message updated :smile:',
]);
$response->assertStatus(200);
$response->assertJsonFragment(['message' => 'Message updated :smile:']);
}
public function test_can_delete_incident_update()
{
$this->beUser();
$incident = factory(Incident::class)->create();
$update = factory(IncidentUpdate::class)->create();
$response = $this->json('DELETE', "/api/v1/incidents/{$incident->id}/updates/{$update->id}");
$response->assertStatus(204);
}
}
Function Calls
None |
Stats
MD5 | ff77182a50b930fc876637db08acfed8 |
Eval Count | 0 |
Decode Time | 123 ms |