A bit of cleanup for account functions

This commit is contained in:
Harald Eilertsen
2025-06-24 07:53:42 +00:00
committed by Mario
parent 37159937d7
commit 66e02c5e3a
3 changed files with 52 additions and 25 deletions

View File

@@ -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);