Testing
Controllers
Note:
- Every Controller Route should at least one corresponding integration tests.
Naming:
The name of the file should be exactly the same name as the Controller, but has Test appended on the end.
For Example:
Controller = WishListController.php
Test File = WishListControllerTest.php
Location:
tests/Controllers/..
Info
Dot Notes should contain the routes.
Naming = Snake Case For Readability
Example
/**
@test
* PUT 'api/inmates/{inmate}'
*/
public function a_admin_employee_can_mark_an_inmate_disabled()
{
$user = factory(Employee::class)->create(['is_admin' => true]);
$inmate = factory(Inmate::class)->create();
$faker = Factory::create();
$identity_field = $faker->catchPhrase;
$response = $this->actingAs($user, 'api')
->json('PUT', '/api/inmates/' . $inmate->token, [
'disabled' => true,
])
->assertJson(['success' => true]);
$response = json_decode($response->getContent());
$this->assertNotEquals($inmate->disabled, $response->data->disabled);
$this->assertEquals($inmate->fresh()->disabled, $response->data->disabled);
}