You are here

public function GetMembershipsTest::membershipDataProvider in Organic groups 8

Provides test data to test retrieval of memberships.

Return value

array An array of test properties. Each property is an indexed array with the following items:

  • The key of the user in the $this->users array for which to retrieve memberships.
  • An array of membership states to filter on.
  • An array containing the expected results to be returned.

File

tests/src/Kernel/Entity/GetMembershipsTest.php, line 181

Class

GetMembershipsTest
Tests retrieving OgMembership entities associated with a given user.

Namespace

Drupal\Tests\og\Kernel\Entity

Code

public function membershipDataProvider() {
  return [
    // The first user is an active member of the first group.
    // Query default values. The group should be returned.
    [
      0,
      [],
      [
        0,
      ],
    ],
    // Filter by active state.
    [
      0,
      [
        OgMembershipInterface::STATE_ACTIVE,
      ],
      [
        0,
      ],
    ],
    // Filter by active + pending state.
    [
      0,
      [
        OgMembershipInterface::STATE_ACTIVE,
        OgMembershipInterface::STATE_PENDING,
      ],
      [
        0,
      ],
    ],
    // Filter by blocked + pending state. Since the user is active this should
    // not return any matches.
    [
      0,
      [
        OgMembershipInterface::STATE_BLOCKED,
        OgMembershipInterface::STATE_PENDING,
      ],
      [],
    ],
    // The second user is a pending member of the second group.
    // Query default values. The group should be returned.
    [
      1,
      [],
      [
        1,
      ],
    ],
    // Filter by pending state.
    [
      1,
      [
        OgMembershipInterface::STATE_PENDING,
      ],
      [
        1,
      ],
    ],
    // Filter by active state. The user is pending so this should not return
    // any matches.
    [
      1,
      [
        OgMembershipInterface::STATE_ACTIVE,
      ],
      [],
    ],
    // The third user is an active member of both groups.
    // Query default values. Both groups should be returned.
    [
      2,
      [],
      [
        0,
        1,
      ],
    ],
    // Filter by active state.
    [
      2,
      [
        OgMembershipInterface::STATE_ACTIVE,
      ],
      [
        0,
        1,
      ],
    ],
    // Filter by blocked state. This should not return any matches.
    [
      2,
      [
        OgMembershipInterface::STATE_BLOCKED,
      ],
      [],
    ],
    // The fourth user is a pending member of the first group and blocked in
    // the second group.
    // Query default values. Both groups should be returned.
    [
      3,
      [],
      [
        0,
        1,
      ],
    ],
    // Filter by active state. No results should be returned.
    [
      3,
      [
        OgMembershipInterface::STATE_ACTIVE,
      ],
      [],
    ],
    // Filter by pending state.
    [
      3,
      [
        OgMembershipInterface::STATE_PENDING,
      ],
      [
        0,
      ],
    ],
    // Filter by blocked state.
    [
      3,
      [
        OgMembershipInterface::STATE_BLOCKED,
      ],
      [
        1,
      ],
    ],
    // Filter by combinations of states.
    [
      3,
      [
        OgMembershipInterface::STATE_ACTIVE,
        OgMembershipInterface::STATE_PENDING,
      ],
      [
        0,
      ],
    ],
    [
      3,
      [
        OgMembershipInterface::STATE_ACTIVE,
        OgMembershipInterface::STATE_PENDING,
        OgMembershipInterface::STATE_BLOCKED,
      ],
      [
        0,
        1,
      ],
    ],
    [
      3,
      [
        OgMembershipInterface::STATE_ACTIVE,
        OgMembershipInterface::STATE_BLOCKED,
      ],
      [
        1,
      ],
    ],
    [
      3,
      [
        OgMembershipInterface::STATE_PENDING,
        OgMembershipInterface::STATE_BLOCKED,
      ],
      [
        0,
        1,
      ],
    ],
    // A user which is not subscribed to either of the two groups.
    [
      4,
      [],
      [],
    ],
    [
      4,
      [
        OgMembershipInterface::STATE_ACTIVE,
      ],
      [],
    ],
    [
      4,
      [
        OgMembershipInterface::STATE_BLOCKED,
      ],
      [],
    ],
    [
      4,
      [
        OgMembershipInterface::STATE_PENDING,
      ],
      [],
    ],
    [
      4,
      [
        OgMembershipInterface::STATE_ACTIVE,
        OgMembershipInterface::STATE_PENDING,
        OgMembershipInterface::STATE_BLOCKED,
      ],
      [],
    ],
  ];
}