You are here

protected function DisabledNodeTypesTest::setUp in Gatsby Live Preview & Incremental Builds 8

Same name and namespace in other branches
  1. 2.0.x modules/gatsby_fastbuilds/tests/src/Kernel/DisabledNodeTypesTest.php \Drupal\Tests\gatsby_fastbuilds\Kernel\DisabledNodeTypesTest::setUp()

Overrides KernelTestBase::setUp

File

modules/gatsby_fastbuilds/tests/src/Kernel/DisabledNodeTypesTest.php, line 55

Class

DisabledNodeTypesTest
Defines a test for fastbuilds with disabled node-types.

Namespace

Drupal\Tests\gatsby_fastbuilds\Kernel

Code

protected function setUp() : void {
  parent::setUp();
  $this
    ->installConfig([
    'node',
    'filter',
  ]);
  $this
    ->installSchema('system', [
    'sequences',
  ]);
  $this
    ->installEntitySchema('path_alias');
  $this
    ->installEntitySchema('node');
  $this
    ->installEntitySchema('user');
  $this
    ->createContentType([
    'type' => 'page',
  ]);
  $this
    ->createContentType([
    'type' => 'article',
  ]);
  $this
    ->installEntitySchema('gatsby_log_entity');
  $config_factory = \Drupal::configFactory();
  $config_factory
    ->getEditable('gatsby.settings')
    ->set('preview_entity_types', [
    'node',
  ])
    ->set('server_url', 'http://example.com')
    ->save();
  $config_factory
    ->getEditable('gatsby_fastbuilds.settings')
    ->set('log_published', TRUE)
    ->save();
  $this
    ->setUpCurrentUser([], [
    'access content',
  ]);
  $disabled_article = JsonapiResourceConfig::create([
    'id' => 'node--article',
    'status' => TRUE,
    'disabled' => TRUE,
    'path' => 'node/article',
    'resourceType' => 'node--article',
  ]);
  $disabled_article
    ->save();
  \Drupal::service('jsonapi.resource_type.repository')
    ->reset();
  \Drupal::service('cache_tags.invalidator')
    ->invalidateTags([
    'jsonapi_resource_types',
  ]);
  \Drupal::service('router.builder')
    ->rebuild();
  try {
    Url::fromRoute('jsonapi.node--article.individual')
      ->toString();
    $this
      ->fail('Route should be disabled');
  } catch (RouteNotFoundException $e) {
    $this
      ->addToAssertionCount(1);
  }
}