You are here

public function FieldFieldTest::testMissingBundleFieldRender in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/views/tests/src/Kernel/Handler/FieldFieldTest.php \Drupal\Tests\views\Kernel\Handler\FieldFieldTest::testMissingBundleFieldRender()

Tests that a field not available for every bundle is rendered as empty.

File

core/modules/views/tests/src/Kernel/Handler/FieldFieldTest.php, line 541

Class

FieldFieldTest
Provides some integration tests for the Field handler.

Namespace

Drupal\Tests\views\Kernel\Handler

Code

public function testMissingBundleFieldRender() {

  // Create a new bundle not having the test field attached.
  $bundle = $this
    ->randomMachineName();
  entity_test_create_bundle($bundle);
  $entity = EntityTest::create([
    'type' => $bundle,
    'name' => $this
      ->randomString(),
    'user_id' => $this->testUsers[0]
      ->id(),
  ]);
  $entity
    ->save();
  $executable = Views::getView('test_field_field_test');
  $executable
    ->execute();
  $this
    ->assertEquals('', $executable
    ->getStyle()
    ->getField(6, 'field_test'));
}