EntityTrait
Helper for tracking entities created in tests.
Table of Contents
Properties
- $ids : array<string|int, mixed>
- Array of IDs created to support the test.
- $tablesToCleanUp : array<string|int, mixed>
- Track tables we have modified during a test.
- $testRecords : array<string|int, mixed>
- Records created which will be deleted during tearDown
Methods
- createTestEntity() : array<string|int, mixed>
- Create an entity, recording it's details for tearDown.
- setTestEntity() : void
- Set the test entity on the class for access.
- setTestEntityID() : void
Properties
$ids
Array of IDs created to support the test.
protected
array<string|int, mixed>
$ids
= []
e.g $this->ids = ['Event' => ['descriptive_key' => $eventID], 'Group' => [$groupID]];
$tablesToCleanUp
Track tables we have modified during a test.
protected
array<string|int, mixed>
$tablesToCleanUp
= []
Set up functions that add entities can register the relevant tables here for the cleanup process.
$testRecords
Records created which will be deleted during tearDown
protected
array<string|int, mixed>
$testRecords
= []
Methods
createTestEntity()
Create an entity, recording it's details for tearDown.
protected
createTestEntity(string $entity, array<string|int, mixed> $values[, string $identifier = 'default' ]) : array<string|int, mixed>
Parameters
- $entity : string
- $values : array<string|int, mixed>
- $identifier : string = 'default'
Return values
array<string|int, mixed>setTestEntity()
Set the test entity on the class for access.
protected
setTestEntity(string $entity, array<string|int, mixed> $values, string $identifier) : void
This follows the ids patter and also the api4TestTrait pattern.
Parameters
- $entity : string
- $values : array<string|int, mixed>
- $identifier : string
setTestEntityID()
protected
setTestEntityID(string $entity, int $id, string $identifier) : void
Parameters
- $entity : string
- $id : int
- $identifier : string