diff options
author | Mario <mario@mariovavti.com> | 2024-01-10 13:34:23 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2024-01-10 13:34:23 +0000 |
commit | ffdf54b097f2c92392396d4636a779f47d226f02 (patch) | |
tree | 5facad9b8b347e300a1a499f7e047f2fa6f03c05 | |
parent | 58593d7da6a893e681b7c64fdf21a02c93dfa0d0 (diff) | |
parent | 232c7f53017c7edcea94598883dca87be0c493fb (diff) | |
download | volse-hubzilla-ffdf54b097f2c92392396d4636a779f47d226f02.tar.gz volse-hubzilla-ffdf54b097f2c92392396d4636a779f47d226f02.tar.bz2 volse-hubzilla-ffdf54b097f2c92392396d4636a779f47d226f02.zip |
Merge branch 'dev' of https://framagit.org/hubzilla/core into dev
-rw-r--r-- | tests/unit/UnitTestCase.php | 10 | ||||
-rw-r--r-- | tests/unit/includes/AccountTest.php | 22 | ||||
-rw-r--r-- | tests/unit/includes/dba/_files/config.yml | 13 |
3 files changed, 39 insertions, 6 deletions
diff --git a/tests/unit/UnitTestCase.php b/tests/unit/UnitTestCase.php index b98845985..97ac1576e 100644 --- a/tests/unit/UnitTestCase.php +++ b/tests/unit/UnitTestCase.php @@ -78,8 +78,11 @@ class UnitTestCase extends TestCase { $this->in_transaction = \DBA::$dba->db->beginTransaction(); $this->loadFixtures(); - } + + // Make sure app config is reset and loaded from fixtures + \App::$config = array(); + \Zotlabs\Lib\Config::Load('system'); } protected function tearDown() : void { @@ -116,10 +119,6 @@ class UnitTestCase extends TestCase { $table_name = basename($file, '.yml'); $this->fixtures[$table_name] = yaml_parse_file($file)[$table_name]; - //echo "\n[*] Loaded fixture '{$table_name}':\n"; - // . print_r($this->fixtures[$table_name], true) - // . PHP_EOL; - foreach ($this->fixtures[$table_name] as $entry) { $query = 'INSERT INTO ' . dbesc($table_name) . '(' . implode(',', array_keys($entry)) @@ -127,7 +126,6 @@ class UnitTestCase extends TestCase { . implode(',', array_map(fn($val) => "'{$val}'", array_values($entry))) . ')'; - //print_r($query); q($query); } } 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']], + ]; + } } diff --git a/tests/unit/includes/dba/_files/config.yml b/tests/unit/includes/dba/_files/config.yml new file mode 100644 index 000000000..80b9ba12f --- /dev/null +++ b/tests/unit/includes/dba/_files/config.yml @@ -0,0 +1,13 @@ +--- +config: + - + id: 1 + cat: system + k: do_not_check_dns + v: true + - + id: 2 + cat: system + k: not_allowed_email + v: 'baduser@example.com,baddomain.com,*.evil.org' + |