You are here

protected function LanguageContextTest::setUp in GraphQL 8.3

Overrides GraphQLTestBase::setUp

File

tests/src/Kernel/Framework/LanguageContextTest.php, line 26

Class

LanguageContextTest
Test contextual language negotiation.

Namespace

Drupal\Tests\graphql\Kernel\Framework

Code

protected function setUp() {
  parent::setUp();
  $this
    ->mockType('node', [
    'name' => 'Node',
  ]);
  $this
    ->mockField('edge', [
    'name' => 'edge',
    'parents' => [
      'Root',
      'Node',
    ],
    'type' => 'Node',
    'arguments' => [
      'language' => 'String',
    ],
    'contextual_arguments' => [
      'language',
    ],
  ], 'foo');
  $this
    ->mockField('language', [
    'name' => 'language',
    'parents' => [
      'Root',
      'Node',
    ],
    'type' => 'String',
    'response_cache_contexts' => [
      'languages:language_interface',
    ],
  ], function () {
    (yield \Drupal::languageManager()
      ->getCurrentLanguage()
      ->getId());
  });
  $this
    ->mockField('deferred', [
    'name' => 'deferred',
    'parents' => [
      'Root',
      'Node',
    ],
    'type' => 'String',
    'response_cache_contexts' => [
      'languages:language_interface',
    ],
  ], function () {
    return function () {
      (yield \Drupal::languageManager()
        ->getCurrentLanguage()
        ->getId());
    };
  });
  $this
    ->mockField('unaware', [
    'name' => 'unaware',
    'parents' => [
      'Root',
      'Node',
    ],
    'type' => 'String',
  ], function () {
    (yield \Drupal::languageManager()
      ->getCurrentLanguage()
      ->getId());
  });
  $this
    ->mockField('leaking', [
    'name' => 'leaking',
    'parents' => [
      'Root',
      'Node',
    ],
    'type' => 'String',
  ], function () {
    (yield new CacheableValue('leak', [
      (new CacheableMetadata())
        ->addCacheContexts([
        'languages:language_interface',
      ]),
    ]));
  });
  $this->container
    ->get('router.builder')
    ->rebuild();
}