core icon indicating copy to clipboard operation
core copied to clipboard

The type of the key must be "int", "string" given. While testing

Open Guervyl opened this issue 3 years ago • 0 comments

API Platform version(s) affected: 2.5

Description
I'm writing some tests but in \Symfony\Bundle\FrameworkBundle\Test\WebTestCase, static::createClient()->xmlHttpRequest() convert everything to string while sending the request. I'm testing an api using Api-platform. The api-platform\\core\\src\\Serializer\\AbstractItemNormalizer.php expect the value to be an int but in the test Symfony is sending the json int a string.

I even extend ApiPlatform\Core\Bridge\Symfony\Bundle\Test\ApiTestCase and use static::createClient()->request(...["json"=[...]]) and it is giving me the same error.

How can I force api-plaform to cast the string to int or how can I force Symfony to send the int instead of a string?

Making curl request works, but I'm using test environment. So when I make the curl request it points to the dev environment. How to reproduce

  1. Create an entity with a integer column.
  2. Create a test extends ApiTestCase.
  3. Send the request with an integer value. static::createClient()->request("POST", "/api/companies", ["json" => [...]])

Guervyl avatar May 01 '22 05:05 Guervyl