Merge branch 'some-account-cleanup' into 'dev'

A bit of cleanup for account functions

See merge request hubzilla/core!2210
This commit is contained in:
Mario
2025-06-24 07:53:43 +00:00
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);