function FieldDiscoveryTest::testAddFields

Same name in other branches
  1. 9 core/modules/migrate_drupal/tests/src/Kernel/d6/FieldDiscoveryTest.php \Drupal\Tests\migrate_drupal\Kernel\d6\FieldDiscoveryTest::testAddFields()
  2. 8.9.x core/modules/migrate_drupal/tests/src/Kernel/d6/FieldDiscoveryTest.php \Drupal\Tests\migrate_drupal\Kernel\d6\FieldDiscoveryTest::testAddFields()
  3. 11.x core/modules/migrate_drupal/tests/src/Kernel/d6/FieldDiscoveryTest.php \Drupal\Tests\migrate_drupal\Kernel\d6\FieldDiscoveryTest::testAddFields()

Tests the addFields method.

@covers ::addAllFieldProcesses

File

core/modules/migrate_drupal/tests/src/Kernel/d6/FieldDiscoveryTest.php, line 224

Class

FieldDiscoveryTest
Tests FieldDiscovery service against Drupal 6.

Namespace

Drupal\Tests\migrate_drupal\Kernel\d6

Code

public function testAddFields() : void {
    $this->migrateFields();
    $field_discovery = $this->container
        ->get('migrate_drupal.field_discovery');
    $migration_plugin_manager = $this->container
        ->get('plugin.manager.migration');
    $definition = [
        'migration_tags' => [
            'Drupal 6',
        ],
    ];
    $migration = $migration_plugin_manager->createStubMigration($definition);
    $field_discovery->addBundleFieldProcesses($migration, 'node', 'test_planet');
    $actual_process = $migration->getProcess();
    $expected_process = [
        'field_multivalue' => [
            0 => [
                'plugin' => 'get',
                'source' => 'field_multivalue',
            ],
        ],
        'field_test_text_single_checkbox' => [
            0 => [
                'plugin' => 'sub_process',
                'source' => 'field_test_text_single_checkbox',
                'process' => [
                    'value' => 'value',
                    'format' => [
                        0 => [
                            'plugin' => 'static_map',
                            'bypass' => TRUE,
                            'source' => 'format',
                            'map' => [
                                0 => NULL,
                            ],
                        ],
                        1 => [
                            'plugin' => 'skip_on_empty',
                            'method' => 'process',
                        ],
                        2 => [
                            'plugin' => 'migration_lookup',
                            'migration' => [
                                0 => 'd6_filter_format',
                                1 => 'd7_filter_format',
                            ],
                            'source' => 'format',
                        ],
                    ],
                ],
            ],
        ],
    ];
    $this->assertEquals($expected_process, $actual_process);
}

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