You are here

public function EntityConverterTest::providerTestConvert in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/ParamConverter/EntityConverterTest.php \Drupal\Tests\Core\ParamConverter\EntityConverterTest::providerTestConvert()
  2. 9 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 204

Class

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

Namespace

Drupal\Tests\Core\ParamConverter

Code

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