Skip to content

Commit

Permalink
feat (#1110): functional test Planete PHP
Browse files Browse the repository at this point in the history
  • Loading branch information
stakovicz committed Oct 25, 2023
1 parent 26bb6b2 commit 49642e8
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/Resources/views/admin/planete/feed_list.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
<i class="flag {{ color|default('blue') }} checkered icon"></i>
{{ text|default('non testé') }}
{% endif %}
</td>
<td style="text-align: right">
Expand Down
43 changes: 43 additions & 0 deletions db/seeds/FeedArticle.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

use Phinx\Seed\AbstractSeed;

class FeedArticle extends AbstractSeed
{
public function run()
{
$feed = [
'nom' => '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();
}
}
8 changes: 8 additions & 0 deletions tests/behat/features/Admin/PlanetePHP/BIllets.feature
Original file line number Diff line number Diff line change
@@ -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"
31 changes: 31 additions & 0 deletions tests/behat/features/Admin/PlanetePHP/Flux.feature
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 49642e8

Please sign in to comment.