assertSame(db_qstr_rlike('router'), thold_rlike_clause('router')); } /** * Core's helper strips the alternation and quantifier characters that make * a filter expensive to evaluate; the plugin must not bypass that. * * @return void */ public function testRlikeClauseInheritsTheCoreOperandRestrictions(): void { $clause = thold_rlike_clause('(a|a){9,}'); $this->assertStringNotContainsString('|', $clause); $this->assertStringNotContainsString('{', $clause); } /** * @return array */ public static function accessorProvider() { return [ 'thresholds' => ['get_allowed_thresholds', 'thold'], 'logs' => ['get_allowed_threshold_logs', 'thold_log'], ]; } /** * The cached row count is used only for the unfiltered listing; a per-graph * query counts directly so the cache is not keyed per graph. * * @dataProvider accessorProvider * * @param string $function * @param string $class * * @return void */ public function testRowCountUsesTheCoreCacheWhenNotFilteredByGraph($function, $class): void { CactiStubs::willReturn('get_total_row_data', 12); $total = 0; $function('', 'td.name', '', $total, -1, 0); $this->assertSame(12, $total); $this->assertSame([], CactiStubs::callsTo('db_fetch_cell_prepared')); } /** * @dataProvider accessorProvider * * @param string $function * @param string $class * * @return void */ public function testRowCountBypassesTheCacheForASingleGraph($function, $class): void { $total = 0; $function('', 'td.name', '', $total, -1, 5); $this->assertSame([], CactiStubs::callsTo('get_total_row_data')); $this->assertNotEmpty(CactiStubs::callsTo('db_fetch_cell_prepared')); } }