You are here

public function LayoutSectionTest::providerTestLayoutSectionFormatter in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/layout_builder/tests/src/Functional/LayoutSectionTest.php \Drupal\Tests\layout_builder\Functional\LayoutSectionTest::providerTestLayoutSectionFormatter()

Provides test data for ::testLayoutSectionFormatter().

File

core/modules/layout_builder/tests/src/Functional/LayoutSectionTest.php, line 62

Class

LayoutSectionTest
Tests the rendering of a layout section field.

Namespace

Drupal\Tests\layout_builder\Functional

Code

public function providerTestLayoutSectionFormatter() {
  $data = [];
  $data['block_with_global_context'] = [
    [
      [
        'section' => new Section('layout_onecol', [], [
          'baz' => new SectionComponent('baz', 'content', [
            'id' => 'test_context_aware',
            'context_mapping' => [
              'user' => '@user.current_user_context:current_user',
            ],
          ]),
        ]),
      ],
    ],
    [
      '.layout--onecol',
      '#test_context_aware--username',
    ],
    [
      'foobar',
    ],
    'user',
    'user:2',
    'UNCACHEABLE',
  ];
  $data['block_with_entity_context'] = [
    [
      [
        'section' => new Section('layout_onecol', [], [
          'baz' => new SectionComponent('baz', 'content', [
            'id' => 'field_block:node:bundle_with_section_field:body',
            'context_mapping' => [
              'entity' => 'layout_builder.entity',
            ],
          ]),
        ]),
      ],
    ],
    [
      '.layout--onecol',
      '.field--name-body',
    ],
    [
      'Body',
      'The node body',
    ],
    '',
    '',
    'MISS',
  ];
  $data['single_section_single_block'] = [
    [
      [
        'section' => new Section('layout_onecol', [], [
          'baz' => new SectionComponent('baz', 'content', [
            'id' => 'system_powered_by_block',
          ]),
        ]),
      ],
    ],
    '.layout--onecol',
    'Powered by',
    '',
    '',
    'MISS',
  ];
  $data['multiple_sections'] = [
    [
      [
        'section' => new Section('layout_onecol', [], [
          'baz' => new SectionComponent('baz', 'content', [
            'id' => 'system_powered_by_block',
          ]),
        ]),
      ],
      [
        'section' => new Section('layout_twocol', [], [
          'foo' => new SectionComponent('foo', 'first', [
            'id' => 'test_block_instantiation',
            'display_message' => 'foo text',
          ]),
          'bar' => new SectionComponent('bar', 'second', [
            'id' => 'test_block_instantiation',
            'display_message' => 'bar text',
          ]),
        ]),
      ],
    ],
    [
      '.layout--onecol',
      '.layout--twocol',
    ],
    [
      'Powered by',
      'foo text',
      'bar text',
    ],
    'user.permissions',
    '',
    'MISS',
  ];
  return $data;
}