Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / rest / tests / src / Functional / EntityResource / XmlEntityNormalizationQuirksTrait.php
index 962d8e9d2ef470f2c466d81260a04076062bd9db..a7e588ad356e29fad3802cb866950fc17024e256 100644 (file)
@@ -14,6 +14,7 @@ use Drupal\image\Plugin\Field\FieldType\ImageItem;
 use Drupal\options\Plugin\Field\FieldType\ListIntegerItem;
 use Drupal\path\Plugin\Field\FieldType\PathItem;
 use Drupal\Tests\rest\Functional\XmlNormalizationQuirksTrait;
+use Drupal\user\StatusItem;
 
 /**
  * Trait for EntityResourceTestBase subclasses testing $format='xml'.
@@ -63,6 +64,9 @@ trait XmlEntityNormalizationQuirksTrait {
       for ($i = 0; $i < count($normalization[$field_name]); $i++) {
         switch ($field->getItemDefinition()->getClass()) {
           case BooleanItem::class:
+          case StatusItem::class:
+            // @todo Remove the StatusItem case in
+            //   https://www.drupal.org/project/drupal/issues/2936864.
             $value = &$normalization[$field_name][$i]['value'];
             $value = $value === TRUE ? '1' : '0';
             break;
@@ -99,7 +103,7 @@ trait XmlEntityNormalizationQuirksTrait {
         }
       }
 
-      if (!empty($normalization[$field_name])) {
+      if (count($normalization[$field_name]) === 1) {
         $normalization[$field_name] = $normalization[$field_name][0];
       }
     }
@@ -107,7 +111,6 @@ trait XmlEntityNormalizationQuirksTrait {
     return $normalization;
   }
 
-
   /**
    * Applies the XML config entity encoding quirks that remain after decoding.
    *