Spin-off issue for #2829283: Language support in Feed import

Problem/Motivation

In the latest patch from #2829283: Language support in Feed import (#54 at the time of writing) there is a method that checks for empty values (called valuesAreEmpty(). Since importing empty values is a valid use case, we need test coverage for clearing out values.

The method in question:

+++ b/src/Plugin/Type/Target/FieldTargetBase.php
@@ -76,12 +80,101 @@ abstract class FieldTargetBase extends TargetBase {
+  /**
+   * Check current field has value.
+   *
+   * This is done because we don't want set empty values to entity.
+   *
+   * @return bool
+   *   TRUE if field has value.
+   */
+  public function valuesAreEmpty(array $values) {
+    $empty = TRUE;
+    foreach ($values as $value) {
+      foreach ($value as $val) {
+        if (!empty($val)) {
+          $empty = FALSE;
+          break 2;
+        }
+      }
+    }
+    return $empty;

Proposed resolution

The D7 version of Feeds has test coverage for clearing out values for several field types. To keep work small in this issue, let's only port FeedsMapperFieldTestCase::testClearOutValues() for now.

Remaining tasks

  • Port FeedsMapperFieldTestCase::testClearOutValues().

User interface changes

None.

API changes

None.

Data model changes

None.

Patch will follow.

Comments

MegaChriz created an issue. See original summary.

megachriz’s picture

Status: Active » Needs review
Parent issue: » #2829283: Language support in Feed import
StatusFileSize
new9.18 KB
megachriz’s picture

StatusFileSize
new9.2 KB
new434 bytes

Forgot to put test in a group.

megachriz’s picture

StatusFileSize
new9.59 KB
new393 bytes

Forgot to add the CSV file that contains empty values.

megachriz’s picture

StatusFileSize
new9.88 KB
new299 bytes

Working on multiple things at once makes you forget what files belong to which issue!

  • MegaChriz committed 7cc0c61 on 8.x-3.x
    Issue #3103561 by MegaChriz: Added basic test coverage for clearing out...
megachriz’s picture

Status: Needs review » Fixed

Committed #5.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.