Skip to content
Snippets Groups Projects
Verified Commit 2a82a293 authored by Lee Rowlands's avatar Lee Rowlands
Browse files

Issue #3488835 by mcdruid, atul_ghate, benjifisher, catch, cilefen,...

Issue #3488835 by mcdruid, atul_ghate, benjifisher, catch, cilefen, zengenuity, larowlan, poker10, longwave, damienmckenna, greggles, kristiaanvandeneynde: Status report confuses null email with duplicate email

(cherry picked from commit 9ed8a79f)
parent 0e2d34fb
No related branches found
No related tags found
15 merge requests!11636Draft: Issue #3515643 by macsim: fieldNameExists method is inconsistent,!11515Issue #3480419 by mondrake, smustgrave, catch: Method...,!11380Issue #3490698 by catch, spokje: Bump MINIMUM_STABILITY back to 'stable' when...,!11281Use Drupal Core Leadership terminology in MAINTAINERS.txt,!11239Issue #3507548: Allow workspace changes listing to show all items, without a pager,!11238Fix issue #3051797,!11213Issue #3506743 by tomislav.matokovic: Increasing the color contrast for the navigation block title against the background of the navigation sidebar to at least 4.5:1,!11147Draft: Try to avoid manually setting required cache contexts,!11108Issue #3490298 by nicxvan: Profiles can be missed in OOP hooks,!11093Drupal on MongoDB 11.1.x,!11017Issue #3502540: Add date filter for moderated content.,!11009Issue #3486972 migrate feed icon,!10999Cleaning up Taxonomy hooks and updating baseline.,!10977Issue #3501457: Fix path used in a A11y Test Admin,!10881Issue #3489329 by mfb, casey: symfony/http-foundation commit 32310ff breaks PathValidator
Pipeline #373522 canceled
Pipeline: drupal

#373523

    <?php
    declare(strict_types=1);
    namespace Drupal\Tests\user\Kernel;
    use Drupal\KernelTests\KernelTestBase;
    use Drupal\Tests\user\Traits\UserCreationTrait;
    /**
    * Tests user_requirements().
    *
    * @group user
    */
    class UserRequirementsTest extends KernelTestBase {
    use UserCreationTrait;
    /**
    * {@inheritdoc}
    */
    protected static $modules = ['user'];
    /**
    * {@inheritdoc}
    */
    protected function setUp(): void {
    parent::setUp();
    $this->container->get('module_handler')->loadInclude('user', 'install');
    $this->installEntitySchema('user');
    }
    /**
    * Tests that the requirements check can detect conflicting user emails.
    *
    * @see \Drupal\Tests\user\Kernel\UserValidationTest::testValidation
    */
    public function testConflictingUserEmails(): void {
    $output = \user_requirements('runtime');
    $this->assertArrayNotHasKey('conflicting emails', $output);
    $this->createUser([], 'User A', FALSE, ['mail' => 'unique@example.com']);
    $this->createUser([], 'User B', FALSE, ['mail' => 'UNIQUE@example.com']);
    $output = \user_requirements('runtime');
    $this->assertArrayHasKey('conflicting emails', $output);
    }
    /**
    * Tests that the requirements check does not incorrectly flag blank emails.
    */
    public function testBlankUserEmails(): void {
    $output = \user_requirements('runtime');
    $this->assertArrayNotHasKey('conflicting emails', $output);
    $this->createUser([], 'User A', FALSE, ['mail' => '']);
    $this->createUser([], 'User B', FALSE, ['mail' => '']);
    $output = \user_requirements('runtime');
    $this->assertArrayNotHasKey('conflicting emails', $output);
    }
    }
    ......@@ -137,6 +137,14 @@ public function testValidation(): void {
    $this->assertCount(1, $violations, 'Violation found when email already exists.');
    $this->assertEquals('mail', $violations[0]->getPropertyPath());
    $this->assertEquals('The email address existing@example.com is already taken.', $violations[0]->getMessage());
    // Ensure case-insensitive uniqueness of email.
    $user->set('mail', 'EXISTING@example.com');
    $violations = $user->validate();
    $this->assertCount(1, $violations, 'Violation found when email already exists.');
    $this->assertEquals('mail', $violations[0]->getPropertyPath());
    $this->assertEquals('The email address EXISTING@example.com is already taken.', $violations[0]->getMessage());
    $user->set('mail', NULL);
    $violations = $user->validate();
    $this->assertCount(1, $violations, 'Email addresses may not be removed');
    ......
    ......@@ -118,6 +118,7 @@ function user_requirements($phase): array {
    $query = \Drupal::database()->select('users_field_data');
    $query->addExpression('LOWER(mail)', 'lower_mail');
    $query->isNotNull('mail');
    $query->groupBy('lower_mail');
    $query->having('COUNT(uid) > :matches', [':matches' => 1]);
    $conflicts = $query->countQuery()->execute()->fetchField();
    ......
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment