public function ParagraphsConfigTest::testAvoidUsingParagraphsWithWrongEntity

Same name in this branch
  1. 8.x-1.x paragraphs/tests/src/Functional/WidgetStable/ParagraphsConfigTest.php \Drupal\Tests\paragraphs\Functional\WidgetStable\ParagraphsConfigTest::testAvoidUsingParagraphsWithWrongEntity()
  2. 8.x-1.x paragraphs/tests/src/Functional/WidgetLegacy/ParagraphsConfigTest.php \Drupal\Tests\paragraphs\Functional\WidgetLegacy\ParagraphsConfigTest::testAvoidUsingParagraphsWithWrongEntity()

Tests that we can use paragraphs widget only for paragraphs.

File

paragraphs/tests/src/Functional/WidgetLegacy/ParagraphsConfigTest.php, line 188

Class

ParagraphsConfigTest
Tests paragraphs configuration.

Namespace

Drupal\Tests\paragraphs\Functional\WidgetLegacy

Code

public function testAvoidUsingParagraphsWithWrongEntity() {
  $node_type = NodeType::create([
    'type' => 'article',
    'name' => 'article',
  ]);
  $node_type
    ->save();
  $this
    ->loginAsAdmin([
    'edit any article content',
  ]);
  $this
    ->addParagraphsType('paragraphed_type');

  // Create reference to node.
  $this
    ->fieldUIAddNewField('admin/structure/types/manage/article', 'node_reference', 'NodeReference', 'entity_reference_revisions', [
    'cardinality' => 'number',
    'cardinality_number' => 1,
    'settings[target_type]' => 'node',
  ], [
    'settings[handler_settings][target_bundles][article]' => 'article',
  ]);
  $this
    ->drupalGet('admin/structure/types/manage/article/form-display');
  $this
    ->assertSession()
    ->optionNotExists('edit-fields-field-node-reference-type', 'entity_reference_paragraphs');
  $this
    ->assertSession()
    ->optionNotExists('edit-fields-field-node-reference-type', 'paragraphs');
}