You are here

TestViewConfiguration.test in Configuration Management 7.2

Tests for Configuration Management: Views.

File

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

/**
 * @file
 * Tests for Configuration Management: Views.
 */
class TestviewConfiguration extends ConfigurationHandlerBaseTestCase {
  protected $view_name;

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

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

  /**
   * Returns an array of configurations to import.
   */
  protected function configToImport() {

    // Create a Developer Role
    return array(
      'views_view.test',
    );
  }

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

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

  /**
   * Return TRUE if the configuration is modified in the active store.
   */
  protected function isModified($config) {
    $modified = FALSE;
    $view = views_get_view('test', TRUE);
    $modified = $view->display['default']->display_options['pager']['options']['items_per_page'] == 5;
    return $modified;
  }

  /**
   * Return TRUE if all the configurations defined in configToImport were saved
   * into the active store.
   */
  protected function savedInActiveStore() {
    $view = views_get_view('test');
    return !empty($view);
  }

  /**
   * This function creates the configurations that will be exported by
   * configuration management.
   */
  protected function createConfigToExport() {
    $web_user = $this
      ->drupalCreateUser(array(
      'administer views',
      'access content',
    ));
    $this
      ->drupalLogin($web_user);
    $edit = array();
    $edit['human_name'] = 'Test';
    $edit['name'] = $this->view_name = strtolower($this
      ->randomName(10));
    $edit['page[title]'] = 'My custom view';
    $edit['page[path]'] = 'custom_view';
    $this
      ->drupalPost('admin/structure/views/add', $edit, t('Save & exit'));
  }

  /**
   * Perform changes in the configuration and save those changes into the active
   * store.
   */
  protected function modifyConfiguration() {

    // @TODO Fix this
    $view = views_get_view('test');
    $view->display['default']->display_options['pager']['options']['items_per_page'] = 5;
    views_save_view($view);
  }

}

Classes

Namesort descending Description
TestviewConfiguration @file Tests for Configuration Management: Views.