/** * Tests the 'untrusted_roles' setting. */ public function testConfigUntrustedRoles() { $this->assertEqual(SecurityReview::getUntrustedRoles(), array(), 'untrusted_roles empty by default.'); $roles = array(0, 1, 2, 3, 4); SecurityReview::setUntrustedRoles($roles); $this->assertEqual($roles, SecurityReview::getUntrustedRoles(), 'untrusted_roles set to test array.'); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { // Frequently used configuration items. $check_settings = $this->config('security_review.checks'); // Save that the module has been configured. SecurityReview::setConfigured(TRUE); // Save the new untrusted roles. $untrusted_roles = array_keys(array_filter($form_state->getValue('untrusted_roles'))); SecurityReview::setUntrustedRoles($untrusted_roles); // Save the new logging setting. $logging = $form_state->getValue('logging') == 1; SecurityReview::setLogging($logging); // Skip selected checks. $skipped = array_keys(array_filter($form_state->getValue('skip'))); foreach (Checklist::getChecks() as $check) { if (in_array($check->id(), $skipped)) { $check->skip(); } else { $check->enable(); } } // Save the check-specific settings. if (isset($form['advanced']['check_specific'])) { $checkSpecificValues = $form_state->getValue('check_specific'); foreach ($checkSpecificValues as $checkIdentifier => $values) { // Get corresponding Check. $check = Checklist::getCheckByIdentifier($checkIdentifier); // Submit parameters. $checkForm =& $form['advanced']['check_specific'][$checkIdentifier]['form']; $checkFormValues = $checkSpecificValues[$checkIdentifier]['form']; // Submit. $check->settings()->submitForm($checkForm, $checkFormValues); } } // Commit the settings. $check_settings->save(); // Finish submitting the form. parent::submitForm($form, $form_state); }