/[openfoncier]/branches/3.14.x/tests/testGeneral.php
ViewVC logotype

Contents of /branches/3.14.x/tests/testGeneral.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3343 - (show annotations)
Thu Mar 19 17:34:18 2015 UTC (9 years, 10 months ago) by vpihour
File size: 3602 byte(s)
Ajout de la branche

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 5 => "",
56 6 => "",
57 7 => "",
58 8 => "2015-12-31",
59 9 => "2015-12-31",
60 10 => "openADS",
61 11 => "openADS",
62 12 => "openADS",
63 );
64 // Tableau des delais
65 $tab_delay = array(
66 0 => "2",
67 1 => "5",
68 2 => "12",
69 3 => "27",
70 4 => "2",
71 5 => "2",
72 6 => "openads",
73 7 => "",
74 8 => "openADS",
75 9 => "",
76 10 => "2",
77 11 => "openads",
78 12 => "",
79 );
80 // Tableau des date résultat
81 $tab_date_fin = array(
82 0 => "2014-02-28",
83 1 => "2014-06-30",
84 2 => "2015-01-01",
85 3 => "2016-04-30",
86 4 => "2016-02-29",
87 5 => null,
88 6 => null,
89 7 => null,
90 8 => "2015-12-31",
91 9 => "2015-12-31",
92 10 => null,
93 11 => null,
94 12 => null,
95 );
96
97 // Pour chaque date
98 foreach ($tab_date_dep as $key => $date_dep) {
99 // Calcul la date résultat
100 $date_fin = $f->mois_date($date_dep, $tab_delay[$key], "+");
101 // Vérifie que la date résultat est correct
102 $this->assertEquals($date_fin, $tab_date_fin[$key]);
103 }
104
105 // Pour les soustractions
106 // Initialisation des tableaux
107 $tab_date_dep = array();
108 $tab_delay = array();
109 $tab_date_fin = array();
110
111 // Tableau des date de départ
112 $tab_date_dep = array(
113 0 => "2014-01-31",
114 );
115 // Tableau des delais
116 $tab_delay = array(
117 0 => "4",
118 );
119 // Tableau des date résultat
120 $tab_date_fin = array(
121 0 => "2013-09-30",
122 );
123
124 // Pour chaque date
125 foreach ($tab_date_dep as $key => $date_dep) {
126 // Calcul la date résultat
127 $date_fin = $f->mois_date($date_dep, $tab_delay[$key], "-");
128 // Vérifie que la date résultat est correct
129 $this->assertEquals($date_fin, $tab_date_fin[$key]);
130 }
131
132 // Destruction de la classe Utils
133 $f->__destruct();
134 }
135
136 }
137
138 ?>

Properties

Name Value
svn:keywords Id

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26