class ConfigTest
Same name in this branch
- 11.x core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/source/d8/ConfigTest.php \Drupal\Tests\migrate_drupal\Kernel\Plugin\migrate\source\d8\ConfigTest
- 11.x core/modules/config/tests/config_test/src/Entity/ConfigTest.php \Drupal\config_test\Entity\ConfigTest
- 11.x core/modules/system/tests/src/Functional/File/ConfigTest.php \Drupal\Tests\system\Functional\File\ConfigTest
- 11.x core/tests/Drupal/Tests/Composer/Plugin/ProjectMessage/ConfigTest.php \Drupal\Tests\Composer\Plugin\ProjectMessage\ConfigTest
- 11.x core/tests/Drupal/Tests/Composer/Plugin/VendorHardening/ConfigTest.php \Drupal\Tests\Composer\Plugin\VendorHardening\ConfigTest
- 11.x core/tests/Drupal/Tests/Core/Config/ConfigTest.php \Drupal\Tests\Core\Config\ConfigTest
Same name in other branches
- 9 core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/source/d8/ConfigTest.php \Drupal\Tests\migrate_drupal\Kernel\Plugin\migrate\source\d8\ConfigTest
- 9 core/modules/config/tests/config_test/src/Entity/ConfigTest.php \Drupal\config_test\Entity\ConfigTest
- 9 core/modules/migrate/tests/src/Unit/destination/ConfigTest.php \Drupal\Tests\migrate\Unit\destination\ConfigTest
- 9 core/modules/system/tests/src/Functional/File/ConfigTest.php \Drupal\Tests\system\Functional\File\ConfigTest
- 9 core/tests/Drupal/Tests/Composer/Plugin/ProjectMessage/ConfigTest.php \Drupal\Tests\Composer\Plugin\ProjectMessage\ConfigTest
- 9 core/tests/Drupal/Tests/Composer/Plugin/VendorHardening/ConfigTest.php \Drupal\Tests\Composer\Plugin\VendorHardening\ConfigTest
- 9 core/tests/Drupal/Tests/Core/Config/ConfigTest.php \Drupal\Tests\Core\Config\ConfigTest
- 8.9.x core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/source/d8/ConfigTest.php \Drupal\Tests\migrate_drupal\Kernel\Plugin\migrate\source\d8\ConfigTest
- 8.9.x core/modules/config/tests/config_test/src/Entity/ConfigTest.php \Drupal\config_test\Entity\ConfigTest
- 8.9.x core/modules/migrate/tests/src/Unit/destination/ConfigTest.php \Drupal\Tests\migrate\Unit\destination\ConfigTest
- 8.9.x core/modules/system/tests/src/Functional/File/ConfigTest.php \Drupal\Tests\system\Functional\File\ConfigTest
- 8.9.x core/tests/Drupal/Tests/Composer/Plugin/ProjectMessage/ConfigTest.php \Drupal\Tests\Composer\Plugin\ProjectMessage\ConfigTest
- 8.9.x core/tests/Drupal/Tests/Composer/Plugin/VendorHardening/ConfigTest.php \Drupal\Tests\Composer\Plugin\VendorHardening\ConfigTest
- 8.9.x core/tests/Drupal/Tests/Core/Config/ConfigTest.php \Drupal\Tests\Core\Config\ConfigTest
- 10 core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/source/d8/ConfigTest.php \Drupal\Tests\migrate_drupal\Kernel\Plugin\migrate\source\d8\ConfigTest
- 10 core/modules/config/tests/config_test/src/Entity/ConfigTest.php \Drupal\config_test\Entity\ConfigTest
- 10 core/modules/migrate/tests/src/Unit/destination/ConfigTest.php \Drupal\Tests\migrate\Unit\destination\ConfigTest
- 10 core/modules/system/tests/src/Functional/File/ConfigTest.php \Drupal\Tests\system\Functional\File\ConfigTest
- 10 core/tests/Drupal/Tests/Composer/Plugin/ProjectMessage/ConfigTest.php \Drupal\Tests\Composer\Plugin\ProjectMessage\ConfigTest
- 10 core/tests/Drupal/Tests/Composer/Plugin/VendorHardening/ConfigTest.php \Drupal\Tests\Composer\Plugin\VendorHardening\ConfigTest
- 10 core/tests/Drupal/Tests/Core/Config/ConfigTest.php \Drupal\Tests\Core\Config\ConfigTest
@coversDefaultClass \Drupal\migrate\Plugin\migrate\destination\Config @group migrate
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses \Drupal\Tests\PhpUnitCompatibilityTrait, \Prophecy\PhpUnit\ProphecyTrait, \Drupal\TestTools\Extension\DeprecationBridge\ExpectDeprecationTrait, \Drupal\Tests\RandomGeneratorTrait
- class \Drupal\Tests\migrate\Unit\destination\ConfigTest extends \Drupal\Tests\UnitTestCase
Expanded class hierarchy of ConfigTest
File
-
core/
modules/ migrate/ tests/ src/ Unit/ destination/ ConfigTest.php, line 16
Namespace
Drupal\Tests\migrate\Unit\destinationView source
class ConfigTest extends UnitTestCase {
/**
* Tests the import method.
*/
public function testImport() : void {
$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->atLeastOnce())
->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, $this->createMock(TypedConfigManagerInterface::class));
$destination_id = $destination->import($row);
$this->assertEquals([
'd8_config',
], $destination_id);
}
/**
* Tests the import method.
*/
public function testLanguageImport() : void {
$source = [
'langcode' => 'mi',
];
$migration = $this->getMockBuilder(MigrationInterface::class)
->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->any())
->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);
$row->expects($this->any())
->method('getDestinationProperty')
->willReturn($source['langcode']);
$language_manager = $this->getMockBuilder('Drupal\\language\\ConfigurableLanguageManagerInterface')
->disableOriginalConstructor()
->getMock();
$language_manager->expects($this->any())
->method('getLanguageConfigOverride')
->with('mi', 'd8_config')
->willReturn($config);
$destination = new Config([
'config_name' => 'd8_config',
'translations' => 'true',
], 'd8_config', [
'pluginId' => 'd8_config',
], $migration, $config_factory, $language_manager, $this->createMock(TypedConfigManagerInterface::class));
$destination_id = $destination->import($row);
$this->assertEquals([
'd8_config',
'mi',
], $destination_id);
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overrides |
---|---|---|---|---|
ConfigTest::testImport | public | function | Tests the import method. | |
ConfigTest::testLanguageImport | public | function | Tests the import method. | |
ExpectDeprecationTrait::expectDeprecation | public | function | Adds an expected deprecation. | |
ExpectDeprecationTrait::getCallableName | private static | function | Returns a callable as a string suitable for inclusion in a message. | |
ExpectDeprecationTrait::setUpErrorHandler | public | function | Sets up the test error handler. | |
ExpectDeprecationTrait::tearDownErrorHandler | public | function | Tears down the test error handler. | |
RandomGeneratorTrait::getRandomGenerator | protected | function | Gets the random generator for the utility methods. | |
RandomGeneratorTrait::randomMachineName | protected | function | Generates a unique random string containing letters and numbers. | |
RandomGeneratorTrait::randomObject | public | function | Generates a random PHP object. | |
RandomGeneratorTrait::randomString | public | function | Generates a pseudo-random string of ASCII characters of codes 32 to 126. | |
UnitTestCase::$root | protected | property | The app root. | |
UnitTestCase::getClassResolverStub | protected | function | Returns a stub class resolver. | |
UnitTestCase::getConfigFactoryStub | public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase::getConfigStorageStub | public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase::getContainerWithCacheTagsInvalidator | protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase::getStringTranslationStub | public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase::setUp | protected | function | 367 | |
UnitTestCase::setUpBeforeClass | public static | function |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.