public function MediaLibraryStateTest::testCreate in Drupal 9
Same name and namespace in other branches
- 8 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 102
Class
- MediaLibraryStateTest
- Tests the media library state value object.
Namespace
Drupal\Tests\media_library\KernelCode
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);
// Ensure that the state object carries cache metadata.
$this
->assertInstanceOf(CacheableDependencyInterface::class, $state);
$this
->assertSame([
'url.query_args',
], $state
->getCacheContexts());
$this
->assertSame(Cache::PERMANENT, $state
->getCacheMaxAge());
}