function HandlerFieldFieldTest::doTestInaccessibleFieldRender

Same name in other branches
  1. 9 core/modules/field/tests/src/Kernel/Views/HandlerFieldFieldTest.php \Drupal\Tests\field\Kernel\Views\HandlerFieldFieldTest::doTestInaccessibleFieldRender()
  2. 8.9.x core/modules/field/tests/src/Kernel/Views/HandlerFieldFieldTest.php \Drupal\Tests\field\Kernel\Views\HandlerFieldFieldTest::doTestInaccessibleFieldRender()
  3. 11.x core/modules/field/tests/src/Kernel/Views/HandlerFieldFieldTest.php \Drupal\Tests\field\Kernel\Views\HandlerFieldFieldTest::doTestInaccessibleFieldRender()

Tests inaccessible field rendering.

1 call to HandlerFieldFieldTest::doTestInaccessibleFieldRender()
HandlerFieldFieldTest::testFieldRender in core/modules/field/tests/src/Kernel/Views/HandlerFieldFieldTest.php
Tests fields rendering in views.

File

core/modules/field/tests/src/Kernel/Views/HandlerFieldFieldTest.php, line 131

Class

HandlerFieldFieldTest
Tests the field rendering in views.

Namespace

Drupal\Tests\field\Kernel\Views

Code

public function doTestInaccessibleFieldRender() {
    $view = Views::getView('test_view_fieldapi');
    $this->prepareView($view);
    $view->preview();
    // Check that the field handler for the hidden field is correctly removed
    // from the display.
    // @see https://www.drupal.org/node/2382931
    $this->assertArrayNotHasKey('field_no_view_access', $view->field);
    // Check that the access-denied field is not visible.
    for ($i = 0; $i < 3; $i++) {
        $field_name = $this->fieldStorages[6]
            ->getName();
        $rendered_field = $view->style_plugin
            ->getField($i, $field_name);
        // Check that a hidden field is not rendered.
        $this->assertNull($rendered_field);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.