Commit c470f142 authored by catch's avatar catch

Issue #2768823 by Jo Fitzgerald, Berdir, quietone: Store uploads in correct translation

parent 639755c7
......@@ -7,6 +7,10 @@ source:
process:
nid: nid
vid: vid
langcode:
plugin: user_langcode
source: language
fallback_to_site_default: true
type: type
upload:
plugin: sub_process
......
......@@ -29,6 +29,7 @@ public function query() {
->fields('u', ['nid', 'vid']);
$query->innerJoin('node', 'n', static::JOIN);
$query->addField('n', 'type');
$query->addField('n', 'language');
return $query;
}
......@@ -54,6 +55,7 @@ public function fields() {
'nid' => $this->t('The node Id.'),
'vid' => $this->t('The version Id.'),
'type' => $this->t('The node type'),
'language' => $this->t('The node language.'),
'description' => $this->t('The file description.'),
'list' => $this->t('Whether the list should be visible on the node page.'),
'weight' => $this->t('The file weight.'),
......
......@@ -16,7 +16,7 @@ class MigrateUploadTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['menu_ui'];
public static $modules = ['language', 'menu_ui'];
/**
* {@inheritdoc}
......@@ -51,7 +51,7 @@ protected function setUp() {
}
$this->prepareMigrations($id_mappings);
$this->migrateContent();
$this->migrateContent(['translations']);
// Since we are only testing a subset of the file migration, do not check
// that the full file migration has been run.
$migration = $this->getMigration('d6_upload');
......@@ -65,16 +65,18 @@ protected function setUp() {
public function testUpload() {
$this->container->get('entity.manager')
->getStorage('node')
->resetCache([1, 2]);
->resetCache([1, 2, 12]);
$nodes = Node::loadMultiple([1, 2]);
$nodes = Node::loadMultiple([1, 2, 12]);
$node = $nodes[1];
$this->assertEquals('en', $node->langcode->value);
$this->assertIdentical(1, count($node->upload));
$this->assertIdentical('1', $node->upload[0]->target_id);
$this->assertIdentical('file 1-1-1', $node->upload[0]->description);
$this->assertIdentical(FALSE, $node->upload[0]->isDisplayed());
$node = $nodes[2];
$this->assertEquals('en', $node->langcode->value);
$this->assertIdentical(2, count($node->upload));
$this->assertIdentical('3', $node->upload[0]->target_id);
$this->assertIdentical('file 2-3-3', $node->upload[0]->description);
......@@ -82,6 +84,13 @@ public function testUpload() {
$this->assertIdentical('2', $node->upload[1]->target_id);
$this->assertIdentical(TRUE, $node->upload[1]->isDisplayed());
$this->assertIdentical('file 2-3-2', $node->upload[1]->description);
$node = $nodes[12];
$this->assertEquals('zu', $node->langcode->value);
$this->assertEquals(1, count($node->upload));
$this->assertEquals('3', $node->upload[0]->target_id);
$this->assertEquals('file 12-15-3', $node->upload[0]->description);
$this->assertEquals(FALSE, $node->upload[0]->isDisplayed());
}
}
......@@ -34,6 +34,14 @@ public function providerSource() {
'list' => '0',
'weight' => '-1',
],
[
'fid' => '3',
'nid' => '12',
'vid' => '15',
'description' => 'file 12-15-3',
'list' => '0',
'weight' => '0',
],
];
$tests[0]['source_data']['node'] = [
......@@ -54,6 +62,23 @@ public function providerSource() {
'tnid' => '0',
'translate' => '0',
],
[
'nid' => '12',
'vid' => '15',
'type' => 'page',
'language' => 'zu',
'title' => 'Abantu zulu',
'uid' => '1',
'status' => '1',
'created' => '1444238800',
'changed' => '1444238808',
'comment' => '0',
'promote' => '0',
'moderate' => '0',
'sticky' => '0',
'tnid' => '12',
'translate' => '0',
],
];
// The expected results.
......@@ -66,10 +91,24 @@ public function providerSource() {
'list' => '0',
],
],
'language' => '',
'nid' => '1',
'vid' => '1',
'type' => 'story',
],
[
'upload' => [
[
'fid' => '3',
'description' => 'file 12-15-3',
'list' => '0',
],
],
'language' => 'zu',
'nid' => '12',
'vid' => '15',
'type' => 'page',
],
];
return $tests;
......
......@@ -46499,6 +46499,14 @@
'list' => '0',
'weight' => '1',
))
->values(array(
'fid' => '3',
'nid' => '12',
'vid' => '15',
'description' => 'file 12-15-3',
'list' => '0',
'weight' => '0',
))
->execute();
$connection->schema()->createTable('url_alias', array(
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment