Skip to content

Commit

Permalink
afup#1482 on valide le raccourci pour valider sans espace
Browse files Browse the repository at this point in the history
  • Loading branch information
stakovicz committed Jul 25, 2024
1 parent 1aa6455 commit ae9ae85
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions htdocs/pages/administration/site_articles.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
$forumLabelsById[$forum['id']] = $forum['titre'];
}

function checkSpaceValidation($value): bool
{
return !preg_match('/(\s)/', $value);
}

if ($action == 'lister') {
$list_champs = '*';
$list_ordre = 'date';
Expand Down Expand Up @@ -121,6 +126,11 @@
$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);


if ($formulaire->validate()) {
$article->id_site_rubrique = $formulaire->exportValue('id_site_rubrique');
Expand Down
9 changes: 9 additions & 0 deletions tests/behat/features/Admin/Site/AdminSiteArticles.feature
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,12 @@ Feature: Administration - Partie Site
And I follow "supprimer_2"
Then I should see "Liste des articles"
But the ".content table" element should not contain "Le titre de l'article modifié"

Scenario: Le raccourci ne doit pas contenir d'espace
Given I am logged in as admin and on the Administration
And I follow "Articles"
Then I should see "Liste des articles"
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"

0 comments on commit ae9ae85

Please sign in to comment.