function MediaLibraryStateTest::testCreate
Same name in other branches
- 9 core/modules/media_library/tests/src/Kernel/MediaLibraryStateTest.php \Drupal\Tests\media_library\Kernel\MediaLibraryStateTest::testCreate()
- 8.9.x core/modules/media_library/tests/src/Kernel/MediaLibraryStateTest.php \Drupal\Tests\media_library\Kernel\MediaLibraryStateTest::testCreate()
- 10 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 103
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 = '') : void {
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());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.