aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/includes/AccountTest.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2024-01-09 08:05:28 +0000
committerMario <mario@mariovavti.com>2024-01-09 08:05:28 +0000
commit232c7f53017c7edcea94598883dca87be0c493fb (patch)
treeaef2a3b380a6b41896f60e6ced916e048dcd6fec /tests/unit/includes/AccountTest.php
parent4aa29db7aac6c389a1908a53bce2ec36d7f94ee1 (diff)
parent16cd8caef3336d88ebf6dc77e7281968a9380859 (diff)
downloadvolse-hubzilla-232c7f53017c7edcea94598883dca87be0c493fb.tar.gz
volse-hubzilla-232c7f53017c7edcea94598883dca87be0c493fb.tar.bz2
volse-hubzilla-232c7f53017c7edcea94598883dca87be0c493fb.zip
Merge branch 'tests/includes/account' into 'dev'
Some test cleanup and tests for check_account_email See merge request hubzilla/core!2083
Diffstat (limited to 'tests/unit/includes/AccountTest.php')
-rw-r--r--tests/unit/includes/AccountTest.php22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/unit/includes/AccountTest.php b/tests/unit/includes/AccountTest.php
index d123a0c70..af5bcd3c1 100644
--- a/tests/unit/includes/AccountTest.php
+++ b/tests/unit/includes/AccountTest.php
@@ -9,4 +9,26 @@ class AccountTest extends Zotlabs\Tests\Unit\UnitTestCase {
$this->assertNotFalse($account);
$this->assertEquals($this->fixtures['account'][0]['account_email'], $account['account_email']);
}
+
+ /**
+ * Test the `check_account_email` function.
+ *
+ * @dataProvider check_account_email_provider
+ */
+ public function test_check_account_email(string $email, array $expected) {
+ $this->assertEquals($expected, check_account_email($email));
+ }
+
+ function check_account_email_provider() : array {
+ return [
+ // Empty and valid emails return the same result
+ ['', ['error' => false, 'message' => '']],
+ ['newuser@example.com', ['error' => false, 'message' => '']],
+
+ // Check emails not valid for various readons
+ ['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']],
+ ];
+ }
}