Support from Acquia helps fund testing for Drupal Acquia logo

Comments

andypost’s picture

Status: Active » Needs review
FileSize
4.98 KB

Just added a weight for test config entity and test that shows exception

Status: Needs review » Needs work

The last submitted patch, 1799600-config-list-test-1.patch, failed testing.

tim.plunkett’s picture

Tagging.

andypost’s picture

Title: Fix sorting of configuration entities » Add test of sorting for configuration entities
FileSize
4.81 KB

Here's patch with test, suppose the issue was fixed with sorting removal for keys

sun’s picture

Status: Needs work » Needs review
+++ b/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTest.php
@@ -42,4 +42,10 @@ class ConfigTest extends ConfigEntityBase {
+  /**
+   * The weight of the configuration entity in relation to others.
+   *
+   * @var integer
+   */
+  public $weight = 0;

Not all config entities need a weight - this property needs to go into individual config entity classes.

Status: Needs review » Needs work

The last submitted patch, 1799600-config-list-test-4.patch, failed testing.

sun’s picture

Status: Needs work » Postponed (maintainer needs more info)

Sorry, my comment in #5 was completely off — I misinterpreted the affected files.

That said, I still do not understand what exact bug this issue tries to fix. The information provided in this issue so far does not clarify either. The issue summary should be updated to precisely state what's wrong and under which circumstances a PHP notice is triggered.

andypost’s picture

Status: Postponed (maintainer needs more info) » Needs review
FileSize
4.89 KB

Here's a re-roll of test.

The purpose of the patch to show that sorting/comparison of 2 config entities throws warning, Proper fix probably depends on php version

Status: Needs review » Needs work

The last submitted patch, 1799600-config-list-test-8.patch, failed testing.

andypost’s picture

Status: Needs work » Needs review
FileSize
5.39 KB

It looks like now sorting is no more issue, test passed locally. But I think it's better to include this test because config entity has ConfigEntityBase::sort() method that is not covered by tests yet, the same applies to ConfigEntityListController::load which calls sort()

andyceo’s picture

Status: Needs review » Needs work

The last submitted patch, 1799600-config-list-test-10.patch, failed testing.

andypost’s picture

Status: Needs work » Needs review
Issue tags: +Configuration system, +Configurables

#10: 1799600-config-list-test-10.patch queued for re-testing.

tim.plunkett’s picture

Component: configuration system » configuration entity system
aspilicious’s picture

#10: 1799600-config-list-test-10.patch queued for re-testing.

damiankloip’s picture

Status: Needs review » Needs work

Always a big fan of more test coverage :)

+++ b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.phpundefined
@@ -88,6 +88,22 @@ function testList() {
+    $entity = entity_create('config_test', array(
+      'id' => 'alpha',
+      'label' => 'Alpha',
+      'weight' => 1,
+    ));
+    $entity->save();
+    $entity = entity_create('config_test', array(
+      'id' => 'omega',
+      'label' => 'Omega',
+      'weight' => 1,
+    ));
+    $entity->save();
+    $list = $controller->load();
+    $entity = end($list);

Would this be better with an assertIdentical($actual, $expected) to test the array order (maybe just test array keys of the actual against an expected order array)? Maybe we should add another entity to the mix too that has a lower weight than these two, then we are not just covering equal weights.

+++ b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.phpundefined
@@ -88,6 +88,22 @@ function testList() {
+    $this->assertEqual($entity->label, 'Omega');

Might as well call the label() method here?

+++ b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.phpundefined
@@ -142,8 +162,8 @@ function testListUI() {
+    $this->assertLink('Edit', 1);
+    $this->clickLink('Edit', 1);

Not really a fan of using the index here, maybe assertLinkByHref instead? Same goes for the changes to the delete assertions.

+++ b/core/modules/config/tests/config_test/lib/Drupal/config_test/Plugin/Core/Entity/ConfigTest.phpundefined
@@ -56,6 +56,13 @@ class ConfigTest extends ConfigEntityBase {
+   * The weight of the configuration entity in relation to others.

Is this in relation to others? only when we list it, otherwise I would just call this 'The weight of the configuration entity'. Do we just use @var int too?

andypost’s picture

Status: Needs work » Needs review
FileSize
5.78 KB
2.33 KB

Changes with #16

andypost’s picture

re-roll

Status: Needs review » Needs work
Issue tags: -Configuration system, -Configurables

The last submitted patch, 1799600-config-list-test-18.patch, failed testing.

andypost’s picture

Status: Needs work » Needs review
Issue tags: +Configuration system, +Configurables

#18: 1799600-config-list-test-18.patch queued for re-testing.

dawehner’s picture

This is looking great so far.

+++ b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.phpundefined
@@ -98,6 +98,27 @@ function testList() {
+    $entity = entity_create('config_test', array(
...
+    $entity = entity_create('config_test', array(
...
+    $entity = entity_create('config_test', array(

Do you know whether there should be used the storage controller directly to create the entities in the test? This would make it easier to convert it to unit tests at some point.

+++ b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.phpundefined
@@ -98,6 +98,27 @@ function testList() {
+    $list = $controller->load();
+    $this->assertIdentical(array_keys($list), array('beta', 'dotted.default', 'alpha', 'omega'));

It would be great to refer somehow to ConfigEntityBase::sort(), as that's what is tested here. That's just easier for people to figure out what's done here. What do you think about a custom assertion message?

+++ b/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestFormController.phpundefined
@@ -35,6 +35,11 @@ public function form(array $form, array &$form_state, EntityInterface $entity) {
+      '#title' => 'Weight',

I know the other form elements don't mark the title as translatable, but shouldn't that be done?

andypost’s picture

FileSize
5.95 KB
1.18 KB

1) fixed
2) We are testing that load() returns in right order
3) we never use t() in testing modules

Status: Needs review » Needs work

The last submitted patch, 1799600-sorttest-22.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review
FileSize
5.96 KB

Rerolled.

dawehner’s picture

ignore comment.

andypost’s picture

@dawehner I cant rtbc my patch :( bot is happy

damiankloip’s picture

Status: Needs review » Reviewed & tested by the community

I think I can... I only rerolled it.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed cbb579b and pushed to 8.x. Thanks!

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Updated issue summary.