You are here

public function DefaultsSectionStorageTest::providerTestExtractEntityFromRoute in Drupal 8

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

Provides data for ::testExtractEntityFromRoute().

File

core/modules/layout_builder/tests/src/Unit/DefaultsSectionStorageTest.php, line 277

Class

DefaultsSectionStorageTest
@coversDefaultClass \Drupal\layout_builder\Plugin\SectionStorage\DefaultsSectionStorage

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'] = [
    TRUE,
    'foo.bar.baz',
    'foo.bar.baz',
    [],
  ];
  $data['empty value, without bundle'] = [
    TRUE,
    'my_entity_type.bundle_name.default',
    '',
    [
      'entity_type_id' => 'my_entity_type',
      'view_mode_name' => 'default',
      'bundle_key' => 'my_bundle',
      'my_bundle' => 'bundle_name',
    ],
  ];
  $data['empty value, with bundle'] = [
    TRUE,
    'my_entity_type.bundle_name.default',
    '',
    [
      'entity_type_id' => 'my_entity_type',
      'view_mode_name' => 'default',
      'bundle' => 'bundle_name',
    ],
  ];
  $data['without value, empty defaults'] = [
    FALSE,
    NULL,
    '',
    [],
  ];
  return $data;
}