function ViewsPagerTest::testStorePagerSettings

Pagers was sometimes not stored.

See also

http://drupal.org/node/652712

File

tests/views_pager.test, line 29

Class

ViewsPagerTest
Tests the pluggable pager system.

Code

public function testStorePagerSettings() {
    $admin_user = $this->drupalCreateUser(array(
        'administer views',
        'administer site configuration',
    ));
    $this->drupalLogin($admin_user);
    // Test behaviour described in
    // http://drupal.org/node/652712#comment-2354918.
    $this->drupalGet('admin/structure/views/view/frontpage/edit');
    $edit = array(
        'pager_options[items_per_page]' => 20,
    );
    $this->drupalPost('admin/structure/views/nojs/display/frontpage/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->drupalPost('admin/structure/views/nojs/display/frontpage/default/pager', $edit, t('Apply'));
    $this->drupalGet('admin/structure/views/view/frontpage/edit');
    $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 editable in the admin interface.
    $view->save();
    $this->drupalGet('admin/structure/views/view/test_store_pager_settings/edit');
    $edit = array();
    $edit = array(
        'pager[type]' => 'full',
    );
    $this->drupalPost('admin/structure/views/nojs/display/test_store_pager_settings/default/pager', $edit, t('Apply'));
    $this->drupalGet('admin/structure/views/view/test_store_pager_settings/edit');
    $this->assertText('Full');
    $edit = array(
        'pager_options[items_per_page]' => 20,
    );
    $this->drupalPost('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->drupalPost('admin/structure/views/view/test_store_pager_settings/edit', $edit, t('Add Page'));
    $edit = array(
        'override[dropdown]' => 'page_1',
    );
    $this->drupalPost('admin/structure/views/nojs/display/test_store_pager_settings/page_1/pager', $edit, t('Apply'));
    $edit = array(
        'pager[type]' => 'mini',
    );
    $this->drupalPost('admin/structure/views/nojs/display/test_store_pager_settings/page_1/pager', $edit, t('Apply'));
    $this->drupalGet('admin/structure/views/view/test_store_pager_settings/edit');
    $this->assertText('Mini', 'Changed pager plugin, should change some text');
    $edit = array(
        'pager_options[items_per_page]' => 10,
    );
    $this->drupalPost('admin/structure/views/nojs/display/test_store_pager_settings/default/pager_options', $edit, t('Apply'));
    $this->assertText('20 items');
}