1 views_pager.test public ViewsPagerTest::testStorePagerSettings()

Pagers was sometimes not stored.

See also

http://drupal.org/node/652712

File

core/modules/views/tests/views_pager.test, line 19
Definition of ViewsPagerTest.

Class

ViewsPagerTest
Tests the pluggable pager system.

Code

public function testStorePagerSettings() {
  $admin_user = $this->backdropCreateUser(array('administer views', 'administer site configuration'));
  $this->backdropLogin($admin_user);
  // Test behaviour described in http://drupal.org/node/652712#comment-2354918.
  $this->backdropGet('admin/structure/views/view/promoted/configure');

  $edit = array(
    'pager_options[items_per_page]' => 20,
  );
  $this->backdropPost('admin/structure/views/nojs/display/promoted/default/pager_options', $edit, t('Apply'));
  $this->assertText('20 items');

  // Change type and check whether the type is new type is stored.
  $edit = array();
  $edit = array(
    'pager[type]' => 'mini',
  );
  $this->backdropPost('admin/structure/views/nojs/display/promoted/default/pager', $edit, t('Apply'));
  $this->backdropGet('admin/structure/views/view/promoted/configure');
  $this->assertText('Mini', 'Changed pager plugin, should change some text');

  // Test behaviour described in http://drupal.org/node/652712#comment-2354400
  $view = $this->viewsStorePagerSettings();
  // Make it configurable in the admin interface.
  $view->save();

  $this->backdropGet('admin/structure/views/view/test_store_pager_settings/configure');

  $edit = array();
  $edit = array(
    'pager[type]' => 'full',
  );
  $this->backdropPost('admin/structure/views/nojs/display/test_store_pager_settings/default/pager', $edit, t('Apply'));
  $this->backdropGet('admin/structure/views/view/test_store_pager_settings/configure');
  $this->assertText('Full');

  $edit = array(
    'pager_options[items_per_page]' => 20,
  );
  $this->backdropPost('admin/structure/views/nojs/display/test_store_pager_settings/default/pager_options', $edit, t('Apply'));
  $this->assertText('20 items');

  // add new display and test the settings again, by override it.
  $edit = array();
  // Add a display and override the pager settings.
  $this->backdropPost('admin/structure/views/view/test_store_pager_settings/configure', $edit, t('Add Page'));
  $edit = array(
    'override[dropdown]' => 'page_1',
  );
  $this->backdropPost('admin/structure/views/nojs/display/test_store_pager_settings/page_1/pager', $edit, t('Apply'));

  $edit = array(
    'pager[type]' => 'mini',
  );
  $this->backdropPost('admin/structure/views/nojs/display/test_store_pager_settings/page_1/pager', $edit, t('Apply'));
  $this->backdropGet('admin/structure/views/view/test_store_pager_settings/configure');
  $this->assertText('Mini', 'Changed pager plugin, should change some text');

  $edit = array(
    'pager_options[items_per_page]' => 10,
  );
  $this->backdropPost('admin/structure/views/nojs/display/test_store_pager_settings/default/pager_options', $edit, t('Apply'));
  $this->assertText('20 items');

}