function LogTest::testLog
Same name in this branch
- 9 core/modules/migrate/tests/src/Unit/process/LogTest.php \Drupal\Tests\migrate\Unit\process\LogTest::testLog()
Same name in other branches
- 8.9.x core/modules/migrate/tests/src/Kernel/Plugin/LogTest.php \Drupal\Tests\migrate\Kernel\Plugin\LogTest::testLog()
- 10 core/modules/migrate/tests/src/Unit/process/LogTest.php \Drupal\Tests\migrate\Unit\process\LogTest::testLog()
- 10 core/modules/migrate/tests/src/Kernel/Plugin/LogTest.php \Drupal\Tests\migrate\Kernel\Plugin\LogTest::testLog()
- 11.x core/modules/migrate/tests/src/Unit/process/LogTest.php \Drupal\Tests\migrate\Unit\process\LogTest::testLog()
- 11.x core/modules/migrate/tests/src/Kernel/Plugin/LogTest.php \Drupal\Tests\migrate\Kernel\Plugin\LogTest::testLog()
Tests the Log plugin.
File
-
core/
modules/ migrate/ tests/ src/ Kernel/ Plugin/ LogTest.php, line 70
Class
- LogTest
- Tests the Log process plugin.
Namespace
Drupal\Tests\migrate\Kernel\PluginCode
public function testLog() {
$values = [
'nid' => 2,
'type' => 'page',
'title' => 'page',
];
$node = new Node($values, 'node', 'test');
$node_array = <<<NODE
Array
(
[nid] => Array
(
)
[uuid] => Array
(
)
[vid] => Array
(
)
[langcode] => Array
(
)
[type] => Array
(
)
[revision_timestamp] => Array
(
)
[revision_uid] => Array
(
)
[revision_log] => Array
(
)
[status] => Array
(
)
[uid] => Array
(
)
[title] => Array
(
)
[created] => Array
(
)
[changed] => Array
(
)
[promote] => Array
(
)
[sticky] => Array
(
)
[default_langcode] => Array
(
)
[revision_default] => Array
(
)
[revision_translation_affected] => Array
(
)
)
NODE;
$data = [
'node' => [
'value' => $node,
'expected_message' => "'foo' value is Drupal\\node\\Entity\\Node:\n'{$node_array}'",
],
'url' => [
'value' => Url::fromUri('https://en.wikipedia.org/wiki/Drupal#Community'),
'expected_message' => "'foo' value is Drupal\\Core\\Url:\n'https://en.wikipedia.org/wiki/Drupal#Community'",
],
];
$i = 1;
foreach ($data as $datum) {
$this->executable->sourceIdValues = [
'id' => $i++,
];
// Test the input value is not altered.
$new_value = $this->logPlugin
->transform($datum['value'], $this->executable, new Row(), 'foo');
$this->assertSame($datum['value'], $new_value);
// Test the stored message.
$message = $this->executable
->getIdMap()
->getMessages($this->executable->sourceIdValues)
->fetchAllAssoc('message');
$actual_message = key($message);
$this->assertSame($datum['expected_message'], $actual_message);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.