You are here

public function ParagraphsConfigTest::testAvoidUsingParagraphsWithWrongEntity in Paragraphs 8

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

Tests that we can use paragraphs widget only for paragraphs.

File

tests/src/Functional/WidgetLegacy/ParagraphsConfigTest.php, line 174

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');
}