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

Annotation of /trunk/tests/testGeneral.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2973 - (hide annotations)
Wed Apr 23 15:43:14 2014 UTC (10 years, 9 months ago) by vpihour
File size: 3602 byte(s)
Correction de l'erreur de base de données qui se produisait si une règle portait sur une date et que la date n'avait pas de valeur

1 softime 2086 <?php
2     /**
3 softime 2786 * Ce fichier regroupe les tests unitaire général à l'application OpenADS
4 fmichon 2258 *
5     * @package openfoncier
6     * @version SVN : $Id$
7 softime 2086 */
8    
9 fmichon 2258 /**
10 softime 2786 * Cette classe permet de tester unitairement les fonctions de l'application.
11 fmichon 2258 */
12 softime 2786 class General extends PHPUnit_Framework_TestCase {
13 fmichon 2258
14 softime 2086 /**
15 softime 2786 * Méthode lancée en début de traitement
16 softime 2086 */
17 softime 2786 public function setUp() {
18 softime 2086
19 softime 2786 // 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 softime 2086
28 softime 2786 //
29 softime 2086 }
30    
31     /**
32 softime 2786 * Test la fonction mois_date() de la classe Utils.
33 softime 2086 */
34 softime 2786 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 vpihour 2973 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 softime 2786 );
64     // Tableau des delais
65     $tab_delay = array(
66     0 => "2",
67     1 => "5",
68     2 => "12",
69     3 => "27",
70 vpihour 2973 4 => "2",
71     5 => "2",
72     6 => "openads",
73     7 => "",
74     8 => "openADS",
75     9 => "",
76     10 => "2",
77     11 => "openads",
78     12 => "",
79 softime 2786 );
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 vpihour 2973 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 softime 2786 );
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 softime 2086 }
104 softime 2786
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 softime 2086 }
131 softime 2786
132     // Destruction de la classe Utils
133     $f->__destruct();
134 softime 2086 }
135    
136     }
137 fmichon 2258
138     ?>

Properties

Name Value
svn:keywords Id

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26