function NodeTranslationUITest::testDisabledBundle

Same name in other branches
  1. 8.9.x 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 284

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.
    $nids = \Drupal::entityQueryAggregate('node')->aggregate('nid', 'COUNT')
        ->accessCheck(FALSE)
        ->condition('type', $this->bundle)
        ->conditionAggregate('nid', 'COUNT', 2, '>=')
        ->groupBy('nid')
        ->execute();
    $this->assertCount(0, $nids);
    // 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.