not->toBeFalse()->and($end)->not->toBeFalse(); $graph_item = ['data_template_rrd_id' => 42, 'cf_reference' => $preferred, 'consolidation_function_id' => $preferred]; // DEF 0 belongs to a different source and must never replace source 42. $cf_ds_cache = ['7:1' => 0, '42:' . $available => 9]; $replacement = array_values(array_filter(explode("\n", $source), static fn ($line) => str_contains($line, "str_replace('CURRENT_DATA_SOURCE',") && str_contains($line, '$cdef_string ='))); expect($replacement)->not->toBeEmpty(); $temporary = []; try { foreach ([substr($source, $start, $end - $start), $replacement[0]] as $body) { $path = tempnam(sys_get_temp_dir(), 'cacti-cf-test-'); file_put_contents($path, 'toBe(generate_graph_def_name(9) . ',2,*'); })->with([[3, 1], [1, 3], [1, 2], [1, 4], [3, 3]]); test('compiled production fallback and substitution retain the selected source', function () { $fixture = dirname(__DIR__, 3) . '/fixtures/Core/Rrd/FallbackSourceIdentity.php'; exec(escapeshellarg(PHP_BINARY) . ' ' . escapeshellarg($fixture), $output, $status); expect($status)->toBe(0); expect(implode("\n", $output))->toStartWith('PASS: all four consolidation fallbacks'); });