You are here

public function BlockContentWizardTest::testViewAddBlockContent in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/block_content/tests/src/Functional/Views/BlockContentWizardTest.php \Drupal\Tests\block_content\Functional\Views\BlockContentWizardTest::testViewAddBlockContent()
  2. 9 core/modules/block_content/tests/src/Functional/Views/BlockContentWizardTest.php \Drupal\Tests\block_content\Functional\Views\BlockContentWizardTest::testViewAddBlockContent()

Tests creating a 'block_content' entity view.

File

core/modules/block_content/tests/src/Functional/Views/BlockContentWizardTest.php, line 36

Class

BlockContentWizardTest
Tests block_content wizard and generic entity integration.

Namespace

Drupal\Tests\block_content\Functional\Views

Code

public function testViewAddBlockContent() {
  $view = [];
  $view['label'] = $this
    ->randomMachineName(16);
  $view['id'] = strtolower($this
    ->randomMachineName(16));
  $view['description'] = $this
    ->randomMachineName(16);
  $view['page[create]'] = FALSE;
  $view['show[wizard_key]'] = 'block_content';
  $this
    ->drupalGet('admin/structure/views/add');
  $this
    ->submitForm($view, 'Save and edit');
  $view_storage_controller = $this->container
    ->get('entity_type.manager')
    ->getStorage('view');

  /** @var \Drupal\views\Entity\View $view */
  $view = $view_storage_controller
    ->load($view['id']);
  $display_options = $view
    ->getDisplay('default')['display_options'];
  $this
    ->assertEquals('block_content', $display_options['filters']['reusable']['entity_type']);
  $this
    ->assertEquals('reusable', $display_options['filters']['reusable']['entity_field']);
  $this
    ->assertEquals('boolean', $display_options['filters']['reusable']['plugin_id']);
  $this
    ->assertEquals('1', $display_options['filters']['reusable']['value']);
}