3 namespace Drupal\Tests\migrate_plus\Unit\process;
5 use Drupal\migrate\MigrateException;
6 use Drupal\migrate\MigrateSkipProcessException;
7 use Drupal\migrate\MigrateSkipRowException;
8 use Drupal\migrate_plus\Plugin\migrate\process\SkipOnValue;
9 use Drupal\Tests\migrate\Unit\process\MigrateProcessTestCase;
12 * Tests the skip on value process plugin.
15 * @coversDefaultClass \Drupal\migrate_plus\Plugin\migrate\process\SkipOnValue
17 class SkipOnValueTest extends MigrateProcessTestCase {
22 public function testProcessSkipsOnValue() {
23 $configuration['method'] = 'process';
24 $configuration['value'] = 86;
25 $this->setExpectedException(MigrateSkipProcessException::class);
26 (new SkipOnValue($configuration, 'skip_on_value', []))
27 ->transform('86', $this->migrateExecutable, $this->row, 'destinationproperty');
33 public function testProcessSkipsOnMultipleValue() {
34 $configuration['method'] = 'process';
35 $configuration['value'] = [1, 1, 2, 3, 5, 8];
36 $this->setExpectedException(MigrateSkipProcessException::class);
37 (new SkipOnValue($configuration, 'skip_on_value', []))
38 ->transform('5', $this->migrateExecutable, $this->row, 'destinationproperty');
44 public function testProcessBypassesOnNonValue() {
45 $configuration['method'] = 'process';
46 $configuration['value'] = 'sourcevalue';
47 $configuration['not_equals'] = TRUE;
48 $value = (new SkipOnValue($configuration, 'skip_on_value', []))
49 ->transform('sourcevalue', $this->migrateExecutable, $this->row, 'destinationproperty');
50 $this->assertEquals($value, 'sourcevalue');
51 $configuration['value'] = 86;
52 $value = (new SkipOnValue($configuration, 'skip_on_value', []))
53 ->transform('86', $this->migrateExecutable, $this->row, 'destinationproperty');
54 $this->assertEquals($value, '86');
60 public function testProcessSkipsOnMultipleNonValue() {
61 $configuration['method'] = 'process';
62 $configuration['value'] = [1, 1, 2, 3, 5, 8];
63 $value = (new SkipOnValue($configuration, 'skip_on_value', []))
64 ->transform(4, $this->migrateExecutable, $this->row, 'destinationproperty');
65 $this->assertEquals($value, '4');
71 public function testRowSkipsOnValue() {
72 $configuration['method'] = 'row';
73 $configuration['value'] = 86;
74 $this->setExpectedException(MigrateSkipRowException::class);
75 (new SkipOnValue($configuration, 'skip_on_value', []))
76 ->transform('86', $this->migrateExecutable, $this->row, 'destinationproperty');
82 public function testRowBypassesOnNonValue() {
83 $configuration['method'] = 'row';
84 $configuration['value'] = 'sourcevalue';
85 $configuration['not_equals'] = TRUE;
86 $value = (new SkipOnValue($configuration, 'skip_on_value', []))
87 ->transform('sourcevalue', $this->migrateExecutable, $this->row, 'destinationproperty');
88 $this->assertEquals($value, 'sourcevalue');
89 $configuration['value'] = 86;
90 $value = (new SkipOnValue($configuration, 'skip_on_value', []))
91 ->transform('86', $this->migrateExecutable, $this->row, 'destinationproperty');
92 $this->assertEquals($value, 86);
98 public function testRequiredRowConfiguration() {
99 $configuration['method'] = 'row';
100 $this->setExpectedException(MigrateException::class);
101 (new SkipOnValue($configuration, 'skip_on_value', []))
102 ->transform('sourcevalue', $this->migrateExecutable, $this->row, 'destinationproperty');
108 public function testRequiredProcessConfiguration() {
109 $configuration['method'] = 'process';
110 $this->setExpectedException(MigrateException::class);
111 (new SkipOnValue($configuration, 'skip_on_value', []))
112 ->transform('sourcevalue', $this->migrateExecutable, $this->row, 'destinationproperty');