class ConfigDiffTransformerTest in Update helper 8
Same name and namespace in other branches
- 2.x tests/src/Unit/ConfigDiffTransformerTest.php \Drupal\Tests\update_helper\Unit\ConfigDiffTransformerTest
Automated tests for the 'update_helper.config_diff_transformer' service.
@group update_helper
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\update_helper\Unit\ConfigDiffTransformerTest
Expanded class hierarchy of ConfigDiffTransformerTest
File
- tests/
src/ Unit/ ConfigDiffTransformerTest.php, line 13
Namespace
Drupal\Tests\update_helper\UnitView source
class ConfigDiffTransformerTest extends UnitTestCase {
/**
* Test transforming of configuration to array of strings.
*
* @param array $config
* Configuration array that should be transformed.
* @param array $expected
* Expected result of "transform" execution.
*
* @dataProvider transformDataProvider
*/
public function testTransform(array $config, array $expected) {
$transformer = new ConfigDiffTransformer();
$result = $transformer
->transform($config);
$this
->assertEquals($expected, $result);
}
/**
* Test transforming of configuration to array of strings.
*
* @param array $expected
* Expected result of "reverseTransform" execution.
* @param array $transformedConfig
* Transformed configuration array that should be reversibly transformed.
*
* @dataProvider transformDataProvider
*/
public function testReverseTransform(array $expected, array $transformedConfig) {
$transformer = new ConfigDiffTransformer();
$result = $transformer
->reverseTransform($transformedConfig);
$this
->assertEquals($expected, $result);
}
/**
* Data provider for transform and reverseTransform methods test.
*
* @return array
* Return test cases for testProcessRiddleResponse.
*/
public function transformDataProvider() {
return [
[
[],
[],
],
[
[
'uuid' => '1234-5678-90',
'id' => 'test.config.id',
'short_text' => 'en',
'long_text' => 'Automated tests for the ConfigDiffTransformer service.',
'true_value' => TRUE,
'false_value' => FALSE,
'nested_array' => [
'flat_array' => [
'value2',
'value1',
'value3',
],
'custom_key' => 'value',
],
'empty_array' => [],
'empty_string' => '',
'null_value' => NULL,
],
[
'uuid : s:12:"1234-5678-90";',
'id : s:14:"test.config.id";',
'short_text : s:2:"en";',
'long_text : s:54:"Automated tests for the ConfigDiffTransformer service.";',
'true_value : b:1;',
'false_value : b:0;',
'nested_array',
'nested_array::flat_array',
'nested_array::flat_array::- : s:6:"value2";',
'nested_array::flat_array::- : s:6:"value1";',
'nested_array::flat_array::- : s:6:"value3";',
'nested_array::custom_key : s:5:"value";',
'empty_array : a:0:{}',
'empty_string : s:0:"";',
'null_value : N;',
],
],
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigDiffTransformerTest:: |
public | function | Test transforming of configuration to array of strings. | |
ConfigDiffTransformerTest:: |
public | function | Test transforming of configuration to array of strings. | |
ConfigDiffTransformerTest:: |
public | function | Data provider for transform and reverseTransform methods test. | |
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. | |
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 |