Fixed default user search order

This commit is contained in:
Marcin Kurczewski 2014-10-01 23:04:32 +02:00
parent 7d8dfd797f
commit 17d898bc0c
2 changed files with 34 additions and 1 deletions

View file

@ -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)
{

View 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());
}
}