Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tim.plunkett’s picture

Status: Active » Needs review
FileSize
47.34 KB
tim.plunkett’s picture

Issue tags: +FormInterface

Tagging.

Status: Needs review » Needs work

The last submitted patch, user-1924992-1.patch, failed testing.

tim.plunkett’s picture

FileSize
1.77 KB
49.11 KB

I'll have to ask chx if he thinks drupal_form_submit() should work with FormInterface. In the meantime, here's a fix.

tim.plunkett’s picture

Status: Needs work » Postponed

Nope, that workaround should be removed, this is a bug. Postponing on #1925140: drupal_form_submit() does not accept FormInterface objects

tim.plunkett’s picture

FileSize
707 bytes

I fixed #1925140: drupal_form_submit() does not accept FormInterface objects but its not in yet, here's the interdiff from #1, I'll post a patch when there are less dependencies.

tim.plunkett’s picture

Status: Postponed » Needs review
FileSize
40.57 KB

Those other issues were committed.

tim.plunkett’s picture

Assigned: tim.plunkett » Unassigned
Status: Needs review » Needs work
Issue tags: +SprintWeekend2013
amateescu’s picture

Status: Needs work » Needs review
FileSize
23.03 KB
40.42 KB

Rerolled.

Status: Needs review » Needs work

The last submitted patch, user-1924992-9.patch, failed testing.

robmc’s picture

Assigned: Unassigned » robmc
damiankloip’s picture

Status: Needs work » Needs review
FileSize
917 bytes
21.31 KB

It looks good, I think we just need to change the test as well to reflect those changes?

Crell’s picture

+++ b/core/modules/user/lib/Drupal/user/AccountSettingsForm.php
@@ -0,0 +1,450 @@
+    $this->configFactory->enterContext($context);

If we're entering a config context here, when are we leaving it?

Otherwise this looks fine to me. Well, aside from the form having way too many values in it to be considered sane, but this is not the issue to deal with that. :-)

tim.plunkett’s picture

Status: Needs review » Needs work

The newest patch is missing all of the changes to user_menu(), as well as deleting any of the old user_admin_settings() code.

I answer @Crell's question with another question: Where does anything ever leave that context? I see config_import(), config_install_default_config(), user_mail() (what?!), and no where else but tests.

Crell’s picture

Um, duh. Crell--. I can't even claim it's late for missing that. :-)

damiankloip’s picture

Assigned: robmc » Unassigned
Status: Needs work » Needs review
FileSize
19.25 KB
40.56 KB

Not sure what happened there, this should be better.

Status: Needs review » Needs work

The last submitted patch, 1924992-16.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review
FileSize
40.56 KB

Without the fatal would be nice.

Crell’s picture

Status: Needs review » Needs work
+++ b/core/modules/user/lib/Drupal/user/Tests/UserAdminSettingsFormTest.php
@@ -21,8 +22,8 @@ public static function getInfo() {
-    module_load_include('admin.inc', 'user');
-    $this->form_id = 'user_admin_settings';
+
+    $this->form_id = AccountSettingsForm::create($this->container);

I know this works, because of how drupal_get_form() works now, but we should probably make it $this->form, not $this->form_id, if what we're saving is a form object and not an ID. (And then adjust the rest of the test accordingly.)

+++ b/core/modules/user/user.module
@@ -1002,8 +1002,7 @@ function user_menu() {
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('user_admin_settings'),
+    'page callback' => 'NOT_USED',

The NOT_USED stuff is gone. Instead, specify 'route_name' => 'user_account_settings'.

I'm actually kinda surprised it worked. :-)

kim.pepper’s picture

Status: Needs work » Needs review
FileSize
2.91 KB
42.21 KB

Made changes as per #19 as well as a couple of other cleanups.

Kim

Status: Needs review » Needs work

The last submitted patch, 1924992-system-config-form-20.patch, failed testing.

kim.pepper’s picture

For some reason Drupal\user\AccountSettingsForm::formSubmit() is not being called to save the form values on drupal_submit_form()

kim.pepper’s picture

Can I suggest we rename this class from SystemConfigFormBase to SystemConfigFormTestBase to make it clearer it's a base class for tests?

tim.plunkett’s picture

There's an issue for that. I'll find it and post it here when I'm at my computer

tim.plunkett’s picture

damiankloip’s picture

Status: Needs work » Needs review
FileSize
1.33 KB
42.8 KB

Just a couple of small things needed fixing.

kim.pepper’s picture

Chasing head.

tim.plunkett’s picture

+++ b/core/modules/user/lib/Drupal/user/AccountSettingsForm.phpundefined
@@ -0,0 +1,450 @@
+    $this->configFactory = $config_factory;
+    $this->configFactory->enterContext($context);

I think this should call parent::__construct($config_factory, $context) instead.

I'm guessing that's the only real change (other than create() which is fine). Interdiffs++ ;)

kim.pepper’s picture

FileSize
1.35 KB

I had some rebasing weirdness for #27 which I assume was due to the rename issue going in #1945326: Rename \Drupal\system\Tests\System\SystemConfigFormBase to \Drupal\system\Tests\System\SystemConfigFormTestBase.

Seems some pretty simple changes to me, but I'm not super sure why those changes came up in the interdiff.

Interdiff for #27 attached.

kim.pepper’s picture

This fixes the issues raised in #28

Crell’s picture

Status: Needs review » Reviewed & tested by the community
+++ b/core/modules/user/lib/Drupal/user/AccountSettingsForm.php
@@ -0,0 +1,449 @@
+    $this->moduleHandler = $module_handler;
+    parent::__construct($config_factory, $context);

It doesn't matter in this case, but it's common practice to call parent::__construct() first and then do the new stuff unless the new stuff is specifically modifying the parameters to pass up to the parent.

Not something that should block a commit; just a note.

I couldn't find anything else to complain about, so unless Tim wants to disagree...

tim.plunkett’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/system/lib/Drupal/system/Tests/Form/FormObjectTest.phpundefined
@@ -33,7 +33,7 @@ public static function getInfo() {
     parent::setUp();
 
-    $this->form_id = new FormTestObject();
+    $this->form = new FormTestObject();
     $this->values = array(
       'bananas' => array(
         '#value' => $this->randomString(10),
diff --git a/core/modules/system/lib/Drupal/system/Tests/System/SystemConfigFormTestBase.php b/core/modules/system/lib/Drupal/system/Tests/System/SystemConfigFormTestBase.php

diff --git a/core/modules/system/lib/Drupal/system/Tests/System/SystemConfigFormTestBase.php b/core/modules/system/lib/Drupal/system/Tests/System/SystemConfigFormTestBase.php
index 69543aa..5686e3f 100644

index 69543aa..5686e3f 100644
--- a/core/modules/system/lib/Drupal/system/Tests/System/SystemConfigFormTestBase.php

--- a/core/modules/system/lib/Drupal/system/Tests/System/SystemConfigFormTestBase.php
+++ b/core/modules/system/lib/Drupal/system/Tests/System/SystemConfigFormTestBase.phpundefined

+++ b/core/modules/system/lib/Drupal/system/Tests/System/SystemConfigFormTestBase.phpundefined
+++ b/core/modules/system/lib/Drupal/system/Tests/System/SystemConfigFormTestBase.phpundefined
@@ -19,9 +19,9 @@

@@ -19,9 +19,9 @@
   /**
    * Form ID to use for testing.
    *
-   * @var string
+   * @var \Drupal\Core\Form\FormInterface.
    */
-  protected $form_id;
+  protected $form;
 
   /**
    * Values to use for testing.
@@ -45,13 +45,13 @@

@@ -45,13 +45,13 @@
   /**
    * Submit the system_config_form ensure the configuration has expected values.
    */
-  function testConfigForm() {
+  public function testConfigForm() {
     // Programmatically submit the given values.
     foreach ($this->values as $form_key => $data) {
       $values[$form_key] = $data['#value'];
     }
     $form_state = array('values' => $values);
-    drupal_form_submit($this->form_id, $form_state);
+    drupal_form_submit($this->form, $form_state);
 
     // Check that the form returns an error when expected, and vice versa.
     $errors = form_get_errors();
@@ -62,7 +62,7 @@ function testConfigForm() {

@@ -62,7 +62,7 @@ function testConfigForm() {
     );
     $this->assertTrue($valid_form, format_string('Input values: %values<br/>Validation handler errors: %errors', $args));
 
-    foreach ($this->values as $form_key => $data) {
+    foreach ($this->values as $data) {
       $this->assertEqual($data['#value'], config($data['#config_name'])->get($data['#config_key']));

I don't see how this is related to the issue.

While removing that, can you swap the __construct bit?

kim.pepper’s picture

Status: Needs work » Needs review
FileSize
2.83 KB
40.63 KB

Not sure how that happened. Here's a patch that removes those changes, as well as swaps the construct bit.

Status: Needs review » Needs work

The last submitted patch, 1924992-system-config-form-33.patch, failed testing.

tim.plunkett’s picture

Oh! That explains why those hunks are in there. The user test extends SystemConfigFormTestBase, which was not using the new approach yet. My sincerest apologies.

@kim.pepper, can you reroll one last time, re-adding those test changes but keeping your constructor switch?

kim.pepper’s picture

Status: Needs work » Needs review
FileSize
2.17 KB
42.8 KB

@tim.plunkett Makes sense now. My head was full of other stuff yesterday afternoon, and I couldn't quite remember what the reasons for adding these changes were!

Here's a re-roll, re-adding those changes, and including the constructor switch.

Status: Needs review » Needs work

The last submitted patch, 1924992-system-config-form-36.patch, failed testing.

kim.pepper’s picture

Status: Needs work » Needs review
FileSize
678 bytes
42.78 KB

Let's try that again.

This is just patch #30 with constructor switch.

tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, that looks good now.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 87f01f0 and pushed to 8.x. Thanks!

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