function PathWithNodeAccessGrantsTest::setUp

Same name in other branches
  1. 10 core/modules/path/tests/src/Functional/PathWithNodeAccessGrantsTest.php \Drupal\Tests\path\Functional\PathWithNodeAccessGrantsTest::setUp()

Overrides PathTestBase::setUp

File

core/modules/path/tests/src/Functional/PathWithNodeAccessGrantsTest.php, line 40

Class

PathWithNodeAccessGrantsTest
Confirm that paths work with node access grants implementations.

Namespace

Drupal\Tests\path\Functional

Code

protected function setUp() : void {
    parent::setUp();
    // Create a workflow for basic page.
    $workflow = $this->createEditorialWorkflow();
    $this->addEntityTypeAndBundleToWorkflow($workflow, 'node', 'page');
    // Login as admin user to configure language detection and selection.
    $admin_user = $this->drupalCreateUser([
        'edit any page content',
        'create page content',
        'administer url aliases',
        'create url aliases',
        'administer languages',
        'access administration pages',
    ]);
    $this->drupalLogin($admin_user);
    // Enable French language.
    static::createLanguageFromLangcode('fr');
    // Enable URL language detection and selection.
    $edit = [
        'language_interface[enabled][language-url]' => 1,
    ];
    $this->drupalGet('admin/config/regional/language/detection');
    $this->submitForm($edit, 'Save settings');
    // Enable translation for page node.
    static::enableContentTranslation('node', 'page');
    static::setFieldTranslatable('node', 'page', 'body', TRUE);
    $definitions = \Drupal::service('entity_field.manager')->getFieldDefinitions('node', 'page');
    $this->assertTrue($definitions['path']->isTranslatable(), 'Node path is translatable.');
    $this->assertTrue($definitions['body']->isTranslatable(), 'Node body is translatable.');
}

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