Skip to content

Commit 5a9a118

Browse files
committed
Unit test 'GROUP N BY'
1 parent 1a03c6f commit 5a9a118

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

tests/SphinxQL/SphinxQLTest.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,42 @@ public function testWithinGroupOrderBy()
711711
$this->assertEquals('16', $result[0]['id']);
712712
}
713713

714+
public function testGroupNBy()
715+
{
716+
$query = SphinxQL::create(self::$conn)->select()
717+
->from('rt')
718+
->groupBy('gid');
719+
$this->assertEquals(
720+
'SELECT * FROM rt GROUP BY gid',
721+
$query->compile()->getCompiled()
722+
);
723+
724+
$query->groupNBy(3);
725+
$this->assertEquals(
726+
'SELECT * FROM rt GROUP 3 BY gid',
727+
$query->compile()->getCompiled()
728+
);
729+
730+
$query->resetGroupBy();
731+
$this->assertEquals(
732+
'SELECT * FROM rt',
733+
$query->compile()->getCompiled()
734+
);
735+
736+
$query->groupBy('gid');
737+
$this->assertEquals(
738+
'SELECT * FROM rt GROUP BY gid',
739+
$query->compile()->getCompiled()
740+
);
741+
742+
$query->resetGroupBy()
743+
->groupNBy(3);
744+
$this->assertEquals(
745+
'SELECT * FROM rt',
746+
$query->compile()->getCompiled()
747+
);
748+
}
749+
714750
public function testOffset()
715751
{
716752
$this->refill();

0 commit comments

Comments
 (0)