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 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.

The annotation @snapshot db:table also accepts wildcards For example: @snapshot entrada:event% will snapshot all tables that start withevent in the ME 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).

Last updated