public function FieldRedirectionResultBuilderLinkTest::testFieldRedirectionResultBuilderDenyStates in Field Redirection 8.2
Tests builder.
@dataProvider providerTestFieldRedirectionResultBuilder
File
- tests/
src/ Kernel/ FieldRedirectionResultBuilderLinkTest.php, line 102
Class
- FieldRedirectionResultBuilderLinkTest
- Defines a class for testing field redirection result builder for link fields.
Namespace
Drupal\Tests\field_redirection\KernelCode
public function testFieldRedirectionResultBuilderDenyStates($field_values = [], $user_permissions = [], $current_path = '/user', $current_route = 'user.page', array $settings = [], callable $request_callback = NULL) {
$entity = $this
->createTestEntity($field_values);
$builder = \Drupal::service('field_redirection.result_builder');
$request = Request::create($current_path);
if ($current_route) {
$request->attributes
->set(RouteObjectInterface::ROUTE_NAME, $current_route);
$request->attributes
->set(RouteObjectInterface::ROUTE_OBJECT, new Route($current_path));
}
if ($request_callback) {
$request_callback($request);
}
\Drupal::requestStack()
->push($request);
$this
->assertEquals(FieldRedirectionResult::deny(), $builder
->buildResult($entity
->get('field_redirect_link'), $request, $this
->createUser($user_permissions), $settings));
}