You are here

protected function MediaEntityFunctionalTestTrait::drupalCreateMediaBundle in Media entity 8

Creates a media bundle.

Parameters

array $values: The media bundle values.

string $type_name: (optional) The media type provider plugin that is responsible for additional logic related to this media).

Return value

\Drupal\Core\Entity\EntityInterface Returns newly created media bundle.

6 calls to MediaEntityFunctionalTestTrait::drupalCreateMediaBundle()
MediaAccessTest::setUp in tests/src/Functional/MediaAccessTest.php
MediaBulkFormTest::setUp in tests/src/Functional/MediaBulkFormTest.php
MediaIefIntegrationTest::setUp in tests/src/FunctionalJavascript/MediaIefIntegrationTest.php
MediaUiFunctionalTest::testMediaWithMultipleBundles in tests/src/Functional/MediaUiFunctionalTest.php
Tests the "media/add" and "admin/content/media" pages.
MediaUiFunctionalTest::testMediaWithOnlyOneBundle in tests/src/Functional/MediaUiFunctionalTest.php
Tests the media actions (add/edit/delete).

... See full list

File

tests/src/Functional/MediaEntityFunctionalTestTrait.php, line 26

Class

MediaEntityFunctionalTestTrait
Trait with helpers for Media Entity functional tests.

Namespace

Drupal\Tests\media_entity\Functional

Code

protected function drupalCreateMediaBundle(array $values = [], $type_name = 'generic') {
  if (!isset($values['bundle'])) {
    $id = strtolower($this
      ->randomMachineName());
  }
  else {
    $id = $values['bundle'];
  }
  $values += [
    'id' => $id,
    'label' => $id,
    'type' => $type_name,
    'type_configuration' => [],
    'field_map' => [],
    'new_revision' => FALSE,
  ];
  $bundle = MediaBundle::create($values);
  $status = $bundle
    ->save();
  $this
    ->assertEquals($status, SAVED_NEW, 'Could not create a media bundle of type ' . $type_name . '.');
  return $bundle;
}