function MailerDsnConfigValidationTest::testMailerTransportNativeOptionsValidation
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Config/ MailerDsnConfigValidationTest.php, line 221
Class
- MailerDsnConfigValidationTest
- Tests validation of mailer dsn config.
Namespace
Drupal\KernelTests\Core\ConfigCode
public function testMailerTransportNativeOptionsValidation() : void {
$config = $this->config('system.mail');
$this->assertFalse($config->isNew());
$data = $config->get();
// Set scheme to native.
$data['mailer_dsn']['scheme'] = 'native';
// If the options contain an invalid key, it should be an error.
$data['mailer_dsn']['options'] = [
'invalid_key' => 'Hello',
];
$violations = $this->configManager
->createFromNameAndData($config->getName(), $data)
->validate();
$this->assertCount(1, $violations);
$this->assertSame('mailer_dsn.options.invalid_key', $violations[0]->getPropertyPath());
$this->assertSame("'invalid_key' is not a supported key.", (string) $violations[0]->getMessage());
// If options is an empty map, it should be accepted.
$data['mailer_dsn']['options'] = [];
$violations = $this->configManager
->createFromNameAndData($config->getName(), $data)
->validate();
$this->assertCount(0, $violations);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.