Fixed default user search order
This commit is contained in:
parent
7d8dfd797f
commit
17d898bc0c
2 changed files with 34 additions and 1 deletions
|
@ -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)
|
||||
{
|
||||
|
|
33
tests/SearchServices/UserSearchParserTest.php
Normal file
33
tests/SearchServices/UserSearchParserTest.php
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
namespace Szurubooru\Tests\SearchService;
|
||||
|
||||
use \Szurubooru\Tests\AbstractTestCase;
|
||||
use \Szurubooru\Helpers\InputReader;
|
||||
use \Szurubooru\SearchServices\Filters\UserFilter;
|
||||
use \Szurubooru\SearchServices\Parsers\UserSearchParser;
|
||||
|
||||
class UserSearchParserTest extends AbstractTestCase
|
||||
{
|
||||
private $inputReader;
|
||||
private $userSearchParser;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->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());
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue