class ConfigOverrideServiceProviderTest in Config override 8
@coversDefaultClass \Drupal\config_override\ConfigOverrideServiceProvider @group config_override
Hierarchy
- class \Drupal\config_override\Tests\Unit\ConfigOverrideServiceProviderTest extends \PHPUnit\Framework\TestCase
Expanded class hierarchy of ConfigOverrideServiceProviderTest
File
- tests/
Unit/ ConfigOverrideServiceProviderTest.php, line 16
Namespace
Drupal\config_override\Tests\UnitView source
class ConfigOverrideServiceProviderTest extends TestCase {
/**
* @covers ::alter
*/
public function testNotExistingEnvironmentFile() {
vfsStreamWrapper::register();
new vfsStreamDirectory('drupal');
$sut = new ConfigOverrideServiceProvider();
$container = new ContainerBuilder();
$container
->set('app.root', 'vfs://');
$sut
->alter($container);
$this
->assertEquals([], $container
->getParameter('config_override__environment'));
}
/**
* @covers ::alter
*/
public function testWithEnvironmentFileWithDots() {
$vfs_root = vfsStream::setup('drupal_root');
vfsStream::create([
'sites/default/.env' => '
CONFIG___CONFIG__NAME___KEY__WITH_DOT=value
',
]);
$sut = new ConfigOverrideServiceProvider();
$container = new ContainerBuilder();
$container
->set('app.root', $vfs_root
->url());
$sut
->alter($container);
$this
->assertEquals([
'config.name' => [
'key.with_dot' => 'value',
],
], $container
->getParameter('config_override__environment'));
}
/**
* @covers ::alter
*/
public function testWithEnvironmentFile() {
$vfs_root = vfsStream::setup('drupal_root');
vfsStream::create([
'sites/default/.env' => '
CONFIG___NAME___KEY=value
CONFIG___NAME___KEY2=value2
CONFIG___NAME2___KEY2=value2
CONFIG___NAME3___KEY3=value3
',
]);
$sut = new ConfigOverrideServiceProvider();
$container = new ContainerBuilder();
$container
->set('app.root', $vfs_root
->url());
$sut
->alter($container);
$this
->assertEquals([
'name' => [
'key' => 'value',
'key2' => 'value2',
],
'name2' => [
'key2' => 'value2',
],
'name3' => [
'key3' => 'value3',
],
], $container
->getParameter('config_override__environment'));
}
/**
* @covers ::alter
*/
public function testWithEnvironmentFiles() {
$vfs_root = vfsStream::setup('drupal_root');
vfsStream::create([
'sites/default/.environment' => '
CONFIG___NAME___KEY2=value2
CONFIG___NAME3___KEY3=value3
',
'sites/default/.env' => '
CONFIG___NAME___KEY=value
CONFIG___NAME2___KEY2=value2
',
]);
$sut = new ConfigOverrideServiceProvider();
$container = new ContainerBuilder();
$container
->set('app.root', $vfs_root
->url());
$sut
->alter($container);
$this
->assertEquals([
'name' => [
'key' => 'value',
'key2' => 'value2',
],
'name2' => [
'key2' => 'value2',
],
'name3' => [
'key3' => 'value3',
],
], $container
->getParameter('config_override__environment'));
}
/**
* @covers ::alter
*/
public function testWithEnvironmentFilesAndOverrideInSitesDefault() {
$vfs_root = vfsStream::setup('drupal_root');
vfsStream::create([
'sites/default/.env' => '
CONFIG___NAME___KEY=value
CONFIG___NAME___KEY=override_value
',
'sites/default/.environment' => '
CONFIG___NAME___KEY2=value2
CONFIG___NAME3___KEY3=value3
',
]);
$sut = new ConfigOverrideServiceProvider();
$container = new ContainerBuilder();
$container
->set('app.root', $vfs_root
->url());
$sut
->alter($container);
$this
->assertEquals([
'name' => [
'key' => 'override_value',
'key2' => 'value2',
],
'name3' => [
'key3' => 'value3',
],
], $container
->getParameter('config_override__environment'));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigOverrideServiceProviderTest:: |
public | function | @covers ::alter | |
ConfigOverrideServiceProviderTest:: |
public | function | @covers ::alter | |
ConfigOverrideServiceProviderTest:: |
public | function | @covers ::alter | |
ConfigOverrideServiceProviderTest:: |
public | function | @covers ::alter | |
ConfigOverrideServiceProviderTest:: |
public | function | @covers ::alter |