1 views_ui.test ViewsUIWizardDefaultViewsTestCase::testDefaultViews()

Tests default views.

File

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

Class

ViewsUIWizardDefaultViewsTestCase
Tests enabling, disabling, and reverting default views via the listing page.

Code

function testDefaultViews() {
  // Make sure the taxonomy term view starts off as disabled.
  $edit_href = 'admin/structure/views/view/taxonomy_term';
  $this->backdropGet('admin/structure/views');
  // TODO: Disabled default views do now appear on the home page. Test this
  // behavior with templates instead.
  // $this->assertNoLinkByHref($edit_href);

  // Enable the home page view, and make sure it is now visible on the main
  // listing page.
  $this->backdropGet('admin/structure/views/templates');
  $this->clickViewsOperationLink(t('Enable'), '/taxonomy_term/');
  $this->assertUrl('admin/structure/views');
  $this->assertLinkByHref($edit_href);

  // Configure the view and add a class. Make sure that the new class is
  // added correctly.
  $new_class = $this->randomName(16);
  $edit = array('css_class' => $new_class);
  $this->backdropPost('admin/structure/views/nojs/display/taxonomy_term/page/css_class', $edit, t('Apply'));
  $this->backdropPost('admin/structure/views/view/taxonomy_term/configure/page', array(), t('Save'));

  // Add a term so we can visit this page to test the view.
  $term = entity_create('taxonomy_term', array(
    'name' => $this->randomName(),
    'description' => $this->randomName(),
    'format' => filter_default_format(),
    'vocabulary' => 'tags',
    'langcode' => LANGUAGE_NONE,
  ));
  taxonomy_term_save($term);

  $this->backdropGet('taxonomy/term/' . $term->tid);
  $this->assertRaw($new_class);

  // It should now be possible to revert the view. Do that, and make sure the
  // view title we added above no longer is displayed.
  $this->backdropGet('admin/structure/views');
  $this->assertLink(t('Revert'));
  $revert_href = 'admin/structure/views/view/taxonomy_term/revert';
  $this->assertLinkByHref($revert_href);
  $this->backdropPost($revert_href, array(), t('Revert'));
  $this->backdropGet('taxonomy/term/' . $term->tid);
  $this->assertNoRaw($new_class);

  // After reverting, the view will be disabled again. Try to click the
  // "enable" link from there again.
  $this->backdropGet('admin/structure/views/templates');
  $this->clickViewsOperationLink(t('Enable'), '/taxonomy_term/');
  $this->assertUrl('admin/structure/views');
  $this->assertLinkByHref($edit_href);
}