> For the complete documentation index, see [llms.txt](https://docs.elentra.org/api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.elentra.org/api/automated-testing/functional-tests/testing-http-verbs/creating-an-http-test.md).

# Creating an HTTP Test

When creating a test function, use the `@test`annotation. This will execute when the functional tests run. The test method should contain a description of what the test is attempting to verify and should be in snake case to make it more readable in the terminal.

### Function Test Naming Convention:

Tests should be in snake case for readability when the test's name is rendered to the CI. The test name should follow this format:

> {% code overflow="wrap" %}
>
> ```
> [module_name]_[controller_name]_[http_method]_[controller method]_returns_[status code]
> ```
>
> {% endcode %}

{% hint style="success" %}
For example, testing the RotationScheduleController with the method index should be called: `clinical_rotations_get_index_returns_200`
{% endhint %}

{% hint style="success" %}
In instances where the controller has the same name as the module, then the word controller can be used instead of the controller name: `clinical_controller_get_index_returns_200`

This is to avoid \`Clinical\` twice in the name
{% endhint %}

**Example:**

```php
/**
 * Test that the GET /events returns 200
 *
 * @test
 * @return void
 */
public function events_get_method_index_returns_200(): void
{
    // ...
}
```

{% hint style="info" %}
The method's name has all the information to determine what and how it’s being tested.
{% endhint %}

To call an endpoint, we need to state what user is requesting the call before we send the request.

```php
/**
 * Test that the GET /events returns 200
 *
 * @test
 * @return void
 */
public function events_get_method_index_returns_200(): void
{
    $this->actingAs(User::find(2));
}
```

{% hint style="info" %}
If the acted-on user has an ID of 1 (default administrator), then `$this->actingAsAdmin()` can be used instead
{% endhint %}
