Commit cbb579b0 authored by alexpott's avatar alexpott
Browse files

Issue #1799600 by andypost, damiankloip: Add test of sorting for configuration entities.

parent 5de39415
......@@ -98,6 +98,28 @@ function testList() {
);
$actual_items = $controller->buildRow($entity);
$this->assertIdentical($expected_items, $actual_items, 'Return value from buildRow matches expected.');
// Test sorting.
$storage_controller = $controller->getStorageController();
$entity = $storage_controller->create(array(
'id' => 'alpha',
'label' => 'Alpha',
'weight' => 1,
));
$entity->save();
$entity = $storage_controller->create(array(
'id' => 'omega',
'label' => 'Omega',
'weight' => 1,
));
$entity->save();
$entity = $storage_controller->create(array(
'id' => 'beta',
'label' => 'Beta',
'weight' => 0,
));
$entity->save();
$list = $controller->load();
$this->assertIdentical(array_keys($list), array('beta', 'dotted.default', 'alpha', 'omega'));
// Test that config entities that do not support status, do not have
// enable/disable operations.
......@@ -172,7 +194,11 @@ function testListUI() {
$this->assertLink('Add test configuration');
$this->clickLink('Add test configuration');
$this->assertResponse(200);
$edit = array('label' => 'Antelope', 'id' => 'antelope');
$edit = array(
'label' => 'Antelope',
'id' => 'antelope',
'weight' => 1,
);
$this->drupalPost(NULL, $edit, t('Save'));
// Ensure that the entity's sort method was called.
......@@ -185,8 +211,8 @@ function testListUI() {
$this->assertFieldByXpath('//td', 'antelope', "Machine name found for added 'Antelope' entity.");
// Edit the entity using the operations link.
$this->assertLink('Edit');
$this->clickLink('Edit');
$this->assertLinkByHref('admin/structure/config_test/manage/antelope/edit');
$this->clickLink('Edit', 1);
$this->assertResponse(200);
$this->assertTitle('Edit Antelope | Drupal');
$edit = array('label' => 'Albatross', 'id' => 'albatross');
......@@ -199,8 +225,8 @@ function testListUI() {
$this->assertFieldByXpath('//td', 'albatross', "Machine name found for updated 'Albatross' entity.");
// Delete the added entity using the operations link.
$this->assertLink('Delete');
$this->clickLink('Delete');
$this->assertLinkByHref('admin/structure/config_test/manage/albatross/delete');
$this->clickLink('Delete', 1);
$this->assertResponse(200);
$this->assertTitle('Are you sure you want to delete Albatross | Drupal');
$this->drupalPost(NULL, array(), t('Delete'));
......
......@@ -59,6 +59,7 @@ function testImport() {
'id' => 'new',
'uuid' => '30df59bd-7b03-4cf7-bb35-d42fc49f0651',
'label' => 'New',
'weight' => '0',
'style' => '',
'status' => '1',
'langcode' => language_default()->langcode,
......
......@@ -129,6 +129,7 @@ function testNew() {
'id' => 'new',
'uuid' => '30df59bd-7b03-4cf7-bb35-d42fc49f0651',
'label' => 'New',
'weight' => '0',
'style' => '',
'status' => '1',
'langcode' => language_default()->langcode,
......
id: dotted.default
label: Default
weight: 0
protected_property: Default
# Intentionally commented out to verify default status behavior.
# status: 1
......@@ -35,6 +35,11 @@ public function form(array $form, array &$form_state) {
'exists' => 'config_test_load',
),
);
$form['weight'] = array(
'#type' => 'weight',
'#title' => 'Weight',
'#default_value' => $entity->get('weight'),
);
$form['style'] = array(
'#type' => 'select',
'#title' => 'Image style',
......
......@@ -58,6 +58,13 @@ class ConfigTest extends ConfigEntityBase {
*/
public $label;
/**
* The weight of the configuration entity.
*
* @var int
*/
public $weight = 0;
/**
* The image style to use.
*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment