diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2025-06-24 07:53:42 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2025-06-24 07:53:42 +0000 |
commit | 66e02c5e3a3c012787b37009b3aad2884d00941a (patch) | |
tree | 519c7efcd3bf47230f0132f9b588fba303efbac1 /tests | |
parent | 37159937d731642a6cf7c84809d8cd11c8c82f6d (diff) | |
download | volse-hubzilla-66e02c5e3a3c012787b37009b3aad2884d00941a.tar.gz volse-hubzilla-66e02c5e3a3c012787b37009b3aad2884d00941a.tar.bz2 volse-hubzilla-66e02c5e3a3c012787b37009b3aad2884d00941a.zip |
A bit of cleanup for account functions
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/includes/AccountTest.php | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/tests/unit/includes/AccountTest.php b/tests/unit/includes/AccountTest.php index 3978f9d04..66c761ef5 100644 --- a/tests/unit/includes/AccountTest.php +++ b/tests/unit/includes/AccountTest.php @@ -1,9 +1,28 @@ <?php + +use Zotlabs\Tests\Unit\UnitTestCase; + /** * Tests for account handling helper functions. */ +class AccountTest extends UnitTestCase { + + /** + * Test the `get_account_id()` function. + */ + public function test_get_account_id() { + App::set_account(null); + unset($_SESSION['account_id']); + + $this->assertEquals(false, get_account_id(), 'get_account_id() should return false if not authenticated'); + + App::set_account(['account_id' => 36]); + $this->assertEquals(36, get_account_id(), 'get_account_id() should return account from global App object'); + + $_SESSION['account_id'] = 42; + $this->assertEquals(42, get_account_id(), 'get_account_id() should return the account from the session'); + } -class AccountTest extends Zotlabs\Tests\Unit\UnitTestCase { public function test_get_account_by_id_returns_existing_account() { $account = get_account_by_id(42); $this->assertNotFalse($account); |