From 49642e8b7b08c9174bddeb3a45402fe798a91b9d Mon Sep 17 00:00:00 2001 From: Albin Date: Wed, 25 Oct 2023 21:58:35 +0200 Subject: [PATCH] feat (afup#1110): functional test Planete PHP --- .../views/admin/planete/feed_list.html.twig | 2 + db/seeds/FeedArticle.php | 43 +++++++++++++++++++ .../features/Admin/PlanetePHP/BIllets.feature | 8 ++++ .../features/Admin/PlanetePHP/Flux.feature | 31 +++++++++++++ 4 files changed, 84 insertions(+) create mode 100644 db/seeds/FeedArticle.php create mode 100644 tests/behat/features/Admin/PlanetePHP/BIllets.feature create mode 100644 tests/behat/features/Admin/PlanetePHP/Flux.feature diff --git a/app/Resources/views/admin/planete/feed_list.html.twig b/app/Resources/views/admin/planete/feed_list.html.twig index 5ebb0163e..7bfe41830 100644 --- a/app/Resources/views/admin/planete/feed_list.html.twig +++ b/app/Resources/views/admin/planete/feed_list.html.twig @@ -83,8 +83,10 @@ {% if feed.status == 1 %} {% if testFeeds and feed.id in feedResults|keys %} {% set color = feedResults[feed.id] ? 'green' : 'red' %} + {% set text = feedResults[feed.id] ? 'validé' : 'erreur' %} {% endif %} + {{ text|default('non testé') }} {% endif %} diff --git a/db/seeds/FeedArticle.php b/db/seeds/FeedArticle.php new file mode 100644 index 000000000..8db307063 --- /dev/null +++ b/db/seeds/FeedArticle.php @@ -0,0 +1,43 @@ + 'Un super site PHP', + 'url' => 'https://afup.org', + 'feed' => 'https://afup.org/rss.xml', + 'etat' => 0, + ]; + $table = $this->table('afup_planete_flux'); + $table->truncate(); + + $table + ->insert($feed) + ->save(); + + $data = [ + [ + 'afup_planete_flux_id' => 2, + 'clef' => '0482a33e-7370-11ee-b962-0242ac120002', + 'titre' => 'Un titre', + 'url' => 'https://afup.org/url.html', + 'maj' => time(), + 'auteur' => 'Un super auteur', + 'resume' => 'Un super article', + 'contenu' => 'Le contenu du super article', + 'etat' => 1 + ], + ]; + + $table = $this->table('afup_planete_billet'); + $table->truncate(); + + $table + ->insert($data) + ->save(); + } +} diff --git a/tests/behat/features/Admin/PlanetePHP/BIllets.feature b/tests/behat/features/Admin/PlanetePHP/BIllets.feature new file mode 100644 index 000000000..a2efbfc18 --- /dev/null +++ b/tests/behat/features/Admin/PlanetePHP/BIllets.feature @@ -0,0 +1,8 @@ +Feature: Administration - Planète PHP - Billets + + @reloadDbWithTestData + Scenario: Gestion des flux + Given I am logged in as admin and on the Administration + When I follow "Billets" + Then the ".content h2" element should contain "Billets" + And I should see "Un titre Le contenu du super article Actif" diff --git a/tests/behat/features/Admin/PlanetePHP/Flux.feature b/tests/behat/features/Admin/PlanetePHP/Flux.feature new file mode 100644 index 000000000..9bb46177a --- /dev/null +++ b/tests/behat/features/Admin/PlanetePHP/Flux.feature @@ -0,0 +1,31 @@ +Feature: Administration - Planète PHP - Flux + + Scenario: Gestion des flux + Given I am logged in as admin and on the Administration + When I follow "Flux" + Then the ".content h2" element should contain "Flux" + # Ajout d'un flux + When I follow "Ajouter" + Then the ".content h2" element should contain "Ajouter un flux" + When I fill in "feed_form[name]" with "Site web les-tilleuls.coop" + And I fill in "feed_form[url]" with "https://les-tilleuls.coop" + And I fill in "feed_form[feed]" with "https://les-tilleuls.coop/feed.xml" + And I press "Ajouter" + Then the ".content .message" element should contain "Le flux a été ajouté" + # Liste des flux + And I should see "les-tilleuls.coop https://les-tilleuls.coop Actif Oui non testé" + # Test de validité + When I follow "Test validité" + And I should see "les-tilleuls.coop https://les-tilleuls.coop Actif Oui validé" + # Modification + désactivation d'un flux + When I follow the button of tooltip "Modifier la fiche de Site web les-tilleuls.coop" + Then the ".content h2" element should contain "Modifier un flux" + When I fill in "feed_form[name]" with "Site web les-tilleuls.coop modifié" + And I select "0" from "feed_form[status]" + And I press "Modifier" + Then the ".content .message" element should contain "Le flux a été modifié" + And I should see "les-tilleuls.coop modifié https://les-tilleuls.coop Inactif" + # Suppression + When I follow the button of tooltip "Supprimer la fiche de Site web les-tilleuls.coop modifié" + Then the ".content .message" element should contain "Le flux a été supprimé" + And I should not see "les-tilleuls.coop"