You are here

public function TeamInvitationEventsTest::testEvents in Apigee Edge 8

Tests team_invitation events.

File

modules/apigee_edge_teams/tests/src/Kernel/Event/TeamInvitationEventsTest.php, line 79

Class

TeamInvitationEventsTest
Tests team_invitation events.

Namespace

Drupal\Tests\apigee_edge_teams\Kernel

Code

public function testEvents() {
  $team = $this
    ->createTeam();
  $this
    ->queueCompanyResponse($team
    ->decorated());

  /** @var \Drupal\apigee_edge_teams\Entity\TeamInvitationInterface $team_invitation */
  $team_invitation = TeamInvitation::create([
    'team' => [
      'target_id' => $team
        ->id(),
    ],
    'team_roles' => [
      TeamRoleInterface::TEAM_MEMBER_ROLE,
    ],
    'recipient' => 'doe@example.com',
  ]);

  // Created.
  $team_invitation
    ->save();
  $this
    ->assertSame("CREATED", $team_invitation
    ->getLabel());
  $this
    ->assertTrue($team_invitation
    ->isPending());

  // Declined.
  $team_invitation
    ->setStatus(TeamInvitationInterface::STATUS_DECLINED)
    ->save();
  $this
    ->assertSame("DECLINED", $team_invitation
    ->getLabel());
  $this
    ->assertTrue($team_invitation
    ->isDeclined());

  // Accepted.
  $team_invitation
    ->setStatus(TeamInvitationInterface::STATUS_ACCEPTED)
    ->save();
  $this
    ->assertSame("ACCEPTED", $team_invitation
    ->getLabel());
  $this
    ->assertTrue($team_invitation
    ->isAccepted());
}