Skip to content

Commit

Permalink
fix: Behat
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentchalamon authored and alanpoulain committed Aug 2, 2022
1 parent 0ad3439 commit 43417f2
Show file tree
Hide file tree
Showing 50 changed files with 116 additions and 147 deletions.
1 change: 0 additions & 1 deletion features/main/operation_resource.feature
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ Feature: Resource operations
"""
{"name": "Patched"}
"""
Then print last JSON response
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; charset=utf-8"
Expand Down
4 changes: 1 addition & 3 deletions src/Doctrine/Odm/Filter/SearchFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,9 @@ private function addEqualityMatchStrategy(string $strategy, Builder $aggregation
/**
* Get equality match value according to the strategy.
*
* @param mixed $value
*
* @throws InvalidArgumentException If strategy does not exist
*/
private function getEqualityMatchStrategyValue(string $strategy, string $field, $value, bool $caseSensitive, ClassMetadata $metadata): Regex|string
private function getEqualityMatchStrategyValue(string $strategy, string $field, mixed $value, bool $caseSensitive, ClassMetadata $metadata): Regex|string|int
{
$type = $metadata->getTypeOfField($field);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use ApiPlatform\Api\UrlGeneratorInterface;
use ApiPlatform\Metadata\ApiResource;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;

#[ApiResource(urlGenerationStrategy: UrlGeneratorInterface::ABS_URL)]
Expand All @@ -26,7 +25,7 @@ class AbsoluteUrlRelationDummy
#[ODM\Id(strategy: 'INCREMENT', type: 'int')]
private $id;
#[ODM\ReferenceMany(targetDocument: AbsoluteUrlDummy::class, mappedBy: 'absoluteUrlRelationDummy')]
public Collection $absoluteUrlDummies;
public $absoluteUrlDummies;

public function __construct()
{
Expand Down
5 changes: 2 additions & 3 deletions tests/Fixtures/TestBundle/Document/Answer.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
use ApiPlatform\Metadata\Patch;
use ApiPlatform\Metadata\Put;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
use Symfony\Component\Serializer\Annotation as Serializer;

Expand All @@ -45,7 +44,7 @@ class Answer
private ?Question $question = null;
#[Serializer\Groups(['foobar'])]
#[ODM\ReferenceMany(targetDocument: Question::class, mappedBy: 'answer')]
private Collection $relatedQuestions;
private $relatedQuestions;

public function __construct()
{
Expand Down Expand Up @@ -99,7 +98,7 @@ public function getQuestion(): ?Question
/**
* Get related question.
*/
public function getRelatedQuestions(): Collection
public function getRelatedQuestions(): iterable
{
return $this->relatedQuestions;
}
Expand Down
3 changes: 1 addition & 2 deletions tests/Fixtures/TestBundle/Document/CircularReference.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

use ApiPlatform\Metadata\ApiResource;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
use Symfony\Component\Serializer\Annotation\Groups;

Expand All @@ -35,7 +34,7 @@ class CircularReference
public $parent;
#[Groups(['circular'])]
#[ODM\ReferenceMany(targetDocument: self::class, mappedBy: 'parent')]
public Collection $children;
public $children;

public function __construct()
{
Expand Down
5 changes: 2 additions & 3 deletions tests/Fixtures/TestBundle/Document/CompositeItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

use ApiPlatform\Metadata\ApiResource;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
use Symfony\Component\Serializer\Annotation\Groups;

Expand All @@ -33,7 +32,7 @@ class CompositeItem implements \Stringable
private ?string $field1 = null;
#[Groups(['default'])]
#[ODM\ReferenceMany(targetDocument: CompositeRelation::class, mappedBy: 'compositeItem')]
private Collection $compositeValues;
private $compositeValues;

public function __construct()
{
Expand Down Expand Up @@ -67,7 +66,7 @@ public function setField1(?string $field1 = null): void
/**
* Gets compositeValues.
*/
public function getCompositeValues(): Collection
public function getCompositeValues(): iterable
{
return $this->compositeValues;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/TestBundle/Document/Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Content implements \JsonSerializable
* @var Collection<Field>
*/
#[ODM\ReferenceMany(targetDocument: Field::class, mappedBy: 'content', strategy: 'set', cascade: ['persist'])]
private Collection $fields;
private $fields;
#[ODM\Field(type: 'string')]
private string $status = ContentStatus::DRAFT;

Expand Down
3 changes: 1 addition & 2 deletions tests/Fixtures/TestBundle/Document/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

use ApiPlatform\Metadata\ApiResource;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
use Symfony\Component\Serializer\Annotation\Groups;

Expand All @@ -31,7 +30,7 @@ class Customer
public $name;
#[Groups(['order_read'])]
#[ODM\ReferenceMany(targetDocument: Address::class)]
public Collection $addresses;
public $addresses;

public function __construct()
{
Expand Down
3 changes: 1 addition & 2 deletions tests/Fixtures/TestBundle/Document/Dummy.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\Link;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
use Symfony\Component\Validator\Constraints as Assert;

Expand Down Expand Up @@ -88,7 +87,7 @@ class Dummy
#[ODM\ReferenceOne(targetDocument: RelatedDummy::class, storeAs: 'id', nullable: true)]
public ?RelatedDummy $relatedDummy = null;
#[ODM\ReferenceMany(targetDocument: RelatedDummy::class, storeAs: 'id', nullable: true)]
public Collection $relatedDummies;
public $relatedDummies;
#[ODM\Field(type: 'hash', nullable: true)]
public array $jsonData = [];
#[ODM\Field(type: 'collection', nullable: true)]
Expand Down
7 changes: 3 additions & 4 deletions tests/Fixtures/TestBundle/Document/DummyAggregateOffer.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Link;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;

/**
Expand All @@ -39,7 +38,7 @@ class DummyAggregateOffer
#[ODM\Id(strategy: 'INCREMENT', type: 'int')]
private ?int $id = null;
#[ODM\ReferenceMany(targetDocument: DummyOffer::class, mappedBy: 'aggregate', cascade: ['persist'])]
private Collection $offers;
private $offers;
/**
* @var DummyProduct The dummy product
*/
Expand All @@ -56,12 +55,12 @@ public function __construct()
$this->offers = new ArrayCollection();
}

public function getOffers(): Collection
public function getOffers(): iterable
{
return $this->offers;
}

public function setOffers(Collection $offers): void
public function setOffers($offers): void
{
$this->offers = $offers;
}
Expand Down
25 changes: 12 additions & 13 deletions tests/Fixtures/TestBundle/Document/DummyCar.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
use ApiPlatform\Serializer\Filter\GroupFilter;
use ApiPlatform\Serializer\Filter\PropertyFilter;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
use Symfony\Component\Serializer\Annotation as Serializer;

Expand All @@ -44,19 +43,19 @@ class DummyCar
#[ApiFilter(SearchFilter::class, properties: ['colors.prop' => 'ipartial', 'colors' => 'exact'])]
#[Serializer\Groups(['colors'])]
#[ODM\ReferenceMany(targetDocument: DummyCarColor::class, mappedBy: 'car')]
private Collection $colors;
private $colors;
#[ApiFilter(SearchFilter::class, strategy: 'exact')]
#[Serializer\Groups(['colors'])]
#[ODM\ReferenceMany(targetDocument: DummyCarColor::class, mappedBy: 'car')]
private Collection $secondColors;
private $secondColors;
#[ApiFilter(SearchFilter::class, strategy: 'exact')]
#[Serializer\Groups(['colors'])]
#[ODM\ReferenceMany(targetDocument: DummyCarColor::class, mappedBy: 'car')]
private Collection $thirdColors;
private $thirdColors;
#[ApiFilter(SearchFilter::class, strategy: 'exact')]
#[Serializer\Groups(['colors'])]
#[ODM\ReferenceMany(targetDocument: UuidIdentifierDummy::class)]
private Collection $uuid;
private $uuid;
#[ApiFilter(SearchFilter::class, strategy: 'partial')]
#[ODM\Field(type: 'string')]
private ?string $name = null;
Expand All @@ -82,44 +81,44 @@ public function getId(): ?int
return $this->id;
}

public function getColors(): Collection
public function getColors(): iterable
{
return $this->colors;
}

public function setColors(Collection $colors): self
public function setColors($colors): self
{
$this->colors = $colors;

return $this;
}

public function getSecondColors(): Collection
public function getSecondColors(): iterable
{
return $this->secondColors;
}

public function setSecondColors(Collection $secondColors): void
public function setSecondColors($secondColors): void
{
$this->secondColors = $secondColors;
}

public function getThirdColors(): Collection
public function getThirdColors(): iterable
{
return $this->thirdColors;
}

public function setThirdColors(Collection $thirdColors): void
public function setThirdColors($thirdColors): void
{
$this->thirdColors = $thirdColors;
}

public function getUuid(): Collection
public function getUuid(): iterable
{
return $this->uuid;
}

public function setUuid(Collection $uuid): void
public function setUuid($uuid): void
{
$this->uuid = $uuid;
}
Expand Down
3 changes: 1 addition & 2 deletions tests/Fixtures/TestBundle/Document/DummyDtoInputOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use ApiPlatform\Tests\Fixtures\TestBundle\State\DummyDtoInputOutputProcessor;
use ApiPlatform\Tests\Fixtures\TestBundle\State\DummyDtoInputOutputProvider;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;

/**
Expand Down Expand Up @@ -51,5 +50,5 @@ public function __construct()
#[ODM\Field(type: 'float')]
public $num;
#[ODM\ReferenceMany(targetDocument: RelatedDummy::class, storeAs: 'id', nullable: true)]
public Collection $relatedDummies;
public $relatedDummies;
}
13 changes: 6 additions & 7 deletions tests/Fixtures/TestBundle/Document/DummyProduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Link;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;

/**
Expand All @@ -38,14 +37,14 @@ class DummyProduct
#[ODM\Id(strategy: 'INCREMENT', type: 'int')]
private ?int $id = null;
#[ODM\ReferenceMany(targetDocument: DummyAggregateOffer::class, mappedBy: 'product', cascade: ['persist'])]
private Collection $offers;
private $offers;
/**
* @var string The tour name
*/
#[ODM\Field]
private string $name;
#[ODM\ReferenceMany(targetDocument: self::class, mappedBy: 'parent')]
private Collection $relatedProducts;
private $relatedProducts;
#[ODM\ReferenceOne(targetDocument: self::class, inversedBy: 'relatedProducts')]
private $parent;

Expand All @@ -55,12 +54,12 @@ public function __construct()
$this->relatedProducts = new ArrayCollection();
}

public function getOffers(): Collection
public function getOffers(): iterable
{
return $this->offers;
}

public function setOffers(Collection $offers): void
public function setOffers($offers): void
{
$this->offers = $offers;
}
Expand All @@ -86,12 +85,12 @@ public function setName(string $name): void
$this->name = $name;
}

public function getRelatedProducts(): Collection
public function getRelatedProducts(): iterable
{
return $this->relatedProducts;
}

public function setRelatedProducts(iterable $relatedProducts): void
public function setRelatedProducts($relatedProducts): void
{
$this->relatedProducts = $relatedProducts;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class DummyTableInheritanceRelated
*/
#[Groups(['default'])]
#[ODM\ReferenceMany(targetDocument: DummyTableInheritance::class, mappedBy: 'parent')]
private Collection $children;
private $children;

public function __construct()
{
Expand All @@ -46,12 +46,12 @@ public function getId(): ?int
return $this->id;
}

public function getChildren(): Collection
public function getChildren(): iterable
{
return $this->children;
}

public function setChildren(Collection $children)
public function setChildren($children)
{
$this->children = $children;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class DummyWithEmbedManyOmittingTargetDocument
* @var EmbeddableDummy[]|Collection
*/
#[ODM\EmbedMany]
private array|Collection $embeddedDummies;
private $embeddedDummies;

public function __construct()
{
Expand All @@ -44,7 +44,7 @@ public function getId(): ?int
return $this->id;
}

public function getEmbeddedDummies(): Collection
public function getEmbeddedDummies(): iterable
{
return $this->embeddedDummies;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use ApiPlatform\Api\UrlGeneratorInterface;
use ApiPlatform\Metadata\ApiResource;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;

#[ApiResource(urlGenerationStrategy: UrlGeneratorInterface::NET_PATH)]
Expand All @@ -26,7 +25,7 @@ class NetworkPathRelationDummy
#[ODM\Id(strategy: 'INCREMENT', type: 'int')]
private $id;
#[ODM\ReferenceMany(targetDocument: NetworkPathDummy::class, mappedBy: 'networkPathRelationDummy')]
public Collection $networkPathDummies;
public $networkPathDummies;

public function __construct()
{
Expand Down
Loading

0 comments on commit 43417f2

Please sign in to comment.