/[openfoncier]/trunk/tests/testGeneral.php
ViewVC logotype

Contents of /trunk/tests/testGeneral.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2786 - (show annotations)
Tue Mar 4 15:37:20 2014 UTC (10 years, 11 months ago) by softime
File size: 2994 byte(s)
Correctiond e la fonction mois_date() + ajout de test unitaire sur cette fonction

1 <?php
2 /**
3 * Ce fichier regroupe les tests unitaire général à l'application OpenADS
4 *
5 * @package openfoncier
6 * @version SVN : $Id$
7 */
8
9 /**
10 * Cette classe permet de tester unitairement les fonctions de l'application.
11 */
12 class General extends PHPUnit_Framework_TestCase {
13
14 /**
15 * Méthode lancée en début de traitement
16 */
17 public function setUp() {
18
19 // Instancie la timezone
20 date_default_timezone_set('Europe/Paris');
21 }
22
23 /**
24 * Méthode lancée en fin de traitement
25 */
26 public function tearDown() {
27
28 //
29 }
30
31 /**
32 * Test la fonction mois_date() de la classe Utils.
33 */
34 public function test_utils_mois_date() {
35 // Instance de la classe Utils
36 require_once "../obj/utils.class.php";
37 $_SESSION['collectivite'] = 1;
38 $_SESSION['login'] = "admin";
39 $_SERVER['REQUEST_URI'] = "";
40 $f = new utils("nohtml");
41
42 // Pour les additions
43 // Initialisation des tableaux
44 $tab_date_dep = array();
45 $tab_delay = array();
46 $tab_date_fin = array();
47
48 // Tableau des date de départ
49 $tab_date_dep = array(
50 0 => "2013-12-31",
51 1 => "2014-01-31",
52 2 => "2014-01-01",
53 3 => "2014-01-31",
54 4 => "2015-12-31",
55 );
56 // Tableau des delais
57 $tab_delay = array(
58 0 => "2",
59 1 => "5",
60 2 => "12",
61 3 => "27",
62 4 => "2",
63 );
64 // Tableau des date résultat
65 $tab_date_fin = array(
66 0 => "2014-02-28",
67 1 => "2014-06-30",
68 2 => "2015-01-01",
69 3 => "2016-04-30",
70 4 => "2016-02-29",
71 );
72
73 // Pour chaque date
74 foreach ($tab_date_dep as $key => $date_dep) {
75 // Calcul la date résultat
76 $date_fin = $f->mois_date($date_dep, $tab_delay[$key], "+");
77 // Vérifie que la date résultat est correct
78 $this->assertEquals($date_fin, $tab_date_fin[$key]);
79 }
80
81 // Pour les soustractions
82 // Initialisation des tableaux
83 $tab_date_dep = array();
84 $tab_delay = array();
85 $tab_date_fin = array();
86
87 // Tableau des date de départ
88 $tab_date_dep = array(
89 0 => "2014-01-31",
90 );
91 // Tableau des delais
92 $tab_delay = array(
93 0 => "4",
94 );
95 // Tableau des date résultat
96 $tab_date_fin = array(
97 0 => "2013-09-30",
98 );
99
100 // Pour chaque date
101 foreach ($tab_date_dep as $key => $date_dep) {
102 // Calcul la date résultat
103 $date_fin = $f->mois_date($date_dep, $tab_delay[$key], "-");
104 // Vérifie que la date résultat est correct
105 $this->assertEquals($date_fin, $tab_date_fin[$key]);
106 }
107
108 // Destruction de la classe Utils
109 $f->__destruct();
110 }
111
112 }
113
114 ?>

Properties

Name Value
svn:keywords Id

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26