From 84ccd61a48664f187c8ddd0bdcf02c968ba3a517 Mon Sep 17 00:00:00 2001 From: Albin Date: Thu, 25 Jul 2024 23:11:11 +0200 Subject: [PATCH] afup#1482 on valide le raccourci pour valider sans espace --- htdocs/pages/administration/site_articles.php | 7 +++---- tests/behat/features/Admin/Site/AdminSiteArticles.feature | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/htdocs/pages/administration/site_articles.php b/htdocs/pages/administration/site_articles.php index c576a087b..51555adac 100755 --- a/htdocs/pages/administration/site_articles.php +++ b/htdocs/pages/administration/site_articles.php @@ -31,7 +31,7 @@ $forumLabelsById[$forum['id']] = $forum['titre']; } -function checkSpaceValidation($value): bool +function checkNoSpace($value): bool { return !preg_match('/(\s)/', $value); } @@ -126,10 +126,9 @@ function checkSpaceValidation($value): bool $formulaire->addRule('titre' , 'Titre manquant' , 'required'); $formulaire->addRule('contenu' , 'Contenu manquant' , 'required'); $formulaire->addRule('raccourci' , 'Raccourci manquant' , 'required'); - $formulaire->addRule('raccourci' , 'Ne doit pas contenir d\'espace' , 'regex', '/(?!\s)/'); - $formulaire->registerRule('checkSpace', 'callback', 'checkSpaceValidation'); - $formulaire->addRule('raccourci', 'Ne doit pas contenir d\'espace', 'checkSpace', true); + $formulaire->registerRule('checkNoSpace', 'callback', 'checkNoSpace'); + $formulaire->addRule('raccourci', 'Ne doit pas contenir d\'espace', 'checkNoSpace', true); if ($formulaire->validate()) { diff --git a/tests/behat/features/Admin/Site/AdminSiteArticles.feature b/tests/behat/features/Admin/Site/AdminSiteArticles.feature index d73b3d8f4..2bbdee33e 100644 --- a/tests/behat/features/Admin/Site/AdminSiteArticles.feature +++ b/tests/behat/features/Admin/Site/AdminSiteArticles.feature @@ -52,4 +52,4 @@ Feature: Administration - Partie Site When I follow "Ajouter" And I fill in "raccourci" with "un mauvais raccourci" And I press "Ajouter" - Then the ".negative.message" element should contain "Ne doit pas contenir d'espace" + Then I should see "Ne doit pas contenir d'espace"