Documentation

CRMTraits_Financial_OrderTrait uses trait:short

Trait OrderTrait

Trait for setting up orders for tests.

Table of Contents

Properties

$_apiversion  : int
Api version - easier to override than just a define

Methods

assertAPIArrayComparison()  : mixed
Check that api returned 'is_error' => 1 else provide full message
assertAPIDeleted()  : mixed
Check that a deleted item has been deleted.
assertAPIFailure()  : void
Check that api returned 'is_error' => 1.
assertAPISuccess()  : mixed
Check that api returned 'is_error' => 0.
callAPIAndDocument()  : array<string|int, mixed>|int
callAPIFailure()  : array<string|int, mixed>|int
This function exists to wrap api functions.
callAPISuccess()  : array<string|int, mixed>|int
wrap api functions.
callAPISuccessGetCount()  : array<string|int, mixed>|int
This function exists to wrap api getValue function & check the result so we can ensure they succeed & throw exceptions without littering the test with checks There is a type check in this
callAPISuccessGetSingle()  : array<string|int, mixed>|int
This function exists to wrap api getsingle function & check the result so we can ensure they succeed & throw exceptions without litterering the test with checks
callAPISuccessGetValue()  : array<string|int, mixed>|int
This function wraps the getValue api and checks the result.
civicrm_api()  : array<string|int, mixed>|int
A stub for the API interface. This can be overriden by subclasses to change how the API is called.
createRepeatMembershipOrder()  : void
Create a pending membership from a recurring order.
runApi4Legacy()  : array<string|int, mixed>|int
Emulate v3 syntax so we can run api3 tests on v4
versionThreeAndFour()  : array<string|int, mixed>
Get the api versions to test.
createContributionAndMembershipOrder()  : void
Create an order with a contribution AND a membership line item.
createEventOrder()  : mixed
Create an order for an event.
createExtraneousContribution()  : mixed
Create an extraneous contribution to throw off any 'number one bugs'.
createMultipleMembershipOrder()  : mixed
Create an order with more than one membership.
getMembershipLineItem()  : array<string|int, array<string|int, mixed>>
runApi4LegacyChain()  : array<string|int, mixed>

Properties

$_apiversion

Api version - easier to override than just a define

protected int $_apiversion = 3

Methods

assertAPIArrayComparison()

Check that api returned 'is_error' => 1 else provide full message

public assertAPIArrayComparison(array<string|int, mixed> $result, mixed $expected[, array<string|int, mixed> $valuesToExclude = [] ][, string $prefix = '' ]) : mixed
Parameters
$result : array<string|int, mixed>
$expected : mixed
$valuesToExclude : array<string|int, mixed> = []
$prefix : string = ''

Extra test to add to message.

assertAPIDeleted()

Check that a deleted item has been deleted.

public assertAPIDeleted(mixed $entity, mixed $id) : mixed
Parameters
$entity : mixed
$id : mixed

assertAPIFailure()

Check that api returned 'is_error' => 1.

public assertAPIFailure(array<string|int, mixed> $apiResult[, string $prefix = '' ][, string|null $expectedError = null ]) : void
Parameters
$apiResult : array<string|int, mixed>

Api result.

$prefix : string = ''

Extra test to add to message.

$expectedError : string|null = null

assertAPISuccess()

Check that api returned 'is_error' => 0.

public assertAPISuccess(array<string|int, mixed> $apiResult[, string $prefix = '' ]) : mixed
Parameters
$apiResult : array<string|int, mixed>

Api result.

$prefix : string = ''

Extra test to add to message.

callAPIAndDocument()

public callAPIAndDocument(string $entity, string $action, array<string|int, mixed> $params) : array<string|int, mixed>|int
Parameters
$entity : string
$action : string
$params : array<string|int, mixed>
Return values
array<string|int, mixed>|int

callAPIFailure()

This function exists to wrap api functions.

public callAPIFailure(string $entity, string $action[, array<string|int, mixed> $params = [] ][, string $expectedErrorMessage = null ][, null $extraOutput = null ]) : array<string|int, mixed>|int

so we can ensure they fail where expected & throw exceptions without litterering the test with checks

Parameters
$entity : string
$action : string
$params : array<string|int, mixed> = []
$expectedErrorMessage : string = null

Error.

$extraOutput : null = null
Return values
array<string|int, mixed>|int

callAPISuccess()

wrap api functions.

public callAPISuccess(string $entity, string $action[, array<string|int, mixed> $params = [] ][, mixed $checkAgainst = null ]) : array<string|int, mixed>|int

so we can ensure they succeed & throw exceptions without litterering the test with checks

Parameters
$entity : string
$action : string
$params : array<string|int, mixed> = []
$checkAgainst : mixed = null

Optional value to check result against, implemented for getvalue,. getcount, getsingle. Note that for getvalue the type is checked rather than the value for getsingle the array is compared against an array passed in - the id is not compared (for better or worse )

Return values
array<string|int, mixed>|int

callAPISuccessGetCount()

This function exists to wrap api getValue function & check the result so we can ensure they succeed & throw exceptions without littering the test with checks There is a type check in this

public callAPISuccessGetCount(string $entity, array<string|int, mixed> $params[, int $count = null ]) : array<string|int, mixed>|int
Parameters
$entity : string
$params : array<string|int, mixed>
$count : int = null
Return values
array<string|int, mixed>|int

callAPISuccessGetSingle()

This function exists to wrap api getsingle function & check the result so we can ensure they succeed & throw exceptions without litterering the test with checks

public callAPISuccessGetSingle(string $entity, array<string|int, mixed> $params[, array<string|int, mixed> $checkAgainst = null ]) : array<string|int, mixed>|int
Parameters
$entity : string
$params : array<string|int, mixed>
$checkAgainst : array<string|int, mixed> = null

Array to compare result against.

  • boolean
  • integer
  • double
  • string
  • array
  • object
Return values
array<string|int, mixed>|int

callAPISuccessGetValue()

This function wraps the getValue api and checks the result.

public callAPISuccessGetValue(string $entity, array<string|int, mixed> $params[, string $type = null ]) : array<string|int, mixed>|int
Parameters
$entity : string
$params : array<string|int, mixed>
$type : string = null

Only 'integer' is supported

Return values
array<string|int, mixed>|int

civicrm_api()

A stub for the API interface. This can be overriden by subclasses to change how the API is called.

public civicrm_api(mixed $entity, mixed $action[, array<string|int, mixed> $params = [] ]) : array<string|int, mixed>|int
Parameters
$entity : mixed
$action : mixed
$params : array<string|int, mixed> = []
Return values
array<string|int, mixed>|int

createRepeatMembershipOrder()

Create a pending membership from a recurring order.

public createRepeatMembershipOrder() : void
Tags
throws
CRM_Core_Exception

runApi4Legacy()

Emulate v3 syntax so we can run api3 tests on v4

public runApi4Legacy(mixed $v3Entity, mixed $v3Action[, array<string|int, mixed> $v3Params = [] ]) : array<string|int, mixed>|int
Parameters
$v3Entity : mixed
$v3Action : mixed
$v3Params : array<string|int, mixed> = []
Tags
throws
CRM_Core_Exception
throws
Exception
Return values
array<string|int, mixed>|int

versionThreeAndFour()

Get the api versions to test.

public static versionThreeAndFour() : array<string|int, mixed>
Return values
array<string|int, mixed>

createContributionAndMembershipOrder()

Create an order with a contribution AND a membership line item.

protected createContributionAndMembershipOrder() : void
Tags
throws
CRM_Core_Exception

createEventOrder()

Create an order for an event.

protected createEventOrder([array<string|int, mixed> $orderParams = [] ]) : mixed
Parameters
$orderParams : array<string|int, mixed> = []
Tags
throws
CRM_Core_Exception

createExtraneousContribution()

Create an extraneous contribution to throw off any 'number one bugs'.

protected createExtraneousContribution() : mixed

Ie this means our real data starts from 2 & we won't hit 'pretend passes' just because the number 1 is used for multiple entities.

createMultipleMembershipOrder()

Create an order with more than one membership.

protected createMultipleMembershipOrder() : mixed
Tags
throws
CRM_Core_Exception

getMembershipLineItem()

protected getMembershipLineItem() : array<string|int, array<string|int, mixed>>
Tags
throws
CRM_Core_Exception
Return values
array<string|int, array<string|int, mixed>>

runApi4LegacyChain()

protected runApi4LegacyChain(string $key, mixed $params, string $mainEntity, array<string|int, mixed> $result, bool $sequential) : array<string|int, mixed>
Parameters
$key : string
$params : mixed
$mainEntity : string
$result : array<string|int, mixed>
$sequential : bool
Tags
throws
CRM_Core_Exception
Return values
array<string|int, mixed>

        
On this page

Search results