-
-
Notifications
You must be signed in to change notification settings - Fork 848
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix and test composite identifier collection retrieval
- Loading branch information
Showing
8 changed files
with
430 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
Feature: Retrieve data with Composite identifiers | ||
In order to retrieve relations with composite identifiers | ||
As a client software developer | ||
I need to retrieve all collections | ||
|
||
@createSchema | ||
@dropSchema | ||
Scenario: Get collection with composite identifiers | ||
Given there are Composite identifier objects | ||
When I send a "GET" request to "/composite_items" | ||
Then the response status code should be 200 | ||
And the response should be in JSON | ||
And the header "Content-Type" should be equal to "application/ld+json" | ||
And the JSON should be equal to: | ||
""" | ||
{ | ||
"@context": "/contexts/CompositeItem", | ||
"@id": "/composite_items", | ||
"@type": "hydra:Collection", | ||
"hydra:member": [ | ||
{ | ||
"@id": "/composite_items/1", | ||
"@type": "CompositeItem", | ||
"field1": "foobar", | ||
"compositeValues": [ | ||
"/composite_relations/1-1", | ||
"/composite_relations/1-2", | ||
"/composite_relations/1-3", | ||
"/composite_relations/1-4" | ||
] | ||
} | ||
], | ||
"hydra:totalItems": 1 | ||
} | ||
""" | ||
|
||
@createSchema | ||
@dropSchema | ||
Scenario: Get collection with composite identifiers | ||
Given there are Composite identifier objects | ||
When I send a "GET" request to "/composite_relations" | ||
Then the response status code should be 200 | ||
And the response should be in JSON | ||
And the header "Content-Type" should be equal to "application/ld+json" | ||
And the JSON should be equal to: | ||
""" | ||
{ | ||
"@context": "\/contexts\/CompositeRelation", | ||
"@id": "\/composite_relations", | ||
"@type": "hydra:Collection", | ||
"hydra:member": [ | ||
{ | ||
"@id": "\/composite_relations\/1-1", | ||
"@type": "CompositeRelation", | ||
"id": "1-1", | ||
"value": "somefoobardummy" | ||
}, | ||
{ | ||
"@id": "\/composite_relations\/1-2", | ||
"@type": "CompositeRelation", | ||
"id": "1-2", | ||
"value": "somefoobardummy" | ||
}, | ||
{ | ||
"@id": "\/composite_relations\/1-3", | ||
"@type": "CompositeRelation", | ||
"id": "1-3", | ||
"value": "somefoobardummy" | ||
} | ||
], | ||
"hydra:totalItems": 4, | ||
"hydra:view": { | ||
"@id": "\/composite_relations?page=1", | ||
"@type": "hydra:PartialCollectionView", | ||
"hydra:first": "\/composite_relations?page=1", | ||
"hydra:last": "\/composite_relations?page=2", | ||
"hydra:next": "\/composite_relations?page=2" | ||
} | ||
} | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <dunglas@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity; | ||
|
||
use ApiPlatform\Core\Annotation\Resource; | ||
use Doctrine\ORM\Mapping as ORM; | ||
use Symfony\Component\Serializer\Annotation\Groups; | ||
|
||
/** | ||
* @Resource | ||
* @ORM\Entity | ||
*/ | ||
class CompositeItem | ||
{ | ||
/** | ||
* @ORM\Id | ||
* @ORM\Column(type="integer") | ||
* @ORM\GeneratedValue(strategy="AUTO") | ||
*/ | ||
private $id; | ||
|
||
/** | ||
* @ORM\Column(type="string", nullable=true) | ||
* @Groups({"default"}) | ||
*/ | ||
private $field1; | ||
|
||
/** | ||
* @ORM\OneToMany(targetEntity="CompositeRelation", mappedBy="compositeItem", fetch="EAGER") | ||
* @Groups({"default"}) | ||
*/ | ||
private $compositeValues; | ||
|
||
/** | ||
* Get id. | ||
* | ||
* @return id. | ||
*/ | ||
public function getId() | ||
{ | ||
return $this->id; | ||
} | ||
|
||
/** | ||
* Get field1. | ||
* | ||
* @return field1. | ||
*/ | ||
public function getField1() | ||
{ | ||
return $this->field1; | ||
} | ||
|
||
/** | ||
* Set field1. | ||
* | ||
* @param field1 the value to set. | ||
*/ | ||
public function setField1($field1) | ||
{ | ||
$this->field1 = $field1; | ||
} | ||
|
||
/** | ||
* Get compositeValues. | ||
* | ||
* @return compositeValues. | ||
*/ | ||
public function getCompositeValues() | ||
{ | ||
return $this->compositeValues; | ||
} | ||
|
||
public function __toString() | ||
{ | ||
return (string) $this->id; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <dunglas@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity; | ||
|
||
use ApiPlatform\Core\Annotation\Resource; | ||
use Doctrine\ORM\Mapping as ORM; | ||
use Symfony\Component\Serializer\Annotation\Groups; | ||
|
||
/** | ||
* @ORM\Entity | ||
* @Resource | ||
*/ | ||
class CompositeLabel | ||
{ | ||
/** | ||
* @ORM\Id | ||
* @ORM\Column(type="integer") | ||
* @ORM\GeneratedValue(strategy="AUTO") | ||
*/ | ||
private $id; | ||
|
||
/** | ||
* @ORM\Column(type="string", nullable=true) | ||
* @Groups({"default"}) | ||
*/ | ||
private $value; | ||
|
||
/** | ||
* Get id. | ||
* | ||
* @return id. | ||
*/ | ||
public function getId() | ||
{ | ||
return $this->id; | ||
} | ||
|
||
/** | ||
* Get value. | ||
* | ||
* @return value. | ||
*/ | ||
public function getValue() | ||
{ | ||
return $this->value; | ||
} | ||
|
||
/** | ||
* Set value. | ||
* | ||
* @param value the value to set. | ||
*/ | ||
public function setValue($value) | ||
{ | ||
$this->value = $value; | ||
} | ||
|
||
public function __toString() | ||
{ | ||
return (string) $this->id; | ||
} | ||
} |
Oops, something went wrong.