diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php index 365f2e4..661d87d 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php @@ -88,6 +88,23 @@ class ConfigEntityListTest extends WebTestBase { ); $actual_items = $controller->buildRow($entity); $this->assertIdentical($expected_items, $actual_items, 'Return value from buildRow matches expected.'); + + // Test sorting. + $entity = entity_create('config_test', array( + 'id' => 'albatros', + 'label' => 'Albatros', + 'weight' => 1, + )); + $entity->save(); + $entity = entity_create('config_test', array( + 'id' => 'antelope', + 'label' => 'Antelope', + 'weight' => 1, + )); + $entity->save(); + $list = $controller->load(); + $entity = end($list); + $this->assertEqual($entity->weight, 1); } /** @@ -98,7 +115,7 @@ class ConfigEntityListTest extends WebTestBase { $this->drupalLogin($this->drupalCreateUser(array('access administration pages'))); // Get the list callback page. - $page = $this->drupalGet('admin/structure/config_test'); + $this->drupalGet('admin/structure/config_test'); // Test for the page title. $this->assertTitle('Test configuration | Drupal'); @@ -146,7 +163,11 @@ class ConfigEntityListTest extends WebTestBase { $this->clickLink('Edit'); $this->assertResponse(200); $this->assertTitle('Edit test configuration | Drupal'); - $edit = array('label' => 'Albatross', 'id' => 'albatross'); + $edit = array( + 'label' => 'Albatross', + 'id' => 'albatross', + 'weight' => 1, + ); $this->drupalPost(NULL, $edit, t('Save')); // Confirm that the user is returned to the listing, and verify that the @@ -156,8 +177,8 @@ class ConfigEntityListTest extends WebTestBase { $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->assertLink('Delete', 1); + $this->clickLink('Delete', 1); $this->assertResponse(200); $this->assertTitle('Are you sure you want to delete Albatross | Drupal'); $this->drupalPost(NULL, array(), t('Delete')); diff --git a/core/modules/config/tests/config_test/config/config_test.dynamic.default.yml b/core/modules/config/tests/config_test/config/config_test.dynamic.default.yml index 3e50e3b..c22273b 100644 --- a/core/modules/config/tests/config_test/config/config_test.dynamic.default.yml +++ b/core/modules/config/tests/config_test/config/config_test.dynamic.default.yml @@ -1,2 +1,3 @@ id: default label: Default +weight: 0 diff --git a/core/modules/config/tests/config_test/config_test.module b/core/modules/config/tests/config_test/config_test.module index 44df4da..670124b 100644 --- a/core/modules/config/tests/config_test/config_test.module +++ b/core/modules/config/tests/config_test/config_test.module @@ -218,6 +218,11 @@ function config_test_form($form, &$form_state, ConfigTest $config_test = NULL) { 'source' => array('label'), ), ); + $form['weight'] = array( + '#type' => 'weight', + '#title' => 'Weight', + '#default_value' => $config_test->weight, + ); $form['style'] = array( '#type' => 'select', '#title' => 'Image style', diff --git a/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTest.php b/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTest.php index e1df5c4..a4c7cbf 100644 --- a/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTest.php +++ b/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTest.php @@ -42,4 +42,11 @@ class ConfigTest extends ConfigEntityBase { */ public $style; + /** + * The weight of the configuration entity in relation to others. + * + * @var integer + */ + public $weight = 0; + }