@coversDefaultClass \Drupal\paragraphs\ParagraphAccessControlHandler @group paragraphs
Expanded class hierarchy of ParagraphsAccessTest
class ParagraphsAccessTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'paragraphs',
];
/**
* @covers ::checkCreateAccess
*
* @dataProvider createAccessTestCases
*/
public function testCreateAccess($request_format, AccessResult $expected_result) {
$cache_contexts_manager = $this
->prophesize(CacheContextsManager::class);
$cache_contexts_manager
->assertValidTokens()
->willReturn(TRUE);
$cache_contexts_manager
->reveal();
$this->container
->set('cache_contexts_manager', $cache_contexts_manager);
$expected_result
->addCacheContexts([
'request_format',
]);
$request = new Request();
$request
->setRequestFormat($request_format);
$this->container
->get('request_stack')
->push($request);
$result = $this->container
->get('entity_type.manager')
->getAccessControlHandler('paragraph')
->createAccess(NULL, NULL, [], TRUE);
$this
->assertEquals($expected_result, $result);
$this->container
->get('request_stack')
->pop();
}
/**
* Test cases for ::testCreateAccess.
*/
public static function createAccessTestCases() {
return [
'Allowed HTML request format' => [
'html',
AccessResult::allowed(),
],
'Forbidden other formats' => [
'json',
AccessResult::neutral(),
],
];
}
}
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ParagraphsAccessTest:: |
protected static | property | ||
ParagraphsAccessTest:: |
public static | function | Test cases for ::testCreateAccess. | |
ParagraphsAccessTest:: |
public | function | @covers ::checkCreateAccess |