Folder Structure

Functional tests require data already populated in the database for the endpoints to return a response. Seed data allows pre-determined data to be populated in the database, allowing accurate asserts.

Seed Data Directory

Each module contains a Database/Seeds directory containing all files to seed the database for that module, including theSeeder class that specifies each seed data class. The seed data classes themselves are located in the Database/Seeds/Data directory.

Example:

- app
  - Modules
    - Events
      - Database
	- Seeds
	  - Data
    - Exams
      - Database
	- Seeds
	  - Data

Seed Data Location:

Seed data should be located in the module responsible for managing that data.

For instance, the Cases module uses Events, Courses, Curriculum Periods, Course Units and Weeks.

The seed data for Event models and tables used for the Cases tests should be under the Events module's seed data.

Sub-folders within the module's seed directory can be created for the purpose of organizing the files according to which other module depends on them. For instance:

- app
  - Modules
    - Events
      - Database
	- Seeds
	  - Data
	    - Cases
	      - EventSeedData.php
	    - Exams
	      - EventSeedData.php

Sub-folders for module-dependencies reduces confusion about which module is some seed data being inserted for.

Be mindful not to duplicate IDs across the different module sub-folders for the same entity.

Last updated