Skip to content

Commit

Permalink
Remove sorting of included resources
Browse files Browse the repository at this point in the history
  • Loading branch information
kocsismate committed Nov 17, 2016
1 parent 1466d7a commit cedb493
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
2 changes: 0 additions & 2 deletions src/JsonApi/Schema/Data/AbstractData.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,6 @@ public function addIncludedResource(array $transformedResource)
*/
public function transformIncludedResources()
{
ksort($this->includedKeys);

return array_values($this->includedKeys);
}

Expand Down
29 changes: 18 additions & 11 deletions tests/JsonApi/Schema/DataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,24 @@ public function transformEmpty()
*/
public function transform()
{
$resource1 = ["type" => "resource", "id" => "1"];
$resource2 = ["type" => "resource", "id" => "2"];
$item1 = ["type" => "item", "id" => "1"];
$item2 = ["type" => "item", "id" => "2"];

$resources = [$item1, $resource2, $resource1, $item2, $item1, $resource1];

$data = $this->createData()->setIncludedResources($resources);

$transformedIncluded = [$item1, $item2, $resource1, $resource2];
$this->assertEquals($transformedIncluded, $data->transformIncludedResources());
$data = $this->createData()->setIncludedResources([
["type" => "item", "id" => "1"],
["type" => "resource", "id" => "2"],
["type" => "resource", "id" => "1"],
["type" => "item", "id" => "2"],
["type" => "item", "id" => "1"],
["type" => "resource", "id" => "2"],
]);

$this->assertEquals(
[
["type" => "item", "id" => "1"],
["type" => "resource", "id" => "2"],
["type" => "resource", "id" => "1"],
["type" => "item", "id" => "2"],
],
$data->transformIncludedResources()
);
}

private function createData()
Expand Down

0 comments on commit cedb493

Please sign in to comment.