-
-
Notifications
You must be signed in to change notification settings - Fork 825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dev/drupal#127 - require email for the Useradd task and errors not showing #17915
Merged
eileenmcnaughton
merged 1 commit into
civicrm:master
from
demeritcowboy:useradd-messages
Aug 4, 2020
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
/* | ||
+--------------------------------------------------------------------+ | ||
| Copyright CiviCRM LLC. All rights reserved. | | ||
| | | ||
| This work is published under the GNU AGPLv3 license with some | | ||
| permitted exceptions and without any warranty. For full license | | ||
| and copyright information, see https://civicrm.org/licensing | | ||
+--------------------------------------------------------------------+ | ||
*/ | ||
|
||
/** | ||
* @group headless | ||
*/ | ||
class CRM_Contact_Form_Task_UseraddTest extends CiviUnitTestCase { | ||
|
||
/** | ||
* Test postProcess failure. | ||
* | ||
* In unit tests, the CMS user creation will always fail, but that's | ||
* ok because that's what we're testing here. | ||
*/ | ||
public function testUserCreateFail() { | ||
$form = new CRM_Contact_Form_Task_Useradd(); | ||
// We don't need to set params or anything because we're testing fail, | ||
// which the user creation will do in unit tests no matter what we set. | ||
// But before the patch, the status messages were always success no | ||
// matter what. | ||
try { | ||
$form->postProcess(); | ||
} | ||
catch (CRM_Core_Exception_PrematureExitException $e) { | ||
} | ||
$statuses = CRM_Core_Session::singleton()->getStatus(TRUE); | ||
$this->assertEquals('alert', $statuses[0]['type']); | ||
} | ||
|
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@demeritcowboy do we need to do this on other CMSes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For drupal 7 no, because of the way it uses drupal's form layer to create a user, so the form errors display.
Let's take a look at what wordpress/joomla do...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok it took a minute to find but it looks like wordpress doesn't override checkPermissionAddUser() so it returns false so you don't even see this feature.
Ok now joomla...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Joomla UF class has pretty extensive checking as a form rule via checkUserNameEmailExists(), and it's beyond my joomla knowledge to know how to get past it to trigger a fail in joomla itself. The only thing I can see it doesn't check for is a blank email, which this PR would cover. But createUser itself doesn't have any kind of error checking, and in fact seems like it would never return FALSE either way, so technically createUser might need some sprucing up, but I'm not a joomla person.