function MediaLibraryStateTest::testFromRequest
Same name in other branches
- 9 core/modules/media_library/tests/src/Kernel/MediaLibraryStateTest.php \Drupal\Tests\media_library\Kernel\MediaLibraryStateTest::testFromRequest()
- 10 core/modules/media_library/tests/src/Kernel/MediaLibraryStateTest.php \Drupal\Tests\media_library\Kernel\MediaLibraryStateTest::testFromRequest()
- 11.x core/modules/media_library/tests/src/Kernel/MediaLibraryStateTest.php \Drupal\Tests\media_library\Kernel\MediaLibraryStateTest::testFromRequest()
Tests the hash validation when the state is created from a request.
@covers ::fromRequest @dataProvider providerFromRequest
Parameters
array $query_overrides: The query parameters to override.
bool $exception_expected: Whether an AccessDeniedHttpException is expected or not.
File
-
core/
modules/ media_library/ tests/ src/ Kernel/ MediaLibraryStateTest.php, line 273
Class
- MediaLibraryStateTest
- Tests the media library state value object.
Namespace
Drupal\Tests\media_library\KernelCode
public function testFromRequest(array $query_overrides, $exception_expected) {
// Override the query parameters and verify an exception is thrown when
// required state parameters are changed.
$query = MediaLibraryState::create('test', [
'file',
'image',
], 'image', 2)->all();
$query = array_merge($query, $query_overrides);
if ($exception_expected) {
$this->expectException(BadRequestHttpException::class);
$this->expectExceptionMessage("Invalid media library parameters specified.");
}
$state = MediaLibraryState::fromRequest(new Request($query));
$this->assertInstanceOf(MediaLibraryState::class, $state);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.