PHP code example of mohamedhekal / testharness

1. Go to this page and download the library: Download mohamedhekal/testharness library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mohamedhekal / testharness example snippets


use Hekal\TestHarness\Support\TimeTravel;

TimeTravel::freeze('2026-01-15 10:00:00');
TimeTravel::travel(hours: 2);
TimeTravel::back();

$value = withFrozenTime('2026-07-01 08:00:00', fn () => now()->toDateString());

Queue::fake();
QueueAssert::assertPushed(MyJob::class, fn (MyJob $job) => $job->id === 1);

ApiEnvelopeAssert::assertOk($response);
ApiEnvelopeAssert::assertError($response, 'validation_failed', 422);

Architecture::assertStrictTypes(__DIR__.'/../src');
Architecture::assertForbiddenFunctions(__DIR__.'/../src', ['dd', 'dump', 'ray']);

TenantContext::run(['tenant_id' => 5], function () {
    // compose with your tenancy package inside the callback
});

use Hekal\TestHarness\Concerns\InteractsWithTestHarness;

abstract class TestCase extends \Tests\TestCase
{
    use InteractsWithTestHarness;
}