function ConfigTest::testImport
Same name in other branches
- 8.9.x core/modules/migrate/tests/src/Unit/destination/ConfigTest.php \Drupal\Tests\migrate\Unit\destination\ConfigTest::testImport()
- 10 core/modules/migrate/tests/src/Unit/destination/ConfigTest.php \Drupal\Tests\migrate\Unit\destination\ConfigTest::testImport()
- 11.x core/modules/migrate/tests/src/Unit/destination/ConfigTest.php \Drupal\Tests\migrate\Unit\destination\ConfigTest::testImport()
Tests the import method.
File
-
core/
modules/ migrate/ tests/ src/ Unit/ destination/ ConfigTest.php, line 18
Class
- ConfigTest
- @coversDefaultClass \Drupal\migrate\Plugin\migrate\destination\Config @group migrate
Namespace
Drupal\Tests\migrate\Unit\destinationCode
public function testImport() {
$source = [
'test' => 'x',
];
$migration = $this->getMockBuilder('Drupal\\migrate\\Plugin\\Migration')
->disableOriginalConstructor()
->getMock();
$config = $this->getMockBuilder('Drupal\\Core\\Config\\Config')
->disableOriginalConstructor()
->getMock();
foreach ($source as $key => $val) {
$config->expects($this->once())
->method('set')
->with($this->equalTo($key), $this->equalTo($val))
->willReturn($config);
}
$config->expects($this->once())
->method('save');
$config->expects($this->once())
->method('getName')
->willReturn('d8_config');
$config_factory = $this->createMock('Drupal\\Core\\Config\\ConfigFactoryInterface');
$config_factory->expects($this->once())
->method('getEditable')
->with('d8_config')
->willReturn($config);
$row = $this->getMockBuilder('Drupal\\migrate\\Row')
->disableOriginalConstructor()
->getMock();
$row->expects($this->any())
->method('getRawDestination')
->willReturn($source);
$language_manager = $this->getMockBuilder('Drupal\\language\\ConfigurableLanguageManagerInterface')
->disableOriginalConstructor()
->getMock();
$language_manager->expects($this->never())
->method('getLanguageConfigOverride')
->with('fr', 'd8_config')
->willReturn($config);
$destination = new Config([
'config_name' => 'd8_config',
], 'd8_config', [
'pluginId' => 'd8_config',
], $migration, $config_factory, $language_manager);
$destination_id = $destination->import($row);
$this->assertEquals([
'd8_config',
], $destination_id);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.