diff --git a/src/SearchServices/Parsers/AbstractSearchParser.php b/src/SearchServices/Parsers/AbstractSearchParser.php index be81a8ee..78e1777c 100644 --- a/src/SearchServices/Parsers/AbstractSearchParser.php +++ b/src/SearchServices/Parsers/AbstractSearchParser.php @@ -9,7 +9,7 @@ abstract class AbstractSearchParser public function createFilterFromInputReader(\Szurubooru\Helpers\InputReader $inputReader) { $filter = $this->createFilter(); - $filter->setOrder(array_merge($this->getOrder($inputReader->order), $filter->getOrder())); + $filter->setOrder(array_merge($filter->getOrder(), $this->getOrder($inputReader->order))); if ($inputReader->page) { diff --git a/tests/SearchServices/UserSearchParserTest.php b/tests/SearchServices/UserSearchParserTest.php new file mode 100644 index 00000000..59b7b127 --- /dev/null +++ b/tests/SearchServices/UserSearchParserTest.php @@ -0,0 +1,33 @@ +inputReader = new InputReader; + $this->userSearchParser = new UserSearchParser(); + } + + public function testDefaultOrder() + { + $filter = $this->userSearchParser->createFilterFromInputReader($this->inputReader); + $this->assertEquals([UserFilter::ORDER_NAME => UserFilter::ORDER_ASC], $filter->getOrder()); + } + + public function testParamOrder() + { + $this->inputReader->order = 'name,desc'; + $filter = $this->userSearchParser->createFilterFromInputReader($this->inputReader); + $this->assertEquals([UserFilter::ORDER_NAME => UserFilter::ORDER_DESC], $filter->getOrder()); + } +}