1 views_ui.test ViewsUIWizardDisplaysTestCase::testWizardMixedDefaultOverriddenDisplays()

Tests that the wizard correctly sets up default and overridden displays.

File

core/modules/views/tests/views_ui.test, line 809
Tests Views UI Wizard.

Class

ViewsUIWizardDisplaysTestCase
Tests that displays can be correctly overridden via the user interface.

Code

function testWizardMixedDefaultOverriddenDisplays() {
  // Create a basic view with a page, block, and feed. Give the page and feed
  // identical titles, but give the block a different one, so we expect the
  // page and feed to inherit their titles from the default display, but the
  // block to override it.
  $view['human_name'] = $this->randomName(16);
  $view['name'] = strtolower($this->randomName(16));
  $view['page[create]'] = 1;
  $view['page[title]'] = $this->randomName(16);
  $view['page[path]'] = $this->randomName(16);
  $view['page[feed]'] = 1;
  $view['page[feed_properties][path]'] = $this->randomName(16);
  $view['block[create]'] = 1;
  $view['block[title]'] = $this->randomName(16);
  $this->backdropPost('admin/structure/views/add', $view, t('Save view'));

  // Put the block into the first sidebar region, and make sure it will not
  // display on the view's page display (since we will be searching for the
  // presence/absence of the view's title in both the page and the block).
  views_invalidate_cache();
  $layout = layout_load('default');
  $block = $layout->addBlock('views', $view['name'] . '-block', 'sidebar');
  $block->conditions[] = layout_create_access('path', array(
    'settings' => array(
      'visibility_setting' => 0,
      'paths' => $view['page[path]'],
    )
  ));
  $layout->save();

  // Add a node that will appear in the view, so that the block will actually
  // be displayed.
  $this->backdropCreateNode();

  // Make sure that the feed, page and block all start off with the correct
  // titles.
  $this->backdropGet($view['page[path]']);
  $this->assertText($view['page[title]']);
  $this->assertNoText($view['block[title]']);
  $this->backdropGet($view['page[feed_properties][path]']);
  $this->assertText($view['page[title]']);
  $this->assertNoText($view['block[title]']);
  $this->backdropGet('user');
  $this->assertText($view['block[title]']);
  $this->assertNoText($view['page[title]']);

  // Configure the page and change the title. This should automatically change
  // the feed's title also, but not the block.
  $edit = array();
  $edit['title'] = $new_default_title = $this->randomName(16);
  $this->backdropPost("admin/structure/views/nojs/display/{$view['name']}/page/title", $edit, t('Apply'));
  $this->backdropPost("admin/structure/views/view/{$view['name']}/configure/page", array(), t('Save'));
  $this->backdropGet($view['page[path]']);
  $this->assertText($new_default_title);
  $this->assertNoText($view['page[title]']);
  $this->assertNoText($view['block[title]']);
  $this->backdropGet($view['page[feed_properties][path]']);
  $this->assertText($new_default_title);
  $this->assertNoText($view['page[title]']);
  $this->assertNoText($view['block[title]']);
  $this->backdropGet('user');
  $this->assertText($view['block[title]']);
  $this->assertNoText($new_default_title);
  $this->assertNoText($view['page[title]']);

  // Configure the block and change the title. This should automatically
  // change the block title only, and leave the defaults alone.
  $edit = array();
  $edit['title'] = $new_block_title = $this->randomName(16);
  $this->backdropPost("admin/structure/views/nojs/display/{$view['name']}/block/title", $edit, t('Apply'));
  $this->backdropPost("admin/structure/views/view/{$view['name']}/configure/block", array(), t('Save'));
  $this->backdropGet($view['page[path]']);
  $this->assertText($new_default_title);
  $this->assertNoText($new_block_title);
  $this->backdropGet($view['page[feed_properties][path]']);
  $this->assertText($new_default_title);
  $this->assertNoText($new_block_title);
  $this->backdropGet('user');
  $this->assertText($new_block_title);
  $this->assertNoText($view['block[title]']);
}