FieldSettingsTest.php

Same filename in this branch
  1. 10 core/modules/field/tests/src/Unit/Plugin/migrate/process/d7/FieldSettingsTest.php
  2. 10 core/tests/Drupal/KernelTests/Core/Field/FieldSettingsTest.php
Same filename in other branches
  1. 9 core/modules/field/tests/src/Unit/Plugin/migrate/process/d6/FieldSettingsTest.php
  2. 9 core/modules/field/tests/src/Unit/Plugin/migrate/process/d7/FieldSettingsTest.php
  3. 9 core/tests/Drupal/KernelTests/Core/Field/FieldSettingsTest.php
  4. 8.9.x core/modules/field/tests/src/Unit/Plugin/migrate/process/d6/FieldSettingsTest.php
  5. 8.9.x core/modules/field/tests/src/Unit/Plugin/migrate/process/d7/FieldSettingsTest.php
  6. 8.9.x core/tests/Drupal/KernelTests/Core/Field/FieldSettingsTest.php
  7. 11.x core/modules/field/tests/src/Unit/Plugin/migrate/process/d6/FieldSettingsTest.php
  8. 11.x core/modules/field/tests/src/Unit/Plugin/migrate/process/d7/FieldSettingsTest.php
  9. 11.x core/tests/Drupal/KernelTests/Core/Field/FieldSettingsTest.php

Namespace

Drupal\Tests\field\Unit\Plugin\migrate\process\d6

File

core/modules/field/tests/src/Unit/Plugin/migrate/process/d6/FieldSettingsTest.php

View source
<?php

declare (strict_types=1);
namespace Drupal\Tests\field\Unit\Plugin\migrate\process\d6;

use Drupal\field\Plugin\migrate\process\d6\FieldSettings;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\Row;
use Drupal\Tests\UnitTestCase;

/**
 * @coversDefaultClass \Drupal\field\Plugin\migrate\process\d6\FieldSettings
 * @group field
 */
class FieldSettingsTest extends UnitTestCase {
    
    /**
     * @covers ::getSettings
     *
     * @dataProvider getSettingsProvider
     */
    public function testGetSettings($field_type, $field_settings, $allowed_values) : void {
        $migration = $this->createMock(MigrationInterface::class);
        $plugin = new FieldSettings([], 'd6_field_settings', []);
        $executable = $this->createMock(MigrateExecutableInterface::class);
        $row = $this->getMockBuilder(Row::class)
            ->disableOriginalConstructor()
            ->getMock();
        $result = $plugin->transform([
            $field_type,
            $field_settings,
            NULL,
        ], $executable, $row, 'foo');
        $this->assertSame($allowed_values, $result['allowed_values']);
    }
    
    /**
     * Provides field settings for testGetSettings().
     */
    public static function getSettingsProvider() {
        return [
            [
                'list_integer',
                [
                    'allowed_values' => "1|One\n2|Two\n3",
                ],
                [
                    '1' => 'One',
                    '2' => 'Two',
                    '3' => '3',
                ],
            ],
            [
                'list_string',
                [
                    'allowed_values' => NULL,
                ],
                [],
            ],
            [
                'list_float',
                [
                    'allowed_values' => "",
                ],
                [],
            ],
            [
                'boolean',
                [],
                [],
            ],
        ];
    }

}

Classes

Title Deprecated Summary
FieldSettingsTest @coversDefaultClass \Drupal\field\Plugin\migrate\process\d6\FieldSettings @group field

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