function NodeTranslationUITest::testDisabledBundle

Same name in other branches
  1. 9 core/modules/node/tests/src/Functional/NodeTranslationUITest.php \Drupal\Tests\node\Functional\NodeTranslationUITest::testDisabledBundle()
  2. 10 core/modules/node/tests/src/Functional/NodeTranslationUITest.php \Drupal\Tests\node\Functional\NodeTranslationUITest::testDisabledBundle()
  3. 11.x core/modules/node/tests/src/Functional/NodeTranslationUITest.php \Drupal\Tests\node\Functional\NodeTranslationUITest::testDisabledBundle()

Tests that no metadata is stored for a disabled bundle.

File

core/modules/node/tests/src/Functional/NodeTranslationUITest.php, line 270

Class

NodeTranslationUITest
Tests the Node Translation UI.

Namespace

Drupal\Tests\node\Functional

Code

public function testDisabledBundle() {
    // Create a bundle that does not have translation enabled.
    $disabledBundle = $this->randomMachineName();
    $this->drupalCreateContentType([
        'type' => $disabledBundle,
        'name' => $disabledBundle,
    ]);
    // Create a node for each bundle.
    $node = $this->drupalCreateNode([
        'type' => $this->bundle,
        'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
    ]);
    // Make sure that nothing was inserted into the {content_translation} table.
    $rows = Database::getConnection()->query('SELECT nid, count(nid) AS count FROM {node_field_data} WHERE type <> :type GROUP BY nid HAVING count(nid) >= 2', [
        ':type' => $this->bundle,
    ])
        ->fetchAll();
    $this->assertCount(0, $rows);
    // Ensure the translation tab is not accessible.
    $this->drupalGet('node/' . $node->id() . '/translations');
    $this->assertSession()
        ->statusCodeEquals(403);
}

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