You are here

password_policy_test.module in Password Policy 7.2

Helper module for testing.

Defines functions to test loading a policy via Ctools. Also provides a hook_form_FORM_ID_alter() function for suppressing some text that interferes with testing.

File

password_policy_test/password_policy_test.module
View source
<?php

/**
 * @file
 * Helper module for testing.
 *
 * Defines functions to test loading a policy via Ctools. Also provides a
 * hook_form_FORM_ID_alter() function for suppressing some text that interferes
 * with testing.
 */

/**
 * Implements hook_ctools_plugin_api().
 */
function password_policy_test_ctools_plugin_api($module, $api) {
  if ($module == 'password_policy' && $api == 'default_password_policy') {
    return array(
      'version' => '1',
    );
  }
}

/**
 * Implements hook_default_password_policy().
 */
function password_policy_test_default_password_policy() {
  $policies = array();
  $password_policy = new stdClass();
  $password_policy->disabled = FALSE;
  $password_policy->api_version = 1;
  $password_policy->name = 'Test policy';
  $password_policy->config = 'a:0:{}';
  $policies['Test policy'] = $password_policy;
  return $policies;
}

/**
 * Implements hook_form_FORM_ID_alter() for user_profile_form().
 */
function password_policy_test_form_user_profile_form_alter(&$form, $form_state) {

  // Remove description so assertText()s can match errors.
  if (variable_get('password_policy_test_no_description', FALSE)) {
    $form['account']['pass']['#description'] = '';
  }
}