You are here

public function ProcessFieldTest::providerTestTransform in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/field/tests/src/Unit/Plugin/migrate/process/ProcessFieldTest.php \Drupal\Tests\field\Unit\Plugin\migrate\process\ProcessFieldTest::providerTestTransform()

Provides data for the transform method test.

Return value

array

  • The method to call.
  • The value to process.
  • The expected transformed value.
  • The MigrateException message to expect.
  • Whether the field plugin is not found.

File

core/modules/field/tests/src/Unit/Plugin/migrate/process/ProcessFieldTest.php, line 86

Class

ProcessFieldTest
Tests the ProcessField migrate process plugin.

Namespace

Drupal\Tests\field\Unit\Plugin\migrate\process

Code

public function providerTestTransform() {
  return [
    // Tests the getFieldType() method.
    [
      'method' => 'getFieldType',
      'value' => 'foo',
      'expected_value' => 'bar',
    ],
    // Tests the getFieldFormatterMap() method.
    [
      'method' => 'getFieldFormatterMap',
      'value' => 'foo',
      'expected_value' => [
        'foo' => 'bar',
      ],
    ],
    // Tests the getFieldWidgetMap() method.
    [
      'method' => 'getFieldWidgetMap',
      'value' => 'foo',
      'expected_value' => [
        'foo' => 'bar',
      ],
    ],
    // Tests that an exception is thrown if the value is not a string.
    [
      'method' => 'getFieldType',
      'value' => [
        'foo',
      ],
      'expected_value' => '',
      'migrate_exception' => 'The input value must be a string.',
    ],
    // Tests that an exception is thrown if no method name is provided.
    [
      'method' => '',
      'value' => '',
      'expected_value' => '',
      'migrate_exception' => 'You need to specify the name of a method to be called on the Field plugin.',
    ],
    // Tests that NULL is returned if no field plugin is found.
    [
      'method' => 'getFieldType',
      'value' => 'foo',
      'expected_value' => NULL,
      'migrate_exception' => '',
      'plugin_not_found' => TRUE,
    ],
  ];
}