Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix query direction constants #191

Merged
merged 1 commit into from
Oct 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Datastore/Query/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ class Query implements QueryInterface
const OP_HAS_ANCESTOR = 'HAS_ANCESTOR';

const ORDER_DEFAULT = self::ORDER_ASCENDING;
const ORDER_DESCENDING = 'ASCENDING';
const ORDER_ASCENDING = 'DESCENDING';
const ORDER_DESCENDING = 'DESCENDING';
const ORDER_ASCENDING = 'ASCENDING';

/**
* @var array A list of all operators supported by datastore
Expand Down
19 changes: 18 additions & 1 deletion tests/Datastore/Query/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ public function testFilterInvalidOperator()

public function testOrder()
{
$direction = 'DESCENDING';
$self = $this->query->order('propname', Query::ORDER_DESCENDING);
$this->assertInstanceOf(Query::class, $self);

Expand All @@ -163,7 +164,23 @@ public function testOrder()
'property' => [
'name' => 'propname'
],
'direction' => Query::ORDER_DESCENDING
'direction' => $direction
]);
}

public function testOrderWithDefaultDireciton()
{
$direction = 'ASCENDING';
$self = $this->query->order('propname');
$this->assertInstanceOf(Query::class, $self);

$res = $this->query->queryObject();

$this->assertEquals($res['order'][0], [
'property' => [
'name' => 'propname'
],
'direction' => $direction
]);
}

Expand Down