function EntityConverterTest::providerTestConvert

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/ParamConverter/EntityConverterTest.php \Drupal\Tests\Core\ParamConverter\EntityConverterTest::providerTestConvert()
  2. 8.9.x core/tests/Drupal/Tests/Core/ParamConverter/EntityConverterTest.php \Drupal\Tests\Core\ParamConverter\EntityConverterTest::providerTestConvert()
  3. 10 core/tests/Drupal/Tests/Core/ParamConverter/EntityConverterTest.php \Drupal\Tests\Core\ParamConverter\EntityConverterTest::providerTestConvert()

Provides test data for testConvert.

File

core/tests/Drupal/Tests/Core/ParamConverter/EntityConverterTest.php, line 197

Class

EntityConverterTest
@coversDefaultClass \Drupal\Core\ParamConverter\EntityConverter @group ParamConverter @group Entity

Namespace

Drupal\Tests\Core\ParamConverter

Code

public static function providerTestConvert() {
    $data = [];
    // Existing entity type.
    $data[] = [
        'valid_id',
        [
            'type' => 'entity:entity_test',
        ],
        [
            'foo' => 'valid_id',
        ],
        (object) [
            'id' => 'valid_id',
        ],
    ];
    // Invalid ID.
    $data[] = [
        'invalid_id',
        [
            'type' => 'entity:entity_test',
        ],
        [
            'foo' => 'invalid_id',
        ],
        NULL,
    ];
    // Entity type placeholder.
    $data[] = [
        'valid_id',
        [
            'type' => 'entity:{entity_type}',
        ],
        [
            'foo' => 'valid_id',
            'entity_type' => 'entity_test',
        ],
        (object) [
            'id' => 'valid_id',
        ],
    ];
    return $data;
}

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