// Click the Expose sort button.
$edit =
[];
$this->
drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/sort/created'
);
$this->
submitForm($edit, 'Expose sort'
);
// Check the label of the expose button.
$this->
helperButtonHasLabel('edit-options-expose-button-button', 'Hide sort'
);
$this->
assertSession()->
fieldValueEquals('edit-options-expose-label', 'Authored on'
);
$this->
assertSession()->
fieldValueEquals('Sort field identifier', 'created'
);
// Test adding a new exposed sort criteria.
$view_id =
$this->
randomView()['id'
];
$this->
drupalGet("admin/structure/views/nojs/add-handler/
$view_id/default/sort"
);
$this->
submitForm(['name[node_field_data.created]' => 1
], 'Add and configure sort criteria'
);
$this->
assertSession()->
fieldValueEquals('options[order]', 'ASC'
);
// Change the order and expose the sort.
$this->
submitForm(['options[order]' => 'DESC'
], 'Apply'
);
$this->
drupalGet("admin/structure/views/nojs/handler/{
$view_id}/default/sort/created"
);
$this->
submitForm([], 'Expose sort'
);
$this->
assertSession()->
fieldValueEquals('options[order]', 'DESC'
);
$this->
assertSession()->
fieldValueEquals('options[expose][label]', 'Authored on'
);
$this->
assertSession()->
fieldValueEquals('Sort field identifier', 'created'
);