You are here

TestVariableConfiguration.test in Configuration Management 7.2

Tests for Configuration Management: Variables.

File

tests/handlers/TestVariableConfiguration.test
View source
<?php

/**
 * @file
 * Tests for Configuration Management: Variables.
 */
class VariableConfiguration extends ConfigurationHandlerBaseTestCase {
  protected $variable_name;

  /**
   * Test info.
   */
  public static function getInfo() {
    return array(
      'name' => t('Handler: VariableConfiguration'),
      'description' => t('Test the configuration API for variable configurations'),
      'group' => t('Configuration'),
    );
  }

  /**
   * Implementation of DrupalWebTestCase::setUp().
   */
  public function setUp($modules = array()) {
    global $base_url;
    if (empty($modules)) {
      parent::setUp(array(
        'configuration',
      ));
    }
    else {
      parent::setUp($modules);
    }
  }

  /**
   * Returns an array of configurations to import.
   */
  protected function configToImport() {
    return array(
      'variable.site_name',
    );
  }

  /**
   * Returns an array of configurations to export.
   */
  protected function configToExport() {
    return array(
      'variable.' . $this->variable_name,
    );
  }

  /**
   * Returns an array of configurations to modify and check for modifications.
   */
  protected function configToModify() {
    return array(
      'variable.site_name',
    );
  }

  /**
   * Return TRUE if the configuration is modified in the active store.
   */
  protected function isModified($config) {
    $modified = FALSE;
    $modified = variable_get('site_name', '') == 'Modified';
    return $modified;
  }

  /**
   * Return TRUE if all the configurations defined in configToImport were saved
   * into the active store.
   */
  protected function savedInActiveStore() {
    return variable_get('site_name', NULL) !== NULL;
  }

  /**
   * This function creates the configurations that will be exported by
   * configuration management.
   */
  protected function createConfigToExport() {
    $this->variable_name = drupal_strtolower($this
      ->randomName());
    variable_set($this->variable_name, $this
      ->randomName());
  }

  /**
   * Perform changes in the configuration and save those changes into the active
   * store.
   */
  protected function modifyConfiguration() {
    variable_set('site_name', 'Modified');
  }

}

Classes

Namesort descending Description
VariableConfiguration @file Tests for Configuration Management: Variables.