public function testAssemble()
 {
     $expression = MatchSelectExpression::create(FieldExpression::createWithTable('field1', 'table1'), StringExpression::create('this is a test search'));
     $this->assertEquals('MATCH (`table1`.`field1`) AGAINST ("this is a test search")', MySQLAssembler::stringify($expression));
     $expression->setAlias('score');
     $this->assertEquals('MATCH (`table1`.`field1`) AGAINST ("this is a test search") AS `score`', MySQLAssembler::stringify($expression));
 }
 public function testAssemble()
 {
     $sel1 = TableSelectExpression::create('table_one');
     $this->assertEquals('`table_one`', MySQLAssembler::stringify($sel1));
     $sel1->setAlias('t1');
     $this->assertEquals('`table_one` AS `t1`', MySQLAssembler::stringify($sel1));
     $sel2 = new TableSelectExpression();
     $sel2->setTable('table_two');
     $this->assertEquals('table_two', QueryAssembler::stringify($sel2));
     $sel2->setAlias('t2');
     $this->assertEquals('table_two AS t2', QueryAssembler::stringify($sel2));
     $sel3 = TableSelectExpression::createWithAlias(TableExpression::create('table_three'), 't3');
     $this->assertEquals('`table_three` AS `t3`', MySQLAssembler::stringify($sel3));
 }
 public function testAssemble()
 {
     $expression = MatchExpression::create(FieldExpression::createWithTable('field1', 'table1'), StringExpression::create('this is a test search'));
     $expression->addField(FieldExpression::createWithTable('field2', 'table2'));
     $this->assertEquals('MATCH (`table1`.`field1`,`table2`.`field2`) AGAINST ("this is a test search")', MySQLAssembler::stringify($expression));
     $expression->setSearchModifier(MatchExpression::BOOLEAN_MODE);
     $this->assertEquals('MATCH (`table1`.`field1`,`table2`.`field2`) AGAINST ("this is a test search" IN BOOLEAN MODE)', MySQLAssembler::stringify($expression));
     $expression->setSearchModifier(MatchExpression::WITH_QUERY_EXPANSION);
     $this->assertEquals('MATCH (`table1`.`field1`,`table2`.`field2`) AGAINST ("this is a test search" WITH QUERY EXPANSION)', MySQLAssembler::stringify($expression));
     $expression->setSearchModifier(MatchExpression::BOOLEAN_MODE);
     $stmt = QueryBuilder::select(AllSelectExpression::create())->from('tbl')->where(GreaterThanPredicate::create($expression, 0))->limit(5);
     $assembler = new MySQLAssembler($stmt);
     $this->assertEquals('SELECT * FROM `tbl` WHERE MATCH (`table1`.`field1`,`table2`.`field2`) AGAINST (? IN BOOLEAN MODE) > ? LIMIT ?', $assembler->getQuery());
     $this->assertEquals(['this is a test search', 0, 5], $assembler->getParameters());
 }
 public function testSelectField()
 {
     $this->assertEquals('`myfield` AS `unique`', MySQLAssembler::stringify(FieldSelectExpression::createWithAlias('myfield', 'unique')));
 }