You are here

class RangeFieldFormatterSettingsTest in Range 8

@coversDefaultClass \Drupal\range\Plugin\migrate\process\d6\RangeFieldFormatterSettings @group range

Hierarchy

Expanded class hierarchy of RangeFieldFormatterSettingsTest

File

tests/src/Unit/Plugin/migrate/process/d6/RangeFieldFormatterSettingsTest.php, line 15

Namespace

Drupal\Tests\range\Unit\Plugin\migrate\process\d6
View source
class RangeFieldFormatterSettingsTest extends UnitTestCase {

  /**
   * Test the range field formatter settings transformations.
   *
   * @covers ::transform
   * @dataProvider transformDataProvider
   */
  public function testTransform($display_type, $format, $expected) {
    $plugin = new RangeFieldFormatterSettings([], '', [], $this
      ->createMock(MigrationInterface::class));
    $row = $this
      ->createMock(Row::class);
    $row
      ->expects(self::once())
      ->method('getDestinationProperty')
      ->willReturn($display_type);
    $actual = $plugin
      ->transform([
      NULL,
      $format,
    ], $this
      ->createMock(MigrateExecutableInterface::class), $row, NULL);
    $this
      ->assertSame($expected, $actual);
  }

  /**
   * Data provider for testTransform.
   */
  public function transformDataProvider() {
    return [
      'range_decimal default' => [
        'range_decimal',
        'default',
        [
          'field_prefix_suffix' => TRUE,
        ],
      ],
      'range_decimal us_0' => [
        'range_decimal',
        'us_0',
        [
          'scale' => 0,
          'decimal_separator' => '.',
          'thousand_separator' => ',',
          'field_prefix_suffix' => TRUE,
        ],
      ],
      'range_decimal us_1' => [
        'range_decimal',
        'us_1',
        [
          'scale' => 1,
          'decimal_separator' => '.',
          'thousand_separator' => ',',
          'field_prefix_suffix' => TRUE,
        ],
      ],
      'range_decimal us_2' => [
        'range_decimal',
        'us_2',
        [
          'scale' => 2,
          'decimal_separator' => '.',
          'thousand_separator' => ',',
          'field_prefix_suffix' => TRUE,
        ],
      ],
      'range_decimal be_0' => [
        'range_decimal',
        'be_0',
        [
          'scale' => 0,
          'decimal_separator' => ',',
          'thousand_separator' => '.',
          'field_prefix_suffix' => TRUE,
        ],
      ],
      'range_decimal be_1' => [
        'range_decimal',
        'be_1',
        [
          'scale' => 1,
          'decimal_separator' => ',',
          'thousand_separator' => '.',
          'field_prefix_suffix' => TRUE,
        ],
      ],
      'range_decimal be_2' => [
        'range_decimal',
        'be_2',
        [
          'scale' => 2,
          'decimal_separator' => ',',
          'thousand_separator' => '.',
          'field_prefix_suffix' => TRUE,
        ],
      ],
      'range_decimal fr_0' => [
        'range_decimal',
        'fr_0',
        [
          'scale' => 0,
          'decimal_separator' => ',',
          'thousand_separator' => ' ',
          'field_prefix_suffix' => TRUE,
        ],
      ],
      'range_decimal fr_1' => [
        'range_decimal',
        'fr_1',
        [
          'scale' => 1,
          'decimal_separator' => ',',
          'thousand_separator' => ' ',
          'field_prefix_suffix' => TRUE,
        ],
      ],
      'range_decimal fr_2' => [
        'range_decimal',
        'fr_2',
        [
          'scale' => 2,
          'decimal_separator' => ',',
          'thousand_separator' => ' ',
          'field_prefix_suffix' => TRUE,
        ],
      ],
      'range_decimal non-existing' => [
        'range_decimal',
        'non-existing',
        [],
      ],
      'range_integer default' => [
        'range_integer',
        'default',
        [
          'field_prefix_suffix' => TRUE,
        ],
      ],
      'range_integer us_0' => [
        'range_integer',
        'us_0',
        [
          'thousand_separator' => ',',
          'field_prefix_suffix' => TRUE,
        ],
      ],
      'range_integer be_0' => [
        'range_integer',
        'be_0',
        [
          'thousand_separator' => '.',
          'field_prefix_suffix' => TRUE,
        ],
      ],
      'range_integer fr_0' => [
        'range_integer',
        'fr_0',
        [
          'thousand_separator' => ' ',
          'field_prefix_suffix' => TRUE,
        ],
      ],
      'range_integer non-existing' => [
        'range_integer',
        'non-existing',
        [],
      ],
      'range_unformatted unformatted' => [
        'range_unformatted',
        'unformatted',
        [
          'field_prefix_suffix' => TRUE,
        ],
      ],
      'range_unformatted non-existing' => [
        'range_unformatted',
        'non-existing',
        [],
      ],
      'non-existing default' => [
        'non-existing',
        'default',
        [],
      ],
      'non-existing non-existing' => [
        'non-existing',
        'non-existing',
        [],
      ],
    ];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PhpunitCompatibilityTrait::getMock Deprecated public function Returns a mock object for the specified class using the available method.
PhpunitCompatibilityTrait::setExpectedException Deprecated public function Compatibility layer for PHPUnit 6 to support PHPUnit 4 code.
RangeFieldFormatterSettingsTest::testTransform public function Test the range field formatter settings transformations.
RangeFieldFormatterSettingsTest::transformDataProvider public function Data provider for testTransform.
UnitTestCase::$randomGenerator protected property The random generator.
UnitTestCase::$root protected property The app root. 1
UnitTestCase::assertArrayEquals protected function Asserts if two arrays are equal by sorting them first.
UnitTestCase::getBlockMockWithMachineName Deprecated protected function Mocks a block with a block plugin. 1
UnitTestCase::getClassResolverStub protected function Returns a stub class resolver.
UnitTestCase::getConfigFactoryStub public function Returns a stub config factory that behaves according to the passed array.
UnitTestCase::getConfigStorageStub public function Returns a stub config storage that returns the supplied configuration.
UnitTestCase::getContainerWithCacheTagsInvalidator protected function Sets up a container with a cache tags invalidator.
UnitTestCase::getRandomGenerator protected function Gets the random generator for the utility methods.
UnitTestCase::getStringTranslationStub public function Returns a stub translation manager that just returns the passed string.
UnitTestCase::randomMachineName public function Generates a unique random string containing letters and numbers.
UnitTestCase::setUp protected function 340