You are here

public function ParagraphsAccessTest::createAccessTestCases in Paragraphs 8

Test cases for ::testCreateAccess.

File

tests/src/Kernel/ParagraphsAccessTest.php, line 40

Class

ParagraphsAccessTest
@coversDefaultClass \Drupal\paragraphs\ParagraphAccessControlHandler @group paragraphs

Namespace

Drupal\Tests\paragraphs\Kernel

Code

public function createAccessTestCases() {
  $container = new ContainerBuilder();
  $cache_contexts_manager = $this
    ->prophesize(CacheContextsManager::class);
  $cache_contexts_manager
    ->assertValidTokens()
    ->willReturn(TRUE);
  $cache_contexts_manager
    ->reveal();
  $container
    ->set('cache_contexts_manager', $cache_contexts_manager);
  \Drupal::setContainer($container);
  return [
    'Allowed HTML request format' => [
      'html',
      AccessResult::allowed()
        ->addCacheContexts([
        'request_format',
      ]),
    ],
    'Forbidden other formats' => [
      'json',
      AccessResult::neutral()
        ->addCacheContexts([
        'request_format',
      ]),
    ],
  ];
}