You are here

protected function LocaleConfigTranslationTest::assertNodeConfig in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/locale/tests/src/Functional/LocaleConfigTranslationTest.php \Drupal\Tests\locale\Functional\LocaleConfigTranslationTest::assertNodeConfig()

Check that node configuration source strings are made available in locale.

Parameters

bool $required: Whether to assume a sample of the required default configuration is present.

bool $optional: Whether to assume a sample of the optional default configuration is present.

1 call to LocaleConfigTranslationTest::assertNodeConfig()
LocaleConfigTranslationTest::testOptionalConfiguration in core/modules/locale/tests/src/Functional/LocaleConfigTranslationTest.php
Tests translatability of optional configuration in locale.

File

core/modules/locale/tests/src/Functional/LocaleConfigTranslationTest.php, line 251

Class

LocaleConfigTranslationTest
Tests translation of configuration strings.

Namespace

Drupal\Tests\locale\Functional

Code

protected function assertNodeConfig($required, $optional) {

  // Check the required default configuration in node module.
  $string = $this->storage
    ->findString([
    'source' => 'Make content sticky',
    'context' => '',
    'type' => 'configuration',
  ]);
  if ($required) {
    $this
      ->assertFalse($this
      ->config('system.action.node_make_sticky_action')
      ->isNew());
    $this
      ->assertNotEmpty($string, 'Node action text can be found with node module.');
  }
  else {
    $this
      ->assertTrue($this
      ->config('system.action.node_make_sticky_action')
      ->isNew());
    $this
      ->assertNull($string, 'Node action text can not be found without node module.');
  }

  // Check the optional default configuration in node module.
  $string = $this->storage
    ->findString([
    'source' => 'No front page content has been created yet.<br/>Follow the <a target="_blank" href="https://www.drupal.org/docs/user_guide/en/index.html">User Guide</a> to start building your site.',
    'context' => '',
    'type' => 'configuration',
  ]);
  if ($optional) {
    $this
      ->assertFalse($this
      ->config('views.view.frontpage')
      ->isNew());
    $this
      ->assertNotEmpty($string, 'Node view text can be found with node and views modules.');
  }
  else {
    $this
      ->assertTrue($this
      ->config('views.view.frontpage')
      ->isNew());
    $this
      ->assertNull($string, 'Node view text can not be found without node and/or views modules.');
  }
}