<?php
namespace App\Tests;
use ApiPlatform\Core\Bridge\Symfony\Bundle\Test\ApiTestCase;
use Hautelook\AliceBundle\PhpUnit\RefreshDatabaseTrait;
class ConfigsTest extends ApiTestCase
{
// This trait provided by HautelookAliceBundle will take care of refreshing the database content to a known state before each test
use RefreshDatabaseTrait;
public function testPutConfigsByAdmin(): void
{
$response = static::createClient()->request('POST', '/login_check', ['json' => [
'login' => 'admin',
'password' => 'password',
]]);
$content = json_decode($response->getContent(), true);
$this->assertResponseIsSuccessful();
$response = static::createClient()->request('PUT', '/configs/1',
[
'json' => [
"valeur" => "test"
],
'headers' => [
'Content-Type' => 'application/json',
"Authorization" => 'Bearer ' . $content['token']
],
]
);
print_r($response->getContent());exit;
$this->assertJsonContains([
'valeur' => 'test'
]
);
}
}
API Platform 2.6 / Symfony 5.3 / PHPUnit 9.5.5
Description
PUT request don't work in PHPUnit with a denormalization_context attribute in my entity. Entity is not modified.
Config Entity :
Working great with cURL :
Return :
With PHPUnit :
Doesn't work. Return :
If I remove denormalization_context in my config entity, it work !
Any idea ?