You are here

public function EntityReferenceRevisionsDestinationTest::getEntityDataProvider in Entity Reference Revisions 8

Provides multiple migration definitions for "getEntity" test.

1 call to EntityReferenceRevisionsDestinationTest::getEntityDataProvider()
EntityReferenceRevisionsDestinationTest::getEntityTypeIdDataProvider in tests/src/Kernel/Plugin/migrate/destination/EntityReferenceRevisionsDestinationTest.php
Provides multiple migration definitions for "getEntityTypeId" test.

File

tests/src/Kernel/Plugin/migrate/destination/EntityReferenceRevisionsDestinationTest.php, line 120

Class

EntityReferenceRevisionsDestinationTest
Tests the migration destination plugin.

Namespace

Drupal\Tests\entity_reference_revisions\Kernel\Plugin\migrate\destination

Code

public function getEntityDataProvider() {
  return [
    'without keys' => [
      'definition' => [
        'source' => [
          'plugin' => 'embedded_data',
          'data_rows' => [
            [
              'id' => 1,
              'name' => 'content item 1a',
            ],
            [
              'id' => 1,
              'name' => 'content item 1b',
            ],
            [
              'id' => 2,
              'name' => 'content item 2',
            ],
          ],
          'ids' => [
            'id' => [
              'type' => 'integer',
            ],
            'name' => [
              'type' => 'text',
            ],
          ],
        ],
        'process' => [
          'name' => 'name',
        ],
        'destination' => [
          'plugin' => 'entity_reference_revisions:entity_test_composite',
        ],
      ],
      'expected' => [
        [
          'id' => 1,
          'revision_id' => 1,
          'label' => 'content item 1a',
        ],
        [
          'id' => 2,
          'revision_id' => 2,
          'label' => 'content item 1b',
        ],
        [
          'id' => 3,
          'revision_id' => 3,
          'label' => 'content item 2',
        ],
      ],
    ],
    'with ids' => [
      'definition' => [
        'source' => [
          'plugin' => 'embedded_data',
          'data_rows' => [
            [
              'id' => 1,
              'name' => 'content item 1a',
            ],
            [
              'id' => 1,
              'name' => 'content item 1b',
            ],
            [
              'id' => 2,
              'name' => 'content item 2',
            ],
            [
              'id' => 3,
              'name' => 'content item 3',
            ],
          ],
          'ids' => [
            'id' => [
              'type' => 'integer',
            ],
            'name' => [
              'type' => 'text',
            ],
          ],
        ],
        'process' => [
          'name' => 'name',
          'id' => 'id',
        ],
        'destination' => [
          'plugin' => 'entity_reference_revisions:entity_test_composite',
        ],
      ],
      'expected' => [
        [
          'id' => 1,
          'revision_id' => 1,
          'label' => 'content item 1b',
        ],
        [
          'id' => 2,
          'revision_id' => 2,
          'label' => 'content item 2',
        ],
        [
          'id' => 3,
          'revision_id' => 3,
          'label' => 'content item 3',
        ],
      ],
    ],
    'with ids and new revisions' => [
      'definition' => [
        'source' => [
          'plugin' => 'embedded_data',
          'data_rows' => [
            [
              'id' => 1,
              'name' => 'content item 1a',
            ],
            [
              'id' => 1,
              'name' => 'content item 1b',
            ],
            [
              'id' => 2,
              'name' => 'content item 2',
            ],
          ],
          'ids' => [
            'id' => [
              'type' => 'integer',
            ],
            'name' => [
              'type' => 'text',
            ],
          ],
        ],
        'process' => [
          'name' => 'name',
          'id' => 'id',
        ],
        'destination' => [
          'plugin' => 'entity_reference_revisions:entity_test_composite',
          'new_revisions' => TRUE,
        ],
      ],
      'expected' => [
        [
          'id' => 1,
          'revision_id' => 1,
          'label' => 'content item 1a',
        ],
        [
          'id' => 1,
          'revision_id' => 2,
          'label' => 'content item 1b',
        ],
        [
          'id' => 2,
          'revision_id' => 3,
          'label' => 'content item 2',
        ],
      ],
    ],
    'with ids and revisions' => [
      'definition' => [
        'source' => [
          'plugin' => 'embedded_data',
          'data_rows' => [
            [
              'id' => 1,
              'revision_id' => 1,
              'name' => 'content item 1',
            ],
            [
              'id' => 2,
              'revision_id' => 2,
              'name' => 'content item 2',
            ],
            [
              'id' => 3,
              'revision_id' => 3,
              'name' => 'content item 3',
            ],
          ],
          'ids' => [
            'id' => [
              'type' => 'integer',
            ],
            'name' => [
              'type' => 'text',
            ],
          ],
        ],
        'process' => [
          'id' => 'id',
          'revision_id' => 'revision_id',
          'name' => 'name',
        ],
        'destination' => [
          'plugin' => 'entity_reference_revisions:entity_test_composite',
        ],
      ],
      'expected' => [
        [
          'id' => 1,
          'revision_id' => 1,
          'label' => 'content item 1',
        ],
        [
          'id' => 2,
          'revision_id' => 2,
          'label' => 'content item 2',
        ],
        [
          'id' => 3,
          'revision_id' => 3,
          'label' => 'content item 3',
        ],
      ],
    ],
  ];
}