Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
27pchrisl committed Oct 31, 2020
2 parents 39f9ff5 + 64a703a commit ab6a8b8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,13 @@ public function emit(Transaction $transaction): void
}
}

while ($this->properties->valid()) {
$requiresSeparator = false;

while (true) {
if (!$this->properties->valid()) {
break;
}

/** @var PropertyValue $propertyValue */
$propertyValue = $this->properties->current();

Expand All @@ -126,6 +132,10 @@ public function emit(Transaction $transaction): void
continue;
}

if ($requiresSeparator) {
$transaction->outputJsonSeparator();
}

if ($propertyValue->getProperty() instanceof NavigationProperty) {
$propertyMetadata = $this->getExpansionMetadata($transaction, $propertyValue);

Expand All @@ -144,11 +154,8 @@ public function emit(Transaction $transaction): void
$transaction->outputJsonValue($value);
}

$requiresSeparator = true;
$this->properties->next();

if ($this->properties->valid() && $this->properties->current()->shouldEmit($transaction)) {
$transaction->outputJsonSeparator();
}
}

$transaction->outputJsonObjectEnd();
Expand Down
9 changes: 9 additions & 0 deletions tests/Unit/Queries/Entity/EntityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,15 @@ public function test_read_with_multiple_select()
);
}

public function test_read_with_multiple_select_non_adjacent()
{
$this->assertJsonResponse(
Request::factory()
->path('/flights(1)')
->query('$select', 'origin,gate')
);
}

public function test_rejects_invalid_select()
{
$this->assertBadRequest(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"@context": "http://localhost/odata/$metadata#flights(origin,gate)/$entity",
"origin": "lhr",
"gate": null
}

0 comments on commit ab6a8b8

Please sign in to comment.