You are here

public function CommerceFieldNameTest::providerCommerceFieldNameAddress in Commerce Migrate 3.1.x

Same name and namespace in other branches
  1. 8.2 modules/commerce/tests/src/Unit/Plugin/migrate/process/commerce1/CommerceFieldNameTest.php \Drupal\Tests\commerce_migrate_commerce\Unit\Plugin\migrate\process\commerce1\CommerceFieldNameTest::providerCommerceFieldNameAddress()
  2. 3.0.x modules/commerce/tests/src/Unit/Plugin/migrate/process/commerce1/CommerceFieldNameTest.php \Drupal\Tests\commerce_migrate_commerce\Unit\Plugin\migrate\process\commerce1\CommerceFieldNameTest::providerCommerceFieldNameAddress()

Data provider for testCommerceFieldNameAddress().

File

modules/commerce/tests/src/Unit/Plugin/migrate/process/commerce1/CommerceFieldNameTest.php, line 136

Class

CommerceFieldNameTest
Tests the CommerceFieldName plugin.

Namespace

Drupal\Tests\commerce_migrate_commerce\Unit\Plugin\migrate\process\commerce1

Code

public function providerCommerceFieldNameAddress() {
  $tests = [];

  // Tests address field name is changed.
  $field_name = 'color';
  $entity_type = 'commerce_customer_profile';
  $type = 'addressfield';
  $instances = [
    [
      'data' => serialize([
        'widget' => [
          'type' => 'options_select',
        ],
      ]),
    ],
    [
      'data' => serialize([
        'widget' => [
          'type' => 'text',
        ],
      ]),
    ],
  ];
  $tests[0]['source_properties'] = [
    $field_name,
    $entity_type,
    $type,
    $instances,
  ];
  $tests[0]['expected'] = 'address';

  // Tests address field name not on commerce_customer_profile is not changed.
  $field_name = 'field_address';
  $entity_type = 'node';
  $type = 'addressfield';
  $instances = [
    [
      'data' => serialize([
        'widget' => [
          'type' => 'options_select',
        ],
      ]),
    ],
    [
      'data' => serialize([
        'widget' => [
          'type' => 'text',
        ],
      ]),
    ],
  ];
  $tests[1]['source_properties'] = [
    $field_name,
    $entity_type,
    $type,
    $instances,
  ];
  $tests[1]['expected'] = 'field_address';

  // Tests the field name for field that is not an address is not changed.
  $field_name = 'field_text';
  $entity_type = 'node';
  $type = 'text';
  $instances = [
    [
      'data' => serialize([
        'widget' => [
          'type' => 'options_select',
        ],
      ]),
    ],
    [
      'data' => serialize([
        'widget' => [
          'type' => 'text',
        ],
      ]),
    ],
  ];
  $tests[1]['source_properties'] = [
    $field_name,
    $entity_type,
    $type,
    $instances,
  ];
  $tests[1]['expected'] = 'field_text';
  return $tests;
}