You are here

protected function MediaBehaviorSettingsFormTest::createEntity in Rabbit Hole 8

Same name and namespace in other branches
  1. 2.x modules/rh_media/tests/src/Functional/MediaBehaviorSettingsFormTest.php \Drupal\Tests\rh_media\Functional\MediaBehaviorSettingsFormTest::createEntity()

Creates new entity.

Parameters

string $action: Rabbit Hole action.

Return value

int ID of the created entity.

Overrides RabbitHoleBehaviorSettingsFormTestBase::createEntity

File

modules/rh_media/tests/src/Functional/MediaBehaviorSettingsFormTest.php, line 78

Class

MediaBehaviorSettingsFormTest
Test the functionality of the rabbit hole form additions to the media.

Namespace

Drupal\Tests\rh_media\Functional

Code

protected function createEntity($action = NULL) {
  $values = [
    'bundle' => $this->bundle
      ->id(),
    'name' => $this
      ->randomString(),
    'field_media_test' => $this
      ->randomMachineName(),
  ];
  if (isset($action)) {
    $values['rh_action'] = $action;
  }
  $media = Media::create($values);
  $media
    ->save();
  return $media
    ->id();
}