class SkipOnEmptyTest
Same name and namespace in other branches
- 11.x core/modules/migrate/tests/src/Unit/process/SkipOnEmptyTest.php \Drupal\Tests\migrate\Unit\process\SkipOnEmptyTest
Tests the skip on empty process plugin.
@group migrate
@coversDefaultClass \Drupal\migrate\Plugin\migrate\process\SkipOnEmpty
Hierarchy
- class \Drupal\Tests\UnitTestCase uses \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\Tests\migrate\Unit\MigrateTestCase implements \Drupal\Tests\UnitTestCase
- class \Drupal\Tests\migrate\Unit\process\MigrateProcessTestCase implements \Drupal\Tests\migrate\Unit\MigrateTestCase
- class \Drupal\Tests\migrate\Unit\process\SkipOnEmptyTest implements \Drupal\Tests\migrate\Unit\process\MigrateProcessTestCase
- class \Drupal\Tests\migrate\Unit\process\MigrateProcessTestCase implements \Drupal\Tests\migrate\Unit\MigrateTestCase
- class \Drupal\Tests\migrate\Unit\MigrateTestCase implements \Drupal\Tests\UnitTestCase
Expanded class hierarchy of SkipOnEmptyTest
File
-
core/
modules/ migrate/ tests/ src/ Unit/ process/ SkipOnEmptyTest.php, line 15
Namespace
Drupal\Tests\migrate\Unit\processView source
class SkipOnEmptyTest extends MigrateProcessTestCase {
/**
* @covers ::process
*/
public function testProcessSkipsOnEmpty() {
$configuration['method'] = 'process';
$this->expectException(MigrateSkipProcessException::class);
(new SkipOnEmpty($configuration, 'skip_on_empty', []))->transform('', $this->migrateExecutable, $this->row, 'destination_property');
}
/**
* @covers ::process
*/
public function testProcessBypassesOnNonEmpty() {
$configuration['method'] = 'process';
$value = (new SkipOnEmpty($configuration, 'skip_on_empty', []))->transform(' ', $this->migrateExecutable, $this->row, 'destination_property');
$this->assertSame(' ', $value);
}
/**
* @covers ::row
*/
public function testRowSkipsOnEmpty() {
$configuration['method'] = 'row';
$this->expectException(MigrateSkipRowException::class);
(new SkipOnEmpty($configuration, 'skip_on_empty', []))->transform('', $this->migrateExecutable, $this->row, 'destination_property');
}
/**
* @covers ::row
*/
public function testRowBypassesOnNonEmpty() {
$configuration['method'] = 'row';
$value = (new SkipOnEmpty($configuration, 'skip_on_empty', []))->transform(' ', $this->migrateExecutable, $this->row, 'destination_property');
$this->assertSame(' ', $value);
}
/**
* Tests that a skip row exception without a message is raised.
*
* @covers ::row
*/
public function testRowSkipWithoutMessage() {
$configuration = [
'method' => 'row',
];
$process = new SkipOnEmpty($configuration, 'skip_on_empty', []);
$this->expectException(MigrateSkipRowException::class);
$process->transform('', $this->migrateExecutable, $this->row, 'destination_property');
}
/**
* Tests that a skip row exception with a message is raised.
*
* @covers ::row
*/
public function testRowSkipWithMessage() {
$configuration = [
'method' => 'row',
'message' => 'The value is empty',
];
$process = new SkipOnEmpty($configuration, 'skip_on_empty', []);
$this->expectException(MigrateSkipRowException::class);
$this->expectExceptionMessage('The value is empty');
$process->transform('', $this->migrateExecutable, $this->row, 'destination_property');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.