You are here

public function NodeTranslationUITest::testDisabledBundle in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/node/src/Tests/NodeTranslationUITest.php \Drupal\node\Tests\NodeTranslationUITest::testDisabledBundle()

Tests that no metadata is stored for a disabled bundle.

File

core/modules/node/src/Tests/NodeTranslationUITest.php, line 251
Contains \Drupal\node\Tests\NodeTranslationUITest.

Class

NodeTranslationUITest
Tests the Node Translation UI.

Namespace

Drupal\node\Tests

Code

public function testDisabledBundle() {

  // Create a bundle that does not have translation enabled.
  $disabledBundle = $this
    ->randomMachineName();
  $this
    ->drupalCreateContentType(array(
    'type' => $disabledBundle,
    'name' => $disabledBundle,
  ));

  // Create a node for each bundle.
  $node = $this
    ->drupalCreateNode(array(
    'type' => $this->bundle,
    'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
  ));

  // Make sure that nothing was inserted into the {content_translation} table.
  $rows = db_query('SELECT nid, count(nid) AS count FROM {node_field_data} WHERE type <> :type GROUP BY nid HAVING count(nid) >= 2', array(
    ':type' => $this->bundle,
  ))
    ->fetchAll();
  $this
    ->assertEqual(0, count($rows));

  // Ensure the translation tab is not accessible.
  $this
    ->drupalGet('node/' . $node
    ->id() . '/translations');
  $this
    ->assertResponse(403);
}