function MigrationTest::testSetInvalidation

Same name in other branches
  1. 9 core/modules/migrate/tests/src/Kernel/MigrationTest.php \Drupal\Tests\migrate\Kernel\MigrationTest::testSetInvalidation()
  2. 8.9.x core/modules/migrate/tests/src/Kernel/MigrationTest.php \Drupal\Tests\migrate\Kernel\MigrationTest::testSetInvalidation()
  3. 10 core/modules/migrate/tests/src/Kernel/MigrationTest.php \Drupal\Tests\migrate\Kernel\MigrationTest::testSetInvalidation()

Tests Migration::set().

@covers ::set

File

core/modules/migrate/tests/src/Kernel/MigrationTest.php, line 30

Class

MigrationTest
Tests the migration plugin.

Namespace

Drupal\Tests\migrate\Kernel

Code

public function testSetInvalidation() : void {
    $migration = \Drupal::service('plugin.manager.migration')->createStubMigration([
        'source' => [
            'plugin' => 'empty',
        ],
        'destination' => [
            'plugin' => 'entity:entity_view_mode',
        ],
    ]);
    $this->assertEquals('empty', $migration->getSourcePlugin()
        ->getPluginId());
    $this->assertEquals('entity:entity_view_mode', $migration->getDestinationPlugin()
        ->getPluginId());
    // Test the source plugin is invalidated.
    $migration->set('source', [
        'plugin' => 'embedded_data',
        'data_rows' => [],
        'ids' => [],
    ]);
    $this->assertEquals('embedded_data', $migration->getSourcePlugin()
        ->getPluginId());
    // Test the destination plugin is invalidated.
    $migration->set('destination', [
        'plugin' => 'null',
    ]);
    $this->assertEquals('null', $migration->getDestinationPlugin()
        ->getPluginId());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.