3 namespace Drupal\Tests\migrate\Unit\process;
5 use Drupal\migrate\MigrateSkipProcessException;
6 use Drupal\migrate\MigrateSkipRowException;
7 use Drupal\migrate\Plugin\migrate\process\SkipOnEmpty;
10 * Tests the skip on empty process plugin.
13 * @coversDefaultClass \Drupal\migrate\Plugin\migrate\process\SkipOnEmpty
15 class SkipOnEmptyTest extends MigrateProcessTestCase {
20 public function testProcessSkipsOnEmpty() {
21 $configuration['method'] = 'process';
22 $this->setExpectedException(MigrateSkipProcessException::class);
23 (new SkipOnEmpty($configuration, 'skip_on_empty', []))
24 ->transform('', $this->migrateExecutable, $this->row, 'destinationproperty');
30 public function testProcessBypassesOnNonEmpty() {
31 $configuration['method'] = 'process';
32 $value = (new SkipOnEmpty($configuration, 'skip_on_empty', []))
33 ->transform(' ', $this->migrateExecutable, $this->row, 'destinationproperty');
34 $this->assertSame($value, ' ');
40 public function testRowSkipsOnEmpty() {
41 $configuration['method'] = 'row';
42 $this->setExpectedException(MigrateSkipRowException::class);
43 (new SkipOnEmpty($configuration, 'skip_on_empty', []))
44 ->transform('', $this->migrateExecutable, $this->row, 'destinationproperty');
50 public function testRowBypassesOnNonEmpty() {
51 $configuration['method'] = 'row';
52 $value = (new SkipOnEmpty($configuration, 'skip_on_empty', []))
53 ->transform(' ', $this->migrateExecutable, $this->row, 'destinationproperty');
54 $this->assertSame($value, ' ');
58 * Tests that a skip row exception without a message is raised.
62 public function testRowSkipWithoutMessage() {
66 $process = new SkipOnEmpty($configuration, 'skip_on_empty', []);
67 $this->setExpectedException(MigrateSkipRowException::class);
68 $process->transform('', $this->migrateExecutable, $this->row, 'destinationproperty');
72 * Tests that a skip row exception with a message is raised.
76 public function testRowSkipWithMessage() {
79 'message' => 'The value is empty',
81 $process = new SkipOnEmpty($configuration, 'skip_on_empty', []);
82 $this->setExpectedException(MigrateSkipRowException::class, 'The value is empty');
83 $process->transform('', $this->migrateExecutable, $this->row, 'destinationproperty');