function DefaultsSectionStorageTest::providerTestExtractEntityFromRoute

Same name in other branches
  1. 8.9.x core/modules/layout_builder/tests/src/Unit/DefaultsSectionStorageTest.php \Drupal\Tests\layout_builder\Unit\DefaultsSectionStorageTest::providerTestExtractEntityFromRoute()
  2. 10 core/modules/layout_builder/tests/src/Unit/DefaultsSectionStorageTest.php \Drupal\Tests\layout_builder\Unit\DefaultsSectionStorageTest::providerTestExtractEntityFromRoute()
  3. 11.x 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 150

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.