Skip to content
Snippets Groups Projects
Unverified Commit 615f109f authored by colemanw's avatar colemanw Committed by GitHub
Browse files

Merge pull request #24154 from totten/master-setting-validate

SettingsStyleTest - Stop the madness
parents 07ab3d1c 8b0d72f8
Branches
Tags
No related merge requests found
......@@ -311,6 +311,7 @@ return [
'is_contact' => 0,
'description' => ts('The number of emails sendable via simple mail. Make sure you understand the implications for your spam reputation and legal requirements for bulk emails before editing. As there is some risk both to your spam reputation and the products if this is misused it is a hidden setting.'),
'help_text' => 'CiviCRM forces users sending more than this number of mails to use CiviMails. CiviMails have additional precautions: not sending to contacts who do not want bulk mail, adding domain name and opt out links. You should familiarise yourself with the law relevant to you on bulk mailings if changing this setting. For the US https://en.wikipedia.org/wiki/CAN-SPAM_Act_of_2003 is a good place to start.',
'add' => '4.7.25',
],
'auto_recipient_rebuild' => [
'group_name' => 'Mailing Preferences',
......@@ -325,6 +326,7 @@ return [
'is_contact' => 0,
'description' => ts('Enable this setting to rebuild recipient list automatically during composing mail. Disable will allow you to rebuild recipient manually.'),
'help_text' => ts('CiviMail automatically fetches recipient list and count whenever mailing groups are included or excluded while composing bulk mail. This phenomena may degrade performance for large sites, so disable this setting to build and fetch recipients for selected groups, manually.'),
'add' => '4.7.30',
],
'allow_mail_from_logged_in_contact' => [
'group_name' => 'Mailing Preferences',
......@@ -338,6 +340,7 @@ return [
'is_contact' => 0,
'description' => ts('Allow sending email from the logged in contact\'s email address.'),
'help_text' => 'CiviCRM allows you to send email from the domain from email addresses and the logged in contact id addresses by default. Disable this if you only want to allow the domain from addresses to be used.',
'add' => '4.7.31',
],
'url_tracking_default' => [
'group_name' => 'Mailing Preferences',
......@@ -352,6 +355,7 @@ return [
'is_contact' => 0,
'description' => ts('If checked, mailings will have click-through tracking enabled by default.'),
'help_text' => NULL,
'add' => '5.27.0',
],
'open_tracking_default' => [
'group_name' => 'Mailing Preferences',
......@@ -366,6 +370,7 @@ return [
'is_contact' => 0,
'description' => ts('If checked, mailings will have open tracking enabled by default.'),
'help_text' => NULL,
'add' => '5.27.0',
],
// dev/cor#1768 Allow mailer sync interval to be configured by the
// adminstrator.
......
......@@ -213,7 +213,7 @@ return [
'group_name' => 'Search Preferences',
'group' => 'Search Preferences',
'name' => 'quicksearch_options',
'type' => 'string',
'type' => 'String',
'serialize' => CRM_Core_DAO::SERIALIZE_SEPARATOR_BOOKEND,
'html_type' => 'checkboxes',
'sortable' => TRUE,
......
<?php
namespace Civi\Core;
class SettingsStyleTest extends \CiviUnitTestCase {
protected function setUp(): void {
parent::setUp();
$this->useTransaction(TRUE);
}
/**
* Scan all known settings
*/
public function testConformance() {
$errors = [];
$assert = function (string $setting, bool $condition, string $message) use (&$errors) {
if (!$condition) {
$errors[] = $setting . ': ' . $message;
}
};
$validTypes = array_merge(
// The list of 'type's are a bit of a mess. We'll prevent it from becoming more of a mess...
array_keys(\CRM_Utils_Type::getValidTypes()),
[\CRM_Utils_Type::T_STRING, \CRM_Utils_Type::T_BOOLEAN, \CRM_Utils_Type::T_INT],
['Array', 'Integer']
);
$all = SettingsMetadata::getMetadata();
$this->assertTrue(count($all) > 10);
foreach ($all as $key => $spec) {
$assert($key, preg_match(';^\d+\.\d+(\.\d+)?$;', $spec['add'] ?? NULL), 'Should have well-formed \"add\" property');
$assert($key, $spec['is_domain'] xor $spec['is_contact'], 'Should be is_domain xor is_contact');
$assert($key, $key === $spec['name'], 'Should have matching name');
$type = $spec['type'] ?? 'UNKNOWN';
$assert($key, in_array($type, $validTypes), 'Should have known type. Found: ' . $type);
if (version_compare($spec['add'], '5.53', '>=')) {
$assert($key, preg_match(';^[a-z0-9]+(_[a-z0-9]+)+$;', $key), 'In 5.53+, names should use snake_case with a group/subsystem prefix.');
}
else {
$assert($key, preg_match(';^[a-z][a-zA-Z0-9_]+$;', $key), 'In 4.1-5.52, names should snake_case or lowerCamelCase.');
}
}
$this->assertEquals([], $errors);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment