You are here

protected function SelectionTest::setUp in Drupal 9

Same name in this branch
  1. 9 core/modules/field/tests/src/Functional/EntityReference/Views/SelectionTest.php \Drupal\Tests\field\Functional\EntityReference\Views\SelectionTest::setUp()
  2. 9 core/modules/field/tests/src/Kernel/EntityReference/Views/SelectionTest.php \Drupal\Tests\field\Kernel\EntityReference\Views\SelectionTest::setUp()
Same name and namespace in other branches
  1. 8 core/modules/field/tests/src/Functional/EntityReference/Views/SelectionTest.php \Drupal\Tests\field\Functional\EntityReference\Views\SelectionTest::setUp()

Overrides BrowserTestBase::setUp

File

core/modules/field/tests/src/Functional/EntityReference/Views/SelectionTest.php, line 54

Class

SelectionTest
Tests entity reference selection handler.

Namespace

Drupal\Tests\field\Functional\EntityReference\Views

Code

protected function setUp() : void {
  parent::setUp();

  // Create content types and nodes.
  $type1 = $this
    ->drupalCreateContentType()
    ->id();
  $type2 = $this
    ->drupalCreateContentType()
    ->id();

  // Add some characters that should be escaped but not double escaped.
  $node1 = $this
    ->drupalCreateNode([
    'type' => $type1,
    'title' => 'Test first node &<>',
  ]);
  $node2 = $this
    ->drupalCreateNode([
    'type' => $type1,
    'title' => 'Test second node &&&',
  ]);
  $node3 = $this
    ->drupalCreateNode([
    'type' => $type2,
    'title' => 'Test third node <span />',
  ]);
  foreach ([
    $node1,
    $node2,
    $node3,
  ] as $node) {
    $this->nodes[$node
      ->id()] = $node;
  }

  // Create an entity reference field.
  $handler_settings = [
    'view' => [
      'view_name' => 'test_entity_reference',
      'display_name' => 'entity_reference_1',
    ],
  ];
  $this->handlerSettings = $handler_settings;
  $this
    ->createEntityReferenceField('entity_test', 'test_bundle', 'test_field', $this
    ->randomString(), 'node', 'views', $handler_settings);
}