public function GetBundleByBundleTest::getBundleIdsByBundleProvider in Organic groups 8
Provides test data for testGetBundleIdsByBundle().
Return value
array An array of test properties. Each property is an indexed array with the following items:
- An array indicating the relationships between groups and group content bundles that need to be set up in the test.
- An array containing the expected results for the call to getGroupBundleIdsByGroupContentBundle().
- An array containing the expected results for the 4 calls to getGroupContentBundleIdsByGroupBundle() that will be made in the test. If an empty array is expected to be returned, this result is omitted.
File
- tests/
src/ Kernel/ Entity/ GetBundleByBundleTest.php, line 198
Class
- GetBundleByBundleTest
- Tests retrieving group content bundles by group bundles and vice versa.
Namespace
Drupal\Tests\og\Kernel\EntityCode
public function getBundleIdsByBundleProvider() {
return [
// Test the simplest case: a single group content type that references a
// single group type.
[
// The first parameter sets up the relations between groups and group
// content.
[
// Creating group content of type 'node'.
'node' => [
// The first of which...
'group_content_0' => [
// Has a single group audience field, configured to reference
// groups of type 'node', targeting bundle '0'.
[
'node' => [
'group_0',
],
],
],
],
],
// The second parameter contains the expected result for the call to
// getGroupBundleIdsByGroupContentBundle(). In this case we expect group
// '0' of type 'node' to be referenced.
[
'node' => [
'group_content_0' => [
'node' => [
'group_0' => 'group_0',
],
],
],
],
// Finally, the third parameter contains all 4 expected results for the
// call to getGroupContentBundleIdsByGroupBundle(). In this test only
// node 0 should be referenced, all others should be empty.
// Note that if the result is expected to be an empty array it can be
// omitted from this list. In reality all 4 possible permutations will
// always be tested.
[
// When calling the method with entity type 'node' and bundle '0' we
// expect an array to be returned containing group content of type
// 'node', bundle '0'.
'node' => [
'group_0' => [
'node' => [
'group_content_0' => 'group_content_0',
],
],
// There is no group content referencing group '1', so we expect an
// empty array. This may be omitted.
'group_1' => [],
],
'block_content' => [
// This may be omitted.
'group_0' => [],
// This may be omitted.
'group_1' => [],
],
],
],
// When the bundles are left empty, all bundles should be referenced.
[
// Group to group content relationship matrix.
[
'node' => [
'group_content_0' => [
[
'node' => [],
],
],
],
],
// Expected result for getGroupBundleIdsByGroupContentBundle().
[
'node' => [
'group_content_0' => [
'node' => [
'group_0' => 'group_0',
'group_1' => 'group_1',
],
],
],
],
// Expected result for getGroupContentBundleIdsByGroupBundle().
[
'node' => [
'group_0' => [
'node' => [
'group_content_0' => 'group_content_0',
],
],
'group_1' => [
'node' => [
'group_content_0' => 'group_content_0',
],
],
],
],
],
// Test having two group audience fields referencing both group types.
[
// Group to group content relationship matrix.
[
'node' => [
'group_content_0' => [
[
'node' => [],
],
[
'block_content' => [
'group_0',
'group_1',
],
],
],
],
],
// Expected result for getGroupBundleIdsByGroupContentBundle().
[
'node' => [
'group_content_0' => [
'node' => [
'group_0' => 'group_0',
'group_1' => 'group_1',
],
'block_content' => [
'group_0' => 'group_0',
'group_1' => 'group_1',
],
],
],
],
// Expected result for getGroupContentBundleIdsByGroupBundle().
[
'node' => [
'group_0' => [
'node' => [
'group_content_0' => 'group_content_0',
],
],
'group_1' => [
'node' => [
'group_content_0' => 'group_content_0',
],
],
],
'block_content' => [
'group_0' => [
'node' => [
'group_content_0' => 'group_content_0',
],
],
'group_1' => [
'node' => [
'group_content_0' => 'group_content_0',
],
],
],
],
],
// Test having two group audience fields, one referencing node group 0 and
// the other entity test group 1.
[
// Group to group content relationship matrix.
[
'node' => [
'group_content_0' => [
[
'node' => [
'group_0',
],
],
[
'block_content' => [
'group_1',
],
],
],
],
],
// Expected result for getGroupBundleIdsByGroupContentBundle().
[
'node' => [
'group_content_0' => [
'node' => [
'group_0' => 'group_0',
],
'block_content' => [
'group_1' => 'group_1',
],
],
],
],
// Expected result for getGroupContentBundleIdsByGroupBundle().
[
'node' => [
'group_0' => [
'node' => [
'group_content_0' => 'group_content_0',
],
],
],
'block_content' => [
'group_1' => [
'node' => [
'group_content_0' => 'group_content_0',
],
],
],
],
],
// Test having two different group content entity types referencing the
// same group.
[
// Group to group content relationship matrix.
[
'node' => [
'group_content_0' => [
[
'node' => [
'group_0',
],
],
],
],
'block_content' => [
'group_content_0' => [
[
'node' => [
'group_0',
],
],
],
],
],
// Expected result for getGroupBundleIdsByGroupContentBundle().
[
'node' => [
'group_content_0' => [
'node' => [
'group_0' => 'group_0',
],
],
],
'block_content' => [
'group_content_0' => [
'node' => [
'group_0' => 'group_0',
],
],
],
],
// Expected result for getGroupContentBundleIdsByGroupBundle().
[
'node' => [
'group_0' => [
'node' => [
'group_content_0' => 'group_content_0',
],
'block_content' => [
'group_content_0' => 'group_content_0',
],
],
],
],
],
// Test having two identical group audience fields on the same group
// content type.
[
// Group to group content relationship matrix.
[
'node' => [
'group_content_0' => [
[
'node' => [
'group_0',
],
],
[
'node' => [
'group_0',
],
],
],
],
],
// Expected result for getGroupBundleIdsByGroupContentBundle().
[
'node' => [
'group_content_0' => [
'node' => [
'group_0' => 'group_0',
],
],
],
],
// Expected result for getGroupContentBundleIdsByGroupBundle().
[
'node' => [
'group_0' => [
'node' => [
'group_content_0' => 'group_content_0',
],
],
],
],
],
// Test having two group audience fields on the same group content type,
// each referencing a different group bundle of the same type.
[
// Group to group content relationship matrix.
[
'node' => [
'group_content_0' => [
[
'node' => [
'group_0',
],
],
[
'node' => [
'group_1',
],
],
],
],
],
// Expected result for getGroupBundleIdsByGroupContentBundle().
[
'node' => [
'group_content_0' => [
'node' => [
'group_0' => 'group_0',
'group_1' => 'group_1',
],
],
],
],
// Expected result for getGroupContentBundleIdsByGroupBundle().
[
'node' => [
'group_0' => [
'node' => [
'group_content_0' => 'group_content_0',
],
],
'group_1' => [
'node' => [
'group_content_0' => 'group_content_0',
],
],
],
],
],
// Test having two group content types referencing the same group. The
// second group content type also references another group with a second
// group audience field.
[
// Group to group content relationship matrix.
[
'node' => [
'group_content_0' => [
[
'node' => [
'group_0',
],
],
],
'group_content_1' => [
[
'node' => [
'group_0',
],
],
[
'node' => [
'group_1',
],
],
],
],
],
// Expected result for getGroupBundleIdsByGroupContentBundle().
[
'node' => [
'group_content_0' => [
'node' => [
'group_0' => 'group_0',
],
],
'group_content_1' => [
'node' => [
'group_0' => 'group_0',
'group_1' => 'group_1',
],
],
],
],
// Expected result for getGroupContentBundleIdsByGroupBundle().
[
'node' => [
'group_0' => [
'node' => [
'group_content_0' => 'group_content_0',
'group_content_1' => 'group_content_1',
],
],
'group_1' => [
'node' => [
'group_content_1' => 'group_content_1',
],
],
],
],
],
// Bananas.
[
// Group to group content relationship matrix.
[
'node' => [
'group_content_0' => [
0 => [
'node' => [
'group_0',
],
],
1 => [
'block_content' => [
'group_0',
'group_1',
],
],
],
'group_content_1' => [
2 => [
'block_content' => [
'group_1',
],
],
],
],
'block_content' => [
'group_content_2' => [
0 => [
'node' => [
'group_0',
],
],
1 => [
'node' => [
'group_0',
],
],
2 => [
'node' => [
'group_1',
],
],
],
'group_content_3' => [
3 => [
'block_content' => [
'group_0',
'group_1',
],
],
],
'group_content_4' => [
4 => [
'node' => [
'group_0',
'group_1',
],
],
5 => [
'block_content' => [
'group_1',
],
],
],
],
],
// Expected result for getGroupBundleIdsByGroupContentBundle().
[
'node' => [
'group_content_0' => [
'node' => [
'group_0' => 'group_0',
],
'block_content' => [
'group_0' => 'group_0',
'group_1' => 'group_1',
],
],
'group_content_1' => [
'block_content' => [
'group_1' => 'group_1',
],
],
],
'block_content' => [
'group_content_2' => [
'node' => [
'group_0' => 'group_0',
'group_1' => 'group_1',
],
],
'group_content_3' => [
'block_content' => [
'group_0' => 'group_0',
'group_1' => 'group_1',
],
],
'group_content_4' => [
'node' => [
'group_0' => 'group_0',
'group_1' => 'group_1',
],
'block_content' => [
'group_1' => 'group_1',
],
],
],
],
// Expected result for getGroupContentBundleIdsByGroupBundle().
[
'node' => [
'group_0' => [
'node' => [
'group_content_0' => 'group_content_0',
],
'block_content' => [
'group_content_2' => 'group_content_2',
'group_content_4' => 'group_content_4',
],
],
'group_1' => [
'block_content' => [
'group_content_2' => 'group_content_2',
'group_content_4' => 'group_content_4',
],
],
],
'block_content' => [
'group_0' => [
'node' => [
'group_content_0' => 'group_content_0',
],
'block_content' => [
'group_content_3' => 'group_content_3',
],
],
'group_1' => [
'node' => [
'group_content_0' => 'group_content_0',
'group_content_1' => 'group_content_1',
],
'block_content' => [
'group_content_3' => 'group_content_3',
'group_content_4' => 'group_content_4',
],
],
],
],
],
];
}