You are here

public function BlockPageVariantTest::providerBuild in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/block/tests/src/Unit/Plugin/DisplayVariant/BlockPageVariantTest.php \Drupal\Tests\block\Unit\Plugin\DisplayVariant\BlockPageVariantTest::providerBuild()

File

core/modules/block/tests/src/Unit/Plugin/DisplayVariant/BlockPageVariantTest.php, line 73
Contains \Drupal\Tests\block\Unit\Plugin\DisplayVariant\BlockPageVariantTest.

Class

BlockPageVariantTest
@coversDefaultClass \Drupal\block\Plugin\DisplayVariant\BlockPageVariant @group block

Namespace

Drupal\Tests\block\Unit\Plugin\DisplayVariant

Code

public function providerBuild() {
  $blocks_config = array(
    'block1' => array(
      // region, is main content block, is messages block, is title block
      'top',
      FALSE,
      FALSE,
      FALSE,
    ),
    // Test multiple blocks in the same region.
    'block2' => array(
      'bottom',
      FALSE,
      FALSE,
      FALSE,
    ),
    'block3' => array(
      'bottom',
      FALSE,
      FALSE,
      FALSE,
    ),
    // Test a block implementing MainContentBlockPluginInterface.
    'block4' => array(
      'center',
      TRUE,
      FALSE,
      FALSE,
    ),
    // Test a block implementing MessagesBlockPluginInterface.
    'block5' => array(
      'center',
      FALSE,
      TRUE,
      FALSE,
    ),
    // Test a block implementing TitleBlockPluginInterface.
    'block6' => array(
      'center',
      FALSE,
      FALSE,
      TRUE,
    ),
  );
  $test_cases = [];
  $test_cases[] = [
    $blocks_config,
    6,
    [
      '#cache' => [
        'tags' => [
          'config:block_list',
          'route',
        ],
        'contexts' => [],
        'max-age' => -1,
      ],
      'top' => [
        'block1' => [],
        '#sorted' => TRUE,
      ],
      // The main content was rendered via a block.
      'center' => [
        'block4' => [],
        'block5' => [],
        'block6' => [],
        '#sorted' => TRUE,
      ],
      'bottom' => [
        'block2' => [],
        'block3' => [],
        '#sorted' => TRUE,
      ],
    ],
  ];
  unset($blocks_config['block5']);
  $test_cases[] = [
    $blocks_config,
    5,
    [
      '#cache' => [
        'tags' => [
          'config:block_list',
          'route',
        ],
        'contexts' => [],
        'max-age' => -1,
      ],
      'top' => [
        'block1' => [],
        '#sorted' => TRUE,
      ],
      'center' => [
        'block4' => [],
        'block6' => [],
        '#sorted' => TRUE,
      ],
      'bottom' => [
        'block2' => [],
        'block3' => [],
        '#sorted' => TRUE,
      ],
      // The messages are rendered via the fallback in case there is no block
      // rendering the main content.
      'content' => [
        'messages' => [
          '#weight' => -1000,
          '#type' => 'status_messages',
        ],
      ],
    ],
  ];
  unset($blocks_config['block4']);
  unset($blocks_config['block6']);
  $test_cases[] = [
    $blocks_config,
    3,
    [
      '#cache' => [
        'tags' => [
          'config:block_list',
          'route',
        ],
        'contexts' => [],
        'max-age' => -1,
      ],
      'top' => [
        'block1' => [],
        '#sorted' => TRUE,
      ],
      'bottom' => [
        'block2' => [],
        'block3' => [],
        '#sorted' => TRUE,
      ],
      // The main content & messages are rendered via the fallback in case
      // there are no blocks rendering them.
      'content' => [
        'system_main' => [
          '#markup' => 'Hello kittens!',
        ],
        'messages' => [
          '#weight' => -1000,
          '#type' => 'status_messages',
        ],
      ],
    ],
  ];
  return $test_cases;
}