protected function ContentLockTimeoutTest::setNewDatetimeTimeService in Content locking (anti-concurrent editing) 8
Same name and namespace in other branches
- 8.2 modules/content_lock_timeout/tests/src/Functional/ContentLockTimeoutTest.php \Drupal\Tests\content_lock_timeout\Functional\ContentLockTimeoutTest::setNewDatetimeTimeService()
Change the service.yml to set own datetime.time service.
See also
FunctionalTestSetupTrait::setContainerParameter
1 call to ContentLockTimeoutTest::setNewDatetimeTimeService()
- ContentLockTimeoutTest::setUp in modules/
content_lock_timeout/ tests/ src/ Functional/ ContentLockTimeoutTest.php - Setup and Rebuild node access.
File
- modules/
content_lock_timeout/ tests/ src/ Functional/ ContentLockTimeoutTest.php, line 181
Class
- ContentLockTimeoutTest
- Test content_lock_timeout sub module.
Namespace
Drupal\Tests\content_lock_timeout\FunctionalCode
protected function setNewDatetimeTimeService() {
$filename = $this->siteDirectory . '/services.yml';
chmod($filename, 0666);
// @todo Remove preg_replace() once
// https://github.com/symfony/symfony/pull/25787 is in Symfony 3.4.
$content = file_get_contents($filename);
$content = preg_replace('/:$\\n^\\s+{\\s*}$/m', ': {}', $content);
$services = Yaml::decode($content);
$services['services']['datetime.time'] = [
'class' => 'Drupal\\content_lock_timeout_test\\TimeChanger',
'arguments' => [
'@request_stack',
],
];
file_put_contents($filename, Yaml::encode($services));
// Ensure that the cache is deleted for the yaml file loader.
$file_cache = FileCacheFactory::get('container_yaml_loader');
$file_cache
->delete($filename);
$this
->rebuildContainer();
}