ProfileFieldOptionTranslationTest.php

Same filename in other branches
  1. 9 core/modules/user/tests/src/Kernel/Plugin/migrate/source/d6/ProfileFieldOptionTranslationTest.php
  2. 8.9.x core/modules/user/tests/src/Kernel/Plugin/migrate/source/d6/ProfileFieldOptionTranslationTest.php
  3. 11.x core/modules/user/tests/src/Kernel/Plugin/migrate/source/d6/ProfileFieldOptionTranslationTest.php

Namespace

Drupal\Tests\user\Kernel\Plugin\migrate\source\d6

File

core/modules/user/tests/src/Kernel/Plugin/migrate/source/d6/ProfileFieldOptionTranslationTest.php

View source
<?php

declare (strict_types=1);
namespace Drupal\Tests\user\Kernel\Plugin\migrate\source\d6;

use Drupal\Tests\user\Kernel\Plugin\migrate\source\ProfileFieldTest;
// cspell:ignore objectid

/**
 * Tests the field option translation source plugin.
 *
 * @covers \Drupal\user\Plugin\migrate\source\d6\ProfileFieldOptionTranslation
 * @group migrate_drupal
 */
class ProfileFieldOptionTranslationTest extends ProfileFieldTest {
    
    /**
     * {@inheritdoc}
     */
    protected static $modules = [
        'user',
        'migrate_drupal',
    ];
    
    /**
     * {@inheritdoc}
     */
    public static function providerSource() {
        $test = parent::providerSource();
        // The source data.
        $test[0]['source_data']['i18n_strings'] = [
            [
                'lid' => 10,
                'objectid' => 'profile_color',
                'type' => 'field',
                'property' => 'options',
            ],
            [
                'lid' => 1,
                'objectid' => 'profile_last_name',
                'type' => 'field',
                'property' => 'options',
            ],
        ];
        $test[0]['source_data']['locales_target'] = [
            [
                'lid' => 10,
                'translation' => "fr - red\nfr - blue\nfr - green",
                'language' => 'fr',
            ],
        ];
        $test[0]['expected_data'] = [
            [
                'fid' => 4,
                'title' => 'Color',
                'name' => 'profile_color',
                'explanation' => 'A selection that allows user to select a color',
                'category' => 'profile',
                'page' => '',
                'type' => 'selection',
                'weight' => 0,
                'required' => 0,
                'register' => 0,
                'visibility' => 2,
                'autocomplete' => 0,
                'options' => [
                    'red' => 'red',
                    'blue' => 'blue',
                    'green' => 'green',
                    'yellow' => 'yellow',
                ],
                'property' => 'options',
                'objectid' => 'profile_color',
                'translation' => "fr - red\nfr - blue\nfr - green",
                'language' => 'fr',
            ],
        ];
        return $test;
    }

}

Classes

Title Deprecated Summary
ProfileFieldOptionTranslationTest Tests the field option translation source plugin.

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