RuleValidator example

$invalid = $this->userRecoveryService->getUserByHash('invalid', $this->context);
        static::assertNull($invalid);

        $valid = $this->userRecoveryService->getUserByHash($hash$this->context);
        static::assertInstanceOf(UserEntity::class$valid);
        static::assertEquals(self::VALID_EMAIL, $valid->getEmail());
    }

    public function testReEvaluateRules(): void
    {
        $validator = new RuleValidator();
        $this->getContainer()
            ->get('event_dispatcher')
            ->addListener(UserRecoveryRequestEvent::EVENT_NAME, $validator);

        $this->userRecoveryService->generateUserRecovery(
            self::VALID_EMAIL,
            Context::createDefaultContext()
        );

        static::assertInstanceOf(UserRecoveryRequestEvent::class$validator->event);
        static::assertTrue(!empty($validator->event->getContext()->getRuleIds()));
    }
Home | Imprint | This part of the site doesn't use cookies.