ContactInterchangeTest
extends Api4TestBase
in package
implements
TransactionalInterface
Assert that interchanging data between APIv3 and APIv4 yields consistent encodings.
Tags
Table of Contents
Interfaces
- TransactionalInterface
- Interface HeadlessInterface
Properties
- $testRecords : array<string|int, mixed>
- Records created which will be deleted during tearDown
Methods
- __construct() : mixed
- cleanup() : void
- Quick clean by emptying tables created for the test.
- create_3() : mixed
- create_4() : mixed
- createLoggedInUser() : int
- Emulate a logged in user since certain functions use that.
- createTestRecord() : array<string|int, mixed>|null
- Inserts a test record, supplying all required values if not provided.
- getExamples() : mixed
- getTestRecord() : array<string|int, mixed>
- readNameByActDetailsChain_3() : mixed
- readNameByActDetailsChain_4() : mixed
- readNameByActDetailsJoin_3() : mixed
- readNameByActDetailsJoin_4() : mixed
- readNameByActSubjectChain_3() : mixed
- readNameByActSubjectChain_4() : mixed
- readNameByActSubjectJoin_3() : mixed
- readNameByActSubjectJoin_4() : mixed
- readNameById_3() : mixed
- readNameById_4() : mixed
- readNameByValueEq_3() : mixed
- readNameByValueEq_4() : mixed
- readNameByValueIn_4() : mixed
- saveTestRecords() : Result
- Saves one or more test records, supplying default values.
- setUpHeadless() : CiviEnvBuilder
- The setupHeadless function runs at the start of each test case, right before the headless environment reboots.
- tearDown() : void
- Post test cleanup.
- testReadWriteAPI() : mixed
- Use the given $writer to create a row with some funny data.
- userLogout() : mixed
- deleteTestRecords() : void
- Delete records previously created by the `saveTestRecords` function.
- getRequiredValuesToCreate() : array<string|int, mixed>
- Get the required fields for the api entity + action.
- autoWrapException() : mixed
- createOptionValue() : mixed|null
- Creates a dummy option value when one is required but the option list is empty
- getFkID() : int
- Get an ID for the appropriate entity.
- getRandomValue() : int|null|string
- getRequiredValue() : mixed
- Attempt to get a value using field option, defaults, FKEntity, or a random value based on the data type.
- randomLetters() : string
- Generate some random lowercase letters.
Properties
$testRecords
Records created which will be deleted during tearDown
protected
array<string|int, mixed>
$testRecords
= []
Methods
__construct()
public
__construct([string $name = NULL ][, array<string|int, mixed> $data = [] ][, string $dataName = '' ]) : mixed
Parameters
- $name : string = NULL
- $data : array<string|int, mixed> = []
- $dataName : string = ''
Tags
cleanup()
Quick clean by emptying tables created for the test.
public
cleanup(array{tablesToTruncate: array} $params) : void
Parameters
- $params : array{tablesToTruncate: array}
create_3()
public
create_3(mixed $strs) : mixed
Parameters
- $strs : mixed
create_4()
public
create_4(mixed $strs) : mixed
Parameters
- $strs : mixed
createLoggedInUser()
Emulate a logged in user since certain functions use that.
public
createLoggedInUser() : int
value to store a record in the DB (like activity)
Tags
Return values
int —Contact ID of the created user.
createTestRecord()
Inserts a test record, supplying all required values if not provided.
public
createTestRecord(string $entityName[, array<string|int, mixed> $values = [] ]) : array<string|int, mixed>|null
Test records will be automatically deleted if deleteTestRecords
is called.
This is a convenience helper for saveTestRecords
when working with a
single entity.
Parameters
- $entityName : string
- $values : array<string|int, mixed> = []
Tags
Return values
array<string|int, mixed>|nullgetExamples()
public
getExamples() : mixed
getTestRecord()
public
getTestRecord(string $entityName, array<string|int, mixed>|string|int $idOrFilters) : array<string|int, mixed>
Parameters
- $entityName : string
- $idOrFilters : array<string|int, mixed>|string|int
-
Either the entity id or filters like ['name' => 'foo']
Tags
Return values
array<string|int, mixed>readNameByActDetailsChain_3()
public
readNameByActDetailsChain_3(mixed $cid, mixed $strs) : mixed
Parameters
- $cid : mixed
- $strs : mixed
readNameByActDetailsChain_4()
public
readNameByActDetailsChain_4(mixed $cid, mixed $strs) : mixed
Parameters
- $cid : mixed
- $strs : mixed
readNameByActDetailsJoin_3()
public
readNameByActDetailsJoin_3(mixed $cid, mixed $strs) : mixed
Parameters
- $cid : mixed
- $strs : mixed
readNameByActDetailsJoin_4()
public
readNameByActDetailsJoin_4(mixed $cid, mixed $strs) : mixed
Parameters
- $cid : mixed
- $strs : mixed
readNameByActSubjectChain_3()
public
readNameByActSubjectChain_3(mixed $cid, mixed $strs) : mixed
Parameters
- $cid : mixed
- $strs : mixed
readNameByActSubjectChain_4()
public
readNameByActSubjectChain_4(mixed $cid, mixed $strs) : mixed
Parameters
- $cid : mixed
- $strs : mixed
readNameByActSubjectJoin_3()
public
readNameByActSubjectJoin_3(mixed $cid, mixed $strs) : mixed
Parameters
- $cid : mixed
- $strs : mixed
readNameByActSubjectJoin_4()
public
readNameByActSubjectJoin_4(mixed $cid, mixed $strs) : mixed
Parameters
- $cid : mixed
- $strs : mixed
readNameById_3()
public
readNameById_3(mixed $cid, mixed $strs) : mixed
Parameters
- $cid : mixed
- $strs : mixed
readNameById_4()
public
readNameById_4(mixed $cid, mixed $strs) : mixed
Parameters
- $cid : mixed
- $strs : mixed
readNameByValueEq_3()
public
readNameByValueEq_3(mixed $cid, mixed $strs) : mixed
Parameters
- $cid : mixed
- $strs : mixed
readNameByValueEq_4()
public
readNameByValueEq_4(mixed $cid, mixed $strs) : mixed
Parameters
- $cid : mixed
- $strs : mixed
readNameByValueIn_4()
public
readNameByValueIn_4(mixed $cid, mixed $strs) : mixed
Parameters
- $cid : mixed
- $strs : mixed
saveTestRecords()
Saves one or more test records, supplying default values.
public
saveTestRecords(string $entityName, array<string|int, mixed> $saveParams) : Result
Test records will be deleted when the deleteTestRecords
function is
called, usually in tearDown
.
If the transactional method is in use (and nothing is down to cause
the transaction to commit, such as creating custom fields) then the
deleteTestRecords
function does not need to be called.
Parameters
- $entityName : string
- $saveParams : array<string|int, mixed>
Tags
Return values
ResultsetUpHeadless()
The setupHeadless function runs at the start of each test case, right before the headless environment reboots.
public
setUpHeadless() : CiviEnvBuilder
It should perform any necessary steps required for putting the database in a consistent baseline -- such as loading schema and extensions.
The utility \Civi\Test::headless()
provides a number of helper functions
for managing this setup, and it includes optimizations to avoid redundant
setup work.
Return values
CiviEnvBuildertearDown()
Post test cleanup.
public
tearDown() : void
testReadWriteAPI()
Use the given $writer to create a row with some funny data.
public
testReadWriteAPI(mixed $writer, mixed $readers, mixed $strs) : mixed
Then use the given $reader to load the row. Assert that the funny data looks the same.
Parameters
- $writer : mixed
- $readers : mixed
- $strs : mixed
Tags
userLogout()
public
userLogout() : mixed
deleteTestRecords()
Delete records previously created by the `saveTestRecords` function.
protected
deleteTestRecords() : void
This should be called during the tearDown
function if the test
class does not use the transactional interface.
Tags
getRequiredValuesToCreate()
Get the required fields for the api entity + action.
protected
getRequiredValuesToCreate(string $entity[, array<string|int, mixed> $values = [] ]) : array<string|int, mixed>
Parameters
- $entity : string
- $values : array<string|int, mixed> = []
Tags
Return values
array<string|int, mixed>autoWrapException()
private
autoWrapException(mixed $callable, mixed $args, mixed $message) : mixed
Parameters
- $callable : mixed
- $args : mixed
- $message : mixed
createOptionValue()
Creates a dummy option value when one is required but the option list is empty
private
createOptionValue(string $tableName, string $fieldName) : mixed|null
Parameters
- $tableName : string
- $fieldName : string
Return values
mixed|nullgetFkID()
Get an ID for the appropriate entity.
private
getFkID(string $fkEntity) : int
Parameters
- $fkEntity : string
Tags
Return values
intgetRandomValue()
private
getRandomValue(mixed $dataType) : int|null|string
Parameters
- $dataType : mixed
Tags
Return values
int|null|stringgetRequiredValue()
Attempt to get a value using field option, defaults, FKEntity, or a random value based on the data type.
private
getRequiredValue(array<string|int, mixed> $field) : mixed
Parameters
- $field : array<string|int, mixed>
Tags
randomLetters()
Generate some random lowercase letters.
private
randomLetters([int $len = 10 ]) : string
Parameters
- $len : int = 10