5 * Contains \Drupal\Tests\migrate_plus\Unit\process\SkipOnValueTest.
8 namespace Drupal\Tests\migrate_plus\Unit\process;
10 use Drupal\migrate_plus\Plugin\migrate\process\SkipOnValue;
11 use Drupal\Tests\migrate\Unit\process\MigrateProcessTestCase;
14 * Tests the skip on value process plugin.
17 * @coversDefaultClass \Drupal\migrate_plus\Plugin\migrate\process\SkipOnValue
19 class SkipOnValueTest extends MigrateProcessTestCase {
23 * @expectedException \Drupal\migrate\MigrateSkipProcessException
25 public function testProcessSkipsOnValue() {
26 $configuration['method'] = 'process';
27 $configuration['value'] = 86;
28 (new SkipOnValue($configuration, 'skip_on_value', []))
29 ->transform('86', $this->migrateExecutable, $this->row, 'destinationproperty');
34 * @expectedException \Drupal\migrate\MigrateSkipProcessException
36 public function testProcessSkipsOnMultipleValue() {
37 $configuration['method'] = 'process';
38 $configuration['value'] = [1, 1, 2, 3, 5, 8];
39 (new SkipOnValue($configuration, 'skip_on_value', []))
40 ->transform('5', $this->migrateExecutable, $this->row, 'destinationproperty');
46 public function testProcessBypassesOnNonValue() {
47 $configuration['method'] = 'process';
48 $configuration['value'] = 'sourcevalue';
49 $configuration['not_equals'] = TRUE;
50 $value = (new SkipOnValue($configuration, 'skip_on_value', []))
51 ->transform('sourcevalue', $this->migrateExecutable, $this->row, 'destinationproperty');
52 $this->assertEquals($value, 'sourcevalue');
53 $configuration['value'] = 86;
54 $value = (new SkipOnValue($configuration, 'skip_on_value', []))
55 ->transform('86', $this->migrateExecutable, $this->row, 'destinationproperty');
56 $this->assertEquals($value, '86');
62 public function testProcessSkipsOnMultipleNonValue() {
63 $configuration['method'] = 'process';
64 $configuration['value'] = [1, 1, 2, 3, 5, 8];
65 $value = (new SkipOnValue($configuration, 'skip_on_value', []))
66 ->transform(4, $this->migrateExecutable, $this->row, 'destinationproperty');
67 $this->assertEquals($value, '4');
72 * @expectedException \Drupal\migrate\MigrateSkipRowException
74 public function testRowSkipsOnValue() {
75 $configuration['method'] = 'row';
76 $configuration['value'] = 86;
77 (new SkipOnValue($configuration, 'skip_on_value', []))
78 ->transform('86', $this->migrateExecutable, $this->row, 'destinationproperty');
84 public function testRowBypassesOnNonValue() {
85 $configuration['method'] = 'row';
86 $configuration['value'] = 'sourcevalue';
87 $configuration['not_equals'] = TRUE;
88 $value = (new SkipOnValue($configuration, 'skip_on_value', []))
89 ->transform('sourcevalue', $this->migrateExecutable, $this->row, 'destinationproperty');
90 $this->assertEquals($value, 'sourcevalue');
91 $configuration['value'] = 86;
92 $value = (new SkipOnValue($configuration, 'skip_on_value', []))
93 ->transform('86', $this->migrateExecutable, $this->row, 'destinationproperty');
94 $this->assertEquals($value, 86);
99 * @expectedException \Drupal\migrate\MigrateException
101 public function testRequiredRowConfiguration() {
102 $configuration['method'] = 'row';
103 (new SkipOnValue($configuration, 'skip_on_value', []))
104 ->transform('sourcevalue', $this->migrateExecutable, $this->row, 'destinationproperty');
109 * @expectedException \Drupal\migrate\MigrateException
111 public function testRequiredProcessConfiguration() {
112 $configuration['method'] = 'process';
113 (new SkipOnValue($configuration, 'skip_on_value', []))
114 ->transform('sourcevalue', $this->migrateExecutable, $this->row, 'destinationproperty');