Skip to content

Commit

Permalink
EZP-30782: allow sorting by trashed field (ezsystems#1440)
Browse files Browse the repository at this point in the history
* EZP-30782: allow sorting by trashed field

* EZP-30782: add table name

* add unit test for new trashed field
  • Loading branch information
carlosmauri authored and andrerom committed Aug 9, 2019
1 parent 0d8aebb commit 0a60562
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions kernel/classes/ezcontentobjecttreenode.php
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,10 @@ static function createSortingSQLStrings( $sortList, $treeTableName = 'ezcontento
{
$sortingFields .= 'ezcontentobject_name.name';
} break;
case 'trashed':
{
$sortingFields .= $treeTableName . '.trashed';
} break;
case 'attribute':
{
$classAttributeID = $sortBy[2];
Expand Down
9 changes: 9 additions & 0 deletions tests/tests/kernel/classes/ezcontentobjecttreenode_test2.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,13 @@ public function testIssue23528( $name, $expected )
$attributeFilter = eZContentObjectTreeNode::createAttributeFilterSQLStrings( $attributeFilterParams );
$this->assertEquals( $expected, $attributeFilter['where'] );
}

public function testSortingByTrashed()
{
// test sorting by trashed
$sortList = array( array( 'trashed', true ) );
$result = eZContentObjectTreeNode::createSortingSQLStrings( $sortList, 'ezcot' );
$this->assertEquals( 'ezcot.trashed asc',
strtolower( $result[ 'sortingFields' ] ) );
}
}

0 comments on commit 0a60562

Please sign in to comment.