You are here

public function ApigeeMockApiClientHelperTrait::addUserToTeam in Apigee Edge 8

Adds a user to a team.

Adding a team to a user will add the team as long as the developer entity is loaded from cache.

Parameters

\Drupal\apigee_edge_teams\Entity\TeamInterface $team: The team.

\Drupal\user\UserInterface $user: A drupal user.

Return value

\Drupal\apigee_edge\Entity\DeveloperInterface The developer entity.

3 calls to ApigeeMockApiClientHelperTrait::addUserToTeam()
EdgeEntityAddMemberEventTest::testEvent in modules/apigee_edge_actions/tests/src/Kernel/Plugin/RulesEvent/EdgeEntityAddMemberEventTest.php
Tests add_member events for Edge entities.
EdgeEntityRemoveMemberEventTest::testEvent in modules/apigee_edge_actions/tests/src/Kernel/Plugin/RulesEvent/EdgeEntityRemoveMemberEventTest.php
Tests add_member events for Edge entities.
TeamListBuilderTest::setUp in modules/apigee_edge_teams/tests/src/Functional/TeamListBuilderTest.php

File

tests/modules/apigee_mock_api_client/tests/src/Traits/ApigeeMockApiClientHelperTrait.php, line 306

Class

ApigeeMockApiClientHelperTrait
Helper functions working with Apigee tests.

Namespace

Drupal\Tests\apigee_mock_api_client\Traits

Code

public function addUserToTeam(TeamInterface $team, UserInterface $user) {
  $this
    ->queueDevsInCompanyResponse([
    [
      'email' => $user
        ->getEmail(),
    ],
  ]);
  $this
    ->queueCompanyResponse($team
    ->decorated());
  $teamMembershipManager = \Drupal::service('apigee_edge_teams.team_membership_manager');
  $teamMembershipManager
    ->addMembers($team
    ->id(), [
    $user
      ->getEmail(),
  ]);
  $this
    ->queueDeveloperResponse($user, 200, [
    'companies' => [
      $team
        ->id(),
    ],
  ]);
  return $this->entityTypeManager
    ->getStorage('developer')
    ->load($user
    ->getEmail());
}