public function AreaEntityUITest::testUI in Zircon Profile 8        
                          
                  
                        Same name and namespace in other branches
- 8.0 core/modules/views_ui/src/Tests/AreaEntityUITest.php \Drupal\views_ui\Tests\AreaEntityUITest::testUI()
File
 
   - core/modules/views_ui/src/Tests/AreaEntityUITest.php, line 27
- Contains \Drupal\views_ui\Tests\AreaEntityUITest.
Class
  
  - AreaEntityUITest 
- Tests the entity area UI test.
Namespace
  Drupal\views_ui\Tests
Code
public function testUI() {
  
  $block = Block::create([
    'id' => 'test_id',
    'plugin' => 'system_main_block',
  ]);
  $block
    ->save();
  $entity_test = EntityTest::create([
    'bundle' => 'entity_test',
  ]);
  $entity_test
    ->save();
  $default = $this
    ->randomView([]);
  $id = $default['id'];
  $view = View::load($id);
  $this
    ->drupalGet($view
    ->urlInfo('edit-form'));
  
  $this
    ->drupalPostForm("admin/structure/views/nojs/add-handler/{$id}/page_1/argument", [
    'name[views.null]' => 1,
  ], 'Add and configure contextual filters');
  $this
    ->drupalPostForm(NULL, [], 'Apply');
  
  $this
    ->drupalPostForm("admin/structure/views/nojs/add-handler/{$id}/page_1/header", [
    'name[views.entity_block]' => 1,
  ], 'Add and configure header');
  $this
    ->drupalPostForm(NULL, [
    'options[target]' => $block
      ->id(),
  ], 'Apply');
  $this
    ->drupalPostForm("admin/structure/views/nojs/add-handler/{$id}/page_1/header", [
    'name[views.entity_entity_test]' => 1,
  ], 'Add and configure header');
  $this
    ->drupalPostForm(NULL, [
    'options[target]' => $entity_test
      ->id(),
  ], 'Apply');
  $this
    ->drupalPostForm(NULL, [], 'Save');
  
  $view = View::load($id);
  $header = $view
    ->getDisplay('default')['display_options']['header'];
  $this
    ->assertEqual([
    'entity_block',
    'entity_entity_test',
  ], array_keys($header));
  $this
    ->assertEqual($block
    ->id(), $header['entity_block']['target']);
  $this
    ->assertEqual($entity_test
    ->uuid(), $header['entity_entity_test']['target']);
  
  $this
    ->drupalGet("admin/structure/views/nojs/handler/{$id}/page_1/header/entity_block");
  $this
    ->assertFieldByName('options[target]', $block
    ->id());
  $this
    ->drupalGet("admin/structure/views/nojs/handler/{$id}/page_1/header/entity_entity_test");
  $this
    ->assertFieldByName('options[target]', $entity_test
    ->id());
  
  $this
    ->drupalPostForm("admin/structure/views/nojs/handler/{$id}/page_1/header/entity_block", [
    'options[target]' => '{{ raw_arguments.null }}',
  ], 'Apply');
  $this
    ->drupalPostForm("admin/structure/views/nojs/handler/{$id}/page_1/header/entity_entity_test", [
    'options[target]' => '{{ raw_arguments.null }}',
  ], 'Apply');
  $this
    ->drupalPostForm(NULL, [], 'Save');
  
  $view = View::load($id);
  $header = $view
    ->getDisplay('default')['display_options']['header'];
  $this
    ->assertEqual([
    'entity_block',
    'entity_entity_test',
  ], array_keys($header));
  $this
    ->assertEqual('{{ raw_arguments.null }}', $header['entity_block']['target']);
  $this
    ->assertEqual('{{ raw_arguments.null }}', $header['entity_entity_test']['target']);
  
  $this
    ->drupalGet("admin/structure/views/nojs/handler/{$id}/page_1/header/entity_block");
  $this
    ->assertFieldByName('options[target]', '{{ raw_arguments.null }}');
  $this
    ->drupalGet("admin/structure/views/nojs/handler/{$id}/page_1/header/entity_entity_test");
  $this
    ->assertFieldByName('options[target]', '{{ raw_arguments.null }}');
  
  $this
    ->drupalPostForm("admin/structure/views/nojs/handler/{$id}/page_1/header/entity_block", [
    'options[target]' => $block
      ->id(),
  ], 'Apply');
  $this
    ->drupalPostForm("admin/structure/views/nojs/handler/{$id}/page_1/header/entity_entity_test", [
    'options[target]' => $entity_test
      ->id(),
  ], 'Apply');
  $this
    ->drupalPostForm(NULL, [], 'Save');
  
  $view = View::load($id);
  $header = $view
    ->getDisplay('default')['display_options']['header'];
  $this
    ->assertEqual([
    'entity_block',
    'entity_entity_test',
  ], array_keys($header));
  $this
    ->assertEqual($block
    ->id(), $header['entity_block']['target']);
  $this
    ->assertEqual($entity_test
    ->uuid(), $header['entity_entity_test']['target']);
}