Unit Tests

Apex utilizes the popular phpUnit package, plus also adds its own layer that includes custom assertions and other methods to aid in testing. For full details, please visit the Unit Tests section of the developer documentation.

Within terminal, run the following create test CLI command:

apex create test disaster projects

Open the newly generated file at /tests/Disaster/ProjectsTest.php and replace it with the following contents:

declare(strict_types = 1);

namespace Tests\Disaster;

use Apex\Svc\{Di, Db};
use Apex\App\Sys\Tests\ApexTestCase;

 * Projects Test
class ProjectsTest extends ApexTestCase

     * Projects menu
    public function testProjectsMenuAdminPanel():void

        // Login as admin
        $db = Di::get(Db::class);
        $admin_user = $db->getField("SELECT username FROM armor_users WHERE type = 'admin'");

        // Send http request to Projects menu

        // Assertions


The above method will login as an admistrator, then proceed to visit the Disaster Relief->Projects menu and ensure the page title is correct and it contains the correct data table.