Annotations
Elentra's API contains custom annotations for functional tests that help developers easily create and manage tests.
Transaction Annotations
@transaction
/**
* Test that the route [GET] /exams/questions/groups/authors return 200
*
* @test
* @transaction
* @return void
*/
public function exams_get_method_exams_questions_groups_authors_returns_200(): void
{
$this->actingAsAdmin()
->authenticate()
->get('/exams/questions/groups/authors')The transaction annotation restores all database tables in Elentra.
@transaction db
/**
* Test that the route [GET] /exams/questions/groups/authors return 200
*
* @test
* @transaction entrada
* @return void
*/
public function exams_get_method_exams_questions_groups_authors_returns_200(): void
{
$this->actingAsAdmin()
->authenticate()
->get('/exams/questions/groups/authors')When the transaction is passed a database name, it only restores that database's tables.
Snapshot Annotations
Snapshot performance is slow; therefore, this should only be used when the transaction annotation will not work. This happens when the endpoint relies on ME code that uses AdoDB, which would use a separate DB connection from Laravel.
@snapshot db
This will snapshot the entire database and then restore it after the test has run.
@snapshot db:table
This will only snapshot and restore the specific table in the given database.
Seed Table Annotations
@seedTable table
This will truncate the table and then find the given seeder in order to seed the table again.
@seedTable db:table
This will truncate the exam_questions table within the ME database, find the given seeder, and seed the table again.
Drop Table Annotations
@dropTable db:table
The @dropTable annotation will run DROP IF EXISTS on the specified table(s) in the specified schema(s).
This is particularly useful when the endpoint creates a new table not already in the schema, and we need to remove that table for subsequent tests to execute successfully.
Last updated