<?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,
        ]);
    }
}