<?php

it('marks system search cache dirty from generic db object mutation flows', function (): void {
    $content = file_get_contents(app_path('traits/db_object_t.php'));

    expect($content)->not->toBeFalse();
    expect($content)->toContain('markSystemSearchDirtyTable');
    expect($content)->toContain('system_search_cache::markDirtyTable');
});

it('marks system search cache dirty from object property mutations', function (): void {
    $content = file_get_contents(app_path('classes/object_property.php'));

    expect($content)->not->toBeFalse();
    expect($content)->toContain("system_search_cache::markDirtyTable(\$this->table)");
});

it('marks system search cache dirty when module config values change', function (): void {
    $content = file_get_contents(app_path('traits/module_config_variable_t.php'));

    expect($content)->not->toBeFalse();
    expect($content)->toContain("system_search_cache::markDirtyTable('module_config')");
});

it('registers cron maintenance task for system search cache', function (): void {
    $content = file_get_contents(app_path('cron/Cron.php'));

    expect($content)->not->toBeFalse();
    expect($content)->toContain('SystemSearchCacheMaintenanceCron');
    expect($content)->toContain("system_search_cache::consumeRebuildRequest()");
    expect($content)->toContain("system_search_cache::consumeDirtyTables()");
});
