<?php

it('wires local e-conomic customer index into customer-related search entities', function (): void {
    $serviceContent = file_get_contents(app_path('classes/system_search_service.php'));

    expect($serviceContent)->not->toBeFalse();
    expect($serviceContent)->toContain('system_search_economic_customer_index::TABLE');
    expect($serviceContent)->toContain('sci.economic_name');
    expect($serviceContent)->toContain('searchCustomerDiscounts');
    expect($serviceContent)->toContain('searchCustomerFixedPrices');
    expect($serviceContent)->toContain('expandLexicalSynonyms');
    expect($serviceContent)->toContain("'rabat' => ['discount', 'discounts']");
});

it('registers cron tasks that keep the e-conomic search index refreshed', function (): void {
    $cronContent = file_get_contents(app_path('cron/Cron.php'));

    expect($cronContent)->not->toBeFalse();
    expect($cronContent)->toContain('SyncSystemSearchEconomicCustomerIndex');
    expect($cronContent)->toContain('$users_o->syncAllUsersEconomicCustomerDetails()');
    expect($cronContent)->toContain('system_search_economic_customer_index::refreshIndex(false)');
});

