Commit e0e50113 authored by gnuget's avatar gnuget Committed by heddn

Issue #2959775 by gnuget, mr.baileys, heddn: SkipOnValue with multiple...

Issue #2959775 by gnuget, mr.baileys, heddn: SkipOnValue with multiple configured values and "not_equals" does not make sense
parent 88b0d143
......@@ -65,10 +65,15 @@ class SkipOnValue extends ProcessPluginBase {
}
if (is_array($this->configuration['value'])) {
$value_in_array = FALSE;
$not_equals = isset($this->configuration['not_equals']);
foreach ($this->configuration['value'] as $skipValue) {
if ($this->compareValue($value, $skipValue, !isset($this->configuration['not_equals']))) {
throw new MigrateSkipRowException();
}
$value_in_array |= $this->compareValue($value, $skipValue);
}
if (($not_equals && !$value_in_array) || (!$not_equals && $value_in_array)) {
throw new MigrateSkipRowException();
}
}
elseif ($this->compareValue($value, $this->configuration['value'], !isset($this->configuration['not_equals']))) {
......@@ -87,10 +92,15 @@ class SkipOnValue extends ProcessPluginBase {
}
if (is_array($this->configuration['value'])) {
$value_in_array = FALSE;
$not_equals = isset($this->configuration['not_equals']);
foreach ($this->configuration['value'] as $skipValue) {
if ($this->compareValue($value, $skipValue, !isset($this->configuration['not_equals']))) {
throw new MigrateSkipProcessException();
}
$value_in_array |= $this->compareValue($value, $skipValue);
}
if (($not_equals && !$value_in_array) || (!$not_equals && $value_in_array)) {
throw new MigrateSkipProcessException();
}
}
elseif ($this->compareValue($value, $this->configuration['value'], !isset($this->configuration['not_equals']))) {
......
......@@ -65,6 +65,36 @@ class SkipOnValueTest extends MigrateProcessTestCase {
$this->assertEquals($value, '4');
}
/**
* @covers ::process
*/
public function testProcessBypassesOnMultipleNonValue() {
$configuration['method'] = 'process';
$configuration['value'] = [1, 1, 2, 3, 5, 8];
$configuration['not_equals'] = TRUE;
$value = (new SkipOnValue($configuration, 'skip_on_value', []))
->transform(5, $this->migrateExecutable, $this->row, 'destinationproperty');
$this->assertEquals($value, '5');
$value = (new SkipOnValue($configuration, 'skip_on_value', []))
->transform(1, $this->migrateExecutable, $this->row, 'destinationproperty');
$this->assertEquals($value, '1');
}
/**
* @covers ::row
*/
public function testRowBypassesOnMultipleNonValue() {
$configuration['method'] = 'row';
$configuration['value'] = [1, 1, 2, 3, 5, 8];
$configuration['not_equals'] = TRUE;
$value = (new SkipOnValue($configuration, 'skip_on_value', []))
->transform(5, $this->migrateExecutable, $this->row, 'destinationproperty');
$this->assertEquals($value, '5');
$value = (new SkipOnValue($configuration, 'skip_on_value', []))
->transform(1, $this->migrateExecutable, $this->row, 'destinationproperty');
$this->assertEquals($value, '1');
}
/**
* @covers ::row
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment