Skip to content
Snippets Groups Projects
Unverified Commit c3152e5a authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2830504 by jungle, megadesk3000, dww, dermario, amateescu, alexpott,...

Issue #2830504 by jungle, megadesk3000, dww, dermario, amateescu, alexpott, Berdir: AssignOwnerNode allows assigning to anonymous users due to misspelling of key #selection_settings
parent 7567d544
Branches
Tags
8 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!1012Issue #3226887: Hreflang on non-canonical content pages,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10,!596Issue #3046532: deleting an entity reference field, used in a contextual view, makes the whole site unrecoverable,!496Issue #2463967: Use .user.ini file for PHP settings,!144Issue #2666286: Clean up menu_ui to conform to Drupal coding standards,!16Draft: Resolve #2081585 "History storage",!13Resolve #2903456
......@@ -1536,7 +1536,6 @@ serviceform
sess
sessionpath
settingstray
setttings
setval
sharedspace
shatner
......
......@@ -99,7 +99,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
'#type' => 'entity_autocomplete',
'#title' => t('Username'),
'#target_type' => 'user',
'#selection_setttings' => [
'#selection_settings' => [
'include_anonymous' => FALSE,
],
'#default_value' => User::load($this->configuration['owner_uid']),
......
......@@ -2,8 +2,10 @@
namespace Drupal\Tests\node\Functional;
use Drupal\Component\Serialization\Json;
use Drupal\Tests\BrowserTestBase;
use Drupal\system\Entity\Action;
use Drupal\user\Entity\User;
/**
* Tests configuration of actions provided by the Node module.
......@@ -85,4 +87,40 @@ public function testAssignOwnerNodeActionConfiguration() {
$this->assertNull($action, 'The node_assign_owner_action action is not available after being deleted.');
}
/**
* Tests the autocomplete field when configuring the AssignOwnerNode action.
*/
public function testAssignOwnerNodeActionAutocomplete() {
// Create 200 users to force the action's configuration page to use an
// autocomplete field instead of a select field. See
// \Drupal\node\Plugin\Action\AssignOwnerNode::buildConfigurationForm().
for ($i = 0; $i < 200; $i++) {
$this->drupalCreateUser();
}
// Create a user with permission to view the actions administration pages
// and additionally permission to administer users. Otherwise the user would
// not be able to reference the anonymous user.
$this->drupalLogin($this->drupalCreateUser(['administer actions', 'administer users']));
// Create AssignOwnerNode action.
$this->drupalPostForm('admin/config/system/actions', ['action' => 'node_assign_owner_action'], 'Create');
// Get the autocomplete URL of the owner_uid textfield.
$autocomplete_field = $this->getSession()->getPage()->findField('owner_uid');
$autocomplete_url = $this->getAbsoluteUrl($autocomplete_field->getAttribute('data-autocomplete-path'));
// Make sure that autocomplete works.
$user = $this->drupalCreateUser();
$data = Json::decode($this->drupalGet($autocomplete_url, ['query' => ['q' => $user->getDisplayName(), '_format' => 'json']]));
$this->assertNotEmpty($data);
$anonymous = User::getAnonymousUser();
// Ensure that the anonymous user exists.
$this->assertNotNull($anonymous);
// Make sure the autocomplete does not show the anonymous user.
$data = Json::decode($this->drupalGet($autocomplete_url, ['query' => ['q' => $anonymous->getDisplayName(), '_format' => 'json']]));
$this->assertEmpty($data);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment