class RangeFieldFormatterSettingsTest in Range 8
@coversDefaultClass \Drupal\range\Plugin\migrate\process\d6\RangeFieldFormatterSettings @group range
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\range\Unit\Plugin\migrate\process\d6\RangeFieldFormatterSettingsTest
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\d6View 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
RangeFieldFormatterSettingsTest:: |
public | function | Test the range field formatter settings transformations. | |
RangeFieldFormatterSettingsTest:: |
public | function | Data provider for testTransform. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | 1 |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. | |
UnitTestCase:: |
protected | function | 340 |