You are here

public function RangeFieldTest::testAlterFieldFormatterMigration in Range 8

@covers ::alterFieldFormatterMigration @dataProvider alterMigrationDataProvider

File

tests/src/Unit/Plugin/migrate/field/d6/RangeFieldTest.php, line 147

Class

RangeFieldTest
@coversDefaultClass \Drupal\range\Plugin\migrate\field\d6\RangeField @group range

Namespace

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

Code

public function testAlterFieldFormatterMigration($field_type, $is_range_field_type) {
  $this->row
    ->expects(self::once())
    ->method('getSourceProperty')
    ->willReturn($field_type);
  $this->plugin
    ->alterFieldFormatterMigration($this->migration);
  $process = $this->migration
    ->getProcess();
  if ($is_range_field_type) {
    $this
      ->assertSame([
      'default' => 'range_decimal',
      'us_0' => 'range_decimal',
      'us_1' => 'range_decimal',
      'us_2' => 'range_decimal',
      'be_0' => 'range_decimal',
      'be_1' => 'range_decimal',
      'be_2' => 'range_decimal',
      'fr_0' => 'range_decimal',
      'fr_1' => 'range_decimal',
      'fr_2' => 'range_decimal',
      'unformatted' => 'range_unformatted',
    ], $process['options/type'][0]['map']['range_decimal']);
    $this
      ->assertSame([
      'default' => 'range_decimal',
      'us_0' => 'range_decimal',
      'us_1' => 'range_decimal',
      'us_2' => 'range_decimal',
      'be_0' => 'range_decimal',
      'be_1' => 'range_decimal',
      'be_2' => 'range_decimal',
      'fr_0' => 'range_decimal',
      'fr_1' => 'range_decimal',
      'fr_2' => 'range_decimal',
      'unformatted' => 'range_unformatted',
    ], $process['options/type'][0]['map']['range_float']);
    $this
      ->assertSame([
      'default' => 'range_integer',
      'us_0' => 'range_integer',
      'be_0' => 'range_integer',
      'fr_0' => 'range_integer',
      'unformatted' => 'range_unformatted',
    ], $process['options/type'][0]['map']['range_integer']);
    $expected_process = [
      'plugin' => 'd6_range_field_formatter_settings',
    ];
    $this
      ->assertSame([
      $expected_process,
    ], $process['options/settings']);
  }
  else {
    $this
      ->assertSame([], $process);
  }
}