update drupal
This commit is contained in:
+2
-2
@@ -21,8 +21,8 @@ function migrate_prepare_row_test_migrate_prepare_row(Row $row, MigrateSourceInt
|
||||
// Record mapping but don't record a message.
|
||||
throw new MigrateSkipRowException('', TRUE);
|
||||
}
|
||||
elseif ($data == 'skip_and_dont_record') {
|
||||
elseif ($data == 'skip_and_do_not_record') {
|
||||
// Don't record mapping but record a message.
|
||||
throw new MigrateSkipRowException('skip_and_dont_record message', FALSE);
|
||||
throw new MigrateSkipRowException('skip_and_do_not_record message', FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ class TestSkipRowProcess extends ProcessPluginBase {
|
||||
if ($data == 'skip_and_record (use plugin)') {
|
||||
throw new MigrateSkipRowException('', TRUE);
|
||||
}
|
||||
elseif ($data == 'skip_and_dont_record (use plugin)') {
|
||||
elseif ($data == 'skip_and_do_not_record (use plugin)') {
|
||||
throw new MigrateSkipRowException('', FALSE);
|
||||
}
|
||||
return $value;
|
||||
|
||||
@@ -33,7 +33,7 @@ class MigrateSkipRowTest extends KernelTestBase {
|
||||
'plugin' => 'embedded_data',
|
||||
'data_rows' => [
|
||||
['id' => '1', 'data' => 'skip_and_record'],
|
||||
['id' => '2', 'data' => 'skip_and_dont_record'],
|
||||
['id' => '2', 'data' => 'skip_and_do_not_record'],
|
||||
],
|
||||
'ids' => [
|
||||
'id' => ['type' => 'string'],
|
||||
@@ -69,7 +69,7 @@ class MigrateSkipRowTest extends KernelTestBase {
|
||||
$messages = $id_map_plugin->getMessages(['id' => 2])->fetchAll();
|
||||
$this->assertCount(1, $messages);
|
||||
$message = reset($messages);
|
||||
$this->assertEquals('skip_and_dont_record message', $message->message);
|
||||
$this->assertEquals('skip_and_do_not_record message', $message->message);
|
||||
$this->assertEquals(MigrationInterface::MESSAGE_INFORMATIONAL, $message->level);
|
||||
|
||||
// Insert a custom processor in the process flow.
|
||||
@@ -80,7 +80,7 @@ class MigrateSkipRowTest extends KernelTestBase {
|
||||
// Change data to avoid triggering again hook_migrate_prepare_row().
|
||||
$definition['source']['data_rows'] = [
|
||||
['id' => '1', 'data' => 'skip_and_record (use plugin)'],
|
||||
['id' => '2', 'data' => 'skip_and_dont_record (use plugin)'],
|
||||
['id' => '2', 'data' => 'skip_and_do_not_record (use plugin)'],
|
||||
];
|
||||
$migration = \Drupal::service('plugin.manager.migration')->createStubMigration($definition);
|
||||
|
||||
|
||||
@@ -267,7 +267,7 @@ class RouteTest extends KernelTestBase {
|
||||
$executable = $this->prophesize(MigrateExecutableInterface::class)->reveal();
|
||||
|
||||
$plugin = new Route([], 'route', [], $migration, $pathValidator);
|
||||
$actual = $plugin->transform($value, $executable, $row, 'destinationproperty');
|
||||
$actual = $plugin->transform($value, $executable, $row, 'destination_property');
|
||||
return $actual;
|
||||
}
|
||||
|
||||
|
||||
@@ -66,12 +66,16 @@ class MigrateExecutableTest extends MigrateTestCase {
|
||||
$source->expects($this->once())
|
||||
->method('rewind')
|
||||
->will($this->throwException(new \Exception($exception_message)));
|
||||
// The exception message contains the line number where it is thrown. Save
|
||||
// it for the testing the exception message.
|
||||
$line = (__LINE__) - 3;
|
||||
|
||||
$this->migration->expects($this->any())
|
||||
->method('getSourcePlugin')
|
||||
->will($this->returnValue($source));
|
||||
|
||||
// Ensure that a message with the proper message was added.
|
||||
$exception_message .= " in " . __FILE__ . " line $line";
|
||||
$this->message->expects($this->once())
|
||||
->method('display')
|
||||
->with("Migration failed with source plugin exception: " . Html::escape($exception_message));
|
||||
|
||||
@@ -405,15 +405,15 @@ class RowTest extends UnitTestCase {
|
||||
'destination_value_3',
|
||||
],
|
||||
],
|
||||
'Mix of keys including non-existant' => [
|
||||
'Mix of keys including non-existent' => [
|
||||
'keys' => [
|
||||
'shared_key_1',
|
||||
'@shared_key_1',
|
||||
'@@shared_key_2',
|
||||
'@@@shared_key_2',
|
||||
'@@@@@@@@@shared_key_3',
|
||||
'non_existant_source_key',
|
||||
'@non_existant_destination_key',
|
||||
'non_existent_source_key',
|
||||
'@non_existent_destination_key',
|
||||
],
|
||||
'values' => [
|
||||
'source_shared_value_1',
|
||||
|
||||
@@ -35,7 +35,7 @@ class ArrayBuildTest extends MigrateProcessTestCase {
|
||||
'Foo' => 'Bar',
|
||||
'foo bar' => 'bar foo',
|
||||
];
|
||||
$value = $this->plugin->transform($source, $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$value = $this->plugin->transform($source, $this->migrateExecutable, $this->row, 'destination_property');
|
||||
$this->assertSame($value, $expected);
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ class ArrayBuildTest extends MigrateProcessTestCase {
|
||||
];
|
||||
$this->expectException(MigrateException::class);
|
||||
$this->expectExceptionMessage("The key 'foo' does not exist");
|
||||
$this->plugin->transform($source, $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$this->plugin->transform($source, $this->migrateExecutable, $this->row, 'destination_property');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,7 +60,7 @@ class ArrayBuildTest extends MigrateProcessTestCase {
|
||||
];
|
||||
$this->expectException(MigrateException::class);
|
||||
$this->expectExceptionMessage("The key 'bar' does not exist");
|
||||
$this->plugin->transform($source, $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$this->plugin->transform($source, $this->migrateExecutable, $this->row, 'destination_property');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -70,7 +70,7 @@ class ArrayBuildTest extends MigrateProcessTestCase {
|
||||
$source = ['foo' => 'bar'];
|
||||
$this->expectException(MigrateException::class);
|
||||
$this->expectExceptionMessage('The input should be an array of arrays');
|
||||
$this->plugin->transform($source, $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$this->plugin->transform($source, $this->migrateExecutable, $this->row, 'destination_property');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,7 +80,7 @@ class ArrayBuildTest extends MigrateProcessTestCase {
|
||||
$source = 'foo';
|
||||
$this->expectException(MigrateException::class);
|
||||
$this->expectExceptionMessage('The input should be an array of arrays');
|
||||
$this->plugin->transform($source, $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$this->plugin->transform($source, $this->migrateExecutable, $this->row, 'destination_property');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ class CallbackTest extends MigrateProcessTestCase {
|
||||
public function testCallback($callable) {
|
||||
$configuration = ['callable' => $callable];
|
||||
$this->plugin = new Callback($configuration, 'map', []);
|
||||
$value = $this->plugin->transform('FooBar', $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$value = $this->plugin->transform('FooBar', $this->migrateExecutable, $this->row, 'destination_property');
|
||||
$this->assertSame('foobar', $value);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ class ConcatTest extends MigrateProcessTestCase {
|
||||
* Test concat works without a delimiter.
|
||||
*/
|
||||
public function testConcatWithoutDelimiter() {
|
||||
$value = $this->plugin->transform(['foo', 'bar'], $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$value = $this->plugin->transform(['foo', 'bar'], $this->migrateExecutable, $this->row, 'destination_property');
|
||||
$this->assertSame('foobar', $value);
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ class ConcatTest extends MigrateProcessTestCase {
|
||||
*/
|
||||
public function testConcatWithNonArray() {
|
||||
$this->expectException(MigrateException::class);
|
||||
$this->plugin->transform('foo', $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$this->plugin->transform('foo', $this->migrateExecutable, $this->row, 'destination_property');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,7 +46,7 @@ class ConcatTest extends MigrateProcessTestCase {
|
||||
*/
|
||||
public function testConcatWithDelimiter() {
|
||||
$this->plugin->setDelimiter('_');
|
||||
$value = $this->plugin->transform(['foo', 'bar'], $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$value = $this->plugin->transform(['foo', 'bar'], $this->migrateExecutable, $this->row, 'destination_property');
|
||||
$this->assertSame('foo_bar', $value);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ class DefaultValueTest extends MigrateProcessTestCase {
|
||||
*/
|
||||
public function testDefaultValue($configuration, $expected_value, $value) {
|
||||
$process = new DefaultValue($configuration, 'default_value', []);
|
||||
$value = $process->transform($value, $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$value = $process->transform($value, $this->migrateExecutable, $this->row, 'destination_property');
|
||||
$this->assertSame($expected_value, $value);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ class ExplodeTest extends MigrateProcessTestCase {
|
||||
* Test explode transform process works.
|
||||
*/
|
||||
public function testTransform() {
|
||||
$value = $this->plugin->transform('foo,bar,tik', $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$value = $this->plugin->transform('foo,bar,tik', $this->migrateExecutable, $this->row, 'destination_property');
|
||||
$this->assertSame(['foo', 'bar', 'tik'], $value);
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ class ExplodeTest extends MigrateProcessTestCase {
|
||||
*/
|
||||
public function testTransformLimit() {
|
||||
$plugin = new Explode(['delimiter' => '_', 'limit' => 2], 'map', []);
|
||||
$value = $plugin->transform('foo_bar_tik', $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$value = $plugin->transform('foo_bar_tik', $this->migrateExecutable, $this->row, 'destination_property');
|
||||
$this->assertSame(['foo', 'bar_tik'], $value);
|
||||
}
|
||||
|
||||
@@ -45,10 +45,10 @@ class ExplodeTest extends MigrateProcessTestCase {
|
||||
* Test if the explode process can be chained with a handles_multiple process.
|
||||
*/
|
||||
public function testChainedTransform() {
|
||||
$exploded = $this->plugin->transform('foo,bar,tik', $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$exploded = $this->plugin->transform('foo,bar,tik', $this->migrateExecutable, $this->row, 'destination_property');
|
||||
|
||||
$concat = new Concat([], 'map', []);
|
||||
$concatenated = $concat->transform($exploded, $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$concatenated = $concat->transform($exploded, $this->migrateExecutable, $this->row, 'destination_property');
|
||||
$this->assertSame('foobartik', $concatenated);
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ class ExplodeTest extends MigrateProcessTestCase {
|
||||
public function testExplodeWithNonString() {
|
||||
$this->expectException(MigrateException::class);
|
||||
$this->expectExceptionMessage('is not a string');
|
||||
$this->plugin->transform(['foo'], $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$this->plugin->transform(['foo'], $this->migrateExecutable, $this->row, 'destination_property');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,7 +69,7 @@ class ExplodeTest extends MigrateProcessTestCase {
|
||||
public function testExplodeWithNonStrictAndEmptySource($value, $expected) {
|
||||
$plugin = new Explode(['delimiter' => '|', 'strict' => FALSE], 'map', []);
|
||||
|
||||
$processed = $plugin->transform($value, $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$processed = $plugin->transform($value, $this->migrateExecutable, $this->row, 'destination_property');
|
||||
$this->assertSame($expected, $processed);
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ class ExplodeTest extends MigrateProcessTestCase {
|
||||
$plugin = new Explode(['delimiter' => '|', 'strict' => FALSE], 'map', []);
|
||||
$this->expectException(MigrateException::class);
|
||||
$this->expectExceptionMessage('cannot be casted to a string');
|
||||
$processed = $plugin->transform(['foo'], $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$processed = $plugin->transform(['foo'], $this->migrateExecutable, $this->row, 'destination_property');
|
||||
$this->assertSame(['foo'], $processed);
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ class ExplodeTest extends MigrateProcessTestCase {
|
||||
*/
|
||||
public function testExplodeWithStrictAndEmptyString() {
|
||||
$plugin = new Explode(['delimiter' => '|'], 'map', []);
|
||||
$processed = $plugin->transform('', $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$processed = $plugin->transform('', $this->migrateExecutable, $this->row, 'destination_property');
|
||||
$this->assertSame([''], $processed);
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ class ExplodeTest extends MigrateProcessTestCase {
|
||||
$this->expectException(MigrateException::class);
|
||||
$this->expectExceptionMessage('delimiter is empty');
|
||||
$plugin = new Explode(['delimiter' => ''], 'map', []);
|
||||
$plugin->transform('foo,bar', $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$plugin->transform('foo,bar', $this->migrateExecutable, $this->row, 'destination_property');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ class ExtractTest extends MigrateProcessTestCase {
|
||||
* Tests successful extraction.
|
||||
*/
|
||||
public function testExtract() {
|
||||
$value = $this->plugin->transform(['foo' => 'bar'], $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$value = $this->plugin->transform(['foo' => 'bar'], $this->migrateExecutable, $this->row, 'destination_property');
|
||||
$this->assertSame('bar', $value);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class ExtractTest extends MigrateProcessTestCase {
|
||||
public function testExtractFromString() {
|
||||
$this->expectException(MigrateException::class);
|
||||
$this->expectExceptionMessage('Input should be an array.');
|
||||
$this->plugin->transform('bar', $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$this->plugin->transform('bar', $this->migrateExecutable, $this->row, 'destination_property');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -43,7 +43,7 @@ class ExtractTest extends MigrateProcessTestCase {
|
||||
public function testExtractFail() {
|
||||
$this->expectException(MigrateException::class);
|
||||
$this->expectExceptionMessage('Array index missing, extraction failed.');
|
||||
$this->plugin->transform(['bar' => 'foo'], $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$this->plugin->transform(['bar' => 'foo'], $this->migrateExecutable, $this->row, 'destination_property');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,7 +51,7 @@ class ExtractTest extends MigrateProcessTestCase {
|
||||
*/
|
||||
public function testExtractFailDefault() {
|
||||
$plugin = new Extract(['index' => ['foo'], 'default' => 'test'], 'map', []);
|
||||
$value = $plugin->transform(['bar' => 'foo'], $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$value = $plugin->transform(['bar' => 'foo'], $this->migrateExecutable, $this->row, 'destination_property');
|
||||
$this->assertSame('test', $value, '');
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ class FlattenTest extends MigrateProcessTestCase {
|
||||
*/
|
||||
public function testFlatten() {
|
||||
$plugin = new Flatten([], 'flatten', []);
|
||||
$flattened = $plugin->transform([1, 2, [3, 4, [5]], [], [7, 8]], $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$flattened = $plugin->transform([1, 2, [3, 4, [5]], [], [7, 8]], $this->migrateExecutable, $this->row, 'destination_property');
|
||||
$this->assertSame([1, 2, 3, 4, 5, 7, 8], $flattened);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ class GetTest extends MigrateProcessTestCase {
|
||||
->with('test')
|
||||
->will($this->returnValue('source_value'));
|
||||
$this->plugin = new Get(['source' => 'test'], '', []);
|
||||
$value = $this->plugin->transform(NULL, $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$value = $this->plugin->transform(NULL, $this->migrateExecutable, $this->row, 'destination_property');
|
||||
$this->assertSame('source_value', $value);
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ class GetTest extends MigrateProcessTestCase {
|
||||
->will($this->returnCallback(function ($argument) use ($map) {
|
||||
return $map[$argument];
|
||||
}));
|
||||
$value = $this->plugin->transform(NULL, $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$value = $this->plugin->transform(NULL, $this->migrateExecutable, $this->row, 'destination_property');
|
||||
$this->assertSame(['source_value1', 'source_value2'], $value);
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ class GetTest extends MigrateProcessTestCase {
|
||||
->with('@@test')
|
||||
->will($this->returnValue('source_value'));
|
||||
$this->plugin = new Get(['source' => '@@test'], '', []);
|
||||
$value = $this->plugin->transform(NULL, $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$value = $this->plugin->transform(NULL, $this->migrateExecutable, $this->row, 'destination_property');
|
||||
$this->assertSame('source_value', $value);
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ class GetTest extends MigrateProcessTestCase {
|
||||
->will($this->returnCallback(function ($argument) use ($map) {
|
||||
return $map[$argument];
|
||||
}));
|
||||
$value = $this->plugin->transform(NULL, $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$value = $this->plugin->transform(NULL, $this->migrateExecutable, $this->row, 'destination_property');
|
||||
$this->assertSame(['source_value1', 'source_value2', 'source_value3', 'source_value4'], $value);
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ class GetTest extends MigrateProcessTestCase {
|
||||
->willReturnOnConsecutiveCalls('val1', 'val2');
|
||||
|
||||
$this->plugin = new Get(['source' => $source], '', []);
|
||||
$return = $this->plugin->transform(NULL, $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$return = $this->plugin->transform(NULL, $this->migrateExecutable, $this->row, 'destination_property');
|
||||
$this->assertSame($expected_value, $return);
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ class MachineNameTest extends MigrateProcessTestCase {
|
||||
->will($this->returnValue($human_name_ascii . 'aeo'));
|
||||
|
||||
$plugin = new MachineName([], 'machine_name', [], $this->transliteration);
|
||||
$value = $plugin->transform($human_name, $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$value = $plugin->transform($human_name, $this->migrateExecutable, $this->row, 'destination_property');
|
||||
$this->assertEquals($expected_result, $value);
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ class MenuLinkParentTest extends MigrateProcessTestCase {
|
||||
$plugin = new MenuLinkParent([], 'map', [], $this->migrateLookup->reveal(), $this->menuLinkManager->reveal(), $this->menuLinkStorage->reveal(), $this->migration->reveal());
|
||||
$this->expectException(MigrateSkipRowException::class);
|
||||
$this->expectExceptionMessage("No parent link found for plid '1' in menu 'admin'.");
|
||||
$plugin->transform([1, 'admin', NULL], $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$plugin->transform([1, 'admin', NULL], $this->migrateExecutable, $this->row, 'destination_property');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,7 +92,7 @@ class MenuLinkParentTest extends MigrateProcessTestCase {
|
||||
$this->menuLinkManager->createInstance('menu_link_content:fe151460-dfa2-4133-8864-c1746f28ab27')->willReturn($plugin->reveal());
|
||||
$plugin = new MenuLinkParent([], 'map', [], $this->migrateLookup->reveal(), $this->menuLinkManager->reveal(), $this->menuLinkStorage->reveal(), $this->migration->reveal());
|
||||
|
||||
$result = $plugin->transform([1, 'admin', 'http://example.com'], $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$result = $plugin->transform([1, 'admin', 'http://example.com'], $this->migrateExecutable, $this->row, 'destination_property');
|
||||
$this->assertEquals('menu_link_content:fe151460-dfa2-4133-8864-c1746f28ab27', $result);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ class NullCoalesceTest extends MigrateProcessTestCase {
|
||||
*/
|
||||
public function testExceptionOnInvalidValue() {
|
||||
$this->expectException(MigrateException::class);
|
||||
(new NullCoalesce([], 'null_coalesce', []))->transform('invalid', $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
(new NullCoalesce([], 'null_coalesce', []))->transform('invalid', $this->migrateExecutable, $this->row, 'destination_property');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,7 +40,7 @@ class NullCoalesceTest extends MigrateProcessTestCase {
|
||||
*/
|
||||
public function testTransform(array $source, $expected_result) {
|
||||
$plugin = new NullCoalesce([], 'null_coalesce', []);
|
||||
$result = $plugin->transform($source, $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$result = $plugin->transform($source, $this->migrateExecutable, $this->row, 'destination_property');
|
||||
$this->assertSame($expected_result, $result);
|
||||
}
|
||||
|
||||
@@ -83,10 +83,10 @@ class NullCoalesceTest extends MigrateProcessTestCase {
|
||||
*/
|
||||
public function testTransformWithDefault() {
|
||||
$plugin = new NullCoalesce(['default_value' => 'default'], 'null_coalesce', []);
|
||||
$result = $plugin->transform([NULL, NULL, 'Test', 'Test 2'], $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$result = $plugin->transform([NULL, NULL, 'Test', 'Test 2'], $this->migrateExecutable, $this->row, 'destination_property');
|
||||
$this->assertSame('Test', $result);
|
||||
|
||||
$this->assertSame('default', $plugin->transform([NULL, NULL], $this->migrateExecutable, $this->row, 'destinationproperty'));
|
||||
$this->assertSame('default', $plugin->transform([NULL, NULL], $this->migrateExecutable, $this->row, 'destination_property'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ class SkipOnEmptyTest extends MigrateProcessTestCase {
|
||||
$configuration['method'] = 'process';
|
||||
$this->expectException(MigrateSkipProcessException::class);
|
||||
(new SkipOnEmpty($configuration, 'skip_on_empty', []))
|
||||
->transform('', $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
->transform('', $this->migrateExecutable, $this->row, 'destination_property');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -30,7 +30,7 @@ class SkipOnEmptyTest extends MigrateProcessTestCase {
|
||||
public function testProcessBypassesOnNonEmpty() {
|
||||
$configuration['method'] = 'process';
|
||||
$value = (new SkipOnEmpty($configuration, 'skip_on_empty', []))
|
||||
->transform(' ', $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
->transform(' ', $this->migrateExecutable, $this->row, 'destination_property');
|
||||
$this->assertSame(' ', $value);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ class SkipOnEmptyTest extends MigrateProcessTestCase {
|
||||
$configuration['method'] = 'row';
|
||||
$this->expectException(MigrateSkipRowException::class);
|
||||
(new SkipOnEmpty($configuration, 'skip_on_empty', []))
|
||||
->transform('', $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
->transform('', $this->migrateExecutable, $this->row, 'destination_property');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,7 +50,7 @@ class SkipOnEmptyTest extends MigrateProcessTestCase {
|
||||
public function testRowBypassesOnNonEmpty() {
|
||||
$configuration['method'] = 'row';
|
||||
$value = (new SkipOnEmpty($configuration, 'skip_on_empty', []))
|
||||
->transform(' ', $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
->transform(' ', $this->migrateExecutable, $this->row, 'destination_property');
|
||||
$this->assertSame(' ', $value);
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ class SkipOnEmptyTest extends MigrateProcessTestCase {
|
||||
];
|
||||
$process = new SkipOnEmpty($configuration, 'skip_on_empty', []);
|
||||
$this->expectException(MigrateSkipRowException::class);
|
||||
$process->transform('', $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$process->transform('', $this->migrateExecutable, $this->row, 'destination_property');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,7 +81,7 @@ class SkipOnEmptyTest extends MigrateProcessTestCase {
|
||||
$process = new SkipOnEmpty($configuration, 'skip_on_empty', []);
|
||||
$this->expectException(MigrateSkipRowException::class);
|
||||
$this->expectExceptionMessage('The value is empty');
|
||||
$process->transform('', $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$process->transform('', $this->migrateExecutable, $this->row, 'destination_property');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ class SkipRowIfNotSetTest extends MigrateProcessTestCase {
|
||||
];
|
||||
$process = new SkipRowIfNotSet($configuration, 'skip_row_if_not_set', []);
|
||||
$this->expectException(MigrateSkipRowException::class);
|
||||
$process->transform('', $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$process->transform('', $this->migrateExecutable, $this->row, 'destination_property');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,7 +40,7 @@ class SkipRowIfNotSetTest extends MigrateProcessTestCase {
|
||||
$process = new SkipRowIfNotSet($configuration, 'skip_row_if_not_set', []);
|
||||
$this->expectException(MigrateSkipRowException::class);
|
||||
$this->expectExceptionMessage("The 'some_key' key is not set");
|
||||
$process->transform('', $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$process->transform('', $this->migrateExecutable, $this->row, 'destination_property');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ class StaticMapTest extends MigrateProcessTestCase {
|
||||
* Tests map when the source is a string.
|
||||
*/
|
||||
public function testMapWithSourceString() {
|
||||
$value = $this->plugin->transform('foo', $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$value = $this->plugin->transform('foo', $this->migrateExecutable, $this->row, 'destination_property');
|
||||
$this->assertSame(['bar' => 'baz'], $value);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ class StaticMapTest extends MigrateProcessTestCase {
|
||||
* Tests map when the source is a list.
|
||||
*/
|
||||
public function testMapWithSourceList() {
|
||||
$value = $this->plugin->transform(['foo', 'bar'], $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$value = $this->plugin->transform(['foo', 'bar'], $this->migrateExecutable, $this->row, 'destination_property');
|
||||
$this->assertSame('baz', $value);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ class StaticMapTest extends MigrateProcessTestCase {
|
||||
*/
|
||||
public function testMapwithEmptySource() {
|
||||
$this->expectException(MigrateException::class);
|
||||
$this->plugin->transform([], $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$this->plugin->transform([], $this->migrateExecutable, $this->row, 'destination_property');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,8 +52,8 @@ class StaticMapTest extends MigrateProcessTestCase {
|
||||
*/
|
||||
public function testMapwithInvalidSource() {
|
||||
$this->expectException(MigrateSkipRowException::class);
|
||||
$this->expectExceptionMessage(sprintf("No static mapping found for '%s' and no default value provided for destination '%s'.", Variable::export(['bar']), 'destinationproperty'));
|
||||
$this->plugin->transform(['bar'], $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$this->expectExceptionMessage(sprintf("No static mapping found for '%s' and no default value provided for destination '%s'.", Variable::export(['bar']), 'destination_property'));
|
||||
$this->plugin->transform(['bar'], $this->migrateExecutable, $this->row, 'destination_property');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,7 +63,7 @@ class StaticMapTest extends MigrateProcessTestCase {
|
||||
$configuration['map']['foo']['bar'] = 'baz';
|
||||
$configuration['default_value'] = 'test';
|
||||
$this->plugin = new StaticMap($configuration, 'map', []);
|
||||
$value = $this->plugin->transform(['bar'], $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$value = $this->plugin->transform(['bar'], $this->migrateExecutable, $this->row, 'destination_property');
|
||||
$this->assertSame('test', $value);
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ class StaticMapTest extends MigrateProcessTestCase {
|
||||
$configuration['map']['foo']['bar'] = 'baz';
|
||||
$configuration['default_value'] = NULL;
|
||||
$this->plugin = new StaticMap($configuration, 'map', []);
|
||||
$value = $this->plugin->transform(['bar'], $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$value = $this->plugin->transform(['bar'], $this->migrateExecutable, $this->row, 'destination_property');
|
||||
$this->assertNull($value);
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ class StaticMapTest extends MigrateProcessTestCase {
|
||||
$this->plugin = new StaticMap($configuration, 'map', []);
|
||||
$this->expectException(MigrateException::class);
|
||||
$this->expectExceptionMessage('Setting both default_value and bypass is invalid.');
|
||||
$this->plugin->transform(['bar'], $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$this->plugin->transform(['bar'], $this->migrateExecutable, $this->row, 'destination_property');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -125,4 +125,73 @@ class SubProcessTest extends MigrateTestCase {
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the sub_process process plugin.
|
||||
*
|
||||
* @dataProvider providerTestNotFoundSubProcess
|
||||
*/
|
||||
public function testNotFoundSubProcess($process_configuration, $source_values = []) {
|
||||
$migration = $this->getMigration();
|
||||
// Set up the properties for the sub_process.
|
||||
$plugin = new SubProcess($process_configuration, 'sub_process', []);
|
||||
// Manually create the plugins. Migration::getProcessPlugins does this
|
||||
// normally but the plugin system is not available.
|
||||
foreach ($process_configuration['process'] as $destination => $source) {
|
||||
$sub_process_plugins[$destination][] = new Get(['source' => $source], 'get', []);
|
||||
}
|
||||
$migration->expects($this->at(1))
|
||||
->method('getProcessPlugins')
|
||||
->willReturn($sub_process_plugins);
|
||||
// Set up the key plugins.
|
||||
if (array_key_exists('key', $process_configuration)) {
|
||||
$key_plugin['key'][] = new Get(['source' => '@id'], 'get', []);
|
||||
$migration->expects($this->at(2))
|
||||
->method('getProcessPlugins')
|
||||
->will($this->returnValue($key_plugin));
|
||||
}
|
||||
$event_dispatcher = $this->createMock(EventDispatcherInterface::class);
|
||||
$migrate_executable = new MigrateExecutable($migration, $this->createMock(MigrateMessageInterface::class), $event_dispatcher);
|
||||
|
||||
// The current value of the pipeline.
|
||||
$current_value = [
|
||||
[
|
||||
'source_foo' => 'test',
|
||||
'source_id' => NULL,
|
||||
] + $source_values,
|
||||
];
|
||||
// This is not used but the interface requires it, so create an empty row.
|
||||
$row = new Row($source_values);
|
||||
|
||||
// After transformation, check to make sure that source_foo and source_id's
|
||||
// values ended up in the proper destinations, and that the value of the
|
||||
// key (@id) is the same as the destination ID (42).
|
||||
$new_value = $plugin->transform($current_value, $migrate_executable, $row, 'test');
|
||||
$this->assertArrayEquals([], $new_value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testNotFoundSubProcess().
|
||||
*/
|
||||
public function providerTestNotFoundSubProcess() {
|
||||
return [
|
||||
'no key' => [
|
||||
'process configuration' => [
|
||||
'process' => [
|
||||
'foo' => 'source_foo',
|
||||
],
|
||||
'key' => '@id',
|
||||
],
|
||||
],
|
||||
'lookup returns NULL' => [
|
||||
'process configuration' => [
|
||||
'process' => [
|
||||
'foo' => 'source_foo',
|
||||
'id' => 'source_id',
|
||||
],
|
||||
'key' => '@id',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ class SubstrTest extends MigrateProcessTestCase {
|
||||
$configuration['start'] = $start;
|
||||
$configuration['length'] = $length;
|
||||
$this->plugin = new Substr($configuration, 'map', []);
|
||||
$value = $this->plugin->transform('Captain Janeway', $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$value = $this->plugin->transform('Captain Janeway', $this->migrateExecutable, $this->row, 'destination_property');
|
||||
$this->assertSame($expected, $value);
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ class SubstrTest extends MigrateProcessTestCase {
|
||||
$this->plugin = new Substr($configuration, 'map', []);
|
||||
$this->expectException(MigrateException::class);
|
||||
$this->expectExceptionMessage('The input value must be a string.');
|
||||
$this->plugin->transform(['Captain Janeway'], $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$this->plugin->transform(['Captain Janeway'], $this->migrateExecutable, $this->row, 'destination_property');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,7 +73,7 @@ class SubstrTest extends MigrateProcessTestCase {
|
||||
$this->plugin = new Substr($configuration, 'map', []);
|
||||
$this->expectException(MigrateException::class);
|
||||
$this->expectExceptionMessage('The start position configuration value should be an integer. Omit this key to capture from the beginning of the string.');
|
||||
$this->plugin->transform(['foo'], $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$this->plugin->transform(['foo'], $this->migrateExecutable, $this->row, 'destination_property');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,7 +84,7 @@ class SubstrTest extends MigrateProcessTestCase {
|
||||
$this->plugin = new Substr($configuration, 'map', []);
|
||||
$this->expectException(MigrateException::class);
|
||||
$this->expectExceptionMessage('The character length configuration value should be an integer. Omit this key to capture from the start position to the end of the string.');
|
||||
$this->plugin->transform(['foo'], $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$this->plugin->transform(['foo'], $this->migrateExecutable, $this->row, 'destination_property');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user