mirror of
https://codeberg.org/icewind/SearchDAV.git
synced 2026-06-03 17:44:06 +02:00
fix descending sort order
This commit is contained in:
parent
7fbf5c5c6f
commit
3071937c64
3 changed files with 58 additions and 1 deletions
|
|
@ -58,7 +58,7 @@ class Order implements XmlDeserializable {
|
||||||
|
|
||||||
$childs = \Sabre\Xml\Deserializer\keyValue($reader);
|
$childs = \Sabre\Xml\Deserializer\keyValue($reader);
|
||||||
|
|
||||||
$order->order = isset($childs['{DAV:}descending']) ? self::DESC : self::ASC;
|
$order->order = array_key_exists('{DAV:}descending', $childs) ? self::DESC : self::ASC;
|
||||||
$order->property = $childs['{DAV:}prop'][0];
|
$order->property = $childs['{DAV:}prop'][0];
|
||||||
|
|
||||||
return $order;
|
return $order;
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,31 @@ class QueryParserTest extends \PHPUnit_Framework_TestCase {
|
||||||
], $search->orderBy);
|
], $search->orderBy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testParseDescending() {
|
||||||
|
$query = file_get_contents(__DIR__ . '/descending.xml');
|
||||||
|
$parser = new QueryParser();
|
||||||
|
$xml = $parser->parse($query, null, $rootElementName);
|
||||||
|
|
||||||
|
$this->assertEquals('{DAV:}searchrequest', $rootElementName);
|
||||||
|
$this->assertArrayHasKey('{DAV:}basicsearch', $xml);
|
||||||
|
|
||||||
|
/** @var BasicSearch $search */
|
||||||
|
$search = $xml['{DAV:}basicsearch'];
|
||||||
|
$this->assertInstanceOf(BasicSearch::class, $search);
|
||||||
|
|
||||||
|
$this->assertEquals(['{DAV:}getcontentlength'], $search->select);
|
||||||
|
$this->assertEquals([
|
||||||
|
new Scope('/container1/', 'infinity')
|
||||||
|
], $search->from);
|
||||||
|
$this->assertEquals(new Operator(Operator::OPERATION_GREATER_THAN, [
|
||||||
|
'{DAV:}getcontentlength',
|
||||||
|
new Literal(10000)
|
||||||
|
]), $search->where);
|
||||||
|
$this->assertEquals([
|
||||||
|
new Order('{DAV:}getcontentlength', Order::DESC)
|
||||||
|
], $search->orderBy);
|
||||||
|
}
|
||||||
|
|
||||||
public function testParseNoOrder() {
|
public function testParseNoOrder() {
|
||||||
$query = file_get_contents(__DIR__ . '/noorder.xml');
|
$query = file_get_contents(__DIR__ . '/noorder.xml');
|
||||||
$parser = new QueryParser();
|
$parser = new QueryParser();
|
||||||
|
|
|
||||||
32
tests/descending.xml
Normal file
32
tests/descending.xml
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<d:searchrequest xmlns:d="DAV:">
|
||||||
|
<d:basicsearch>
|
||||||
|
<d:select>
|
||||||
|
<d:prop>
|
||||||
|
<d:getcontentlength/>
|
||||||
|
</d:prop>
|
||||||
|
</d:select>
|
||||||
|
<d:from>
|
||||||
|
<d:scope>
|
||||||
|
<d:href>/container1/</d:href>
|
||||||
|
<d:depth>infinity</d:depth>
|
||||||
|
</d:scope>
|
||||||
|
</d:from>
|
||||||
|
<d:where>
|
||||||
|
<d:gt>
|
||||||
|
<d:prop>
|
||||||
|
<d:getcontentlength/>
|
||||||
|
</d:prop>
|
||||||
|
<d:literal>10000</d:literal>
|
||||||
|
</d:gt>
|
||||||
|
</d:where>
|
||||||
|
<d:orderby>
|
||||||
|
<d:order>
|
||||||
|
<d:prop>
|
||||||
|
<d:getcontentlength/>
|
||||||
|
</d:prop>
|
||||||
|
<d:descending/>
|
||||||
|
</d:order>
|
||||||
|
</d:orderby>
|
||||||
|
</d:basicsearch>
|
||||||
|
</d:searchrequest>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue