From c82640410d83fd0f03314333190722e296954a43 Mon Sep 17 00:00:00 2001 From: Stakovicz Date: Fri, 6 Dec 2024 17:35:07 +0100 Subject: [PATCH] afup#1437 fix article save --- htdocs/pages/administration/site_articles.php | 1 + sources/Afup/Corporate/Article.php | 12 ++++++------ .../Admin/Site/AdminSiteArticles.feature | 16 ++++++++++++++++ 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/htdocs/pages/administration/site_articles.php b/htdocs/pages/administration/site_articles.php index 51555adac..939bed4e9 100755 --- a/htdocs/pages/administration/site_articles.php +++ b/htdocs/pages/administration/site_articles.php @@ -126,6 +126,7 @@ function checkNoSpace($value): bool $formulaire->addRule('titre' , 'Titre manquant' , 'required'); $formulaire->addRule('contenu' , 'Contenu manquant' , 'required'); $formulaire->addRule('raccourci' , 'Raccourci manquant' , 'required'); + $formulaire->addRule('id_site_rubrique' , 'Rubrique manquante' , 'required'); $formulaire->registerRule('checkNoSpace', 'callback', 'checkNoSpace'); $formulaire->addRule('raccourci', 'Ne doit pas contenir d\'espace', 'checkNoSpace', true); diff --git a/sources/Afup/Corporate/Article.php b/sources/Afup/Corporate/Article.php index c724b2746..0b0332efd 100644 --- a/sources/Afup/Corporate/Article.php +++ b/sources/Afup/Corporate/Article.php @@ -230,7 +230,7 @@ function modifier() $requete = 'UPDATE afup_site_article SET id_site_rubrique = ' . $this->bdd->echapper($this->id_site_rubrique) . ', - id_personne_physique = ' . $this->bdd->echapper($this->id_personne_physique) . ', + id_personne_physique = ' . $this->bdd->echapper($this->id_personne_physique ?: null) . ', titre = ' . $this->bdd->echapper($this->titre) . ', raccourci = ' . $this->bdd->echapper($this->raccourci) . ', chapeau = ' . $this->bdd->echapper($this->chapeau) . ', @@ -238,8 +238,8 @@ function modifier() type_contenu = ' . $this->bdd->echapper($this->type_contenu) . ', position = ' . $this->bdd->echapper($this->position) . ', date = ' . $this->bdd->echapper($this->date) . ', - theme = ' . $this->bdd->echapper($this->theme) . ', - id_forum = ' . $this->bdd->echapper($this->id_forum) . ', + theme = ' . $this->bdd->echapper($this->theme ?: null) . ', + id_forum = ' . $this->bdd->echapper($this->id_forum ?: null) . ', etat = ' . $this->bdd->echapper($this->etat) . ' WHERE id = ' . $this->bdd->echapper($this->id); @@ -252,7 +252,7 @@ function inserer() $requete = 'INSERT INTO afup_site_article SET id_site_rubrique = ' . $this->bdd->echapper($this->id_site_rubrique) . ', - id_personne_physique = ' . $this->bdd->echapper($this->id_personne_physique) . ', + id_personne_physique = ' . $this->bdd->echapper($this->id_personne_physique ?: null) . ', titre = ' . $this->bdd->echapper($this->titre) . ', raccourci = ' . $this->bdd->echapper($this->raccourci) . ', chapeau = ' . $this->bdd->echapper($this->chapeau) . ', @@ -260,8 +260,8 @@ function inserer() type_contenu = ' . $this->bdd->echapper($this->type_contenu) . ', position = ' . $this->bdd->echapper($this->position) . ', date = ' . $this->bdd->echapper($this->date) . ', - theme = ' . $this->bdd->echapper($this->theme) . ', - id_forum = ' . $this->bdd->echapper($this->id_forum) . ', + theme = ' . $this->bdd->echapper($this->theme ?: null) . ', + id_forum = ' . $this->bdd->echapper($this->id_forum ?: null) . ', etat = ' . $this->bdd->echapper($this->etat); if ($this->id > 0) { $requete .= ', id = ' . $this->bdd->echapper($this->id); diff --git a/tests/behat/features/Admin/Site/AdminSiteArticles.feature b/tests/behat/features/Admin/Site/AdminSiteArticles.feature index 2bbdee33e..3a0b7b695 100644 --- a/tests/behat/features/Admin/Site/AdminSiteArticles.feature +++ b/tests/behat/features/Admin/Site/AdminSiteArticles.feature @@ -1,5 +1,21 @@ Feature: Administration - Partie Site + Scenario: Ajout d'un article avec le minimum d'info + Given I am logged in as admin and on the Administration + And I follow "Articles" + Then I should see "Liste des articles" + And I should see "Actualités" + When I follow "Ajouter" + Then I should see "Ajouter un article" + And I fill in "titre" with "Le titre mini" + And I fill in "contenu" with "Le contenu mini" + And I fill in "raccourci" with "url-article-mini" + And I select "Actualités" from "id_site_rubrique" + And I select "9" from "position" + And I press "Ajouter" + When I should see "Liste des articles" + Then the ".content table" element should contain "Le titre mini" + @reloadDbWithTestData Scenario: Ajout/modification/suppression d'un article Given I am logged in as admin and on the Administration