3 namespace Drupal\Tests\media_entity\Functional;
5 use Drupal\media_entity\Entity\MediaBundle;
8 * Trait with helpers for Media Entity functional tests.
10 * @package Drupal\Tests\media_entity\Functional
12 trait MediaEntityFunctionalTestTrait {
15 * Creates a media bundle.
17 * @param array $values
18 * The media bundle values.
19 * @param string $type_name
20 * (optional) The media type provider plugin that is responsible for
21 * additional logic related to this media).
23 * @return \Drupal\Core\Entity\EntityInterface
24 * Returns newly created media bundle.
26 protected function drupalCreateMediaBundle(array $values = [], $type_name = 'generic') {
27 if (!isset($values['bundle'])) {
28 $id = strtolower($this->randomMachineName());
31 $id = $values['bundle'];
37 'type_configuration' => [],
39 'new_revision' => FALSE,
42 $bundle = MediaBundle::create($values);
43 $status = $bundle->save();
45 $this->assertEquals($status, SAVED_NEW, 'Could not create a media bundle of type ' . $type_name . '.');