public function PagerTest::testStorePagerSettings in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/views/src/Tests/Plugin/PagerTest.php \Drupal\views\Tests\Plugin\PagerTest::testStorePagerSettings()
Pagers was sometimes not stored.
See also
https://www.drupal.org/node/652712
File
- core/
modules/ views/ src/ Tests/ Plugin/ PagerTest.php, line 49 - Contains \Drupal\views\Tests\Plugin\PagerTest.
Class
- PagerTest
- Tests the pluggable pager system.
Namespace
Drupal\views\Tests\PluginCode
public function testStorePagerSettings() {
$admin_user = $this
->drupalCreateUser(array(
'administer views',
'administer site configuration',
));
$this
->drupalLogin($admin_user);
// Test behavior described in
// https://www.drupal.org/node/652712#comment-2354918.
$this
->drupalGet('admin/structure/views/view/test_view/edit');
$edit = array(
'pager[type]' => 'full',
);
$this
->drupalPostForm('admin/structure/views/nojs/display/test_view/default/pager', $edit, t('Apply'));
$edit = array(
'pager_options[items_per_page]' => 20,
);
$this
->drupalPostForm('admin/structure/views/nojs/display/test_view/default/pager_options', $edit, t('Apply'));
$this
->assertText('20 items');
// Change type and check whether the type is new type is stored.
$edit = array(
'pager[type]' => 'mini',
);
$this
->drupalPostForm('admin/structure/views/nojs/display/test_view/default/pager', $edit, t('Apply'));
$this
->drupalGet('admin/structure/views/view/test_view/edit');
$this
->assertText('Mini', 'Changed pager plugin, should change some text');
// Test behavior described in
// https://www.drupal.org/node/652712#comment-2354400.
$view = Views::getView('test_store_pager_settings');
// Make it editable in the admin interface.
$view
->save();
$this
->drupalGet('admin/structure/views/view/test_store_pager_settings/edit');
$edit = array(
'pager[type]' => 'full',
);
$this
->drupalPostForm('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
->drupalPostForm('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
->drupalPostForm('admin/structure/views/view/test_store_pager_settings/edit', $edit, t('Add Page'));
$edit = array(
'override[dropdown]' => 'page_1',
);
$this
->drupalPostForm('admin/structure/views/nojs/display/test_store_pager_settings/page_1/pager', $edit, t('Apply'));
$edit = array(
'pager[type]' => 'mini',
);
$this
->drupalPostForm('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
->drupalPostForm('admin/structure/views/nojs/display/test_store_pager_settings/default/pager_options', $edit, t('Apply'));
$this
->assertText('10 items', 'The default value has been changed.');
$this
->drupalGet('admin/structure/views/view/test_store_pager_settings/edit/page_1');
$this
->assertText('20 items', 'The original value remains unchanged.');
// Test that the override element is only displayed on pager plugin selection form.
$this
->drupalGet('admin/structure/views/nojs/display/test_store_pager_settings/page_1/pager');
$this
->assertFieldByName('override[dropdown]', 'page_1', 'The override element is displayed on plugin selection form.');
$this
->drupalGet('admin/structure/views/nojs/display/test_store_pager_settings/page_1/pager_options');
$this
->assertNoFieldByName('override[dropdown]', NULL, 'The override element is not displayed on plugin settings form.');
}