You are here

public function MigrationPluginsAltererTest::providerParagraphsMigrationPrepareProcess in Paragraphs 8

Provides data and expected results for testing the prepare process method.

Return value

array[] Data and expected results.

File

tests/src/Unit/migrate/MigrationPluginsAltererTest.php, line 62

Class

MigrationPluginsAltererTest
Tests the MigrationPluginsAlterer service.

Namespace

Drupal\Tests\paragraphs\Unit\migrate

Code

public function providerParagraphsMigrationPrepareProcess() {
  return [
    // Missing property (no change).
    [
      'input' => [
        'process' => [
          'catname' => 'Picurka',
          'wont/touch' => 'this',
        ],
        'property' => 'missing',
      ],
      'expected' => [
        'return' => FALSE,
        'process' => [
          'catname' => 'Picurka',
          'wont/touch' => 'this',
        ],
      ],
    ],
    // Existing string property.
    [
      'input' => [
        'process' => [
          'catname' => 'Picurka',
          'wont/touch' => 'this',
        ],
        'property' => 'catname',
      ],
      'expected' => [
        'return' => TRUE,
        'process' => [
          'catname' => [
            [
              'plugin' => 'get',
              'source' => 'Picurka',
            ],
          ],
          'wont/touch' => 'this',
        ],
      ],
    ],
    // Single process plugin.
    [
      'input' => [
        'process' => [
          'cat' => [
            'plugin' => 'migration_lookup',
            'migration' => 'cats',
            'source' => 'cat_id',
          ],
        ],
        'property' => 'cat',
      ],
      'expected' => [
        'return' => TRUE,
        'process' => [
          'cat' => [
            [
              'plugin' => 'migration_lookup',
              'migration' => 'cats',
              'source' => 'cat_id',
            ],
          ],
        ],
      ],
    ],
    // Array of process plugins (no change).
    [
      'input' => [
        'process' => [
          'catname' => [
            [
              'plugin' => 'migration_lookup',
              'migration' => 'cats',
              'source' => 'cat_id',
            ],
            [
              'plugin' => 'extract',
              'index' => [
                'name',
              ],
            ],
            [
              'plugin' => 'callback',
              'callable' => 'ucfirst',
            ],
          ],
        ],
        'property' => 'catname',
      ],
      'expected' => [
        'return' => TRUE,
        'process' => [
          'catname' => [
            [
              'plugin' => 'migration_lookup',
              'migration' => 'cats',
              'source' => 'cat_id',
            ],
            [
              'plugin' => 'extract',
              'index' => [
                'name',
              ],
            ],
            [
              'plugin' => 'callback',
              'callable' => 'ucfirst',
            ],
          ],
        ],
      ],
    ],
    // Invalid type.
    [
      'input' => [
        'process' => [
          'invalid' => (object) [
            [
              'not a' => 'kitten',
            ],
          ],
        ],
        'property' => 'invalid',
      ],
      'expected' => [
        'return' => FALSE,
        'process' => [
          'invalid' => (object) [
            [
              'not a' => 'kitten',
            ],
          ],
        ],
      ],
    ],
  ];
}