You are here

public function OverridesSectionStorageTest::providerTestExtractEntityFromRoute in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/layout_builder/tests/src/Unit/OverridesSectionStorageTest.php \Drupal\Tests\layout_builder\Unit\OverridesSectionStorageTest::providerTestExtractEntityFromRoute()

Provides data for ::testExtractEntityFromRoute().

File

core/modules/layout_builder/tests/src/Unit/OverridesSectionStorageTest.php, line 231

Class

OverridesSectionStorageTest
@coversDefaultClass \Drupal\layout_builder\Plugin\SectionStorage\OverridesSectionStorage

Namespace

Drupal\Tests\layout_builder\Unit

Code

public function providerTestExtractEntityFromRoute() {

  // Data provider values are:
  // - whether a successful result is expected
  // - the expected entity ID
  // - the value to pass to ::extractEntityFromRoute()
  // - the defaults to pass to ::extractEntityFromRoute().
  $data = [];
  $data['with value, with layout'] = [
    TRUE,
    'my_entity_type',
    'my_entity_type.entity_with_layout',
    [],
  ];
  $data['with value, without layout'] = [
    FALSE,
    'my_entity_type',
    'my_entity_type.entity_without_layout',
    [],
  ];
  $data['empty value, populated defaults'] = [
    TRUE,
    'my_entity_type',
    '',
    [
      'entity_type_id' => 'my_entity_type',
      'my_entity_type' => 'entity_with_layout',
    ],
  ];
  $data['empty value, empty defaults'] = [
    FALSE,
    NULL,
    '',
    [],
  ];
  return $data;
}