Documentation

CRM_Core_Resources_CollectionTestTrait

Class CRM_Core_Resources_CollectionTestTrait

If you have a concrete class which uses CollectionTrait, this helper should make it easier to write a unit-test.

Table of Contents

Methods

add()  : array<string|int, mixed>
Add an item to the collection.
assertSameSnippet()  : mixed
Assert that two snippets are equivalent.
createEmptyCollection()  : CRM_Core_Resources_CollectionInterface
findCreateSettingSnippet()  : array<string|int, mixed>
Locate the 'settings' snippet.
getSnippetExamples()  : mixed
testAddBundle()  : void
testAddDefaults()  : mixed
Add a snippet with some method and ensure that it's actually added.
testAliases()  : void
Create a few resources with aliases. Use a mix of reads+writes on both the canonical names and aliased names.
testClear()  : void
Add some items to a bundle - then clear() all of them.
testMerge()  : void
Create two bundles (parent, child) - and merge the child into the parent.
testSettingsSplatParser()  : void
Functions like `addVars()` accept positional arguments in the order ($region).
testStandardSplatParser()  : void
Functions like `addScriptFile()` accept positional arguments in the order ($weight, $region, $translate).

Methods

assertSameSnippet()

Assert that two snippets are equivalent.

public assertSameSnippet(array<string|int, mixed> $expect, array<string|int, mixed> $actual[, string $message = '' ]) : mixed
Parameters
$expect : array<string|int, mixed>
$actual : array<string|int, mixed>
$message : string = ''

testAddDefaults()

Add a snippet with some method and ensure that it's actually added.

public testAddDefaults(array<string|int, mixed> $callbackArgs, array<string|int, mixed> $expectSnippet) : mixed
Parameters
$callbackArgs : array<string|int, mixed>

Ex: ['addScriptUrl', 'http://example.com/foo.js'].

$expectSnippet : array<string|int, mixed>
Tags
dataProvider

getSnippetExamples

testAliases()

Create a few resources with aliases. Use a mix of reads+writes on both the canonical names and aliased names.

public testAliases() : void

testClear()

Add some items to a bundle - then clear() all of them.

public testClear() : void

testMerge()

Create two bundles (parent, child) - and merge the child into the parent.

public testMerge() : void

testSettingsSplatParser()

Functions like `addVars()` accept positional arguments in the order ($region).

public testSettingsSplatParser() : void

testStandardSplatParser()

Functions like `addScriptFile()` accept positional arguments in the order ($weight, $region, $translate).

public testStandardSplatParser() : void

        
On this page

Search results