Skip to content

Commit

Permalink
Fix MongoDB tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidBennettUK committed Mar 30, 2021
1 parent 07aa257 commit 6c1df25
Showing 1 changed file with 43 additions and 1 deletion.
44 changes: 43 additions & 1 deletion tests/Fixtures/TestBundle/Document/SecuredDummy.php
Expand Up @@ -15,6 +15,7 @@

use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Core\Annotation\ApiResource;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
use Symfony\Component\Validator\Constraints as Assert;

Expand All @@ -40,7 +41,7 @@
* "put"={"security_post_denormalize"="is_granted('ROLE_USER') and previous_object.getOwner() == user"},
* },
* graphql={
* "item_query"={"security"="is_granted('ROLE_USER') and object.getOwner() == user"},
* "item_query"={"security"="is_granted('ROLE_ADMIN') or (is_granted('ROLE_USER') and object.getOwner() == user)"},
* "collection_query"={"security"="is_granted('ROLE_ADMIN')"},
* "delete"={},
* "update"={"security_post_denormalize"="is_granted('ROLE_USER') and previous_object.getOwner() == user"},
Expand Down Expand Up @@ -89,6 +90,27 @@ class SecuredDummy
*/
private $owner;

/**
* @var ArrayCollection Several dummies
*
* @ODM\ReferenceMany(targetDocument=RelatedDummy::class, storeAs="id", nullable=true)
* @ApiProperty(security="is_granted('ROLE_ADMIN')")
*/
public $relatedDummies;

/**
* @var RelatedDummy
*
* @ODM\ReferenceOne(targetDocument=RelatedDummy::class, storeAs="id", nullable=true)
* @ApiProperty(security="is_granted('ROLE_ADMIN')")
*/
protected $relatedDummy;

public function __construct()
{
$this->relatedDummies = new ArrayCollection();
}

public function getId(): int
{
return $this->id;
Expand Down Expand Up @@ -133,4 +155,24 @@ public function setOwner(string $owner)
{
$this->owner = $owner;
}

public function addRelatedDummy(RelatedDummy $relatedDummy)
{
$this->relatedDummies->add($relatedDummy);
}

public function getRelatedDummies()
{
return $this->relatedDummies;
}

public function getRelatedDummy()
{
return $this->relatedDummy;
}

public function setRelatedDummy(RelatedDummy $relatedDummy)
{
$this->relatedDummy = $relatedDummy;
}
}

0 comments on commit 6c1df25

Please sign in to comment.