You are here

configuration.ctools.test in Configuration Management 7

Test cases for contrib modules supported by configuration.

File

tests/configuration.ctools.test
View source
<?php

/**
 * @file
 * Test cases for contrib modules supported by configuration.
 */

/**
 * Configuration test case for ctools.
 */
class ConfigurationCtoolsWebTestCase extends ConfigurationContribWebTestCase {

  /**
   * Test info.
   */
  public static function getInfo() {
    return array(
      'name' => t('Test Ctools Integration'),
      'description' => t('Test contributed ctools integration supported by configuration management.'),
      'group' => t('Configuration'),
      'dependencies' => array(
        'ctools',
        'views',
        'configuration_test',
      ),
    );
  }

  /**
   * Set up test.
   */
  public function setUp() {
    parent::setUp(array(
      'ctools',
      'views',
      'views_ui',
    ));
    $permissions = array(
      'administer content types',
      'access administration pages',
      'administer views',
      'access configuration management',
      'administer modules',
      'administer site configuration',
      'administer filters',
      'administer permissions',
      'administer users',
      'administer image styles',
      'administer taxonomy',
    );
    $this
      ->adminLogin($permissions);
  }

  /**
   * Tests tracking configurations for the views module.
   */
  public function trackViewsConfigurations() {

    // Track default views.
    $components = array(
      'views_view' => array(
        'archive',
        'backlinks',
        'frontpage',
        'glossary',
        'comments_recent',
        'taxonomy_term',
        'tracker',
      ),
    );
    $files = array();
    foreach ($components as $name => $value) {
      $files[] = 'configuration.' . $name . '.inc';
    }
    $this
      ->trackConfigurations($components, $files);
  }

  /**
   * Tests that views configurations that are marked as overriden are reverted properly.
   */
  public function testViewsOverridden() {
    $this
      ->trackViewsConfigurations();

    // Test frontpage view overrides.
    // Edit the view and change the title.
    $new_title = $this
      ->randomName(16);
    $edit = array(
      'title' => $new_title,
    );
    $this
      ->drupalPost('admin/structure/views/nojs/display/frontpage/page/title', $edit, t('Apply'));
    $this
      ->drupalPost('admin/structure/views/view/frontpage/edit/page', array(), t('Save'));

    // @todo remove this line once we have a observer for ctools components.
    $this
      ->drupalPost('admin/config/system/configuration/settings', array(), t('Check for new configurations'));
    $this
      ->assertRaw($this->configuration_needs_saving_text, t('Activestore overriden message is present'));
    $status = configuration_get_status('views_view', 'frontpage');
    $this
      ->assertEqual($status, CONFIGURATION_ACTIVESTORE_OVERRIDDEN, t('frontpage view component status overridden'));

    // Test frontpage view back to default.
    $edit = array(
      'title' => '',
    );
    $this
      ->drupalPost('admin/structure/views/nojs/display/frontpage/page/title', $edit, t('Apply'));
    $this
      ->drupalPost('admin/structure/views/view/frontpage/edit/page', array(), t('Save'));

    // @todo remove this line once we have a observer for ctools components.
    $this
      ->drupalPost('admin/config/system/configuration/settings', array(), t('Check for new configurations'));
    $this
      ->assertNoRaw($this->configuration_needs_saving_text, t('Activestore overriden message is not present'));
    $status = configuration_get_status('views_view', 'frontpage');
    $this
      ->assertEqual($status, CONFIGURATION_IN_SYNC, t('frontpage view component status in sync'));
  }

  /**
   * Tests that configurations that are marked as overriden are reverted properly.
   */
  public function testViewsImportDatastoreToActivestore() {
    $this
      ->trackViewsConfigurations();

    // Test frontpage view overrides.
    // Edit the view and change the title.
    $new_title = $this
      ->randomName(16);
    $edit = array(
      'title' => $new_title,
    );
    $this
      ->drupalPost('admin/structure/views/nojs/display/frontpage/page/title', $edit, t('Apply'));
    $this
      ->drupalPost('admin/structure/views/view/frontpage/edit/page', array(), t('Save'));

    // @todo remove this line once we have a observer for ctools components.
    $this
      ->drupalPost('admin/config/system/configuration/settings', array(), t('Check for new configurations'));
    $this
      ->assertRaw($this->configuration_needs_saving_text, t('Activestore overriden message is present'));

    // Try to revert
    $edit = array();
    $edit['views_view[items][frontpage]'] = TRUE;
    $this
      ->drupalPost('admin/config/system/configuration', $edit, t('Import Datastore to Activestore'));

    // @todo remove this line once we have a observer for ctools components.
    $this
      ->drupalPost('admin/config/system/configuration/settings', array(), t('Check for new configurations'));
    $this
      ->assertNoRaw($this->configuration_needs_saving_text, t('Activestore overriden message not present'));
  }

}

Classes

Namesort descending Description
ConfigurationCtoolsWebTestCase Configuration test case for ctools.