Commit eac02c74 authored by webchick's avatar webchick

Issue #2570541 by mikeryan, phenaproxima: Track simple configuration...

Issue #2570541 by mikeryan, phenaproxima: Track simple configuration migrations like normal migrations
parent ede86717
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\destination\Config.
......@@ -78,7 +79,7 @@ public function import(Row $row, array $old_destination_id_values = array()) {
}
}
$this->config->save();
return TRUE;
return [$this->config->getName()];
}
/**
......@@ -92,7 +93,8 @@ public function fields(MigrationInterface $migration = NULL) {
* {@inheritdoc}
*/
public function getIds() {
return array();
$ids['config_name']['type'] = 'string';
return $ids;
}
/**
......
......@@ -121,6 +121,13 @@ public function testSourceCount() {
$this->assertEquals($this->source->count(), $this->expectedCount);
}
/**
* Test the source defines a valid ID.
*/
public function testSourceId() {
$this->assertNotEmpty($this->source->getIds());
}
/**
* @param \Drupal\migrate\Row $row
* @param string $key
......
......@@ -37,6 +37,9 @@ public function testImport() {
}
$config->expects($this->once())
->method('save');
$config->expects($this->once())
->method('getName')
->willReturn('d8_config');
$config_factory = $this->getMock('Drupal\Core\Config\ConfigFactoryInterface');
$config_factory->expects($this->once())
->method('getEditable')
......@@ -49,7 +52,8 @@ public function testImport() {
->method('getRawDestination')
->will($this->returnValue($source));
$destination = new Config(array('config_name' => 'd8_config'), 'd8_config', array('pluginId' => 'd8_config'), $migration, $config_factory);
$destination->import($row);
$destination_id = $destination->import($row);
$this->assertEquals($destination_id, ['d8_config']);
}
}
......@@ -53,7 +53,10 @@ protected function initializeIterator() {
* Only those values are returned that are actually in the database.
*/
protected function values() {
return array_map('unserialize', $this->prepareQuery()->execute()->fetchAllKeyed());
// Create an ID field so we can record migration in the map table.
// Arbitrarily, use the first variable name.
$values['id'] = reset($this->variables);
return $values + array_map('unserialize', $this->prepareQuery()->execute()->fetchAllKeyed());
}
/**
......@@ -84,7 +87,8 @@ public function query() {
* {@inheritdoc}
*/
public function getIds() {
return array();
$ids['id']['type'] = 'string';
return $ids;
}
}
......@@ -32,6 +32,7 @@ class VariableTest extends MigrateSqlSourceTestCase {
protected $expectedResults = array(
array(
'id' => 'foo',
'foo' => 1,
'bar' => FALSE,
),
......
......@@ -55,13 +55,15 @@ public function testSearchPage() {
->condition('name', 'node_rank_comments')
->execute();
/** @var \Drupal\migrate\Entity\MigrationInterface $migration */
$migration = \Drupal::entityManager()
->getStorage('migration')
->loadUnchanged('d6_search_page');
// Indicate we're rerunning a migration that's already run.
$migration->getIdMap()->prepareUpdate();
$this->executeMigration($migration);
$search_page = SearchPage::load($id);
$configuration = $search_page->getPlugin()->getConfiguration();
$configuration = SearchPage::load($id)->getPlugin()->getConfiguration();
$this->assertIdentical(4, $configuration['rankings']['comments']);
}
......
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