Commit 174f8c18 authored by JonathanMM's avatar JonathanMM

Ajout d'intégration continue

parent f04256f4
......@@ -12,3 +12,5 @@ event/systemeExterne/src/XF.php
config/cron-derniere-execution.txt
sauvegardes/*.sql
config/cron-derniere-execution.txt
tests/rapport/*
tests/resultatsUnitTest.xml
# Tests unitaires uniquement pour le moment
before_script:
- apt-get update
- apt install -y git zip unzip
- php composer.phar install
unitTests:
image: php:7.2
script:
- vendor/bin/phpunit
artifacts:
expire_in: 3 days
when: on_failure
paths:
- tests/rapport/
- tests/resultatsUnitTest.xml
reports:
junit: tests/resultatsUnitTest.xml
\ No newline at end of file
[![pipeline status](https://framagit.org/JonathanMM/haruhi/badges/master/pipeline.svg)](https://framagit.org/JonathanMM/haruhi/commits/master)
Un vrai Lisez-moi arrive bientôt ^^'
Haruhi, c'est un outil pour les associations, afin de gérer facilement leur
......@@ -32,4 +34,12 @@ revision actuelle + 1 jusqu'à la révision d'arrivée. Par exemple, si vous êt
en r20, et que vous voulez arriver en r22, vous devez executer les requêtes SQL
se trouvant dans r21.sql et r22.sql. Ces fichiers sont conçus pour des tables
utilisant le préfixe haruhi_, si ce n'est pas votre cas, remplacez le par le
préfixe que vous utiliser !
\ No newline at end of file
préfixe que vous utiliser !
Tests unitaires
---------------
Pour lancer les tests unitaires, lancer la commande suivante :
```sh
vendor/bin/phpunit
```
......@@ -2,6 +2,7 @@
"require": {
"ovh/ovh": "^2.0",
"jsvrcek/ics": "^0.2",
"ramsey/uuid": "^3.8"
"ramsey/uuid": "^3.8",
"phpunit/phpunit": "^7.4"
}
}
This diff is collapsed.
......@@ -55,7 +55,7 @@ if($nbExecution > 0)
//Si on est lundi, on fait une sauvegarde
if($auj->format('w') == 1)
{
sauvegarder();
sauvegarder(__DIR__.'/');
}
//Maintenant que c'est fini, on met à jour le fichier
......
......@@ -60,8 +60,10 @@ if(isset($_POST['envoi']) && $_POST['envoi'] == 1)
foreach($titres as $idTitre => $titre)
{
if($mode == MODE_AJOUT)
{
$pdo->exec('INSERT INTO '.$bdd_prefixe.'calendrier_permissions (idCategorie, idTitre, lecture, ecriture) VALUES ('.
$id.', '.$idTitre.', '.(isset($titre['lecture']) && $titre['lecture']) ? '1' : '0'.', '.(isset($titre['ecriture']) && $titre['ecriture']) ? '1' : '0'.')');
$id.', '.$idTitre.', '.((isset($titre['lecture']) && $titre['lecture']) ? '1' : '0').', '.((isset($titre['ecriture']) && $titre['ecriture']) ? '1' : '0').')');
}
elseif($mode == MODE_MODIF)
{
$pdo->exec('INSERT INTO '.$bdd_prefixe.'calendrier_permissions (idCategorie, idTitre, lecture, ecriture) VALUES ('.
......
......@@ -236,7 +236,7 @@ $user = $requete->fetch();
<div class="cellule intitule"><label name="adherent">Adhérent de destination :</label></div>
<div class="cellule">
<select name="adherent" required>
<?php $requete = $pdo->query('SELECT * FROM '.$bdd_prefixe.'adherents');
<?php $requete = $pdo->query('SELECT * FROM '.$bdd_prefixe.'adherents WHERE id != '.$id.' ORDER BY prenom, nom ASC');
if(!($requete === false))
{
$users = $requete->fetchAll();
......
......@@ -36,11 +36,11 @@
$fonctionnalites_statut = [
"se" => false,
"ovh" => false,
"xenforo" => true,
"xenforo" => false,
"yuki" => false,
"mikuru" => false,
"intervenants" => false,
"factures" => true,
"factures" => false,
"stockage" => false,
"calendrier" => false,
"avatar" => false,
......
......@@ -76,16 +76,24 @@ function resultatHumainDroitsEcriture($chemin)
</div>
</div>
<div class="ligne">
<div class="cellule intitule"><label for="ovh_nic">Nic</label></div>
<div class="cellule"><input name="ovh_nic" /></div>
<div class="cellule intitule"><label for="ovh_applicationKey">Application key</label></div>
<div class="cellule"><input name="ovh_applicationKey" /></div>
</div>
<div class="ligne">
<div class="cellule intitule"><label for="ovh_mdp">Mot de passe</label></div>
<div class="cellule"><input type="password" name="ovh_mdp" /></div>
<div class="cellule intitule"><label for="ovh_applicationSecret">Application secret</label></div>
<div class="cellule"><input name="ovh_applicationSecret" /></div>
</div>
<div class="ligne">
<div class="cellule intitule"><label for="ovh_ndd">Nom de domaine</label></div>
<div class="cellule"><input name="ovh_ndd" /></div>
<div class="cellule intitule"><label for="ovh_endpoint">Endpoint</label></div>
<div class="cellule"><input name="ovh_endpoint" /></div>
</div>
<div class="ligne">
<div class="cellule intitule"><label for="ovh_consumerKey">Consumer key</label></div>
<div class="cellule"><input name="ovh_consumerKey" /></div>
</div>
<div class="ligne">
<div class="cellule intitule"><label for="ovh_domaineEmail">Domaine e-mail</label></div>
<div class="cellule"><input name="ovh_domaineEmail" /></div>
</div>
<div class="ligne">
<h2>Yuki</h2>
......@@ -109,9 +117,49 @@ function resultatHumainDroitsEcriture($chemin)
<div class="cellule intitule"><label for="yuki_server">Serveur</label></div>
<div class="cellule"><input name="yuki_server" /></div>
</div>
<div class="ligne">
<h2>XenForo</h2>
</div>
<div class="ligne">
<div class="cellule intitule">Activer</div>
<div class="cellule">
<input type="radio" name="xenforo_state" id="xenforo_state_true" value="true" /> <label for="xenforo_state_true">Oui</label>
<input type="radio" name="xenforo_state" id="xenforo_state_false" value="false" /> <label for="xenforo_state_false">Non</label>
</div>
</div>
<div class="ligne">
<div class="cellule intitule"><label for="xenforo_fileDir">Chemin du forum</label></div>
<div class="cellule"><input name="xenforo_fileDir" /></div>
</div>
<div class="ligne">
<h2>HelloAsso</h2>
</div>
<div class="ligne">
<div class="cellule intitule">Activer</div>
<div class="cellule">
<input type="radio" name="helloasso_state" id="helloasso_state_true" value="true" /> <label for="helloasso_state_true">Oui</label>
<input type="radio" name="helloasso_state" id="helloasso_state_false" value="false" /> <label for="helloasso_state_false">Non</label>
</div>
</div>
<div class="ligne">
<div class="cellule intitule"><label for="helloasso_cle">Clé API</label></div>
<div class="cellule"><input name="helloasso_cle" /></div>
</div>
<div class="ligne">
<div class="cellule intitule"><label for="helloasso_mdp">Mot de passe API</label></div>
<div class="cellule"><input name="helloasso_mdp" /></div>
</div>
<div class="ligne">
<h2>Fonctionnalités</h2>
</div>
<div class="ligne">
<div class="cellule intitule">Système externe</div>
<div class="cellule">
<input type="radio" name="se_state" id="se_state_true" value="true" /> <label for="se_state_true">Oui</label>
<input type="radio" name="se_state" id="se_state_false" value="false" /> <label for="se_state_false">Non</label>
(doit être à oui si OVH ou Xenforo activé)
</div>
</div>
<div class="ligne">
<div class="cellule intitule">Mikuru</div>
<div class="cellule">
......
......@@ -17,9 +17,12 @@ $contenu = '<?php
$bdd_prefixe = "'.$_POST['bdd_prefixe'].'";
//OVH
$nic_ovh = "'.$_POST['ovh_nic'].'";
$mdp_ovh = "'.$_POST['ovh_mdp'].'";
$domaine_ovh = "'.$_POST['ovh_ndd'].'";
$applicationKey_ovh = "'.$_POST['ovh_applicationKey'].'";
$applicationSecret_ovh = "'.$_POST['ovh_applicationSecret'].'";
$endpoint_ovh = "'.$_POST['ovh_endpoint'].'";
$consumerKey_ovh = "'.$_POST['ovh_consumerKey'].'";
$domaineEmail_ovh = "'.$_POST['ovh_domaineEmail'].'";
//Yuki
$serveur_yuki = "'.$_POST['yuki_server'].'";
......@@ -27,13 +30,23 @@ $contenu = '<?php
$mdp_yuki = "'.$_POST['yuki_mdp'].'";
//Mikuru
$adresse_mikuru = "";
//Questions tutorats :
$questions_tutorat = array();
//XenForo
$fileDir_xenforo = "'.$_POST['xenforo_fileDir'].'";
//HelloAsso
$cle_helloasso = "'.$_POST['helloasso_cle'].'";
$mdp_helloasso = "'.$_POST['helloasso_mdp'].'";
//Fonctionnalités
$fonctionnalites_statut = [
"se" => '.def('se_state').',
"ovh" => '.def('ovh_state').',
"xenforo" => '.def('xenforo_state').',
"yuki" => '.def('yuki_state').',
"mikuru" => '.def('mikuru_state').',
"intervenants" => '.def('intervenants_state').',
......@@ -43,6 +56,7 @@ $contenu = '<?php
"avatar" => '.def('avatar_state').',
"cartemembre" => '.def('cartemembre_state').',
"nolife" => '.def('nolife_state').',
"helloasso" => '.def('helloasso_state').',
"tresorerie" => '.def('tresorerie_state').'
];
......
......@@ -127,7 +127,7 @@ function supprimerAdherent($idAdherent)
$classes = importerEvent('adherent');
foreach($classes as $classe)
{
$classe::supprimer($adherent);
$classe::supprimer($idAdherent, $adherent);
}
$pdo->exec('DELETE FROM '.$bdd_prefixe.'adherents WHERE id = '.$idAdherent);
......@@ -145,10 +145,10 @@ function deplacerElementsEntreAdherents($idSource, $idDestination)
function getValeurFusionner($propriete, $adherentSource, $adherentDestination)
{
if(is_null($adherentSource[$propriete]) || strlen($adherentSource[$propriete]) == 0)
return $adherentDestination[$propriete];
if(!isset($adherentSource[$propriete]) || is_null($adherentSource[$propriete]) || strlen($adherentSource[$propriete]) == 0)
return isset($adherentDestination[$propriete]) ? $adherentDestination[$propriete] : '';
if(is_null($adherentDestination[$propriete]) || strlen($adherentDestination[$propriete]) == 0)
if(!isset($adherentDestination[$propriete]) || is_null($adherentDestination[$propriete]) || strlen($adherentDestination[$propriete]) == 0)
return $adherentSource[$propriete];
if($adherentSource[$propriete] == $adherentDestination[$propriete])
......@@ -197,7 +197,7 @@ function genererRequeteSQLListeAdherent($terme = NULL, $titre = NULL, $allCotisa
$triSQL = '';
if(!is_null($tri) && strlen($tri) > 0)
{
$option_tri = array('id' => 'a.id', 'numero' => 'a.numero', 'nom' => 'a.nom', 'prenom' => 'a.prenom', 'pseudo' => 'a.pseudo', 'statut' => 't.nom', 'di' => 'date_inscription', 'df' => 'date_fin_cotisation', 'com' => 'commentaire');
$option_tri = array('id' => 'a.id', 'numero' => 'a.numero', 'nom' => 'a.nom', 'prenom' => 'a.prenom', 'pseudo' => 'a.pseudo', 'statut' => 't.nom', 'di' => 'a.date_inscription', 'df' => 'a.date_fin_cotisation', 'com' => 'a.commentaire');
$tri = htmlspecialchars($tri);
if(isset($option_tri[$tri]))
$tri = $option_tri[$tri];
......@@ -215,7 +215,7 @@ function genererRequeteSQLListeAdherent($terme = NULL, $titre = NULL, $allCotisa
if(count($plus_req) > 0)
$where = 'WHERE '.implode(' AND ', $plus_req);
return $where.$triSQL;
return trim($where.$triSQL);
}
function formater_adresse($adresse)
......
......@@ -28,8 +28,8 @@ function reste_jour($date) //Format AAAA-MM-JJ
if(is_null($date))
return '';
$coupe = explode('-', $date);
return ($coupe[0] - date('Y')) * 365 + ($coupe[1] - date('m')) * 30 + ($coupe[2] - date('d'));
$dateObj = new DateTime($date);
return ($dateObj->format('Y') - date('Y')) * 365 + $dateObj->format('z') - date('z');
}
?>
......@@ -4,13 +4,13 @@ function aBesoinDeGuillemets($type)
return in_array($type, array(PDO::PARAM_STR, PDO::PARAM_LOB));
}
function sauvegarder()
function sauvegarder($prefixeChemin = '')
{
global $pdo, $bdd_prefixe;
//On prépare le fichier
$auj = new DateTime();
$nomFichier = $auj->format('Y-m-d-G-i-s').'.sql';
$fichierSQL = fopen('sauvegardes/'.$nomFichier, 'w');
$fichierSQL = fopen($prefixeChemin.'sauvegardes/'.$nomFichier, 'w');
// On récupère la liste des tables
$requete = $pdo->query('show tables LIKE "'.$bdd_prefixe.'%"');
......
<phpunit bootstrap="vendor/autoload.php">
<testsuites>
<testsuite name="unitTests">
<directory>tests/unitTests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">lib/internal/</directory>
<!--
<directory suffix=".php">/path/to/files</directory>
<file>lib/internal/adresse.php</file>
<exclude>
<directory suffix=".php">/path/to/files</directory>
<file>/path/to/file</file>
</exclude>
-->
</whitelist>
</filter>
<logging>
<log type="junit" target="tests/resultatsUnitTest.xml" />
<log type="coverage-html" target="tests/rapport" />
</logging>
</phpunit>
\ No newline at end of file
<?php
namespace UnitTests\Lib\Internal;
require_once(__DIR__.'/../../../../lib/internal/adherent.php');
require_once(__DIR__.'/../../../../lib/internal/adresse.php');
use PHPUnit\Framework\TestCase;
class AdherentTest extends TestCase
{
/**
* @dataProvider providerGetValeurFusionner
*/
public function testGetValeurFusionner($expected, $propriete, $adherentSource, $adherentDestination)
{
$this->assertSame($expected, getValeurFusionner($propriete, $adherentSource, $adherentDestination));
}
public function providerGetValeurFusionner()
{
return array(
['', 'prop', array(), array()],
['a', 'prop', array(), array('prop' => 'a')],
['a', 'prop', array('prop' => null), array('prop' => 'a')],
['a', 'prop', array('prop' => ''), array('prop' => 'a')],
['a', 'prop', array('prop' => 'a'), array()],
['a', 'prop', array('prop' => 'a'), array('prop' => null)],
['a', 'prop', array('prop' => 'a'), array('prop' => '')],
['a', 'prop', array('prop' => 'a'), array('prop' => 'a')],
['', 'prop', array('prop' => 'a'), array('prop' => 'b')]
);
}
/**
* @dataProvider providerGenererFormulaireFusion
*/
public function testGenererFormulaireFusion($expected, $propriete, $adherentSource, $adherentDestination, $nom = "", $obligatoire = false, $aide = "", $typeInput = null)
{
$this->assertSame($expected, genererFormulaireFusion($propriete, $adherentSource, $adherentDestination, $nom, $obligatoire, $aide, $typeInput));
}
public function providerGenererFormulaireFusion()
{
return array(
['
<div class="ligne">
<div class="cellule intitule"><label name="prop"></label></div>
<div class="cellule">a</div>
<div class="cellule"><input name="prop" value="" /></div>
<div class="cellule">b</div>
<div class="cellule"></div>
</div>', 'prop', array('prop' => 'a'), array('prop' => 'b')],
['
<div class="ligne">
<div class="cellule intitule"><label name="prop"></label></div>
<div class="cellule">a</div>
<div class="cellule"><input name="prop" value="a" /></div>
<div class="cellule">a</div>
<div class="cellule"></div>
</div>', 'prop', array('prop' => 'a'), array('prop' => 'a')],
['
<div class="ligne">
<div class="cellule intitule"><label name="prop">nom</label></div>
<div class="cellule">a</div>
<div class="cellule"><input name="prop" value="" /></div>
<div class="cellule">b</div>
<div class="cellule"></div>
</div>', 'prop', array('prop' => 'a'), array('prop' => 'b'), 'nom'],
['
<div class="ligne">
<div class="cellule intitule"><label name="prop"></label></div>
<div class="cellule">a</div>
<div class="cellule"><input required name="prop" value="" /></div>
<div class="cellule">b</div>
<div class="cellule"></div>
</div>', 'prop', array('prop' => 'a'), array('prop' => 'b'), '', true],
['
<div class="ligne">
<div class="cellule intitule"><label name="prop"></label></div>
<div class="cellule">a</div>
<div class="cellule"><input name="prop" value="" /></div>
<div class="cellule">b</div>
<div class="cellule">aide</div>
</div>', 'prop', array('prop' => 'a'), array('prop' => 'b'), '', false, 'aide'],
['
<div class="ligne">
<div class="cellule intitule"><label name="prop"></label></div>
<div class="cellule">a</div>
<div class="cellule"><input type="number" name="prop" value="" /></div>
<div class="cellule">b</div>
<div class="cellule"></div>
</div>', 'prop', array('prop' => 'a'), array('prop' => 'b'), '', false, '', 'number'],
['
<div class="ligne">
<div class="cellule intitule"><label name="prop">nom</label></div>
<div class="cellule">a</div>
<div class="cellule"><input type="number" required name="prop" value="" /></div>
<div class="cellule">b</div>
<div class="cellule">aide</div>
</div>', 'prop', array('prop' => 'a'), array('prop' => 'b'), 'nom', true, 'aide', 'number']
);
}
/**
* @dataProvider providerGenererRequeteSQLListeAdherent
*/
public function testGenererRequeteSQLListeAdherent($expected, $terme = NULL, $titre = NULL, $allCotisations = false, $tri = NULL, $ordre = null)
{
$this->assertSame($expected, genererRequeteSQLListeAdherent($terme, $titre, $allCotisations, $tri, $ordre));
}
public function providerGenererRequeteSQLListeAdherent()
{
return array(
['WHERE (a.date_fin_cotisation >= CURDATE() OR (a.date_fin_cotisation = "0000-00-00" AND a.date_inscription != "0000-00-00")) ORDER BY IF(a.numero = 0, 0, -1), a.numero ASC'],
['WHERE (a.date_fin_cotisation >= CURDATE() OR (a.date_fin_cotisation = "0000-00-00" AND a.date_inscription != "0000-00-00")) ORDER BY IF(a.numero = 0, 0, -1), a.numero ASC', ''],
['WHERE a.prenom LIKE "%a%" OR a.nom LIKE "%a%" OR a.pseudo LIKE "%a%" AND (a.date_fin_cotisation >= CURDATE() OR (a.date_fin_cotisation = "0000-00-00" AND a.date_inscription != "0000-00-00")) ORDER BY IF(a.numero = 0, 0, -1), a.numero ASC', 'a'],
['WHERE a.prenom LIKE "%a%" OR a.prenom LIKE "%b%" OR a.nom LIKE "%a%" OR a.nom LIKE "%b%" OR a.pseudo LIKE "%a%" OR a.pseudo LIKE "%b%" AND (a.date_fin_cotisation >= CURDATE() OR (a.date_fin_cotisation = "0000-00-00" AND a.date_inscription != "0000-00-00")) ORDER BY IF(a.numero = 0, 0, -1), a.numero ASC', 'a b'],
['WHERE (a.date_fin_cotisation >= CURDATE() OR (a.date_fin_cotisation = "0000-00-00" AND a.date_inscription != "0000-00-00")) ORDER BY IF(a.numero = 0, 0, -1), a.numero ASC', null, array()],
['WHERE a.titre = 1 AND (a.date_fin_cotisation >= CURDATE() OR (a.date_fin_cotisation = "0000-00-00" AND a.date_inscription != "0000-00-00")) ORDER BY IF(a.numero = 0, 0, -1), a.numero ASC', null, array(1)],
['WHERE a.titre = 1 OR a.titre = 2 AND (a.date_fin_cotisation >= CURDATE() OR (a.date_fin_cotisation = "0000-00-00" AND a.date_inscription != "0000-00-00")) ORDER BY IF(a.numero = 0, 0, -1), a.numero ASC', null, array(1, 2)],
['ORDER BY IF(a.numero = 0, 0, -1), a.numero ASC', null, null, true],
['WHERE (a.date_fin_cotisation >= CURDATE() OR (a.date_fin_cotisation = "0000-00-00" AND a.date_inscription != "0000-00-00")) ORDER BY a.nom, a.prenom ASC', null, null, false, 'xxx'],
['WHERE (a.date_fin_cotisation >= CURDATE() OR (a.date_fin_cotisation = "0000-00-00" AND a.date_inscription != "0000-00-00")) ORDER BY a.nom, a.prenom ASC', null, null, false, 'xxx', 'xxx'],
['WHERE (a.date_fin_cotisation >= CURDATE() OR (a.date_fin_cotisation = "0000-00-00" AND a.date_inscription != "0000-00-00")) ORDER BY a.nom, a.prenom DESC', null, null, false, 'xxx', 'desc'],
['WHERE (a.date_fin_cotisation >= CURDATE() OR (a.date_fin_cotisation = "0000-00-00" AND a.date_inscription != "0000-00-00")) ORDER BY a.id ASC', null, null, false, 'id'],
['WHERE (a.date_fin_cotisation >= CURDATE() OR (a.date_fin_cotisation = "0000-00-00" AND a.date_inscription != "0000-00-00")) ORDER BY a.numero ASC', null, null, false, 'numero'],
['WHERE (a.date_fin_cotisation >= CURDATE() OR (a.date_fin_cotisation = "0000-00-00" AND a.date_inscription != "0000-00-00")) ORDER BY a.nom ASC', null, null, false, 'nom'],
['WHERE (a.date_fin_cotisation >= CURDATE() OR (a.date_fin_cotisation = "0000-00-00" AND a.date_inscription != "0000-00-00")) ORDER BY a.prenom ASC', null, null, false, 'prenom'],
['WHERE (a.date_fin_cotisation >= CURDATE() OR (a.date_fin_cotisation = "0000-00-00" AND a.date_inscription != "0000-00-00")) ORDER BY a.pseudo ASC', null, null, false, 'pseudo'],
['WHERE (a.date_fin_cotisation >= CURDATE() OR (a.date_fin_cotisation = "0000-00-00" AND a.date_inscription != "0000-00-00")) ORDER BY a.date_inscription ASC', null, null, false, 'di'],
['WHERE (a.date_fin_cotisation >= CURDATE() OR (a.date_fin_cotisation = "0000-00-00" AND a.date_inscription != "0000-00-00")) ORDER BY a.date_fin_cotisation ASC', null, null, false, 'df'],
['WHERE (a.date_fin_cotisation >= CURDATE() OR (a.date_fin_cotisation = "0000-00-00" AND a.date_inscription != "0000-00-00")) ORDER BY a.commentaire ASC', null, null, false, 'com'],
['WHERE (a.date_fin_cotisation >= CURDATE() OR (a.date_fin_cotisation = "0000-00-00" AND a.date_inscription != "0000-00-00")) ORDER BY t.nom ASC', null, null, false, 'statut']
);
}
/**
* @dataProvider providerFormater_adresse
*/
public function testFormater_adresse($expected, $adresse)
{
$this->assertSame($expected, formater_adresse($adresse));
}
public function providerFormater_adresse()
{
return array(
['', ''],
['a', 'a'],
['Ligne1 Ligne2 CP Ville Pays', 'Ligne1'.ADRESSE_SEPARATEUR_CASE.'Ligne2'.ADRESSE_SEPARATEUR_CASE.'CP'.ADRESSE_SEPARATEUR_CASE.'Ville'.ADRESSE_SEPARATEUR_CASE.'Pays'],
['Ligne1 CP Ville Pays', 'Ligne1'.ADRESSE_SEPARATEUR_CASE.ADRESSE_SEPARATEUR_CASE.'CP'.ADRESSE_SEPARATEUR_CASE.'Ville'.ADRESSE_SEPARATEUR_CASE.'Pays']
);
}
}
?>
\ No newline at end of file
<?php
namespace UnitTests\Lib\Internal;
require_once(__DIR__.'/../../../../lib/internal/adresse.php');
use PHPUnit\Framework\TestCase;
class AdresseTest extends TestCase
{
/**
* @dataProvider providerParseAdresse
*/
public function testParseAdresse($expected, $date)
{
$this->assertSame($expected, parseAdresse($date));
}
public function providerParseAdresse()
{
return array(
[array(), ''],
[array(), 'InvalidAdresse'],
[array(array(
'ligne1' => 'Ligne1',
'ligne2' => 'Ligne2',
'cp' => 'CP',
'ville' => 'Ville',
'pays' => 'Pays'
)), 'Ligne1'.ADRESSE_SEPARATEUR_CASE.'Ligne2'.ADRESSE_SEPARATEUR_CASE.'CP'.ADRESSE_SEPARATEUR_CASE.'Ville'.ADRESSE_SEPARATEUR_CASE.'Pays']
);
}
/**
* @dataProvider providerAfficherAdresseSurUneLigne
*/
public function testAfficherAdresseSurUneLigne($expected, $date)
{
$this->assertSame($expected, afficherAdresseSurUneLigne($date));
}
public function providerAfficherAdresseSurUneLigne()
{
return array(
['', ''],
['', 'InvalidAdresse'],
['Ligne1 Ligne2 CP Ville Pays', 'Ligne1'.ADRESSE_SEPARATEUR_CASE.'Ligne2'.ADRESSE_SEPARATEUR_CASE.'CP'.ADRESSE_SEPARATEUR_CASE.'Ville'.ADRESSE_SEPARATEUR_CASE.'Pays']
);
}
/**
* @dataProvider providerStringifyAdresse
*/
public function testStringifyAdresse($expected, $date)
{
$this->assertSame($expected, stringifyAdresse($date));
}
public function providerStringifyAdresse()
{
return array(
['', array()],
['Ligne1'.ADRESSE_SEPARATEUR_CASE.'Ligne2'.ADRESSE_SEPARATEUR_CASE.'CP'.ADRESSE_SEPARATEUR_CASE.'Ville'.ADRESSE_SEPARATEUR_CASE.'Pays', array(array(
'ligne1' => 'Ligne1',
'ligne2' => 'Ligne2',
'cp' => 'CP',
'ville' => 'Ville',
'pays' => 'Pays'
))]
);
}
}
?>
\ No newline at end of file
<?php
namespace UnitTests\Lib\Internal;
require_once(__DIR__.'/../../../../lib/internal/calendrier.php');
use PHPUnit\Framework\TestCase;
class CalendrierTest extends TestCase
{
/**
* @dataProvider providerValeursConstants
*/
public function testValeursConstants($cst)
{
$this->assertTrue(defined($cst));
}
public function providerValeursConstants()
{
return array(
['CALENDRIER_REPONSE_NON_REPONDU'],
['CALENDRIER_REPONSE_REFUS'],
['CALENDRIER_REPONSE_PROVISOIRE'],
['CALENDRIER_REPONSE_ACCEPTE']
);
}
}
?>
\ No newline at end of file
<?php
namespace UnitTests\Lib\Internal;
require_once(__DIR__.'/../../../../lib/internal/date.php');
use PHPUnit\Framework\TestCase;
class DateTest extends TestCase
{
/**
* @dataProvider providerFormater_date
*/
public function testFormater_date($expected, $date)
{
$this->assertSame($expected, formater_date($date));
}
public function providerFormater_date()
{
return array(
['', '0000-00-00'],
['10', '10'],
['01/02/2003', '2003-02-01']
);
}
/**
* @dataProvider providerFormater_date_heure
*/
public function testFormater_date_heure($expected, $dateHeure)
{
$this->assertSame($expected, formater_date_heure($dateHeure));
}
public function providerFormater_date_heure()
{
return array(
[' 00:00:00', '0000-00-00 00:00:00'],
['01/02/2003 12:34:56', '2003-02-01 12:34:56']
);
}
/**
* @dataProvider providerReste_jour
*/
public function testReste_jour($expected, $date)
{
$this->assertSame($expected, reste_jour($date));
}
public function providerReste_jour()
{
return array(
['', null],
[0, date('Y-m-d')],
[1, date('Y-m-d', time() + 24*3600)],
[7, date('Y-m-d', time() + 7*24*3600)]
);
}
}
?>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment