You are here

function ViewsUIWizardDefaultViewsTestCase::testDefaultViews in Views (for Drupal 7) 7.3

Tests default views.

File

tests/views_ui.test, line 183
Tests Views UI Wizard.

Class

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

Code

function testDefaultViews() {

  // Make sure the front page view starts off as disabled (does not appear on
  // the listing page).
  $edit_href = 'admin/structure/views/view/frontpage/edit';
  $this
    ->drupalGet('admin/structure/views');

  // @todo Disabled default views do now appear on the front page. Test this
  // behavior with templates instead.
  // $this->assertNoLinkByHref($edit_href);
  // Enable the front page view, and make sure it is now visible on the main
  // listing page.
  $this
    ->drupalGet('admin/structure/views/templates');
  $this
    ->clickViewsOperationLink(t('Enable'), '/frontpage/');
  $this
    ->assertUrl('admin/structure/views');
  $this
    ->assertLinkByHref($edit_href);

  // It should not be possible to revert the view yet.
  $this
    ->assertNoLink(t('Revert'));
  $revert_href = 'admin/structure/views/view/frontpage/revert';
  $this
    ->assertNoLinkByHref($revert_href);

  // Edit the view and change the title. Make sure that the new title is
  // displayed.
  $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'));
  $this
    ->drupalGet('frontpage');
  $this
    ->assertText($new_title);

  // 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
    ->drupalGet('admin/structure/views');
  $this
    ->assertLink(t('Revert'));
  $this
    ->assertLinkByHref($revert_href);
  $this
    ->drupalPost($revert_href, array(), t('Revert'));
  $this
    ->drupalGet('frontpage');
  $this
    ->assertNoText($new_title);

  // Now disable the view, and make sure it stops appearing on the main view
  // listing page but instead goes back to displaying on the disabled views
  // listing page.
  // @todo Test this behavior with templates instead.
  $this
    ->drupalGet('admin/structure/views');
  $this
    ->clickViewsOperationLink(t('Disable'), '/frontpage/');

  // $this->assertUrl('admin/structure/views');
  // $this->assertNoLinkByHref($edit_href);
  // The easiest way to verify it appears on the disabled views listing page
  // is to try to click the "enable" link from there again.
  $this
    ->drupalGet('admin/structure/views/templates');
  $this
    ->clickViewsOperationLink(t('Enable'), '/frontpage/');
  $this
    ->assertUrl('admin/structure/views');
  $this
    ->assertLinkByHref($edit_href);
}