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

Annotation of /trunk/tests/testGeneral.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2786 - (hide 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 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     );
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 softime 2086 }
80 softime 2786
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 softime 2086 }
107 softime 2786
108     // Destruction de la classe Utils
109     $f->__destruct();
110 softime 2086 }
111    
112     }
113 fmichon 2258
114     ?>

Properties

Name Value
svn:keywords Id

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26