summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2013-05-31 08:53:45 (GMT)
committer Alex Pott2013-05-31 08:53:45 (GMT)
commitcbb579b037aad72069cd38e1e04cde7068cf0df1 (patch)
tree06b9a488619f5c7409131da99741fa1ff15f52ba
parent5de39415fd07f8d9f643c272613699248d911f41 (diff)
Issue #1799600 by andypost, damiankloip: Add test of sorting for configuration entities.
-rw-r--r--core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php36
-rw-r--r--core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php1
-rw-r--r--core/modules/config/lib/Drupal/config/Tests/ConfigImporterTest.php1
-rw-r--r--core/modules/config/tests/config_test/config/config_test.dynamic.dotted.default.yml1
-rw-r--r--core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestFormController.php5
-rw-r--r--core/modules/config/tests/config_test/lib/Drupal/config_test/Plugin/Core/Entity/ConfigTest.php7
6 files changed, 46 insertions, 5 deletions
diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php
index b67cb4a..1847a98 100644
--- a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php
+++ b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php
@@ -98,6 +98,28 @@ class ConfigEntityListTest extends WebTestBase {
);
$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 @@ class ConfigEntityListTest extends WebTestBase {
$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 @@ class ConfigEntityListTest extends WebTestBase {
$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 @@ 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->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'));
diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php
index 61c6e47..c2863f7 100644
--- a/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php
+++ b/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php
@@ -59,6 +59,7 @@ class ConfigImportUITest extends WebTestBase {
'id' => 'new',
'uuid' => '30df59bd-7b03-4cf7-bb35-d42fc49f0651',
'label' => 'New',
+ 'weight' => '0',
'style' => '',
'status' => '1',
'langcode' => language_default()->langcode,
diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigImporterTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigImporterTest.php
index 9d1e6be..0160ee3 100644
--- a/core/modules/config/lib/Drupal/config/Tests/ConfigImporterTest.php
+++ b/core/modules/config/lib/Drupal/config/Tests/ConfigImporterTest.php
@@ -129,6 +129,7 @@ class ConfigImporterTest extends DrupalUnitTestBase {
'id' => 'new',
'uuid' => '30df59bd-7b03-4cf7-bb35-d42fc49f0651',
'label' => 'New',
+ 'weight' => '0',
'style' => '',
'status' => '1',
'langcode' => language_default()->langcode,
diff --git a/core/modules/config/tests/config_test/config/config_test.dynamic.dotted.default.yml b/core/modules/config/tests/config_test/config/config_test.dynamic.dotted.default.yml
index bc52b35..93c3a77 100644
--- a/core/modules/config/tests/config_test/config/config_test.dynamic.dotted.default.yml
+++ b/core/modules/config/tests/config_test/config/config_test.dynamic.dotted.default.yml
@@ -1,5 +1,6 @@
id: dotted.default
label: Default
+weight: 0
protected_property: Default
# Intentionally commented out to verify default status behavior.
# status: 1
diff --git a/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestFormController.php b/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestFormController.php
index efba401..119774b 100644
--- a/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestFormController.php
+++ b/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestFormController.php
@@ -35,6 +35,11 @@ class ConfigTestFormController extends EntityFormController {
'exists' => 'config_test_load',
),
);
+ $form['weight'] = array(
+ '#type' => 'weight',
+ '#title' => 'Weight',
+ '#default_value' => $entity->get('weight'),
+ );
$form['style'] = array(
'#type' => 'select',
'#title' => 'Image style',
diff --git a/core/modules/config/tests/config_test/lib/Drupal/config_test/Plugin/Core/Entity/ConfigTest.php b/core/modules/config/tests/config_test/lib/Drupal/config_test/Plugin/Core/Entity/ConfigTest.php
index 2983a44..2337a69 100644
--- a/core/modules/config/tests/config_test/lib/Drupal/config_test/Plugin/Core/Entity/ConfigTest.php
+++ b/core/modules/config/tests/config_test/lib/Drupal/config_test/Plugin/Core/Entity/ConfigTest.php
@@ -59,6 +59,13 @@ class ConfigTest extends ConfigEntityBase {
public $label;
/**
+ * The weight of the configuration entity.
+ *
+ * @var int
+ */
+ public $weight = 0;
+
+ /**
* The image style to use.
*
* @var string