From 0a605628ed5bc2069e5a38c8adc37fb12bf9d0be Mon Sep 17 00:00:00 2001 From: Carlos Mauri Date: Fri, 9 Aug 2019 01:31:18 -0700 Subject: [PATCH] EZP-30782: allow sorting by trashed field (#1440) * EZP-30782: allow sorting by trashed field * EZP-30782: add table name * add unit test for new trashed field --- kernel/classes/ezcontentobjecttreenode.php | 4 ++++ .../kernel/classes/ezcontentobjecttreenode_test2.php | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/kernel/classes/ezcontentobjecttreenode.php b/kernel/classes/ezcontentobjecttreenode.php index ec1ac4ed8f4..421c783f807 100644 --- a/kernel/classes/ezcontentobjecttreenode.php +++ b/kernel/classes/ezcontentobjecttreenode.php @@ -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]; diff --git a/tests/tests/kernel/classes/ezcontentobjecttreenode_test2.php b/tests/tests/kernel/classes/ezcontentobjecttreenode_test2.php index da55dc5abe0..e5f65b646bf 100644 --- a/tests/tests/kernel/classes/ezcontentobjecttreenode_test2.php +++ b/tests/tests/kernel/classes/ezcontentobjecttreenode_test2.php @@ -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' ] ) ); + } }