You are here

protected function BynderUploadWidgetTest::setUp in Bynder 8

Same name and namespace in other branches
  1. 8.3 tests/src/FunctionalJavascript/BynderUploadWidgetTest.php \Drupal\Tests\bynder\FunctionalJavascript\BynderUploadWidgetTest::setUp()
  2. 8.2 tests/src/FunctionalJavascript/BynderUploadWidgetTest.php \Drupal\Tests\bynder\FunctionalJavascript\BynderUploadWidgetTest::setUp()
  3. 4.0.x tests/src/FunctionalJavascript/BynderUploadWidgetTest.php \Drupal\Tests\bynder\FunctionalJavascript\BynderUploadWidgetTest::setUp()

Overrides BrowserTestBase::setUp

File

tests/src/FunctionalJavascript/BynderUploadWidgetTest.php, line 49
Tests Bynder upload widget.

Class

BynderUploadWidgetTest
Test the Bynder upload 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([
    'administer entity browsers',
  ]);
  $this
    ->drupalLogin($account);
}