diff --git a/modules/apigee_edge_teams/tests/src/Kernel/ApigeeX/EntityControllerCacheTest.php b/modules/apigee_edge_teams/tests/src/Kernel/ApigeeX/EntityControllerCacheTest.php new file mode 100644 index 00000000..15ca122b --- /dev/null +++ b/modules/apigee_edge_teams/tests/src/Kernel/ApigeeX/EntityControllerCacheTest.php @@ -0,0 +1,85 @@ +container->get('apigee_edge_teams.controller.cache.team'); + /** @var \Drupal\apigee_edge\Entity\Controller\Cache\EntityIdCacheInterface $team_id_cache */ + $team_id_cache = $this->container->get('apigee_edge_teams.controller.cache.team_ids'); + + // Generate team entities with random data. + $teams = []; + for ($i = 0; $i < 3; $i++) { + $id = $this->getRandomUniqueId(); + $teams[$id] = new AppGroup([ + 'name' => $id, + ]); + } + + $this->saveAllEntitiesAndValidate($teams, $team_cache, $team_id_cache); + + /** @var \Apigee\Edge\Api\Management\Entity\AppGroupInterface $team */ + foreach ($teams as $team) { + // Load team by name. + $this->assertSame($team, $team_cache->getEntity($team->getName())); + $this->assertContains($team->getName(), $team_id_cache->getIds()); + + // Pass an invalid entity id to ensure it does not cause any trouble + // anymore. + // @see \Drupal\apigee_edge\Entity\Controller\Cache\EntityCache::removeEntities() + // @see https://www.drupal.org/project/drupal/issues/3017753 + $team_cache->removeEntities([$team->getName(), $this->getRandomGenerator()->string()]); + $this->assertNull($team_cache->getEntity($team->getName())); + $this->assertNotContains($team->getName(), $team_id_cache->getIds()); + } + + $this->assertEmptyCaches($team_cache, $team_id_cache); + } + +} diff --git a/modules/apigee_edge_teams/tests/src/Kernel/ApigeeX/Event/TeamInvitationEventsTest.php b/modules/apigee_edge_teams/tests/src/Kernel/ApigeeX/Event/TeamInvitationEventsTest.php new file mode 100644 index 00000000..6b81c873 --- /dev/null +++ b/modules/apigee_edge_teams/tests/src/Kernel/ApigeeX/Event/TeamInvitationEventsTest.php @@ -0,0 +1,115 @@ +installConfig(['apigee_edge']); + $this->installConfig(['apigee_edge_teams']); + $this->installEntitySchema('user'); + $this->installEntitySchema('team_member_role'); + $this->installEntitySchema('team_invitation'); + $this->installSchema('system', ['sequences']); + $this->installSchema('user', ['users_data']); + + $this->baseSetUp(); + + $this->addApigeexOrganizationMatchedResponse(); + } + + /** + * Tests team_invitation events for AppGroup org. + */ + public function testEvents() { + $this->entity = $this->createApigeexTeam(); + $this->queueAppGroupResponse($this->entity->decorated()); + + /** @var \Drupal\apigee_edge_teams\Entity\TeamInvitationInterface $team_invitation */ + $team_invitation = TeamInvitation::create([ + 'team' => ['target_id' => $this->entity->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()); + } + +} diff --git a/tests/modules/apigee_mock_api_client/tests/src/Traits/ApigeeMockApiClientHelperTrait.php b/tests/modules/apigee_mock_api_client/tests/src/Traits/ApigeeMockApiClientHelperTrait.php index f6177fe6..8c7ec5ef 100644 --- a/tests/modules/apigee_mock_api_client/tests/src/Traits/ApigeeMockApiClientHelperTrait.php +++ b/tests/modules/apigee_mock_api_client/tests/src/Traits/ApigeeMockApiClientHelperTrait.php @@ -378,7 +378,6 @@ protected function createApigeexTeam(): TeamInterface { ]); $this->queueAppGroupResponse($team->decorated()); - $this->stack->queueMockResponse('no_content'); $team->save(); return $team;