You are here

TestPageManagerConfiguration.test in Configuration Management 7.2

Tests for Configuration Management: Page manager components and dependencies.

File

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

/**
 * @file
 * Tests for Configuration Management: Page manager components and dependencies.
 */
class TestPageManagerConfiguration extends ConfigurationHandlerBaseTestCase {

  /**
   * Test info.
   */
  public static function getInfo() {
    return array(
      'name' => t('Handler: Page Manager'),
      'description' => t('Test the configuration API for Page Managers configurations'),
      'group' => t('Configuration'),
    );
  }
  protected function addModules() {
    $modules = array();
    $modules[] = 'ctools';
    $modules[] = 'page_manager';
    $modules[] = 'views';
    $modules[] = 'views_ui';
    $modules[] = 'node';
    $modules[] = 'views_content';
    return $modules;
  }

  /**
   * Returns an array of configurations to import.
   */
  protected function configToImport() {
    $configs = array();
    $configs[] = 'page_manager_pages.configuration_test_page';
    $configs[] = 'page_manager_pages.news';
    return $configs;
  }
  protected function importDependencies() {
    return TRUE;
  }

  /**
   * Returns an array of configurations to check if they were imported.
   */
  protected function dependenciesToImport() {
    $dependencies = array();
    $dependencies[] = 'page_manager_handlers.page_configuration_test_page_panel_context';
    $dependencies[] = 'views_view.test';
    $dependencies[] = 'page_manager_handlers.page_news_panel_context';
    $dependencies[] = 'views_view.news_recent';
    return $dependencies;
  }
  protected function exportDependencies() {
    return TRUE;
  }

  /**
   * Returns an array of configurations to check if they were exported.
   */
  protected function dependenciesToExport() {
    $dependencies = array();
    $dependencies[] = 'page_manager_handlers.page_configuration_test_page_panel_context';
    $dependencies[] = 'views_view.test';

    //    $dependencies[] = 'page_manager_handlers.page_home_panel_context';
    //    $dependencies[] = 'views_view.news_recent';
    return $dependencies;
  }

  /**
   * Returns an array of configurations to export.
   */
  protected function configToExport() {
    $configs = array();
    $configs[] = 'page_manager_pages.configuration_test_page';

    //$configs[] = 'page_manager_pages.home';
    return $configs;
  }

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

  /**
   * Return TRUE if the configuration is modified in the active store.
   */
  protected function isModified($config) {
    $modified = FALSE;
    $web_user = $this
      ->drupalCreateUser(array(
      'use page manager',
    ));
    $this
      ->drupalLogin($web_user);
    $this
      ->drupalGet('admin/structure/pages');
    $modified = strpos($this
      ->drupalGetContent(), 'The title has changed.') !== FALSE;
    return $modified;
  }

  /**
   * Return TRUE if all the configurations defined in configToImport were saved
   * into the active store.
   */
  protected function savedInActiveStore() {
    $view_exists = views_get_view('test');
    $result = $this
      ->assertTrue(!empty($view_exists->name), "The view was saved in the ActiveStore.");
    $web_user = $this
      ->drupalCreateUser(array(
      'use page manager',
    ));
    $this
      ->drupalLogin($web_user);
    $this
      ->drupalGet('admin/structure/pages');
    $result &= $this
      ->assertRaw('Configuration Test Page', 'Page Manager Page was created correctly.');
    return $result;
  }

  /**
   * This function creates the configurations that will be exported by
   * configuration management.
   */
  protected function createConfigToExport() {

    // Create a page object.
    $page = new stdClass();
    $page->disabled = FALSE;

    /* Edit this to true to make a default page disabled initially */
    $page->api_version = 1;
    $page->name = 'configuration_test_page';
    $page->task = 'page';
    $page->admin_title = 'Configuration Test Page';
    $page->admin_description = 'Configuration Test Page Description.';
    $page->path = 'config-test-page';
    $page->access = array(
      'logic' => 'and',
    );
    $page->menu = array(
      'type' => 'none',
      'title' => '',
      'name' => 'navigation',
      'weight' => '0',
      'parent' => array(
        'type' => 'none',
        'title' => '',
        'name' => 'navigation',
        'weight' => '0',
      ),
    );
    $page->arguments = array();
    $page->conf = array(
      'admin_paths' => FALSE,
    );
    $page->export_type = NULL;
    $result = ctools_export_crud_save('page_manager_pages', $page);

    // Create a page handler object.
    $handler = new stdClass();
    $handler->disabled = FALSE;

    /* Edit this to true to make a default handler disabled initially */
    $handler->api_version = 1;
    $handler->name = 'page_configuration_test_page_panel_context';
    $handler->task = 'page';
    $handler->subtask = 'configuration_test_page';
    $handler->handler = 'panel_context';
    $handler->weight = 0;
    $handler->conf = array(
      'title' => 'Panel',
      'no_blocks' => 0,
      'pipeline' => 'standard',
      'body_classes_to_remove' => '',
      'body_classes_to_add' => '',
      'css_id' => '',
      'css' => '',
      'contexts' => array(),
      'relationships' => array(),
      'access' => array(
        'logic' => 'and',
      ),
    );
    $display = new panels_display();
    $display->layout = 'threecol_33_34_33';
    $display->layout_settings = array();
    $display->panel_settings = array(
      'style_settings' => array(
        'default' => NULL,
        'left' => NULL,
        'middle' => NULL,
        'right' => NULL,
      ),
    );
    $display->cache = array();
    $display->title = '';
    $display->content = array();
    $display->panels = array();
    $pane = new stdClass();
    $pane->pid = 'new-3';
    $pane->panel = 'middle';
    $pane->type = 'views';
    $pane->subtype = 'test';
    $pane->shown = TRUE;
    $pane->access = array();
    $pane->configuration = array(
      'override_pager_settings' => 0,
      'use_pager' => 1,
      'nodes_per_page' => '10',
      'pager_id' => '0',
      'offset' => '0',
      'more_link' => 0,
      'feed_icons' => 0,
      'panel_args' => 0,
      'link_to_view' => 0,
      'args' => '',
      'url' => '',
      'display' => 'default',
      'override_title' => 0,
      'override_title_text' => '',
    );
    $pane->cache = array();
    $pane->style = array(
      'settings' => NULL,
    );
    $pane->css = array();
    $pane->extras = array();
    $pane->position = 0;
    $pane->locks = array();
    $display->content['new-3'] = $pane;
    $display->panels['middle'][0] = 'new-3';
    $display->hide_title = PANELS_TITLE_FIXED;
    $display->title_pane = '0';
    $handler->conf['display'] = $display;
    $handler->export_type = NULL;
    $result = ctools_export_crud_save('page_manager_handlers', $handler);
    $web_user = $this
      ->drupalCreateUser(array(
      'administer views',
      'access content',
    ));
    $this
      ->drupalLogin($web_user);
    $edit = array();
    $edit['human_name'] = 'Test';
    $edit['name'] = 'test';
    $edit['page[title]'] = 'My custom view';
    $edit['page[path]'] = 'custom_view';
    $this
      ->drupalPost('admin/structure/views/add', $edit, t('Save & exit'));
    $this
      ->assertRaw('My custom view', "The view was saved in the ActiveStore.");
  }

  /**
   * Perform changes in the configuration and save those changes into the active
   * store.
   */
  protected function modifyConfiguration() {
    $web_user = $this
      ->drupalCreateUser(array(
      'use page manager',
    ));
    $this
      ->drupalLogin($web_user);
    $edit = array();
    $edit['admin_title'] = 'The title has changed.';
    $this
      ->drupalPost('admin/structure/pages/nojs/operation/page-configuration_test_page/settings/basic', $edit, t('Update and save'));
  }

}

Classes

Namesort descending Description
TestPageManagerConfiguration @file Tests for Configuration Management: Page manager components and dependencies.