Skip to content
Snippets Groups Projects
Commit 4fb94a8f authored by Nazar Velychenko's avatar Nazar Velychenko Committed by Ivan Doroshenko
Browse files

Issue #3261275 by Matroskeen: Throw consistent exceptions on...

Issue #3261275 by Matroskeen: Throw consistent exceptions on \Drupal\migrate_plus\Plugin\migrate\process\SkipOnValue process plugin 
parent f522823e
No related branches found
No related tags found
1 merge request!37Issue #3261275: Throw consistent exceptions on \Drupal\migrate_plus\Plugin\migrate\process\SkipOnValue process plugin
......@@ -61,11 +61,18 @@ class SkipOnValue extends ProcessPluginBase {
/**
* {@inheritdoc}
*/
public function row($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
if (empty($this->configuration['value']) && !array_key_exists('value', $this->configuration)) {
throw new MigrateException('Skip on value plugin is missing value configuration.');
public function __construct(array $configuration, $plugin_id, $plugin_definition) {
if (empty($configuration['value']) && !array_key_exists('value', $configuration)) {
throw new \InvalidArgumentException('Skip on value plugin is missing value configuration.');
}
parent::__construct($configuration, $plugin_id, $plugin_definition);
}
/**
* {@inheritdoc}
*/
public function row($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
if (is_array($this->configuration['value'])) {
$value_in_array = FALSE;
$not_equals = isset($this->configuration['not_equals']);
......@@ -89,10 +96,6 @@ class SkipOnValue extends ProcessPluginBase {
* {@inheritdoc}
*/
public function process($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
if (empty($this->configuration['value']) && !array_key_exists('value', $this->configuration)) {
throw new MigrateException('Skip on value plugin is missing value configuration.');
}
if (is_array($this->configuration['value'])) {
$value_in_array = FALSE;
$not_equals = isset($this->configuration['not_equals']);
......
......@@ -123,23 +123,14 @@ class SkipOnValueTest extends MigrateProcessTestCase {
}
/**
* @covers ::row
* @covers ::__construct
*/
public function testRequiredRowConfiguration(): void {
public function testRequiredConfiguration() {
// It doesn't meter which method we will put here, because it should throw
// error on contraction of Plugin.
$configuration['method'] = 'row';
$this->expectException(MigrateException::class);
(new SkipOnValue($configuration, 'skip_on_value', []))
->transform('sourcevalue', $this->migrateExecutable, $this->row, 'destinationproperty');
}
/**
* @covers ::process
*/
public function testRequiredProcessConfiguration(): void {
$configuration['method'] = 'process';
$this->expectException(MigrateException::class);
(new SkipOnValue($configuration, 'skip_on_value', []))
->transform('sourcevalue', $this->migrateExecutable, $this->row, 'destinationproperty');
$this->expectException(\InvalidArgumentException::class);
(new SkipOnValue($configuration, 'skip_on_value', []));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment