You are here

public function CommentNonNodeTest::testsNonIntegerIdEntities in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/comment/src/Tests/CommentNonNodeTest.php \Drupal\comment\Tests\CommentNonNodeTest::testsNonIntegerIdEntities()

Tests comment fields cannot be added to entity types without integer IDs.

File

core/modules/comment/src/Tests/CommentNonNodeTest.php, line 470
Contains \Drupal\comment\Tests\CommentNonNodeTest.

Class

CommentNonNodeTest
Tests commenting on a test entity.

Namespace

Drupal\comment\Tests

Code

public function testsNonIntegerIdEntities() {

  // Create a bundle for entity_test_string_id.
  entity_test_create_bundle('entity_test', 'Entity Test', 'entity_test_string_id');
  $limited_user = $this
    ->drupalCreateUser(array(
    'administer entity_test_string_id fields',
  ));
  $this
    ->drupalLogin($limited_user);

  // Visit the Field UI field add page.
  $this
    ->drupalGet('entity_test_string_id/structure/entity_test/fields/add-field');

  // Ensure field isn't shown for string IDs.
  $this
    ->assertNoOption('edit-new-storage-type', 'comment');

  // Ensure a core field type shown.
  $this
    ->assertOption('edit-new-storage-type', 'boolean');

  // Create a bundle for entity_test_no_id.
  entity_test_create_bundle('entity_test', 'Entity Test', 'entity_test_no_id');
  $this
    ->drupalLogin($this
    ->drupalCreateUser(array(
    'administer entity_test_no_id fields',
  )));

  // Visit the Field UI field add page.
  $this
    ->drupalGet('entity_test_no_id/structure/entity_test/fields/add-field');

  // Ensure field isn't shown for empty IDs.
  $this
    ->assertNoOption('edit-new-storage-type', 'comment');

  // Ensure a core field type shown.
  $this
    ->assertOption('edit-new-storage-type', 'boolean');
}