aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2024-11-27 15:16:03 +0100
committerHarald Eilertsen <haraldei@anduin.net>2025-06-29 13:28:20 +0200
commita17601643b1e9f5f6505487ca5e761f1e6073656 (patch)
tree3a796c6cf08f7deff9b01c6e88ffe23c1d7adac9 /tests/unit
parenta7cc2293fd77a0fa45cd42fb06586c253b3413a3 (diff)
downloadvolse-hubzilla-a17601643b1e9f5f6505487ca5e761f1e6073656.tar.gz
volse-hubzilla-a17601643b1e9f5f6505487ca5e761f1e6073656.tar.bz2
volse-hubzilla-a17601643b1e9f5f6505487ca5e761f1e6073656.zip
Replace direct db query with Registration class
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/includes/AccountTest.php25
-rw-r--r--tests/unit/includes/dba/_files/register.yml2
2 files changed, 26 insertions, 1 deletions
diff --git a/tests/unit/includes/AccountTest.php b/tests/unit/includes/AccountTest.php
index 66c761ef5..3070f57a8 100644
--- a/tests/unit/includes/AccountTest.php
+++ b/tests/unit/includes/AccountTest.php
@@ -1,5 +1,7 @@
<?php
+use PHPUnit\Framework\Attributes\DataProvider;
+use Zotlabs\Lib\Config;
use Zotlabs\Tests\Unit\UnitTestCase;
/**
@@ -48,6 +50,29 @@ class AccountTest extends UnitTestCase {
['not_an_email', ['error' => true, 'message' => 'The provided email address is not valid']],
['baduser@example.com', ['error' => true, 'message' => 'The provided email domain is not among those allowed on this site']],
['hubzilla@example.com', ['error' => true, 'message' => 'The provided email address is already registered at this site']],
+ ['verified@example.com', [
+ 'error' => true,
+ 'message' => 'There is a pending registration for this address - click "Register" to continue verification',
+ 'email_unverified' => true,
+ ]],
+ ];
+ }
+
+ #[DataProvider('check_account_invite_provider')]
+ public function test_check_account_invite(string $invite_code, bool $error, string $msg): void {
+ Config::Set('system', 'invitation_only', true);
+
+ $result = check_account_invite($invite_code);
+
+ $this->assertEquals($error, $result['error']);
+ $this->assertEquals($msg, $result['message']);
+ }
+
+ public static function check_account_invite_provider(): array {
+ return [
+ 'existing invite code' => [ 'invite code x', false, '' ],
+ 'no invite code' => [ '', true, "ZAR0510E,An invitation is required.<br>\r\n" ],
+ 'invite code not found' => [ 'not invited', true, "ZAR0511E,Invitation could not be verified.<br>\r\n" ],
];
}
}
diff --git a/tests/unit/includes/dba/_files/register.yml b/tests/unit/includes/dba/_files/register.yml
index e8c439d92..e8b3d634f 100644
--- a/tests/unit/includes/dba/_files/register.yml
+++ b/tests/unit/includes/dba/_files/register.yml
@@ -27,7 +27,7 @@ register:
reg_didx: 'i'
reg_did2: 'invited@example.com'
reg_email: 'invited@example.com'
- reg_hash: '138'
+ reg_hash: 'invite code x'
reg_uid: 0
reg_pass: 'verify'
reg_stuff: ''