From 960d59e6531021c45a20f577c76fdcd23922de19 Mon Sep 17 00:00:00 2001 From: Dimitri Gritsajuk Date: Tue, 10 Dec 2024 18:06:33 +0100 Subject: [PATCH] Fix tests 4 --- features/api/adherent_messages.feature | 2 +- features/api/adherents.feature | 2 -- features/api/audiences.feature | 1 - features/api/committees.feature | 7 +++---- features/api/department_sites.feature | 2 -- features/api/designations.feature | 3 +-- features/api/events.feature | 2 -- features/api/jecoute_news.feature | 3 --- features/api/jecoute_ripostes.feature | 8 +------ features/api/membership_avecvous.feature | 7 ------- features/api/my_teams.feature | 4 ---- features/api/pap_address.feature | 1 - features/api/pap_campaigns.feature | 6 ------ features/api/phoning_campaigns.feature | 5 ----- features/api/report.feature | 2 -- features/api/surveys.feature | 5 ++--- features/api/surveys_replys.feature | 1 - features/api/teams.feature | 3 --- src/Adhesion/Request/MembershipRequest.php | 1 - src/Api/IriConverterDecorator.php | 3 +++ src/Entity/Action/Action.php | 7 ++++--- .../AbstractAdherentMessage.php | 21 ++++++++++++------- .../ElectedRepresentative.php | 2 +- src/Entity/ElectedRepresentative/Mandate.php | 2 +- src/Entity/Event/BaseEvent.php | 18 +++++++++------- src/Entity/Jecoute/JemarcheDataSurvey.php | 6 ++++-- src/Entity/Jecoute/Region.php | 1 - src/Entity/Jecoute/Riposte.php | 10 ++++----- src/Entity/MyTeam/MyTeam.php | 7 ++++--- src/Entity/Pap/Campaign.php | 1 - src/Entity/Pap/CampaignHistory.php | 6 ++++-- src/Entity/Phoning/Campaign.php | 1 - src/Entity/Phoning/CampaignHistory.php | 7 ++++--- src/Entity/ProcurationV2/Request.php | 12 ++++++----- .../Designation/Designation.php | 10 +++++---- tests/AbstractApiTestCase.php | 2 ++ 36 files changed, 76 insertions(+), 105 deletions(-) diff --git a/features/api/adherent_messages.feature b/features/api/adherent_messages.feature index 0b3819068a8..fed5842fcc6 100644 --- a/features/api/adherent_messages.feature +++ b/features/api/adherent_messages.feature @@ -234,7 +234,7 @@ Feature: When I send a "POST" request to "/api/v3/adherent_messages/969b1f08-53ec-4a7d-8d6e-7654a001b13f/send?scope=delegated_08f40730-d807-4975-8773-69d8fae1da74" Then the response status code should be 400 And the response should be in JSON - And the JSON node "detail" should be equal to "The message is not yet ready to send." + And the JSON node "violations[0].message" should be equal to "The message is not yet ready to send." Scenario: As a regional coordinator I can create a message Given I am logged with "coordinateur@en-marche-dev.fr" via OAuth client "JeMengage Web" diff --git a/features/api/adherents.feature b/features/api/adherents.feature index 5249c7ee4f4..e46b89f6f09 100644 --- a/features/api/adherents.feature +++ b/features/api/adherents.feature @@ -127,7 +127,6 @@ Feature: { "message": "Validation Failed", "status": "error", - "violations": [ { "propertyPath": "nickname", @@ -152,7 +151,6 @@ Feature: { "message": "Validation Failed", "status": "error", - "violations": [ { "propertyPath": "nickname", diff --git a/features/api/audiences.feature b/features/api/audiences.feature index 8f9d7f09089..d1a9a95c43e 100644 --- a/features/api/audiences.feature +++ b/features/api/audiences.feature @@ -79,7 +79,6 @@ Feature: { "message": "Validation Failed", "status": "error", - "violations": [ { "propertyPath": "zone", diff --git a/features/api/committees.feature b/features/api/committees.feature index b5c4aba018e..fb4ad6263e8 100644 --- a/features/api/committees.feature +++ b/features/api/committees.feature @@ -379,7 +379,6 @@ Feature: { "message": "Validation Failed", "status": "error", - "violations": [ { "propertyPath": "zones", @@ -500,7 +499,7 @@ Feature: """ Then the response status code should be 400 And the response should be in JSON - And the JSON node "detail" should be equal to "Vous ne pouvez pas créer de liste sur une élection en cours" + And the JSON node "violations[0].message" should be equal to "Vous ne pouvez pas créer de liste sur une élection en cours" Examples: | user | scope | @@ -645,7 +644,7 @@ Feature: """ Then the response status code should be 400 And the response should be in JSON - And the JSON node "detail" should be equal to "Vous ne pouvez pas créer de candidature sur une élection en cours" + And the JSON node "violations[0].message" should be equal to "Vous ne pouvez pas créer de candidature sur une élection en cours" Examples: | user | scope | @@ -675,7 +674,7 @@ Feature: """ Then the response status code should be 400 And the response should be in JSON - And the JSON node "detail" should be equal to "committee_membership: L'adhérent ne fait pas partie de votre zone de couverture." + And the JSON node "violations[0].message" should be equal to "L'adhérent ne fait pas partie de votre zone de couverture." Examples: | user | scope | diff --git a/features/api/department_sites.feature b/features/api/department_sites.feature index bfc1596ff3d..068a4738f96 100644 --- a/features/api/department_sites.feature +++ b/features/api/department_sites.feature @@ -54,7 +54,6 @@ Feature: { "message": "Validation Failed", "status": "error", - "violations": [ { "propertyPath": "zone", @@ -125,7 +124,6 @@ Feature: { "message": "Validation Failed", "status": "error", - "violations": [ { "propertyPath": "zone", diff --git a/features/api/designations.feature b/features/api/designations.feature index 33fc2cf927c..e341ea576bf 100644 --- a/features/api/designations.feature +++ b/features/api/designations.feature @@ -18,7 +18,6 @@ Feature: { "message": "Validation Failed", "status": "error", - "violations": [ { "propertyPath": "custom_title", @@ -59,7 +58,7 @@ Feature: """ Then the response status code should be 400 And the response should be in JSON - And the JSON node "detail" should be equal to "election_entity_identifier: Un identifiant est requis pour ce champs." + And the JSON node "violations[0].message" should be equal to "Un identifiant est requis pour ce champs." Examples: | user | scope | diff --git a/features/api/events.feature b/features/api/events.feature index afeab4aedf8..3ab14f1afd7 100644 --- a/features/api/events.feature +++ b/features/api/events.feature @@ -1132,7 +1132,6 @@ Feature: { "message": "Validation Failed", "status": "error", - "violations": [ { "message": "Catégorie est requise.", @@ -1187,7 +1186,6 @@ Feature: { "message": "Validation Failed", "status": "error", - "violations": [ { "message": "La date de fin de l'événement doit être postérieure à la date de début.", diff --git a/features/api/jecoute_news.feature b/features/api/jecoute_news.feature index 2d1675b9ae1..e2dabe431f7 100644 --- a/features/api/jecoute_news.feature +++ b/features/api/jecoute_news.feature @@ -749,7 +749,6 @@ Feature: { "message": "Validation Failed", "status": "error", - "violations": [ { "propertyPath": "text", @@ -780,7 +779,6 @@ Feature: { "message": "Validation Failed", "status": "error", - "violations": [ { "propertyPath": "text", @@ -1213,7 +1211,6 @@ Feature: { "message": "Validation Failed", "status": "error", - "violations": [ { "propertyPath": "zone", diff --git a/features/api/jecoute_ripostes.feature b/features/api/jecoute_ripostes.feature index b3b06853cd0..81dad8487be 100644 --- a/features/api/jecoute_ripostes.feature +++ b/features/api/jecoute_ripostes.feature @@ -259,7 +259,6 @@ Feature: { "message": "Validation Failed", "status": "error", - "violations": [ { "propertyPath": "title", @@ -283,7 +282,7 @@ Feature: """ { "title": "Une nouvelle riposte d'aujourd'hui - Une nouvelle riposte d'aujourd'hui - Une nouvelle riposte d'aujourd'hui - Une nouvelle riposte d'aujourd'hui - Une nouvelle riposte d'aujourd'hui - Une nouvelle riposte d'aujourd'hui - Une nouvelle riposte d'aujourd'hui", - "with_notification": "true" + "with_notification": true } """ Then the response status code should be 400 @@ -293,7 +292,6 @@ Feature: { "message": "Validation Failed", "status": "error", - "violations": [ { "propertyPath": "title", @@ -306,10 +304,6 @@ Feature: { "propertyPath": "source_url", "message": "Cette valeur ne doit pas être vide." - }, - { - "propertyPath": "with_notification", - "message": "Cette valeur doit être de type bool." } ] } diff --git a/features/api/membership_avecvous.feature b/features/api/membership_avecvous.feature index 9fe37873197..c75979e2532 100644 --- a/features/api/membership_avecvous.feature +++ b/features/api/membership_avecvous.feature @@ -507,7 +507,6 @@ Feature: { "message": "Validation Failed", "status": "error", - "violations": [ { "propertyPath": "cgu_accepted", @@ -531,7 +530,6 @@ Feature: { "message": "Validation Failed", "status": "error", - "violations": [ { "propertyPath": "phone", @@ -555,7 +553,6 @@ Feature: { "message": "Validation Failed", "status": "error", - "violations": [ { "propertyPath": "birthdate", @@ -581,7 +578,6 @@ Feature: { "message": "Validation Failed", "status": "error", - "violations": [ { "propertyPath": "post_address.address", @@ -607,7 +603,6 @@ Feature: { "message": "Validation Failed", "status": "error", - "violations": [ { "propertyPath": "post_address.postal_code", @@ -633,7 +628,6 @@ Feature: { "message": "Validation Failed", "status": "error", - "violations": [ { "propertyPath": "post_address.city_name", @@ -659,7 +653,6 @@ Feature: { "message": "Validation Failed", "status": "error", - "violations": [ { "propertyPath": "post_address.country", diff --git a/features/api/my_teams.feature b/features/api/my_teams.feature index 444202cc3c2..985d01a8779 100644 --- a/features/api/my_teams.feature +++ b/features/api/my_teams.feature @@ -79,7 +79,6 @@ Feature: { "message": "Validation Failed", "status": "error", - "violations": [ { "propertyPath": "role", @@ -105,7 +104,6 @@ Feature: { "message": "Validation Failed", "status": "error", - "violations": [ { "propertyPath": "adherent", @@ -136,7 +134,6 @@ Feature: { "message": "Validation Failed", "status": "error", - "violations": [ { "propertyPath": "adherent", @@ -163,7 +160,6 @@ Feature: { "message": "Validation Failed", "status": "error", - "violations": [ { "propertyPath": "adherent", diff --git a/features/api/pap_address.feature b/features/api/pap_address.feature index 7fd51e3c327..ce853105279 100644 --- a/features/api/pap_address.feature +++ b/features/api/pap_address.feature @@ -719,7 +719,6 @@ Feature: { "message": "Validation Failed", "status": "error", - "violations": [ { "propertyPath": "type", diff --git a/features/api/pap_campaigns.feature b/features/api/pap_campaigns.feature index 594d0525c4f..c59889e6c41 100644 --- a/features/api/pap_campaigns.feature +++ b/features/api/pap_campaigns.feature @@ -834,7 +834,6 @@ Feature: { "message": "Validation Failed", "status": "error", - "violations": [ { "propertyPath": "vote_places", @@ -957,7 +956,6 @@ Feature: { "message": "Validation Failed", "status": "error", - "violations": [ { "message": "La campagne a déjà commencé, vous ne pouvez pas changer le questionnaire.", @@ -1507,7 +1505,6 @@ Feature: { "message": "Validation Failed", "status": "error", - "violations": [ { "propertyPath": "building", @@ -1591,7 +1588,6 @@ Feature: { "message": "Validation Failed", "status": "error", - "violations": [ { "propertyPath": "status", @@ -1663,7 +1659,6 @@ Feature: { "message": "Validation Failed", "status": "error", - "violations": [ { "propertyPath": "title", @@ -1704,7 +1699,6 @@ Feature: { "message": "Validation Failed", "status": "error", - "violations": [ { "propertyPath": "goal", diff --git a/features/api/phoning_campaigns.feature b/features/api/phoning_campaigns.feature index d143941ffc4..d43c6ebb70e 100644 --- a/features/api/phoning_campaigns.feature +++ b/features/api/phoning_campaigns.feature @@ -276,7 +276,6 @@ Feature: { "message": "Validation Failed", "status": "error", - "violations": [ { "message": "Un rôle national ne peut pas définir de zone.", @@ -656,7 +655,6 @@ Feature: { "message": "Validation Failed", "status": "error", - "violations": [ { "propertyPath": "zone", @@ -719,7 +717,6 @@ Feature: { "message": "Validation Failed", "status": "error", - "violations": [ { "propertyPath": "zone", @@ -1149,7 +1146,6 @@ Feature: { "message": "Validation Failed", "status": "error", - "violations": [ { "propertyPath": "status", @@ -1646,7 +1642,6 @@ Feature: { "message": "Validation Failed", "status": "error", - "violations": [ { "propertyPath": "title", diff --git a/features/api/report.feature b/features/api/report.feature index ac5b5814611..68ae47f9a55 100644 --- a/features/api/report.feature +++ b/features/api/report.feature @@ -63,7 +63,6 @@ Feature: "type": "@string@.isUrl()", "message": "Validation Failed", "status": "error", - "violations": [ { "propertyPath": "comment", @@ -89,7 +88,6 @@ Feature: "type": "@string@.isUrl()", "message": "Validation Failed", "status": "error", - "violations": [ { "propertyPath": "reasons", diff --git a/features/api/surveys.feature b/features/api/surveys.feature index 56bb0815200..e9def7d1509 100644 --- a/features/api/surveys.feature +++ b/features/api/surveys.feature @@ -1232,7 +1232,7 @@ Feature: } """ Then the response status code should be 400 - And the JSON node "detail" should be equal to "Vous ne pouvez pas créer ou modifier un questionnaire de type local avec le scope national." + And the JSON node "violations[0].message" should be equal to "Vous ne pouvez pas créer ou modifier un questionnaire de type local avec le scope national." Scenario: As a user with national scope I cannot create a local survey Given I am logged with "referent@en-marche-dev.fr" via OAuth client "JeMengage Web" @@ -1287,7 +1287,7 @@ Feature: } """ Then the response status code should be 400 - And the JSON node "detail" should be equal to "Vous ne pouvez pas créer ou modifier un questionnaire de type national avec le scope president_departmental_assembly." + And the JSON node "violations[0].message" should be equal to "Vous ne pouvez pas créer ou modifier un questionnaire de type national avec le scope president_departmental_assembly." Scenario: As a user with national role I can create a national survey Given I am logged with "deputy@en-marche-dev.fr" via OAuth client "JeMengage Web" @@ -1947,7 +1947,6 @@ Feature: { "message": "Validation Failed", "status": "error", - "violations": [ { "propertyPath": "questions", diff --git a/features/api/surveys_replys.feature b/features/api/surveys_replys.feature index 00acab24257..31432684356 100644 --- a/features/api/surveys_replys.feature +++ b/features/api/surveys_replys.feature @@ -148,7 +148,6 @@ Feature: { "message": "Validation Failed", "status": "error", - "violations": [ { "propertyPath": "profession", diff --git a/features/api/teams.feature b/features/api/teams.feature index 1d217f1c1e1..a00261623c3 100644 --- a/features/api/teams.feature +++ b/features/api/teams.feature @@ -464,7 +464,6 @@ Feature: { "message": "Validation Failed", "status": "error", - "violations": [ { "propertyPath": "zone", @@ -532,7 +531,6 @@ Feature: { "message": "Validation Failed", "status": "error", - "violations": [ { "propertyPath": "name", @@ -566,7 +564,6 @@ Feature: { "message": "Validation Failed", "status": "error", - "violations": [ { "propertyPath": "name", diff --git a/src/Adhesion/Request/MembershipRequest.php b/src/Adhesion/Request/MembershipRequest.php index 239eb2cc2d6..faf97c28a36 100644 --- a/src/Adhesion/Request/MembershipRequest.php +++ b/src/Adhesion/Request/MembershipRequest.php @@ -41,7 +41,6 @@ class MembershipRequest implements DonationRequestInterface #[Assert\NotBlank] public ?string $nationality = null; - #[Assert\Type('bool')] public ?bool $exclusiveMembership = null; #[Assert\AtLeastOneOf([ diff --git a/src/Api/IriConverterDecorator.php b/src/Api/IriConverterDecorator.php index 647472b4140..00fa74e6e87 100644 --- a/src/Api/IriConverterDecorator.php +++ b/src/Api/IriConverterDecorator.php @@ -5,6 +5,7 @@ use ApiPlatform\Metadata\IriConverterInterface; use ApiPlatform\Metadata\Operation; use ApiPlatform\Metadata\UrlGeneratorInterface; +use App\Entity\Event\BaseEventCategory; use Ramsey\Uuid\Uuid; class IriConverterDecorator implements IriConverterInterface @@ -17,6 +18,8 @@ public function getResourceFromIri(string $iri, array $context = [], ?Operation { if (Uuid::isValid($iri)) { $iri = $this->decorated->getIriFromResource(resource: $context['resource_class'], context: ['uri_variables' => ['uuid' => $iri]]); + } elseif (is_a($context['resource_class'], BaseEventCategory::class, true)) { + $iri = $this->decorated->getIriFromResource(resource: $context['resource_class'], context: ['uri_variables' => ['slug' => $iri]]); } return $this->decorated->getResourceFromIri($iri, $context, $operation); diff --git a/src/Entity/Action/Action.php b/src/Entity/Action/Action.php index 518a2440f19..8714dfaf3ef 100644 --- a/src/Entity/Action/Action.php +++ b/src/Entity/Action/Action.php @@ -53,16 +53,17 @@ uriTemplate: '/v3/actions/{uuid}', security: 'object.getAuthor() == user or user.hasDelegatedFromUser(object.getAuthor(), \'actions\')' ), - new Put( + new HttpOperation( + method: 'PUT', uriTemplate: '/v3/actions/{uuid}/cancel', - defaults: ['_api_receive' => false], + deserialize: false, requirements: ['uuid' => '%pattern_uuid%'], controller: CancelActionController::class ), new HttpOperation( method: 'POST|DELETE', uriTemplate: '/v3/actions/{uuid}/register', - defaults: ['_api_receive' => false], + deserialize: false, requirements: ['uuid' => '%pattern_uuid%'], controller: RegisterController::class ), diff --git a/src/Entity/AdherentMessage/AbstractAdherentMessage.php b/src/Entity/AdherentMessage/AbstractAdherentMessage.php index 8c99c1240ed..cfc7844b30a 100644 --- a/src/Entity/AdherentMessage/AbstractAdherentMessage.php +++ b/src/Entity/AdherentMessage/AbstractAdherentMessage.php @@ -9,6 +9,7 @@ use ApiPlatform\Metadata\Delete; use ApiPlatform\Metadata\Get; use ApiPlatform\Metadata\GetCollection; +use ApiPlatform\Metadata\HttpOperation; use ApiPlatform\Metadata\Post; use ApiPlatform\Metadata\Put; use App\AdherentMessage\AdherentMessageDataObject; @@ -64,27 +65,31 @@ normalizationContext: ['groups' => ['message_read']], security: 'is_granted(\'IS_FEATURE_GRANTED\', \'messages\') and (object.getAuthor() == user or user.hasDelegatedFromUser(object.getAuthor(), \'messages\'))' ), - new Post( + new HttpOperation( + method: 'POST', uriTemplate: '/v3/adherent_messages/{uuid}/send', - defaults: ['_api_receive' => false], + deserialize: false, requirements: ['uuid' => '%pattern_uuid%'], controller: SendAdherentMessageController::class ), - new Post( + new HttpOperation( + method: 'POST', uriTemplate: '/v3/adherent_messages/{uuid}/send-test', - defaults: ['_api_receive' => false], + deserialize: false, requirements: ['uuid' => '%pattern_uuid%'], controller: SendTestAdherentMessageController::class ), - new Put( + new HttpOperation( + method: 'PUT', uriTemplate: '/v3/adherent_messages/{uuid}/filter', - defaults: ['_api_receive' => false], + deserialize: false, requirements: ['uuid' => '%pattern_uuid%'], controller: UpdateAdherentMessageFilterController::class ), - new Post( + new HttpOperation( + method: 'POST', uriTemplate: '/v3/adherent_messages/{uuid}/duplicate', - defaults: ['_api_receive' => false], + deserialize: false, requirements: ['uuid' => '%pattern_uuid%'], controller: DuplicateMessageController::class ), diff --git a/src/Entity/ElectedRepresentative/ElectedRepresentative.php b/src/Entity/ElectedRepresentative/ElectedRepresentative.php index 2ba71feeef9..dc11f16cc22 100644 --- a/src/Entity/ElectedRepresentative/ElectedRepresentative.php +++ b/src/Entity/ElectedRepresentative/ElectedRepresentative.php @@ -131,7 +131,7 @@ class ElectedRepresentative implements EntityAdherentBlameableInterface, EntityA */ #[Groups(['elected_representative_write', 'elected_representative_read'])] #[ORM\Column(type: 'boolean', options: ['default' => false])] - private $hasFollowedTraining = false; + public bool $hasFollowedTraining = false; /** * Mailchimp unsubscribed date diff --git a/src/Entity/ElectedRepresentative/Mandate.php b/src/Entity/ElectedRepresentative/Mandate.php index ee7be39e3b4..2a2a5318de9 100644 --- a/src/Entity/ElectedRepresentative/Mandate.php +++ b/src/Entity/ElectedRepresentative/Mandate.php @@ -63,7 +63,7 @@ class Mandate */ #[Groups(['elected_mandate_write', 'elected_mandate_read', 'elected_representative_read'])] #[ORM\Column(type: 'boolean', options: ['default' => false])] - private $isElected; + public $isElected; /** * @var Zone|null diff --git a/src/Entity/Event/BaseEvent.php b/src/Entity/Event/BaseEvent.php index 73b09a4ebd0..b01327b4510 100644 --- a/src/Entity/Event/BaseEvent.php +++ b/src/Entity/Event/BaseEvent.php @@ -97,16 +97,17 @@ new HttpOperation( method: 'POST|DELETE', uriTemplate: '/v3/events/{uuid}/subscribe', - defaults: ['_api_receive' => false], requirements: ['uuid' => '%pattern_uuid%'], controller: SubscribeAsAdherentController::class, - security: 'is_granted(\'ROLE_USER\')' + security: 'is_granted(\'ROLE_USER\')', + deserialize: false ), - new Post( + new HttpOperation( + method: 'POST', uriTemplate: '/events/{uuid}/subscribe', - defaults: ['_api_receive' => false], requirements: ['uuid' => '%pattern_uuid%'], - controller: SubscribeAsAnonymousController::class + controller: SubscribeAsAnonymousController::class, + deserialize: false ), new HttpOperation( method: 'POST|DELETE', @@ -116,11 +117,12 @@ security: "is_granted('ROLE_OAUTH_SCOPE_JEMENGAGE_ADMIN') and is_granted('CAN_MANAGE_EVENT', request.attributes.get('data'))", deserialize: false ), - new Put( + new HttpOperation( + method: 'PUT', uriTemplate: '/v3/events/{uuid}/cancel', - defaults: ['_api_receive' => false], requirements: ['uuid' => '%pattern_uuid%'], - controller: CancelEventController::class + controller: CancelEventController::class, + deserialize: false ), new GetCollection( uriTemplate: '/v3/events', diff --git a/src/Entity/Jecoute/JemarcheDataSurvey.php b/src/Entity/Jecoute/JemarcheDataSurvey.php index 9381592889b..4af50646ac2 100644 --- a/src/Entity/Jecoute/JemarcheDataSurvey.php +++ b/src/Entity/Jecoute/JemarcheDataSurvey.php @@ -4,6 +4,7 @@ use ApiPlatform\Metadata\ApiResource; use ApiPlatform\Metadata\GetCollection; +use ApiPlatform\Metadata\HttpOperation; use ApiPlatform\Metadata\Post; use App\Controller\Api\Jecoute\JemarcheDataSurveyKpiController; use App\Controller\Api\Jecoute\JemarcheDataSurveyReplyController; @@ -22,9 +23,10 @@ #[ApiResource( operations: [ - new Post( + new HttpOperation( + method: 'POST', uriTemplate: '/v3/jemarche_data_surveys/{uuid}/reply', - defaults: ['_api_receive' => false], + deserialize: false, requirements: ['uuid' => '%pattern_uuid%'], controller: JemarcheDataSurveyReplyController::class, normalizationContext: ['groups' => ['data_survey_read']], diff --git a/src/Entity/Jecoute/Region.php b/src/Entity/Jecoute/Region.php index c1055d5b184..73f9141bb73 100644 --- a/src/Entity/Jecoute/Region.php +++ b/src/Entity/Jecoute/Region.php @@ -111,7 +111,6 @@ class Region /** * @var bool */ - #[Assert\Type('bool')] #[ORM\Column(type: 'boolean', options: ['default' => true])] private $enabled; diff --git a/src/Entity/Jecoute/Riposte.php b/src/Entity/Jecoute/Riposte.php index a6dad593aa1..0d129c18033 100644 --- a/src/Entity/Jecoute/Riposte.php +++ b/src/Entity/Jecoute/Riposte.php @@ -6,6 +6,7 @@ use ApiPlatform\Metadata\Delete; use ApiPlatform\Metadata\Get; use ApiPlatform\Metadata\GetCollection; +use ApiPlatform\Metadata\HttpOperation; use ApiPlatform\Metadata\Post; use ApiPlatform\Metadata\Put; use App\Controller\Api\Jecoute\IncrementRiposteStatsCounterController; @@ -42,12 +43,13 @@ uriTemplate: '/v3/ripostes/{uuid}', requirements: ['uuid' => '%pattern_uuid%'] ), - new Put( + new HttpOperation( + method: 'PUT', uriTemplate: '/v3/ripostes/{uuid}/action/{action}', - defaults: ['_api_receive' => false], requirements: ['uuid' => '%pattern_uuid%'], controller: IncrementRiposteStatsCounterController::class, - security: 'is_granted(\'IS_FEATURE_GRANTED\', \'ripostes\') or (is_granted(\'ROLE_USER\') and is_granted(\'ROLE_OAUTH_SCOPE_JEMARCHE_APP\'))' + security: 'is_granted(\'IS_FEATURE_GRANTED\', \'ripostes\') or (is_granted(\'ROLE_USER\') and is_granted(\'ROLE_OAUTH_SCOPE_JEMARCHE_APP\'))', + deserialize: false ), new GetCollection( uriTemplate: '/v3/ripostes', @@ -107,7 +109,6 @@ class Riposte implements AuthorInterface, IndexableEntityInterface, DynamicLinkO /** * @var bool */ - #[Assert\Type('bool')] #[Groups(['riposte_list_read', 'riposte_read', 'riposte_write'])] #[ORM\Column(type: 'boolean', options: ['default' => true])] private $withNotification; @@ -115,7 +116,6 @@ class Riposte implements AuthorInterface, IndexableEntityInterface, DynamicLinkO /** * @var bool */ - #[Assert\Type('bool')] #[Groups(['riposte_list_read', 'riposte_read', 'riposte_write'])] #[ORM\Column(type: 'boolean', options: ['default' => true])] private $enabled; diff --git a/src/Entity/MyTeam/MyTeam.php b/src/Entity/MyTeam/MyTeam.php index 1d0023d7074..28d8720c065 100644 --- a/src/Entity/MyTeam/MyTeam.php +++ b/src/Entity/MyTeam/MyTeam.php @@ -4,7 +4,7 @@ use ApiPlatform\Metadata\ApiResource; use ApiPlatform\Metadata\GetCollection; -use ApiPlatform\Metadata\Post; +use ApiPlatform\Metadata\HttpOperation; use App\Api\Filter\MyTeamScopeFilter; use App\Controller\Api\MyTeam\InitializeMyTeamController; use App\Entity\Adherent; @@ -26,9 +26,10 @@ uriTemplate: '/v3/my_teams', normalizationContext: ['groups' => ['my_team_read_list']] ), - new Post( + new HttpOperation( + method: 'POST', uriTemplate: '/v3/my_teams', - defaults: ['_api_receive' => false], + deserialize: false, controller: InitializeMyTeamController::class ), ], diff --git a/src/Entity/Pap/Campaign.php b/src/Entity/Pap/Campaign.php index b2df206cb22..66359eab545 100644 --- a/src/Entity/Pap/Campaign.php +++ b/src/Entity/Pap/Campaign.php @@ -63,7 +63,6 @@ ), new Get( uriTemplate: '/v3/pap_campaigns/{uuid}/questioners', - defaults: ['_api_receive' => false], requirements: ['uuid' => '%pattern_uuid%'], controller: GetPapCampaignQuestionersStatsController::class, security: 'is_granted(\'IS_FEATURE_GRANTED\', [\'pap_v2\', \'pap\'])' diff --git a/src/Entity/Pap/CampaignHistory.php b/src/Entity/Pap/CampaignHistory.php index c4aa320f385..a6f2add2daf 100644 --- a/src/Entity/Pap/CampaignHistory.php +++ b/src/Entity/Pap/CampaignHistory.php @@ -8,6 +8,7 @@ use ApiPlatform\Metadata\ApiFilter; use ApiPlatform\Metadata\ApiResource; use ApiPlatform\Metadata\GetCollection; +use ApiPlatform\Metadata\HttpOperation; use ApiPlatform\Metadata\Post; use ApiPlatform\Metadata\Put; use App\Api\Filter\AdherentIdentityFilter; @@ -42,9 +43,10 @@ requirements: ['uuid' => '%pattern_uuid%'], security: 'is_granted(\'ROLE_OAUTH_SCOPE_JEMARCHE_APP\') and object.getQuestioner() == user' ), - new Post( + new HttpOperation( + method: 'POST', uriTemplate: '/v3/pap_campaign_histories/{uuid}/reply', - defaults: ['_api_receive' => false], + deserialize: false, requirements: ['uuid' => '%pattern_uuid%'], controller: CampaignHistoryReplyController::class, normalizationContext: ['groups' => ['data_survey_read']] diff --git a/src/Entity/Phoning/Campaign.php b/src/Entity/Phoning/Campaign.php index 9fccb257c60..2145718bd5e 100644 --- a/src/Entity/Phoning/Campaign.php +++ b/src/Entity/Phoning/Campaign.php @@ -66,7 +66,6 @@ ), new Get( uriTemplate: '/v3/phoning_campaigns/{uuid}/callers', - defaults: ['_api_receive' => false], requirements: ['uuid' => '%pattern_uuid%'], controller: GetPhoningCampaignCallersStatsController::class, security: 'is_granted(\'IS_FEATURE_GRANTED\', \'phoning_campaign\')' diff --git a/src/Entity/Phoning/CampaignHistory.php b/src/Entity/Phoning/CampaignHistory.php index 4578dce82a6..bd895f26183 100644 --- a/src/Entity/Phoning/CampaignHistory.php +++ b/src/Entity/Phoning/CampaignHistory.php @@ -7,7 +7,7 @@ use ApiPlatform\Metadata\ApiFilter; use ApiPlatform\Metadata\ApiResource; use ApiPlatform\Metadata\GetCollection; -use ApiPlatform\Metadata\Post; +use ApiPlatform\Metadata\HttpOperation; use ApiPlatform\Metadata\Put; use App\Api\Filter\AdherentIdentityFilter; use App\Controller\Api\Phoning\CampaignHistoryReplyController; @@ -37,9 +37,10 @@ requirements: ['uuid' => '%pattern_uuid%'], security: 'is_granted(\'IS_CAMPAIGN_HISTORY_CALLER\', object)' ), - new Post( + new HttpOperation( + method: 'POST', uriTemplate: '/v3/phoning_campaign_histories/{uuid}/reply', - defaults: ['_api_receive' => false], + deserialize: false, requirements: ['uuid' => '%pattern_uuid%'], controller: CampaignHistoryReplyController::class, normalizationContext: ['groups' => ['data_survey_read']] diff --git a/src/Entity/ProcurationV2/Request.php b/src/Entity/ProcurationV2/Request.php index 303b3c16f3b..7b2543bc658 100644 --- a/src/Entity/ProcurationV2/Request.php +++ b/src/Entity/ProcurationV2/Request.php @@ -8,8 +8,8 @@ use ApiPlatform\Metadata\ApiResource; use ApiPlatform\Metadata\Get; use ApiPlatform\Metadata\GetCollection; +use ApiPlatform\Metadata\HttpOperation; use ApiPlatform\Metadata\Patch; -use ApiPlatform\Metadata\Post; use App\Api\Filter\OrTextSearchFilter; use App\Api\Filter\ProcurationZoneFilter; use App\Controller\Api\Procuration\GetMatchedProxiesController; @@ -42,15 +42,17 @@ requirements: ['uuid' => '%pattern_uuid%'], normalizationContext: ['groups' => ['procuration_request_read'], 'enable_tag_translator' => true] ), - new Post( + new HttpOperation( + method: 'POST', uriTemplate: '/requests/{uuid}/match', - defaults: ['_api_receive' => false], + deserialize: false, requirements: ['uuid' => '%pattern_uuid%'], controller: MatchRequestWithProxyController::class ), - new Post( + new HttpOperation( + method: 'POST', uriTemplate: '/requests/{uuid}/unmatch', - defaults: ['_api_receive' => false], + deserialize: false, requirements: ['uuid' => '%pattern_uuid%'], controller: UnmatchRequestAndProxyController::class ), diff --git a/src/Entity/VotingPlatform/Designation/Designation.php b/src/Entity/VotingPlatform/Designation/Designation.php index e25c8155e5e..4cccd31fe57 100644 --- a/src/Entity/VotingPlatform/Designation/Designation.php +++ b/src/Entity/VotingPlatform/Designation/Designation.php @@ -7,6 +7,7 @@ use ApiPlatform\Metadata\ApiResource; use ApiPlatform\Metadata\Get; use ApiPlatform\Metadata\GetCollection; +use ApiPlatform\Metadata\HttpOperation; use ApiPlatform\Metadata\Post; use ApiPlatform\Metadata\Put; use App\Api\Filter\InZoneOfScopeFilter; @@ -54,12 +55,13 @@ security: 'is_granted(\'ROLE_OAUTH_SCOPE_JEMENGAGE_ADMIN\') and is_granted(\'IS_FEATURE_GRANTED\', \'designation\')', validationContext: ['groups' => UpdateDesignationGroupGenerator::class] ), - new Put( + new HttpOperation( + method: 'PUT', uriTemplate: '/designations/{uuid}/cancel', - defaults: ['_api_receive' => false], requirements: ['uuid' => '%pattern_uuid%'], controller: CancelElectionController::class, - security: 'is_granted(\'ROLE_OAUTH_SCOPE_JEMENGAGE_ADMIN\') and is_granted(\'IS_FEATURE_GRANTED\', \'designation\')' + security: 'is_granted(\'ROLE_OAUTH_SCOPE_JEMENGAGE_ADMIN\') and is_granted(\'IS_FEATURE_GRANTED\', \'designation\')', + deserialize: false ), new GetCollection(normalizationContext: ['groups' => ['designation_list']]), new Post(validationContext: ['groups' => ['api_designation_write']]), @@ -273,7 +275,7 @@ class Designation implements EntityAdministratorBlameableInterface, EntityAdhere #[Groups(['designation_read', 'designation_list'])] #[ORM\Column(type: 'boolean', options: ['default' => false])] - private bool $isCanceled = false; + public bool $isCanceled = false; #[ORM\Column(nullable: true)] public ?string $alertTitle = null; diff --git a/tests/AbstractApiTestCase.php b/tests/AbstractApiTestCase.php index 91e43b7820f..059cb95c715 100644 --- a/tests/AbstractApiTestCase.php +++ b/tests/AbstractApiTestCase.php @@ -9,5 +9,7 @@ protected function setUp(): void parent::setUp(); $this->client->setServerParameter('HTTP_ACCEPT', 'application/json'); + // $this->client->setServerParameter('HTTP_CONTENT_TYPE', 'application/json'); + // $this->client->setServerParameter('HTTP_CONTENT-TYPE', 'application/json'); } }