In the world of PHP development, the “standard path” is well known: PHPUnit, CI/CD pipelines, frameworks that dictate how you should work. But Ascoos OS follows a different philosophy. Testing is not something added afterwards; it is part of the runtime.
The TTestHandler class is the heart of this logic. With a single API you can validate classes, objects, and methods, execute functions with timing, log results, and collect system statistics. All of this without ever leaving the Ascoos OS ecosystem.
Let’s see how a simple test becomes a complete log with TTestHandler.
$result = $testHandler->executeWithTiming(function () {
AscoosThrowException(InvalidArgumentException::class, 100);
}, [], true);
print_r($result);
The result is an array that tells you everything: whether it succeeded, what it returned, how long it took, the system state, and any error. A unified contract that simplifies debugging and profiling.
use ASCOOS\OS\Kernel\Tests\TTestHandler;
use ASCOOS\OS\Kernel\Core\TObject;
use ASCOOS\OS\Kernel\Core\DebugLevel;
global $AOS_LOGS_PATH;
$properties = [
'logs' => [
'useLogger' => true,
'dir' => $AOS_LOGS_PATH . '/',
'file' => 'test_handler.log',
'level' => DebugLevel::Info
],
'lang' => 'en-US',
'debug' => [
'precision' => 4,
'log_threshold' => DebugLevel::Info
]
];
$testHandler = new TTestHandler($properties);
$object = new TObject();
$testHandler->checkClass(TObject::class, true);
$testHandler->checkObject($object, true);
$testHandler->checkMethod($object, 'getClassMetadata', true);
$result = $testHandler->executeWithTiming(function () {
AscoosThrowException(InvalidArgumentException::class, 100);
}, [], true);
print_r($result);
$testHandler->Free();
$object->Free();
The executeWithTiming method returns an array with fields
success, result, execution_time, system_stats, error.
TTestHandler is not just a tool. It proves that Ascoos OS sees testing not as an “addition” but as an integral part of the runtime.
If you are tired of setting up frameworks just to run tests, it’s time to try a different logic. With Ascoos OS, testing is there from the very first moment.