public static function ParagraphsFieldInstanceSettingsTest::getData

Data provider for unit test.

Return value

array The source data and expected data.

File

paragraphs/tests/src/Unit/migrate/ParagraphsFieldInstanceSettingsTest.php, line 51

Class

ParagraphsFieldInstanceSettingsTest
Test the ParagraphFieldInstanceSettings Process Plugin.

Namespace

Drupal\Tests\paragraphs\Unit\migrate

Code

public static function getData() {
  $data = [
    'With one bundle allowed' => [
      'source' => [
        'allowed_bundles' => [
          'paragraph_bundle_one' => 'paragraph_bundle_one',
          'paragraph_bundle_two' => -1,
        ],
        'bundle_weights' => [
          'paragraph_bundle_one' => 1,
          'paragraph_bundle_two' => 2,
        ],
      ],
      'expected' => [
        'handler_settings' => [
          'negate' => 0,
          'target_bundles' => [
            'paragraph_bundle_one' => 'paragraph_bundle_one',
          ],
          'target_bundles_drag_drop' => [
            'paragraph_bundle_one' => [
              'enabled' => TRUE,
              'weight' => 1,
            ],
            'paragraph_bundle_two' => [
              'enabled' => FALSE,
              'weight' => 2,
            ],
            'field_collection_bundle_one' => [
              'enabled' => FALSE,
              'weight' => 3,
            ],
            'field_collection_bundle_two' => [
              'enabled' => FALSE,
              'weight' => 4,
            ],
            'prexisting_bundle_one' => [
              'enabled' => FALSE,
              'weight' => 5,
            ],
            'prexisting_bundle_two' => [
              'enabled' => FALSE,
              'weight' => 6,
            ],
          ],
        ],
      ],
    ],
    'With all bundles allowed' => [
      'source' => [
        'allowed_bundles' => [
          'paragraph_bundle_one' => -1,
          'paragraph_bundle_two' => -1,
        ],
        'bundle_weights' => [
          'paragraph_bundle_one' => 1,
          'paragraph_bundle_two' => 2,
        ],
      ],
      'expected' => [
        'handler_settings' => [
          'negate' => 0,
          'target_bundles' => NULL,
          'target_bundles_drag_drop' => [
            'paragraph_bundle_one' => [
              'enabled' => FALSE,
              'weight' => 1,
            ],
            'paragraph_bundle_two' => [
              'enabled' => FALSE,
              'weight' => 2,
            ],
            'field_collection_bundle_one' => [
              'enabled' => FALSE,
              'weight' => 3,
            ],
            'field_collection_bundle_two' => [
              'enabled' => FALSE,
              'weight' => 4,
            ],
            'prexisting_bundle_one' => [
              'enabled' => FALSE,
              'weight' => 5,
            ],
            'prexisting_bundle_two' => [
              'enabled' => FALSE,
              'weight' => 6,
            ],
          ],
        ],
      ],
    ],
  ];
  return $data;
}