You are here

public function MediaLibraryStateTest::testCreate in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/media_library/tests/src/Kernel/MediaLibraryStateTest.php \Drupal\Tests\media_library\Kernel\MediaLibraryStateTest::testCreate()

Tests the media library state creation.

@covers ::create @dataProvider providerCreate

Parameters

string $opener_id: The opener ID.

string[] $allowed_media_type_ids: The allowed media type IDs.

string $selected_type_id: The selected media type ID.

int $remaining_slots: The number of remaining items the user is allowed to select or add in the library.

string $exception_message: The expected exception message.

File

core/modules/media_library/tests/src/Kernel/MediaLibraryStateTest.php, line 100

Class

MediaLibraryStateTest
Tests the media library state value object.

Namespace

Drupal\Tests\media_library\Kernel

Code

public function testCreate($opener_id, array $allowed_media_type_ids, $selected_type_id, $remaining_slots, $exception_message = '') {
  if ($exception_message) {
    $this
      ->expectException(\InvalidArgumentException::class);
    $this
      ->expectExceptionMessage($exception_message);
  }
  $state = MediaLibraryState::create($opener_id, $allowed_media_type_ids, $selected_type_id, $remaining_slots);
  $this
    ->assertInstanceOf(MediaLibraryState::class, $state);
}