-
-
Notifications
You must be signed in to change notification settings - Fork 900
Unit tests using assertMatchesJsonSchema fail for ManyToOne properties #6146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Same problems for me in 3.2.13
Got this with #[ORM\Column(type: 'smallint', nullable: true)]
#[Groups(['billing_company:read', 'billing_company:edit'])]
#[Assert\NotBlank]
#[Assert\Positive]
private ?int $quoteValidityPeriod = null;
#[ORM\OneToOne(targetEntity: File::class, cascade: ['persist'])]
#[ORM\JoinColumn(nullable: true)]
public ?File $logo = null; |
Thanks, this works for my first problem |
@jvengeon Hum this is very strange since my change are supposed to restore 3.12 test behaviours. |
The problem |
just released it, can you try? |
We tried and it's ok. |
All my tests are green again, seems great! Thanks @kevin-macquer-omnilog and @soyuka 🙏 I can close this. |
API Platform version(s) affected: 3.2.13
Description
Since #6098 has been merged, my Unit Tests including
assertMatchesResourceCollectionJsonSchema
orassertMatchesResourceItemJsonSchema
fail for ManyToOne properties.The error message is
Object value found, but a string or a null is required
.How to reproduce
I have a BlogArticle Entity that contains a blogCategory property. This category is serialized into the json answer for Get and GetCollection operations.
I test my GetCollection api calls with the following method:
Possible Solution
Inside
ApiTestAssertionsTrait
, I noticed these changes for methodsassertMatchesResourceCollectionJsonSchema
andassertMatchesResourceItemJsonSchema
=>became
If I change it back to the previous version, my tests are working again but I get new errors instead =>
For this property of the
Recipe
entityAll my tests were green when using API Platform 3.1.
Thanks for your help!
The text was updated successfully, but these errors were encountered: