mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-03 16:51:40 +09:00
Add unit tests for RVE-2025-1
This commit is contained in:
parent
a208e0dbbc
commit
2b8656eaf0
2 changed files with 39 additions and 0 deletions
14
tests/_data/dbquery/sortIndexTest.xml
Normal file
14
tests/_data/dbquery/sortIndexTest.xml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<query id="sortIndexTest" action="select">
|
||||
<tables>
|
||||
<table name="documents" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="*" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="equal" column="status" default="PUBLIC" />
|
||||
</conditions>
|
||||
<navigation>
|
||||
<index var="sort_index" default="RAND()" order="order_type" order-default="DESC" />
|
||||
</navigation>
|
||||
</query>
|
||||
|
|
@ -598,4 +598,29 @@ class DBQueryParserTest extends \Codeception\Test\Unit
|
|||
$this->assertEquals('SELECT `module_srl` FROM `rx_documents` AS `documents` ORDER BY `list_order` DESC LIMIT 40, 20', $sql);
|
||||
$this->assertTrue($query->requires_pagination);
|
||||
}
|
||||
|
||||
public function testSortIndex()
|
||||
{
|
||||
$query = Rhymix\Framework\Parsers\DBQueryParser::loadXML(\RX_BASEDIR . 'tests/_data/dbquery/sortIndexTest.xml');
|
||||
|
||||
$sql = $query->getQueryString('rx_', array());
|
||||
$this->assertEquals('SELECT * FROM `rx_documents` AS `documents` WHERE `status` = ? ORDER BY RAND() DESC', $sql);
|
||||
|
||||
$sql = $query->getQueryString('rx_', array(
|
||||
'sort_index' => 'list_order',
|
||||
'order_type' => 'asc',
|
||||
));
|
||||
$this->assertEquals('SELECT * FROM `rx_documents` AS `documents` WHERE `status` = ? ORDER BY `list_order` ASC', $sql);
|
||||
|
||||
$sql = $query->getQueryString('rx_', array(
|
||||
'sort_index' => 'voted_count + blamed_count',
|
||||
'order_type' => 'desc',
|
||||
));
|
||||
$this->assertEquals('SELECT * FROM `rx_documents` AS `documents` WHERE `status` = ?', $sql);
|
||||
|
||||
$sql = $query->getQueryString('rx_', array(
|
||||
'sort_index' => 'RAND()',
|
||||
));
|
||||
$this->assertEquals('SELECT * FROM `rx_documents` AS `documents` WHERE `status` = ?', $sql);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue