MigrationTest.php

Same filename in this branch
  1. 10 core/modules/migrate/tests/src/Unit/MigrationTest.php
  2. 10 core/modules/migrate/tests/src/Kernel/Plugin/MigrationTest.php
Same filename in other branches
  1. 9 core/modules/migrate/tests/src/Unit/MigrationTest.php
  2. 9 core/modules/migrate/tests/src/Kernel/MigrationTest.php
  3. 9 core/modules/migrate/tests/src/Kernel/Plugin/MigrationTest.php
  4. 8.9.x core/modules/migrate/tests/src/Unit/MigrationTest.php
  5. 8.9.x core/modules/migrate/tests/src/Unit/process/MigrationTest.php
  6. 8.9.x core/modules/migrate/tests/src/Kernel/MigrationTest.php
  7. 8.9.x core/modules/migrate/tests/src/Kernel/Plugin/MigrationTest.php
  8. 11.x core/modules/migrate/tests/src/Unit/MigrationTest.php
  9. 11.x core/modules/migrate/tests/src/Kernel/MigrationTest.php
  10. 11.x core/modules/migrate/tests/src/Kernel/Plugin/MigrationTest.php

Namespace

Drupal\Tests\migrate\Kernel

File

core/modules/migrate/tests/src/Kernel/MigrationTest.php

View source
<?php

declare (strict_types=1);
namespace Drupal\Tests\migrate\Kernel;

use Drupal\KernelTests\KernelTestBase;

/**
 * Tests the migration plugin.
 *
 * @group migrate
 *
 * @coversDefaultClass \Drupal\migrate\Plugin\Migration
 */
class MigrationTest extends KernelTestBase {
    
    /**
     * Enable field because we are using one of its source plugins.
     *
     * @var array
     */
    protected static $modules = [
        'migrate',
        'field',
    ];
    
    /**
     * Tests Migration::set().
     *
     * @covers ::set
     */
    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());
    }

}

Classes

Title Deprecated Summary
MigrationTest Tests the migration plugin.

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