You are here

protected function PagerElementTest::setUp in Entity Browser 8.2

Same name and namespace in other branches
  1. 8 tests/src/FunctionalJavascript/PagerElementTest.php \Drupal\Tests\entity_browser\FunctionalJavascript\PagerElementTest::setUp()

Overrides EntityBrowserWebDriverTestBase::setUp

File

tests/src/FunctionalJavascript/PagerElementTest.php, line 32

Class

PagerElementTest
Tests entity browser pager form element.

Namespace

Drupal\Tests\entity_browser\FunctionalJavascript

Code

protected function setUp() {
  parent::setUp();
  $this
    ->drupalCreateContentType([
    'type' => 'foo',
    'name' => 'Foo',
  ]);
  FieldStorageConfig::create([
    'field_name' => 'field_reference_pager',
    'type' => 'entity_reference',
    'entity_type' => 'node',
    'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
    'settings' => [
      'target_type' => 'node',
    ],
  ])
    ->save();
  FieldConfig::create([
    'field_name' => 'field_reference_pager',
    'entity_type' => 'node',
    'bundle' => 'foo',
    'label' => 'Reference',
    'settings' => [],
  ])
    ->save();

  /** @var \Drupal\Core\Entity\Display\EntityFormDisplayInterface $form_display */
  $form_display = $this->container
    ->get('entity_type.manager')
    ->getStorage('entity_form_display')
    ->load('node.foo.default');
  $form_display
    ->setComponent('field_reference_pager', [
    'type' => 'entity_browser_entity_reference',
    'settings' => [
      'entity_browser' => 'pager',
      'field_widget_display' => 'label',
      'open' => TRUE,
    ],
  ])
    ->save();
  $account = $this
    ->drupalCreateUser([
    'access pager entity browser pages',
    'create foo content',
    'access content',
  ]);
  $this
    ->drupalLogin($account);
}