public function KernelTestBase::register in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/tests/Drupal/KernelTests/KernelTestBase.php \Drupal\KernelTests\KernelTestBase::register()
Registers test-specific services.
Extend this method in your test to register additional services. This method is called whenever the kernel is rebuilt.
Parameters
\Drupal\Core\DependencyInjection\ContainerBuilder $container: The service container to enhance.
Overrides ServiceProviderInterface::register
See also
\Drupal\Tests\KernelTestBase::bootKernel()
2 calls to KernelTestBase::register()
- CacheCollectorTest::register in core/
tests/ Drupal/ KernelTests/ Core/ Cache/ CacheCollectorTest.php - Registers test-specific services.
- ModuleHandlerTest::register in core/
modules/ system/ tests/ src/ Kernel/ Extension/ ModuleHandlerTest.php - Registers test-specific services.
2 methods override KernelTestBase::register()
- CacheCollectorTest::register in core/
tests/ Drupal/ KernelTests/ Core/ Cache/ CacheCollectorTest.php - Registers test-specific services.
- ModuleHandlerTest::register in core/
modules/ system/ tests/ src/ Kernel/ Extension/ ModuleHandlerTest.php - Registers test-specific services.
File
- core/
tests/ Drupal/ KernelTests/ KernelTestBase.php, line 560 - Contains \Drupal\KernelTests\KernelTestBase.
Class
- KernelTestBase
- Base class for functional integration tests.
Namespace
Drupal\KernelTestsCode
public function register(ContainerBuilder $container) {
// Keep the container object around for tests.
$this->container = $container;
$container
->register('flood', 'Drupal\\Core\\Flood\\MemoryBackend')
->addArgument(new Reference('request_stack'));
$container
->register('lock', 'Drupal\\Core\\Lock\\NullLockBackend');
$container
->register('cache_factory', 'Drupal\\Core\\Cache\\MemoryBackendFactory');
$container
->register('keyvalue.memory', 'Drupal\\Core\\KeyValueStore\\KeyValueMemoryFactory')
->addTag('persist');
$container
->setAlias('keyvalue', 'keyvalue.memory');
if ($this->strictConfigSchema) {
$container
->register('simpletest.config_schema_checker', 'Drupal\\Core\\Config\\Testing\\ConfigSchemaChecker')
->addArgument(new Reference('config.typed'))
->addTag('event_subscriber');
}
if ($container
->hasDefinition('path_processor_alias')) {
// Prevent the alias-based path processor, which requires a url_alias db
// table, from being registered to the path processor manager. We do this
// by removing the tags that the compiler pass looks for. This means the
// url generator can safely be used within tests.
$container
->getDefinition('path_processor_alias')
->clearTag('path_processor_inbound')
->clearTag('path_processor_outbound');
}
if ($container
->hasDefinition('password')) {
$container
->getDefinition('password')
->setArguments(array(
1,
));
}
}