diff --git a/src/Plugin/migrate/process/Dom.php b/src/Plugin/migrate/process/Dom.php index b66a511..20e9b8a 100644 --- a/src/Plugin/migrate/process/Dom.php +++ b/src/Plugin/migrate/process/Dom.php @@ -66,7 +66,7 @@ class Dom extends ProcessPluginBase { $this->idMapLogging = (bool) $this->configuration['warnings_to_idmap']; } if (isset($this->configuration['non_root'])) { - $this->idMapLogging = (bool) $this->configuration['non_root']; + $this->nonRoot = (bool) $this->configuration['non_root']; } } diff --git a/tests/src/Unit/process/DomTest.php b/tests/src/Unit/process/DomTest.php new file mode 100644 index 0000000..cde4609 --- /dev/null +++ b/tests/src/Unit/process/DomTest.php @@ -0,0 +1,65 @@ +A simple paragraph.

'; + $document = (new Dom($configuration, 'dom', [])) + ->transform($value, $this->migrateExecutable, $this->row, 'destinationproperty'); + $this->assertTrue($document instanceof \DOMDocument); + } + + /** + * @covers ::import + */ + public function testImportNonRootInvalidInput() { + $configuration['method'] = 'import'; + $value = [1, 1]; + $this->setExpectedException(MigrateException::class); + (new Dom($configuration, 'dom', [])) + ->transform($value, $this->migrateExecutable, $this->row, 'destinationproperty'); + } + + /** + * @covers ::export + */ + public function testExportNonRoot( ){ + $configuration['method'] = 'export'; + $partial = '

A simple paragraph.

'; + $document = Html::load($partial); + $value = (new Dom($configuration, 'dom', [])) + ->transform($document, $this->migrateExecutable, $this->row, 'destinationproperty'); + $this->assertEquals($value, $partial); + } + + /** + * @covers ::export + */ + public function testExportNonRootInvalidInput( ){ + $configuration['method'] = 'export'; + $partial = '

A simple paragraph.

'; + $this->setExpectedException(MigrateException::class); + $value = (new Dom($configuration, 'dom', [])) + ->transform('string in not DOMDocument', $this->migrateExecutable, $this->row, 'destinationproperty'); + } + +}