Files
alrahma_sunday_school/tests/_support/BaseWebTestCase.php
T
2026-02-10 22:11:06 -05:00

31 lines
696 B
PHP

<?php
namespace Tests\Support;
use CodeIgniter\Test\CIUnitTestCase;
class BaseWebTestCase extends CIUnitTestCase
{
protected function setUp(): void
{
parent::setUp();
// Start session if not already started
if (!session()->isStarted()) {
session()->start();
}
}
/**
* Set session role and user ID
*
* @param string $role e.g., 'administrator', 'teacher', 'parent', etc.
* @param int $userId Default to 1
*/
protected function setSessionRole(string $role, int $userId = 1): void
{
session()->set([
'role' => strtolower($role),
'user_id' => $userId,
]);
}
}