function LocaleConfigTranslationTest::assertNodeConfig

Same name in other branches
  1. 9 core/modules/locale/tests/src/Functional/LocaleConfigTranslationTest.php \Drupal\Tests\locale\Functional\LocaleConfigTranslationTest::assertNodeConfig()
  2. 8.9.x core/modules/locale/tests/src/Functional/LocaleConfigTranslationTest.php \Drupal\Tests\locale\Functional\LocaleConfigTranslationTest::assertNodeConfig()
  3. 10 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.

@internal

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 259

Class

LocaleConfigTranslationTest
Tests translation of configuration strings.

Namespace

Drupal\Tests\locale\Functional

Code

protected function assertNodeConfig(bool $required, bool $optional) : void {
    // 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.');
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.