function RearrangeFieldsTest::testRearrangeFields
Same name in other branches
- 9 core/modules/views_ui/tests/src/Functional/RearrangeFieldsTest.php \Drupal\Tests\views_ui\Functional\RearrangeFieldsTest::testRearrangeFields()
- 8.9.x core/modules/views_ui/tests/src/Functional/RearrangeFieldsTest.php \Drupal\Tests\views_ui\Functional\RearrangeFieldsTest::testRearrangeFields()
- 10 core/modules/views_ui/tests/src/Functional/RearrangeFieldsTest.php \Drupal\Tests\views_ui\Functional\RearrangeFieldsTest::testRearrangeFields()
Tests field sorting.
File
-
core/
modules/ views_ui/ tests/ src/ Functional/ RearrangeFieldsTest.php, line 63
Class
- RearrangeFieldsTest
- Tests the reordering of fields via AJAX.
Namespace
Drupal\Tests\views_ui\FunctionalCode
public function testRearrangeFields() : void {
$view_name = 'test_view';
// Checks that the order on the rearrange form matches the creation order.
$this->assertFieldOrder($view_name, $this->getViewFields($view_name));
// Checks that a field is not deleted if a value is not passed back.
$fields = [];
$this->drupalGet('admin/structure/views/nojs/rearrange/' . $view_name . '/default/field');
$this->submitForm($fields, 'Apply');
$this->assertFieldOrder($view_name, $this->getViewFields($view_name));
// Checks that revers the new field order is respected.
$reversedFields = array_reverse($this->getViewFields($view_name));
$fields = [];
foreach ($reversedFields as $delta => $field) {
$fields['fields[' . $field . '][weight]'] = $delta;
}
$fields_count = count($fields);
$this->drupalGet('admin/structure/views/nojs/rearrange/' . $view_name . '/default/field');
$this->submitForm($fields, 'Apply');
$this->assertFieldOrder($view_name, $reversedFields);
// Checks that there is a remove link for each field.
$this->assertCount($fields_count, $this->cssSelect('a.views-remove-link'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.