/** * {@inheritdoc} */ public function setup() { parent::setup(); $this->installConfig(['media_entity']); $this->mediaVideoPlugin = $this->container->get('plugin.manager.media_entity.type')->createInstance('video_embed_field', []); $bundle = MediaBundle::create(['id' => 'video', 'type' => 'video_embed_field']); $bundle->save(); }
/** * Creates media bundle. * * @param array $values * The media bundle values. * * @param string $type_name * (optional) The media type provider plugin that is responsible for * additional logic related to this media). * * @return \Drupal\Core\Entity\EntityInterface * Returns newly created media bundle. */ protected function drupalCreateMediaBundle(array $values = array(), $type_name = 'generic') { if (!isset($values['bundle'])) { $id = strtolower($this->randomMachineName()); } else { $id = $values['bundle']; } $values += array('id' => $id, 'label' => $id, 'type' => $type_name, 'type_configuration' => array(), 'field_map' => array()); $bundle = MediaBundle::create($values); $status = $bundle->save(); $this->assertEqual($status, SAVED_NEW, t('Created media bundle %bundle.', array('%bundle' => $bundle->id()))); return $bundle; }