You are here

public function EntityConverterTest::providerTestConvert in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 103
Contains \Drupal\Tests\Core\ParamConverter\EntityConverterTest.

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