You are here

protected function ChangeMultipleOgMembershipRolesActionTestBase::assertStoredMemberships in Organic groups 8

Checks that the memberships in temporary storage match the expected ones.

Parameters

array $membership_ids: An array of membership IDs that are expected to be present in the private temporary storage of the logged in user.

2 calls to ChangeMultipleOgMembershipRolesActionTestBase::assertStoredMemberships()
ChangeMultipleOgMembershipRolesActionTestBase::testExecute in tests/src/Kernel/Action/ChangeMultipleOgMembershipRolesActionTestBase.php
Checks if the action can be performed correctly.
ChangeMultipleOgMembershipRolesActionTestBase::testExecuteMultiple in tests/src/Kernel/Action/ChangeMultipleOgMembershipRolesActionTestBase.php
Checks if the action can be performed correctly.

File

tests/src/Kernel/Action/ChangeMultipleOgMembershipRolesActionTestBase.php, line 152

Class

ChangeMultipleOgMembershipRolesActionTestBase
Base class for tests for plugins that change multiple roles at once.

Namespace

Drupal\Tests\og\Kernel\Action

Code

protected function assertStoredMemberships(array $membership_ids) {
  $private_tempstore = $this->tempStorageFactory
    ->get($this->pluginId);
  $actual_membership_ids = $private_tempstore
    ->get('membership_ids');

  // Get the actual entity IDs of the memberships as stored in the database.
  $memberships = $this->memberships;
  $expected_membership_ids = array_map(function ($membership_id) use ($memberships) {
    return $memberships[$membership_id]
      ->id();
  }, $membership_ids);
  sort($expected_membership_ids);
  sort($actual_membership_ids);
  $this
    ->assertEquals($expected_membership_ids, $actual_membership_ids);
}