function OverridesSectionStorageTest::providerTestExtractEntityFromRoute

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

Class

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

Namespace

Drupal\Tests\layout_builder\Unit

Code

public static 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'] = [
        TRUE,
        '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;
}

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