public function getFunctionTests() { $args = array(); $args[] = [AggregateFunction::SUM(10), 'SELECT SUM(10)']; $args[] = [AggregateFunction::SUM('total_amount'), 'SELECT SUM(total_amount)']; $args[] = [AggregateFunction::SUM(new Distinct('total_amount')), 'SELECT SUM(DISTINCT total_amount)']; $args[] = [AggregateFunction::MAX('views'), 'SELECT MAX(views)']; $args[] = [AggregateFunction::MIN('views'), 'SELECT MIN(views)']; $args[] = [AggregateFunction::AVG('buyPrice'), 'SELECT AVG(buyPrice)']; $args[] = [AggregateFunction::COUNT('*'), 'SELECT COUNT(*)']; $args[] = [new SelectAs(AggregateFunction::COUNT('*'), 'a'), 'SELECT COUNT(*) AS `a`']; return $args; }
public function testFuncExpr() { $expr = new SelectAs(AggregateFunction::COUNT('*'), 'a'); $sql = $expr->toSql(new MySQLDriver(), new ArgumentArray()); is('COUNT(*) AS `a`', $sql); }