You are here

GraphQLViewerEndpointTest.php in Open Social 10.1.x

File

modules/social_features/social_user/tests/src/Kernel/GraphQL/GraphQLViewerEndpointTest.php
View source
<?php

namespace Drupal\Tests\social_user\Kernel\GraphQL;

use Drupal\Tests\social_graphql\Kernel\SocialGraphQLTestBase;

/**
 * Tests the root viewer endpoint.
 *
 * @group social_graphql
 */
class GraphQLViewerEndpointTest extends SocialGraphQLTestBase {

  /**
   * {@inheritdoc}
   */
  public static $modules = [
    "social_user",
    // User creation in social_user requires a service in role_delegation.
    // TODO: Possibly untangle this?
    "role_delegation",
  ];

  /**
   * It loads the current user.
   */
  public function testViewerLoadsCurrentUser() : void {
    $user = $this
      ->createUser();
    $this
      ->setCurrentUser($user);
    $this
      ->assertResults("\n        query {\n          viewer {\n            id\n          }\n        }\n      ", [], [
      'viewer' => [
        'id' => $user
          ->uuid(),
      ],
    ], $this
      ->defaultCacheMetaData()
      ->setCacheMaxAge(0)
      ->addCacheableDependency($user)
      ->addCacheContexts([
      'languages:language_interface',
    ]));
  }

}

Classes

Namesort descending Description
GraphQLViewerEndpointTest Tests the root viewer endpoint.