not->toBeFalse('Failed to read lib/aggregate.php'); return $src; } test('totalling item query has no graph_type_id exclusion', function () { $src = getAggregateTotallingSource(); $fnPos = strpos($src, 'function aggregate_cdef_totalling('); expect($fnPos)->not->toBeFalse('aggregate_cdef_totalling must exist'); $fnEnd = strpos($src, "\nfunction ", $fnPos + 1); $body = substr($src, $fnPos, ($fnEnd === false ? strlen($src) : $fnEnd) - $fnPos); expect(strpos($body, 'graph_type_id NOT IN'))->toBeFalse( 'the totalling query must select GPRINT legend items too, or the legend prints untotalled values (#7216)'); }); test('totalling item query stays prepared and sequence ordered', function () { $src = getAggregateTotallingSource(); $pattern = '/db_fetch_assoc_prepared\(\s*\'SELECT id, cdef_id\s+FROM graph_templates_item\s+WHERE local_graph_id = \?\s+AND sequence >= \?\s+ORDER BY sequence\'/s'; expect(preg_match($pattern, $src))->toBe(1, 'the totalling item query must remain a prepared statement selecting by graph and sequence only'); });