You are here

protected function BynderSearchWidgetTest::setUp in Bynder 8

Same name and namespace in other branches
  1. 8.2 tests/src/FunctionalJavascript/BynderSearchWidgetTest.php \Drupal\Tests\bynder\FunctionalJavascript\BynderSearchWidgetTest::setUp()

Overrides BrowserTestBase::setUp

File

tests/src/FunctionalJavascript/BynderSearchWidgetTest.php, line 40

Class

BynderSearchWidgetTest
Test the Bynder search widget.

Namespace

Drupal\Tests\bynder\FunctionalJavascript

Code

protected function setUp() {
  parent::setUp();
  $this
    ->drupalCreateContentType([
    'type' => 'media_entity_ct',
    'name' => 'Media Type',
  ]);
  FieldStorageConfig::create([
    'field_name' => 'field_reference',
    'type' => 'entity_reference',
    'entity_type' => 'node',
    'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
    'settings' => [
      'target_type' => 'media',
    ],
  ])
    ->save();
  FieldConfig::create([
    'field_name' => 'field_reference',
    'entity_type' => 'node',
    'bundle' => 'media_entity_ct',
    'label' => 'Reference',
    'settings' => [
      'handler' => 'default:media',
      'handler_settings' => [
        'target_bundles' => [
          'bynder' => 'bynder',
        ],
      ],
    ],
  ])
    ->save();

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