.../src/Kernel/FieldItemSerializationTest.php | 62 ++++++++++++++++------ 1 file changed, 45 insertions(+), 17 deletions(-) diff --git a/core/modules/serialization/tests/src/Kernel/FieldItemSerializationTest.php b/core/modules/serialization/tests/src/Kernel/FieldItemSerializationTest.php index 0933bb4428..75cc0180e1 100644 --- a/core/modules/serialization/tests/src/Kernel/FieldItemSerializationTest.php +++ b/core/modules/serialization/tests/src/Kernel/FieldItemSerializationTest.php @@ -157,7 +157,7 @@ public function testFieldDenormalizeWithScalarValue() { * @param string $format * The format to test. (NULL results in the format-agnostic normalization.) * - * @dataProvider providerTestCustomBooleanNormalization + * @dataProvider providerTestCustomBooleanDataTypeNormalization */ public function testCustomBooleanNormalization(array $test_modules, $format) { // Asserts the entity contains the value we set. @@ -198,46 +198,74 @@ public function testCustomBooleanNormalization(array $test_modules, $format) { $assert_denormalization($core_normalization); } + /** + * Tests a format-agnostic normalizer. + * + * @param string[] $test_modules + * The test modules to install. + * @param string $format + * The format to test. (NULL results in the format-agnostic normalization.) + * + * @group legacy + * @expectedDeprecation Drupal\test_fieldtype_boolean_emoji_normalizer\Normalizer\BooleanItemNormalizer is a normalizer for a @FieldType plugin. This is very strongly discouraged because it requires similar logic to be implemented for every normalization. Please write this as a normalizer for a @DataType plugin instead, then it works for the entire Drupal API-First ecosystem! + * + * @dataProvider providerTestCustomBooleanFieldTypeNormalization + */ + public function testDeprecatedCustomBooleanFieldTypeLevelNormalization(array $test_modules, $format) { + $this->testCustomBooleanNormalization($test_modules, $format); + } + /** * Data provider. * * @return array * Test cases. */ - public function providerTestCustomBooleanNormalization() { + public function providerTestCustomBooleanDataTypeNormalization() { return [ - 'Format-agnostic @FieldType-level normalizers SHOULD be able to affect the format-agnostic normalization' => [ - ['test_fieldtype_boolean_emoji_normalizer'], - NULL, - ], 'Format-agnostic @DataType-level normalizers SHOULD be able to affect the format-agnostic normalization' => [ ['test_datatype_boolean_emoji_normalizer'], NULL, ], - 'Format-agnostic @FieldType-level normalizers SHOULD be able to affect the JSON normalization' => [ - ['test_fieldtype_boolean_emoji_normalizer'], - 'json', - ], 'Format-agnostic @DataType-level normalizers SHOULD be able to affect the JSON normalization' => [ ['test_datatype_boolean_emoji_normalizer'], 'json', ], - 'Format-agnostic @FieldType-level normalizers SHOULD be able to affect the HAL+JSON normalization' => [ - ['test_fieldtype_boolean_emoji_normalizer'], + 'Format-agnostic @DataType-level normalizers SHOULD be able to affect the HAL+JSON normalization' => [ + ['test_datatype_boolean_emoji_normalizer', 'hal'], 'hal_json', ], - 'Format-agnostic @DataType-level normalizers SHOULD be able to affect the HAL+JSON normalization' => [ + 'Format-agnostic @DataType-level normalizers SHOULD be able to affect the XML normalization' => [ ['test_datatype_boolean_emoji_normalizer', 'hal'], + 'xml', + ], + ]; + } + + /** + * Data provider. + * + * @return array + * Test cases. + */ + public function providerTestCustomBooleanFieldTypeNormalization() { + return [ + 'Format-agnostic @FieldType-level normalizers SHOULD be able to affect the format-agnostic normalization' => [ + ['test_fieldtype_boolean_emoji_normalizer'], + NULL, + ], + 'Format-agnostic @FieldType-level normalizers SHOULD be able to affect the JSON normalization' => [ + ['test_fieldtype_boolean_emoji_normalizer'], + 'json', + ], + 'Format-agnostic @FieldType-level normalizers SHOULD be able to affect the HAL+JSON normalization' => [ + ['test_fieldtype_boolean_emoji_normalizer'], 'hal_json', ], 'Format-agnostic @FieldType-level normalizers SHOULD be able to affect the XML normalization' => [ ['test_fieldtype_boolean_emoji_normalizer'], 'xml', ], - 'Format-agnostic @DataType-level normalizers SHOULD be able to affect the XML normalization' => [ - ['test_datatype_boolean_emoji_normalizer', 'hal'], - 'xml', - ], ]; }