You are here

protected function BynderCreateMediaTest::setUp in Bynder 8.3

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

Overrides BrowserTestBase::setUp

File

tests/src/Functional/BynderCreateMediaTest.php, line 41

Class

BynderCreateMediaTest
Tests duplicate media on Bynder search widget.

Namespace

Drupal\Tests\bynder\Functional

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',
    'access content',
  ]);
  $this
    ->drupalLogin($account);
  \Drupal::service('config.factory')
    ->getEditable('bynder.settings')
    ->set('consumer_key', 'key')
    ->set('consumer_secret', 'secret')
    ->set('token', 'token')
    ->set('token_secret', 'secret')
    ->set('account_domain', 'https://dam.bynder.com')
    ->save();
}