Test Failed
Push — master ( e0c20c...b8c830 )
by Alxarafe
39:29
created
dolibarr/test/phpunit/FactureTest.php 3 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -60,9 +60,9 @@  discard block
 block discarded – undo
60 60
      */
61 61
     function __construct()
62 62
     {
63
-    	parent::__construct();
63
+        parent::__construct();
64 64
 
65
-    	//$this->sharedFixture
65
+        //$this->sharedFixture
66 66
         global $conf,$user,$langs,$db;
67 67
         $this->savconf=$conf;
68 68
         $this->savuser=$user;
@@ -225,22 +225,22 @@  discard block
 block discarded – undo
225 225
         unset($localobject->array_options['options_reseller']);
226 226
 
227 227
         $arraywithdiff = $this->objCompare(
228
-			$localobject,
229
-			$newlocalobject,
230
-			true,
231
-			array(
232
-				'newref','oldref','id','lines','client','thirdparty','brouillon','user_author','date_creation','date_validation','datem','date_modification',
233
-				'ref','statut','paye','specimen','ref','actiontypecode','actionmsg2','actionmsg','mode_reglement','cond_reglement',
234
-				'cond_reglement_doc','situation_cycle_ref','situation_counter','situation_final','multicurrency_total_ht','multicurrency_total_tva',
235
-				'multicurrency_total_ttc','fk_multicurrency','multicurrency_code','multicurrency_tx'
236
-			)
237
-		);
228
+            $localobject,
229
+            $newlocalobject,
230
+            true,
231
+            array(
232
+                'newref','oldref','id','lines','client','thirdparty','brouillon','user_author','date_creation','date_validation','datem','date_modification',
233
+                'ref','statut','paye','specimen','ref','actiontypecode','actionmsg2','actionmsg','mode_reglement','cond_reglement',
234
+                'cond_reglement_doc','situation_cycle_ref','situation_counter','situation_final','multicurrency_total_ht','multicurrency_total_tva',
235
+                'multicurrency_total_ttc','fk_multicurrency','multicurrency_code','multicurrency_tx'
236
+            )
237
+        );
238 238
         $this->assertEquals($arraywithdiff, array());    // Actual, Expected
239 239
 
240 240
         return $localobject;
241 241
     }
242 242
 
243
-   /**
243
+    /**
244 244
      * testFactureOther
245 245
      *
246 246
      * @param   Object $localobject Invoice
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 
269 269
         $result=$localobject->demande_prelevement($user);
270 270
         print __METHOD__." result=".$result."\n";
271
-       	$this->assertLessThan($result, 0);
271
+            $this->assertLessThan($result, 0);
272 272
 
273 273
         return $localobject->id;
274 274
     }
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
         $result=$localobject2->initAsSpecimen();
303 303
         $result=$localobject2->create($user);
304 304
         $result=$localobject2->validate($user);
305
-		print 'Invoice $localobject ref = '.$localobject->ref."\n";
305
+        print 'Invoice $localobject ref = '.$localobject->ref."\n";
306 306
         print 'Invoice $localobject2 created with ref = '.$localobject2->ref."\n";
307 307
 
308 308
         $conf->global->INVOICE_CAN_NEVER_BE_REMOVED = 1;
Please login to merge, or discard this patch.
Spacing   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  *      \remarks    To run this script as CLI:  phpunit filename.php
25 25
  */
26 26
 
27
-global $conf,$user,$langs,$db;
27
+global $conf, $user, $langs, $db;
28 28
 //define('TEST_DB_FORCE_TYPE','mysql');	// This is to force using mysql driver
29 29
 //require_once 'PHPUnit/Autoload.php';
30 30
 require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
     $user->fetch(1);
36 36
     $user->getrights();
37 37
 }
38
-$conf->global->MAIN_DISABLE_ALL_MAILS=1;
38
+$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
39 39
 
40 40
 
41 41
 /**
@@ -63,11 +63,11 @@  discard block
 block discarded – undo
63 63
     	parent::__construct();
64 64
 
65 65
     	//$this->sharedFixture
66
-        global $conf,$user,$langs,$db;
67
-        $this->savconf=$conf;
68
-        $this->savuser=$user;
69
-        $this->savlangs=$langs;
70
-        $this->savdb=$db;
66
+        global $conf, $user, $langs, $db;
67
+        $this->savconf = $conf;
68
+        $this->savuser = $user;
69
+        $this->savlangs = $langs;
70
+        $this->savdb = $db;
71 71
 
72 72
         print __METHOD__." db->type=".$db->type." user->id=".$user->id;
73 73
         //print " - db ".$db->db;
@@ -77,10 +77,10 @@  discard block
 block discarded – undo
77 77
     // Static methods
78 78
     public static function setUpBeforeClass()
79 79
     {
80
-        global $conf,$user,$langs,$db;
80
+        global $conf, $user, $langs, $db;
81 81
 
82 82
         if (empty($conf->facture->enabled)) { print __METHOD__." module customer invoice must be enabled.\n"; die(); }
83
-        if (! empty($conf->ecotaxdeee->enabled)) { print __METHOD__." ecotaxdeee module must not be enabled.\n"; die(); }
83
+        if (!empty($conf->ecotaxdeee->enabled)) { print __METHOD__." ecotaxdeee module must not be enabled.\n"; die(); }
84 84
 
85 85
         $db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
86 86
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
     // tear down after class
91 91
     public static function tearDownAfterClass()
92 92
     {
93
-        global $conf,$user,$langs,$db;
93
+        global $conf, $user, $langs, $db;
94 94
         $db->rollback();
95 95
 
96 96
         print __METHOD__."\n";
@@ -103,11 +103,11 @@  discard block
 block discarded – undo
103 103
      */
104 104
     protected function setUp()
105 105
     {
106
-        global $conf,$user,$langs,$db;
107
-        $conf=$this->savconf;
108
-        $user=$this->savuser;
109
-        $langs=$this->savlangs;
110
-        $db=$this->savdb;
106
+        global $conf, $user, $langs, $db;
107
+        $conf = $this->savconf;
108
+        $user = $this->savuser;
109
+        $langs = $this->savlangs;
110
+        $db = $this->savdb;
111 111
 
112 112
         print __METHOD__."\n";
113 113
     }
@@ -129,15 +129,15 @@  discard block
 block discarded – undo
129 129
      */
130 130
     public function testFactureCreate()
131 131
     {
132
-        global $conf,$user,$langs,$db;
133
-        $conf=$this->savconf;
134
-        $user=$this->savuser;
135
-        $langs=$this->savlangs;
136
-        $db=$this->savdb;
132
+        global $conf, $user, $langs, $db;
133
+        $conf = $this->savconf;
134
+        $user = $this->savuser;
135
+        $langs = $this->savlangs;
136
+        $db = $this->savdb;
137 137
 
138
-        $localobject=new Facture($this->savdb);
138
+        $localobject = new Facture($this->savdb);
139 139
         $localobject->initAsSpecimen();
140
-        $result=$localobject->create($user);
140
+        $result = $localobject->create($user);
141 141
         $this->assertLessThan($result, 0);
142 142
         print __METHOD__." result=".$result."\n";
143 143
         return $result;
@@ -154,14 +154,14 @@  discard block
 block discarded – undo
154 154
      */
155 155
     public function testFactureFetch($id)
156 156
     {
157
-        global $conf,$user,$langs,$db;
158
-        $conf=$this->savconf;
159
-        $user=$this->savuser;
160
-        $langs=$this->savlangs;
161
-        $db=$this->savdb;
157
+        global $conf, $user, $langs, $db;
158
+        $conf = $this->savconf;
159
+        $user = $this->savuser;
160
+        $langs = $this->savlangs;
161
+        $db = $this->savdb;
162 162
 
163
-        $localobject=new Facture($this->savdb);
164
-        $result=$localobject->fetch($id);
163
+        $localobject = new Facture($this->savdb);
164
+        $result = $localobject->fetch($id);
165 165
 
166 166
         $this->assertLessThan($result, 0);
167 167
         print __METHOD__." id=".$id." result=".$result."\n";
@@ -179,14 +179,14 @@  discard block
 block discarded – undo
179 179
      */
180 180
     public function testFactureUpdate($localobject)
181 181
     {
182
-        global $conf,$user,$langs,$db;
183
-        $conf=$this->savconf;
184
-        $user=$this->savuser;
185
-        $langs=$this->savlangs;
186
-        $db=$this->savdb;
182
+        global $conf, $user, $langs, $db;
183
+        $conf = $this->savconf;
184
+        $user = $this->savuser;
185
+        $langs = $this->savlangs;
186
+        $db = $this->savdb;
187 187
 
188 188
         $this->changeProperties($localobject);
189
-        $result=$localobject->update($user);
189
+        $result = $localobject->update($user);
190 190
 
191 191
         print __METHOD__." id=".$localobject->id." result=".$result."\n";
192 192
         $this->assertLessThan($result, 0);
@@ -204,19 +204,19 @@  discard block
 block discarded – undo
204 204
      */
205 205
     public function testFactureValid($localobject)
206 206
     {
207
-        global $conf,$user,$langs,$db;
208
-        $conf=$this->savconf;
209
-        $user=$this->savuser;
210
-        $langs=$this->savlangs;
211
-        $db=$this->savdb;
207
+        global $conf, $user, $langs, $db;
208
+        $conf = $this->savconf;
209
+        $user = $this->savuser;
210
+        $langs = $this->savlangs;
211
+        $db = $this->savdb;
212 212
 
213
-        $result=$localobject->validate($user);
213
+        $result = $localobject->validate($user);
214 214
         print __METHOD__." id=".$localobject->id." result=".$result."\n";
215 215
 
216 216
         $this->assertLessThan($result, 0);
217 217
 
218 218
         // Test everything are still same than specimen
219
-        $newlocalobject=new Facture($this->savdb);
219
+        $newlocalobject = new Facture($this->savdb);
220 220
         $newlocalobject->initAsSpecimen();
221 221
         $this->changeProperties($newlocalobject);
222 222
 
@@ -229,13 +229,13 @@  discard block
 block discarded – undo
229 229
 			$newlocalobject,
230 230
 			true,
231 231
 			array(
232
-				'newref','oldref','id','lines','client','thirdparty','brouillon','user_author','date_creation','date_validation','datem','date_modification',
233
-				'ref','statut','paye','specimen','ref','actiontypecode','actionmsg2','actionmsg','mode_reglement','cond_reglement',
234
-				'cond_reglement_doc','situation_cycle_ref','situation_counter','situation_final','multicurrency_total_ht','multicurrency_total_tva',
235
-				'multicurrency_total_ttc','fk_multicurrency','multicurrency_code','multicurrency_tx'
232
+				'newref', 'oldref', 'id', 'lines', 'client', 'thirdparty', 'brouillon', 'user_author', 'date_creation', 'date_validation', 'datem', 'date_modification',
233
+				'ref', 'statut', 'paye', 'specimen', 'ref', 'actiontypecode', 'actionmsg2', 'actionmsg', 'mode_reglement', 'cond_reglement',
234
+				'cond_reglement_doc', 'situation_cycle_ref', 'situation_counter', 'situation_final', 'multicurrency_total_ht', 'multicurrency_total_tva',
235
+				'multicurrency_total_ttc', 'fk_multicurrency', 'multicurrency_code', 'multicurrency_tx'
236 236
 			)
237 237
 		);
238
-        $this->assertEquals($arraywithdiff, array());    // Actual, Expected
238
+        $this->assertEquals($arraywithdiff, array()); // Actual, Expected
239 239
 
240 240
         return $localobject;
241 241
     }
@@ -251,11 +251,11 @@  discard block
 block discarded – undo
251 251
      */
252 252
     public function testFactureOther($localobject)
253 253
     {
254
-        global $conf,$user,$langs,$db;
255
-        $conf=$this->savconf;
256
-        $user=$this->savuser;
257
-        $langs=$this->savlangs;
258
-        $db=$this->savdb;
254
+        global $conf, $user, $langs, $db;
255
+        $conf = $this->savconf;
256
+        $user = $this->savuser;
257
+        $langs = $this->savlangs;
258
+        $db = $this->savdb;
259 259
 
260 260
         /*$result=$localobject->setstatus(0);
261 261
         print __METHOD__." id=".$localobject->id." result=".$result."\n";
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
         print __METHOD__." localobject->date_creation=".$localobject->date_creation."\n";
267 267
         $this->assertNotEquals($localobject->date_creation, '');
268 268
 
269
-        $result=$localobject->demande_prelevement($user);
269
+        $result = $localobject->demande_prelevement($user);
270 270
         print __METHOD__." result=".$result."\n";
271 271
        	$this->assertLessThan($result, 0);
272 272
 
@@ -284,44 +284,44 @@  discard block
 block discarded – undo
284 284
      */
285 285
     public function testFactureDelete($id)
286 286
     {
287
-        global $conf,$user,$langs,$db;
288
-        $conf=$this->savconf;
289
-        $user=$this->savuser;
290
-        $langs=$this->savlangs;
291
-        $db=$this->savdb;
287
+        global $conf, $user, $langs, $db;
288
+        $conf = $this->savconf;
289
+        $user = $this->savuser;
290
+        $langs = $this->savlangs;
291
+        $db = $this->savdb;
292 292
 
293 293
         // Force default setup
294 294
         unset($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED);
295 295
         unset($conf->global->INVOICE_CAN_NEVER_BE_REMOVED);
296 296
 
297
-        $localobject=new Facture($this->savdb);
298
-        $result=$localobject->fetch($id);
297
+        $localobject = new Facture($this->savdb);
298
+        $result = $localobject->fetch($id);
299 299
 
300 300
         // Create another invoice and validate it after $localobject
301
-        $localobject2=new Facture($this->savdb);
302
-        $result=$localobject2->initAsSpecimen();
303
-        $result=$localobject2->create($user);
304
-        $result=$localobject2->validate($user);
301
+        $localobject2 = new Facture($this->savdb);
302
+        $result = $localobject2->initAsSpecimen();
303
+        $result = $localobject2->create($user);
304
+        $result = $localobject2->validate($user);
305 305
 		print 'Invoice $localobject ref = '.$localobject->ref."\n";
306 306
         print 'Invoice $localobject2 created with ref = '.$localobject2->ref."\n";
307 307
 
308 308
         $conf->global->INVOICE_CAN_NEVER_BE_REMOVED = 1;
309 309
 
310
-        $result=$localobject2->delete($user);					// Deletion is KO, option INVOICE_CAN_NEVER_BE_REMOVED is on
310
+        $result = $localobject2->delete($user); // Deletion is KO, option INVOICE_CAN_NEVER_BE_REMOVED is on
311 311
         print __METHOD__." id=".$localobject2->id." ref=".$localobject2->ref." result=".$result."\n";
312 312
         $this->assertEquals(0, $result, 'Deletion should fail, option INVOICE_CAN_NEVER_BE_REMOVED is on');
313 313
 
314 314
         unset($conf->global->INVOICE_CAN_NEVER_BE_REMOVED);
315 315
 
316
-        $result=$localobject->delete($user);					// Deletion is KO, it is not last invoice
316
+        $result = $localobject->delete($user); // Deletion is KO, it is not last invoice
317 317
         print __METHOD__." id=".$localobject->id." ref=".$localobject->ref." result=".$result."\n";
318 318
         $this->assertEquals(0, $result, 'Deletion should fail, it is not last invoice');
319 319
 
320
-        $result=$localobject2->delete($user);					// Deletion is OK, it is last invoice
320
+        $result = $localobject2->delete($user); // Deletion is OK, it is last invoice
321 321
         print __METHOD__." id=".$localobject2->id." ref=".$localobject2->ref." result=".$result."\n";
322 322
         $this->assertGreaterThan(0, $result, 'Deletion should work, it is last invoice');
323 323
 
324
-        $result=$localobject->delete($user);					// Deletion is KO, it is not last invoice
324
+        $result = $localobject->delete($user); // Deletion is KO, it is not last invoice
325 325
         print __METHOD__." id=".$localobject->id." ref=".$localobject->ref." result=".$result."\n";
326 326
         $this->assertGreaterThan(0, $result, 'Deletion should work, it is again last invoice');
327 327
 
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
      */
337 337
     public function changeProperties(&$localobject)
338 338
     {
339
-        $localobject->note_private='New note';
339
+        $localobject->note_private = 'New note';
340 340
         //$localobject->note='New note after update';
341 341
     }
342 342
 
@@ -349,29 +349,29 @@  discard block
 block discarded – undo
349 349
      * @param   array $fieldstoignorearray      Array of fields to ignore in diff
350 350
      * @return  array                           Array with differences
351 351
      */
352
-    public function objCompare($oA,$oB,$ignoretype=true,$fieldstoignorearray=array('id'))
352
+    public function objCompare($oA, $oB, $ignoretype = true, $fieldstoignorearray = array('id'))
353 353
     {
354
-        $retAr=array();
354
+        $retAr = array();
355 355
 
356 356
         if (get_class($oA) !== get_class($oB))
357 357
         {
358
-            $retAr[]="Supplied objects are not of same class.";
358
+            $retAr[] = "Supplied objects are not of same class.";
359 359
         }
360 360
         else
361 361
         {
362
-            $oVarsA=get_object_vars($oA);
363
-            $oVarsB=get_object_vars($oB);
364
-            $aKeys=array_keys($oVarsA);
365
-            foreach($aKeys as $sKey)
362
+            $oVarsA = get_object_vars($oA);
363
+            $oVarsB = get_object_vars($oB);
364
+            $aKeys = array_keys($oVarsA);
365
+            foreach ($aKeys as $sKey)
366 366
             {
367
-                if (in_array($sKey,$fieldstoignorearray)) continue;
368
-                if (! $ignoretype && $oVarsA[$sKey] !== $oVarsB[$sKey])
367
+                if (in_array($sKey, $fieldstoignorearray)) continue;
368
+                if (!$ignoretype && $oVarsA[$sKey] !== $oVarsB[$sKey])
369 369
                 {
370
-                    $retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey])?get_class($oVarsA[$sKey]):$oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey])?get_class($oVarsB[$sKey]):$oVarsB[$sKey]);
370
+                    $retAr[] = $sKey.' : '.(is_object($oVarsA[$sKey]) ?get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ?get_class($oVarsB[$sKey]) : $oVarsB[$sKey]);
371 371
                 }
372 372
                 if ($ignoretype && $oVarsA[$sKey] != $oVarsB[$sKey])
373 373
                 {
374
-                    $retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey])?get_class($oVarsA[$sKey]):$oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey])?get_class($oVarsB[$sKey]):$oVarsB[$sKey]);
374
+                    $retAr[] = $sKey.' : '.(is_object($oVarsA[$sKey]) ?get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ?get_class($oVarsB[$sKey]) : $oVarsB[$sKey]);
375 375
                 }
376 376
             }
377 377
         }
Please login to merge, or discard this patch.
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -356,15 +356,16 @@
 block discarded – undo
356 356
         if (get_class($oA) !== get_class($oB))
357 357
         {
358 358
             $retAr[]="Supplied objects are not of same class.";
359
-        }
360
-        else
359
+        } else
361 360
         {
362 361
             $oVarsA=get_object_vars($oA);
363 362
             $oVarsB=get_object_vars($oB);
364 363
             $aKeys=array_keys($oVarsA);
365 364
             foreach($aKeys as $sKey)
366 365
             {
367
-                if (in_array($sKey,$fieldstoignorearray)) continue;
366
+                if (in_array($sKey,$fieldstoignorearray)) {
367
+                    continue;
368
+                }
368 369
                 if (! $ignoretype && $oVarsA[$sKey] !== $oVarsB[$sKey])
369 370
                 {
370 371
                     $retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey])?get_class($oVarsA[$sKey]):$oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey])?get_class($oVarsB[$sKey]):$oVarsB[$sKey]);
Please login to merge, or discard this patch.
dolibarr/test/phpunit/CompanyLibTest.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -59,9 +59,9 @@
 block discarded – undo
59 59
      */
60 60
     function __construct()
61 61
     {
62
-    	parent::__construct();
62
+        parent::__construct();
63 63
 
64
-    	//$this->sharedFixture
64
+        //$this->sharedFixture
65 65
         global $conf,$user,$langs,$db;
66 66
         $this->savconf=$conf;
67 67
         $this->savuser=$user;
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  *      \remarks    To run this script as CLI:  phpunit filename.php
24 24
  */
25 25
 
26
-global $conf,$user,$langs,$db;
26
+global $conf, $user, $langs, $db;
27 27
 //define('TEST_DB_FORCE_TYPE','mysql');	// This is to force using mysql driver
28 28
 //require_once 'PHPUnit/Autoload.php';
29 29
 require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
     $user->fetch(1);
35 35
     $user->getrights();
36 36
 }
37
-$conf->global->MAIN_DISABLE_ALL_MAILS=1;
37
+$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
38 38
 
39 39
 
40 40
 /**
@@ -62,11 +62,11 @@  discard block
 block discarded – undo
62 62
     	parent::__construct();
63 63
 
64 64
     	//$this->sharedFixture
65
-        global $conf,$user,$langs,$db;
66
-        $this->savconf=$conf;
67
-        $this->savuser=$user;
68
-        $this->savlangs=$langs;
69
-        $this->savdb=$db;
65
+        global $conf, $user, $langs, $db;
66
+        $this->savconf = $conf;
67
+        $this->savuser = $user;
68
+        $this->savlangs = $langs;
69
+        $this->savdb = $db;
70 70
 
71 71
         print __METHOD__." db->type=".$db->type." user->id=".$user->id;
72 72
         //print " - db ".$db->db;
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     // Static methods
77 77
     public static function setUpBeforeClass()
78 78
     {
79
-        global $conf,$user,$langs,$db;
79
+        global $conf, $user, $langs, $db;
80 80
         $db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
81 81
 
82 82
         print __METHOD__."\n";
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
     // tear down after class
86 86
     public static function tearDownAfterClass()
87 87
     {
88
-        global $conf,$user,$langs,$db;
88
+        global $conf, $user, $langs, $db;
89 89
         $db->rollback();
90 90
 
91 91
         print __METHOD__."\n";
@@ -98,11 +98,11 @@  discard block
 block discarded – undo
98 98
      */
99 99
     protected function setUp()
100 100
     {
101
-        global $conf,$user,$langs,$db;
102
-        $conf=$this->savconf;
103
-        $user=$this->savuser;
104
-        $langs=$this->savlangs;
105
-        $db=$this->savdb;
101
+        global $conf, $user, $langs, $db;
102
+        $conf = $this->savconf;
103
+        $user = $this->savuser;
104
+        $langs = $this->savlangs;
105
+        $db = $this->savdb;
106 106
 
107 107
         print __METHOD__."\n";
108 108
     }
@@ -123,22 +123,22 @@  discard block
 block discarded – undo
123 123
      */
124 124
     public function testNameCurrency()
125 125
     {
126
-        global $conf,$user,$langs,$db;
127
-        $conf=$this->savconf;
128
-        $user=$this->savuser;
129
-        $langs=$this->savlangs;
130
-        $db=$this->savdb;
126
+        global $conf, $user, $langs, $db;
127
+        $conf = $this->savconf;
128
+        $user = $this->savuser;
129
+        $langs = $this->savlangs;
130
+        $db = $this->savdb;
131 131
 
132
-        $result=currency_name('USD');
132
+        $result = currency_name('USD');
133 133
         print __METHOD__." result=".$result."\n";
134
-        $this->assertEquals('US Dollars',$result,'Test to get currency name USD in default language '.$langs->defaultlang);
134
+        $this->assertEquals('US Dollars', $result, 'Test to get currency name USD in default language '.$langs->defaultlang);
135 135
 
136
-        $outputlangs=new Translate('', $conf);
136
+        $outputlangs = new Translate('', $conf);
137 137
         $outputlangs->setDefaultLang('fr_FR');
138 138
 
139
-        $result=currency_name('USD', 1, $outputlangs);
139
+        $result = currency_name('USD', 1, $outputlangs);
140 140
         print __METHOD__." result=".$result."\n";
141
-        $this->assertEquals('USD - Dollars US',$result,'Test to get currency name USD in default language '.$outputlangs->getDefaultLang());
141
+        $this->assertEquals('USD - Dollars US', $result, 'Test to get currency name USD in default language '.$outputlangs->getDefaultLang());
142 142
 
143 143
         return $result;
144 144
     }
Please login to merge, or discard this patch.
dolibarr/test/phpunit/FactureRecTest.php 3 patches
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -32,9 +32,9 @@  discard block
 block discarded – undo
32 32
 
33 33
 if (empty($user->id))
34 34
 {
35
-	print "Load permissions for admin user nb 1\n";
36
-	$user->fetch(1);
37
-	$user->getrights();
35
+    print "Load permissions for admin user nb 1\n";
36
+    $user->fetch(1);
37
+    $user->getrights();
38 38
 }
39 39
 $conf->global->MAIN_DISABLE_ALL_MAILS=1;
40 40
 
@@ -48,75 +48,75 @@  discard block
 block discarded – undo
48 48
  */
49 49
 class FactureRecTest extends PHPUnit_Framework_TestCase
50 50
 {
51
-	protected $savconf;
52
-	protected $savuser;
53
-	protected $savlangs;
54
-	protected $savdb;
55
-
56
-	/**
57
-	 * Constructor
58
-	 * We save global variables into local variables
59
-	 *
60
-	 * @return FactureTest
61
-	 */
62
-	function __construct()
63
-	{
64
-		parent::__construct();
65
-
66
-		//$this->sharedFixture
67
-		global $conf,$user,$langs,$db;
68
-		$this->savconf=$conf;
69
-		$this->savuser=$user;
70
-		$this->savlangs=$langs;
71
-		$this->savdb=$db;
72
-
73
-		print __METHOD__." db->type=".$db->type." user->id=".$user->id;
74
-		//print " - db ".$db->db;
75
-		print "\n";
76
-	}
77
-
78
-	// Static methods
79
-  	public static function setUpBeforeClass()
51
+    protected $savconf;
52
+    protected $savuser;
53
+    protected $savlangs;
54
+    protected $savdb;
55
+
56
+    /**
57
+     * Constructor
58
+     * We save global variables into local variables
59
+     *
60
+     * @return FactureTest
61
+     */
62
+    function __construct()
80 63
     {
81
-    	global $conf,$user,$langs,$db;
82
-		$db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
64
+        parent::__construct();
65
+
66
+        //$this->sharedFixture
67
+        global $conf,$user,$langs,$db;
68
+        $this->savconf=$conf;
69
+        $this->savuser=$user;
70
+        $this->savlangs=$langs;
71
+        $this->savdb=$db;
72
+
73
+        print __METHOD__." db->type=".$db->type." user->id=".$user->id;
74
+        //print " - db ".$db->db;
75
+        print "\n";
76
+    }
77
+
78
+    // Static methods
79
+        public static function setUpBeforeClass()
80
+    {
81
+        global $conf,$user,$langs,$db;
82
+        $db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
83 83
 
84
-    	print __METHOD__."\n";
84
+        print __METHOD__."\n";
85 85
     }
86 86
 
87 87
     // tear down after class
88 88
     public static function tearDownAfterClass()
89 89
     {
90
-    	global $conf,$user,$langs,$db;
91
-		$db->rollback();
90
+        global $conf,$user,$langs,$db;
91
+        $db->rollback();
92 92
 
93
-		print __METHOD__."\n";
93
+        print __METHOD__."\n";
94 94
     }
95 95
 
96
-	/**
97
-	 * Init phpunit tests
98
-	 *
99
-	 * @return	void
100
-	 */
96
+    /**
97
+     * Init phpunit tests
98
+     *
99
+     * @return	void
100
+     */
101 101
     protected function setUp()
102 102
     {
103
-    	global $conf,$user,$langs,$db;
104
-		$conf=$this->savconf;
105
-		$user=$this->savuser;
106
-		$langs=$this->savlangs;
107
-		$db=$this->savdb;
103
+        global $conf,$user,$langs,$db;
104
+        $conf=$this->savconf;
105
+        $user=$this->savuser;
106
+        $langs=$this->savlangs;
107
+        $db=$this->savdb;
108 108
 
109
-		print __METHOD__."\n";
109
+        print __METHOD__."\n";
110 110
     }
111 111
 
112
-	/**
113
-	 * End phpunit tests
114
-	 *
115
-	 * @return	void
116
-	 */
117
-	protected function tearDown()
112
+    /**
113
+     * End phpunit tests
114
+     *
115
+     * @return	void
116
+     */
117
+    protected function tearDown()
118 118
     {
119
-    	print __METHOD__."\n";
119
+        print __METHOD__."\n";
120 120
     }
121 121
 
122 122
     /**
@@ -126,23 +126,23 @@  discard block
 block discarded – undo
126 126
      */
127 127
     public function testFactureRecCreate()
128 128
     {
129
-    	global $conf,$user,$langs,$db;
130
-		$conf=$this->savconf;
131
-		$user=$this->savuser;
132
-		$langs=$this->savlangs;
133
-		$db=$this->savdb;
134
-
135
-		$localobjectinv=new Facture($this->savdb);
136
-		$localobjectinv->initAsSpecimen();
137
-		$localobjectinv->create($user);
138
-
139
-		$localobject=new FactureRec($this->savdb);
140
-    	$localobject->initAsSpecimen();
141
-    	$result=$localobject->create($user, $localobjectinv->id);
142
-
143
-    	$this->assertLessThan($result, 0);
144
-    	print __METHOD__." result=".$result."\n";
145
-    	return $result;
129
+        global $conf,$user,$langs,$db;
130
+        $conf=$this->savconf;
131
+        $user=$this->savuser;
132
+        $langs=$this->savlangs;
133
+        $db=$this->savdb;
134
+
135
+        $localobjectinv=new Facture($this->savdb);
136
+        $localobjectinv->initAsSpecimen();
137
+        $localobjectinv->create($user);
138
+
139
+        $localobject=new FactureRec($this->savdb);
140
+        $localobject->initAsSpecimen();
141
+        $result=$localobject->create($user, $localobjectinv->id);
142
+
143
+        $this->assertLessThan($result, 0);
144
+        print __METHOD__." result=".$result."\n";
145
+        return $result;
146 146
     }
147 147
 
148 148
 
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
      * @param 	Object		$oB						Object operand 2
170 170
      * @param	boolean		$ignoretype				False will not report diff if type of value differs
171 171
      * @param	array		$fieldstoignorearray	Array of fields to ignore in diff
172
-	 * @return	array								Array with differences
172
+     * @return	array								Array with differences
173 173
      */
174 174
     public function objCompare($oA,$oB,$ignoretype=true,$fieldstoignorearray=array('id'))
175 175
     {
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  *		\remarks	To run this script as CLI:  phpunit filename.php
24 24
  */
25 25
 
26
-global $conf,$user,$langs,$db;
26
+global $conf, $user, $langs, $db;
27 27
 //define('TEST_DB_FORCE_TYPE','mysql');	// This is to force using mysql driver
28 28
 //require_once 'PHPUnit/Autoload.php';
29 29
 require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	$user->fetch(1);
37 37
 	$user->getrights();
38 38
 }
39
-$conf->global->MAIN_DISABLE_ALL_MAILS=1;
39
+$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
40 40
 
41 41
 
42 42
 /**
@@ -64,11 +64,11 @@  discard block
 block discarded – undo
64 64
 		parent::__construct();
65 65
 
66 66
 		//$this->sharedFixture
67
-		global $conf,$user,$langs,$db;
68
-		$this->savconf=$conf;
69
-		$this->savuser=$user;
70
-		$this->savlangs=$langs;
71
-		$this->savdb=$db;
67
+		global $conf, $user, $langs, $db;
68
+		$this->savconf = $conf;
69
+		$this->savuser = $user;
70
+		$this->savlangs = $langs;
71
+		$this->savdb = $db;
72 72
 
73 73
 		print __METHOD__." db->type=".$db->type." user->id=".$user->id;
74 74
 		//print " - db ".$db->db;
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
 	// Static methods
79 79
   	public static function setUpBeforeClass()
80 80
     {
81
-    	global $conf,$user,$langs,$db;
82
-		$db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
81
+    	global $conf, $user, $langs, $db;
82
+		$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
83 83
 
84 84
     	print __METHOD__."\n";
85 85
     }
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
     // tear down after class
88 88
     public static function tearDownAfterClass()
89 89
     {
90
-    	global $conf,$user,$langs,$db;
90
+    	global $conf, $user, $langs, $db;
91 91
 		$db->rollback();
92 92
 
93 93
 		print __METHOD__."\n";
@@ -100,11 +100,11 @@  discard block
 block discarded – undo
100 100
 	 */
101 101
     protected function setUp()
102 102
     {
103
-    	global $conf,$user,$langs,$db;
104
-		$conf=$this->savconf;
105
-		$user=$this->savuser;
106
-		$langs=$this->savlangs;
107
-		$db=$this->savdb;
103
+    	global $conf, $user, $langs, $db;
104
+		$conf = $this->savconf;
105
+		$user = $this->savuser;
106
+		$langs = $this->savlangs;
107
+		$db = $this->savdb;
108 108
 
109 109
 		print __METHOD__."\n";
110 110
     }
@@ -126,19 +126,19 @@  discard block
 block discarded – undo
126 126
      */
127 127
     public function testFactureRecCreate()
128 128
     {
129
-    	global $conf,$user,$langs,$db;
130
-		$conf=$this->savconf;
131
-		$user=$this->savuser;
132
-		$langs=$this->savlangs;
133
-		$db=$this->savdb;
129
+    	global $conf, $user, $langs, $db;
130
+		$conf = $this->savconf;
131
+		$user = $this->savuser;
132
+		$langs = $this->savlangs;
133
+		$db = $this->savdb;
134 134
 
135
-		$localobjectinv=new Facture($this->savdb);
135
+		$localobjectinv = new Facture($this->savdb);
136 136
 		$localobjectinv->initAsSpecimen();
137 137
 		$localobjectinv->create($user);
138 138
 
139
-		$localobject=new FactureRec($this->savdb);
139
+		$localobject = new FactureRec($this->savdb);
140 140
     	$localobject->initAsSpecimen();
141
-    	$result=$localobject->create($user, $localobjectinv->id);
141
+    	$result = $localobject->create($user, $localobjectinv->id);
142 142
 
143 143
     	$this->assertLessThan($result, 0);
144 144
     	print __METHOD__." result=".$result."\n";
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
      */
159 159
     public function changeProperties(&$localobject)
160 160
     {
161
-        $localobject->note_private='New note';
161
+        $localobject->note_private = 'New note';
162 162
         //$localobject->note='New note after update';
163 163
     }
164 164
 
@@ -171,29 +171,29 @@  discard block
 block discarded – undo
171 171
      * @param	array		$fieldstoignorearray	Array of fields to ignore in diff
172 172
 	 * @return	array								Array with differences
173 173
      */
174
-    public function objCompare($oA,$oB,$ignoretype=true,$fieldstoignorearray=array('id'))
174
+    public function objCompare($oA, $oB, $ignoretype = true, $fieldstoignorearray = array('id'))
175 175
     {
176
-        $retAr=array();
176
+        $retAr = array();
177 177
 
178 178
         if (get_class($oA) !== get_class($oB))
179 179
         {
180
-            $retAr[]="Supplied objects are not of same class.";
180
+            $retAr[] = "Supplied objects are not of same class.";
181 181
         }
182 182
         else
183 183
         {
184
-            $oVarsA=get_object_vars($oA);
185
-            $oVarsB=get_object_vars($oB);
186
-            $aKeys=array_keys($oVarsA);
187
-            foreach($aKeys as $sKey)
184
+            $oVarsA = get_object_vars($oA);
185
+            $oVarsB = get_object_vars($oB);
186
+            $aKeys = array_keys($oVarsA);
187
+            foreach ($aKeys as $sKey)
188 188
             {
189
-                if (in_array($sKey,$fieldstoignorearray)) continue;
190
-                if (! $ignoretype && $oVarsA[$sKey] !== $oVarsB[$sKey])
189
+                if (in_array($sKey, $fieldstoignorearray)) continue;
190
+                if (!$ignoretype && $oVarsA[$sKey] !== $oVarsB[$sKey])
191 191
                 {
192
-                    $retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey])?get_class($oVarsA[$sKey]):$oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey])?get_class($oVarsB[$sKey]):$oVarsB[$sKey]);
192
+                    $retAr[] = $sKey.' : '.(is_object($oVarsA[$sKey]) ?get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ?get_class($oVarsB[$sKey]) : $oVarsB[$sKey]);
193 193
                 }
194 194
                 if ($ignoretype && $oVarsA[$sKey] != $oVarsB[$sKey])
195 195
                 {
196
-                    $retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey])?get_class($oVarsA[$sKey]):$oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey])?get_class($oVarsB[$sKey]):$oVarsB[$sKey]);
196
+                    $retAr[] = $sKey.' : '.(is_object($oVarsA[$sKey]) ?get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ?get_class($oVarsB[$sKey]) : $oVarsB[$sKey]);
197 197
                 }
198 198
             }
199 199
         }
Please login to merge, or discard this patch.
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -178,15 +178,16 @@
 block discarded – undo
178 178
         if (get_class($oA) !== get_class($oB))
179 179
         {
180 180
             $retAr[]="Supplied objects are not of same class.";
181
-        }
182
-        else
181
+        } else
183 182
         {
184 183
             $oVarsA=get_object_vars($oA);
185 184
             $oVarsB=get_object_vars($oB);
186 185
             $aKeys=array_keys($oVarsA);
187 186
             foreach($aKeys as $sKey)
188 187
             {
189
-                if (in_array($sKey,$fieldstoignorearray)) continue;
188
+                if (in_array($sKey,$fieldstoignorearray)) {
189
+                    continue;
190
+                }
190 191
                 if (! $ignoretype && $oVarsA[$sKey] !== $oVarsB[$sKey])
191 192
                 {
192 193
                     $retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey])?get_class($oVarsA[$sKey]):$oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey])?get_class($oVarsB[$sKey]):$oVarsB[$sKey]);
Please login to merge, or discard this patch.
dolibarr/test/phpunit/CodingSqlTest.php 3 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -72,9 +72,9 @@  discard block
 block discarded – undo
72 72
      */
73 73
     function __construct()
74 74
     {
75
-    	parent::__construct();
75
+        parent::__construct();
76 76
 
77
-    	//$this->sharedFixture
77
+        //$this->sharedFixture
78 78
         global $conf,$user,$langs,$db;
79 79
         $this->savconf=$conf;
80 80
         $this->savuser=$user;
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
                 $result=strpos($filecontent,'"');
166 166
                 if ($result)
167 167
                 {
168
-                	$result=(! strpos($filecontent,'["') && ! strpos($filecontent,'{"'));
168
+                    $result=(! strpos($filecontent,'["') && ! strpos($filecontent,'{"'));
169 169
                 }
170 170
                 print __METHOD__." Result for checking we don't have double quote = ".$result."\n";
171 171
                 $this->assertTrue($result===false, 'Found double quote that is not [" neither {" (used for json content) into '.$file.'. Bad.');
Please login to merge, or discard this patch.
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -23,23 +23,23 @@  discard block
 block discarded – undo
23 23
  *      \remarks    To run this script as CLI:  phpunit filename.php
24 24
  */
25 25
 
26
-global $conf,$user,$langs,$db;
26
+global $conf, $user, $langs, $db;
27 27
 //define('TEST_DB_FORCE_TYPE','mysql');	// This is to force using mysql driver
28 28
 //require_once 'PHPUnit/Autoload.php';
29 29
 require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
30 30
 require_once dirname(__FILE__).'/../../htdocs/core/lib/security.lib.php';
31 31
 require_once dirname(__FILE__).'/../../htdocs/core/lib/security2.lib.php';
32 32
 
33
-if (! defined('NOREQUIREUSER'))  define('NOREQUIREUSER','1');
34
-if (! defined('NOREQUIREDB'))    define('NOREQUIREDB','1');
35
-if (! defined('NOREQUIRESOC'))   define('NOREQUIRESOC','1');
36
-if (! defined('NOREQUIRETRAN'))  define('NOREQUIRETRAN','1');
37
-if (! defined('NOCSRFCHECK'))    define('NOCSRFCHECK','1');
38
-if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1');
39
-if (! defined('NOREQUIREMENU'))  define('NOREQUIREMENU','1'); // If there is no menu to show
40
-if (! defined('NOREQUIREHTML'))  define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php
41
-if (! defined('NOREQUIREAJAX'))  define('NOREQUIREAJAX','1');
42
-if (! defined("NOLOGIN"))        define("NOLOGIN",'1');       // If this page is public (can be called outside logged session)
33
+if (!defined('NOREQUIREUSER'))  define('NOREQUIREUSER', '1');
34
+if (!defined('NOREQUIREDB'))    define('NOREQUIREDB', '1');
35
+if (!defined('NOREQUIRESOC'))   define('NOREQUIRESOC', '1');
36
+if (!defined('NOREQUIRETRAN'))  define('NOREQUIRETRAN', '1');
37
+if (!defined('NOCSRFCHECK'))    define('NOCSRFCHECK', '1');
38
+if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1');
39
+if (!defined('NOREQUIREMENU'))  define('NOREQUIREMENU', '1'); // If there is no menu to show
40
+if (!defined('NOREQUIREHTML'))  define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
41
+if (!defined('NOREQUIREAJAX'))  define('NOREQUIREAJAX', '1');
42
+if (!defined("NOLOGIN"))        define("NOLOGIN", '1'); // If this page is public (can be called outside logged session)
43 43
 
44 44
 if (empty($user->id))
45 45
 {
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
     $user->fetch(1);
48 48
     $user->getrights();
49 49
 }
50
-$conf->global->MAIN_DISABLE_ALL_MAILS=1;
50
+$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
51 51
 
52 52
 
53 53
 /**
@@ -75,11 +75,11 @@  discard block
 block discarded – undo
75 75
     	parent::__construct();
76 76
 
77 77
     	//$this->sharedFixture
78
-        global $conf,$user,$langs,$db;
79
-        $this->savconf=$conf;
80
-        $this->savuser=$user;
81
-        $this->savlangs=$langs;
82
-        $this->savdb=$db;
78
+        global $conf, $user, $langs, $db;
79
+        $this->savconf = $conf;
80
+        $this->savuser = $user;
81
+        $this->savlangs = $langs;
82
+        $this->savdb = $db;
83 83
 
84 84
         print __METHOD__." db->type=".$db->type." user->id=".$user->id;
85 85
         //print " - db ".$db->db;
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
     // Static methods
90 90
     public static function setUpBeforeClass()
91 91
     {
92
-        global $conf,$user,$langs,$db;
92
+        global $conf, $user, $langs, $db;
93 93
         $db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
94 94
 
95 95
         print __METHOD__."\n";
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
     // tear down after class
99 99
     public static function tearDownAfterClass()
100 100
     {
101
-        global $conf,$user,$langs,$db;
101
+        global $conf, $user, $langs, $db;
102 102
         $db->rollback();
103 103
 
104 104
         print __METHOD__."\n";
@@ -111,11 +111,11 @@  discard block
 block discarded – undo
111 111
      */
112 112
     protected function setUp()
113 113
     {
114
-        global $conf,$user,$langs,$db;
115
-        $conf=$this->savconf;
116
-        $user=$this->savuser;
117
-        $langs=$this->savlangs;
118
-        $db=$this->savdb;
114
+        global $conf, $user, $langs, $db;
115
+        $conf = $this->savconf;
116
+        $user = $this->savuser;
117
+        $langs = $this->savlangs;
118
+        $db = $this->savdb;
119 119
 
120 120
         print __METHOD__."\n";
121 121
     }
@@ -137,11 +137,11 @@  discard block
 block discarded – undo
137 137
      */
138 138
     public function testSql()
139 139
     {
140
-        global $conf,$user,$langs,$db;
141
-        $conf=$this->savconf;
142
-        $user=$this->savuser;
143
-        $langs=$this->savlangs;
144
-        $db=$this->savdb;
140
+        global $conf, $user, $langs, $db;
141
+        $conf = $this->savconf;
142
+        $user = $this->savuser;
143
+        $langs = $this->savlangs;
144
+        $db = $this->savdb;
145 145
 
146 146
         $listofsqldir = array(DOL_DOCUMENT_ROOT.'/install/mysql/data', DOL_DOCUMENT_ROOT.'/install/mysql/tables', DOL_DOCUMENT_ROOT.'/install/mysql/migration');
147 147
 
@@ -150,37 +150,37 @@  discard block
 block discarded – undo
150 150
             print 'Process dir '.$dir."\n";
151 151
             $filesarray = scandir($dir);
152 152
 
153
-            foreach($filesarray as $key => $file)
153
+            foreach ($filesarray as $key => $file)
154 154
             {
155
-                if (! preg_match('/\.sql$/',$file))
155
+                if (!preg_match('/\.sql$/', $file))
156 156
                     continue;
157 157
 
158 158
                 print 'Check sql file '.$file."\n";
159
-                $filecontent=file_get_contents($dir.'/'.$file);
159
+                $filecontent = file_get_contents($dir.'/'.$file);
160 160
 
161
-                $result=strpos($filecontent,'`');
161
+                $result = strpos($filecontent, '`');
162 162
                 print __METHOD__." Result for checking we don't have back quote = ".$result."\n";
163
-                $this->assertTrue($result===false, 'Found back quote into '.$file.'. Bad.');
163
+                $this->assertTrue($result === false, 'Found back quote into '.$file.'. Bad.');
164 164
 
165
-                $result=strpos($filecontent,'"');
165
+                $result = strpos($filecontent, '"');
166 166
                 if ($result)
167 167
                 {
168
-                	$result=(! strpos($filecontent,'["') && ! strpos($filecontent,'{"'));
168
+                	$result = (!strpos($filecontent, '["') && !strpos($filecontent, '{"'));
169 169
                 }
170 170
                 print __METHOD__." Result for checking we don't have double quote = ".$result."\n";
171
-                $this->assertTrue($result===false, 'Found double quote that is not [" neither {" (used for json content) into '.$file.'. Bad.');
171
+                $this->assertTrue($result === false, 'Found double quote that is not [" neither {" (used for json content) into '.$file.'. Bad.');
172 172
 
173
-                $result=strpos($filecontent,'int(');
173
+                $result = strpos($filecontent, 'int(');
174 174
                 print __METHOD__." Result for checking we don't have 'int(' instead of 'integer' = ".$result."\n";
175
-                $this->assertTrue($result===false, 'Found int(x) or tinyint(x) instead of integer or tinyint into '.$file.'. Bad.');
175
+                $this->assertTrue($result === false, 'Found int(x) or tinyint(x) instead of integer or tinyint into '.$file.'. Bad.');
176 176
 
177
-                $result=strpos($filecontent,'ON DELETE CASCADE');
177
+                $result = strpos($filecontent, 'ON DELETE CASCADE');
178 178
                 print __METHOD__." Result for checking we don't have 'ON DELETE CASCADE' = ".$result."\n";
179
-                $this->assertTrue($result===false, 'Found ON DELETE CASCADE into '.$file.'. Bad.');
179
+                $this->assertTrue($result === false, 'Found ON DELETE CASCADE into '.$file.'. Bad.');
180 180
 
181
-                $result=strpos($filecontent,'NUMERIC(');
181
+                $result = strpos($filecontent, 'NUMERIC(');
182 182
                 print __METHOD__." Result for checking we don't have 'NUMERIC(' = ".$result."\n";
183
-                $this->assertTrue($result===false, 'Found NUMERIC( into '.$file.'. Bad.');
183
+                $this->assertTrue($result === false, 'Found NUMERIC( into '.$file.'. Bad.');
184 184
 
185 185
                 if ($dir == DOL_DOCUMENT_ROOT.'/install/mysql/migration')
186 186
                 {
@@ -192,18 +192,18 @@  discard block
 block discarded – undo
192 192
                 }
193 193
                 else
194 194
                 {
195
-                    if (preg_match('/\.key\.sql$/',$file))
195
+                    if (preg_match('/\.key\.sql$/', $file))
196 196
                     {
197 197
                         // Test for key files only
198 198
                     }
199 199
                     else
200 200
                     {
201 201
                         // Test for non key files only
202
-                        $result=(strpos($filecontent,'KEY ') && strpos($filecontent,'PRIMARY KEY') == 0);
202
+                        $result = (strpos($filecontent, 'KEY ') && strpos($filecontent, 'PRIMARY KEY') == 0);
203 203
                         print __METHOD__." Result for checking we don't have ' KEY ' instead of a sql file to create index = ".$result."\n";
204
-                        $this->assertTrue($result===false, 'Found KEY into '.$file.'. Bad.');
204
+                        $this->assertTrue($result === false, 'Found KEY into '.$file.'. Bad.');
205 205
 
206
-                        $result=stripos($filecontent,'ENGINE=innodb');
206
+                        $result = stripos($filecontent, 'ENGINE=innodb');
207 207
                         print __METHOD__." Result for checking we have the ENGINE=innodb string = ".$result."\n";
208 208
                         $this->assertGreaterThan(0, $result, 'The ENGINE=innodb was not found into '.$file.'. Add it or just fix syntax to match case.');
209 209
                     }
@@ -221,27 +221,27 @@  discard block
 block discarded – undo
221 221
      */
222 222
     public function testInitData()
223 223
     {
224
-        global $conf,$user,$langs,$db;
225
-        $conf=$this->savconf;
226
-        $user=$this->savuser;
227
-        $langs=$this->savlangs;
228
-        $db=$this->savdb;
224
+        global $conf, $user, $langs, $db;
225
+        $conf = $this->savconf;
226
+        $user = $this->savuser;
227
+        $langs = $this->savlangs;
228
+        $db = $this->savdb;
229 229
 
230 230
         $filesarray = scandir(DOL_DOCUMENT_ROOT.'/../dev/initdata');
231
-        foreach($filesarray as $key => $file) {
232
-            if (! preg_match('/\.sql$/',$file))
231
+        foreach ($filesarray as $key => $file) {
232
+            if (!preg_match('/\.sql$/', $file))
233 233
                 continue;
234 234
 
235 235
             print 'Check sql file '.$file."\n";
236
-            $filecontent=file_get_contents(DOL_DOCUMENT_ROOT.'/../dev/initdata/'.$file);
236
+            $filecontent = file_get_contents(DOL_DOCUMENT_ROOT.'/../dev/initdata/'.$file);
237 237
 
238
-            $result=strpos($filecontent,'@gmail.com');
238
+            $result = strpos($filecontent, '@gmail.com');
239 239
             print __METHOD__." Result for checking we don't have personal data = ".$result."\n";
240
-            $this->assertTrue($result===false, 'Found a bad key into file '.$file);
240
+            $this->assertTrue($result === false, 'Found a bad key into file '.$file);
241 241
 
242
-            $result=strpos($filecontent,'eldy@');
242
+            $result = strpos($filecontent, 'eldy@');
243 243
             print __METHOD__." Result for checking we don't have personal data = ".$result."\n";
244
-            $this->assertTrue($result===false, 'Found a bad key into file '.$file);
244
+            $this->assertTrue($result === false, 'Found a bad key into file '.$file);
245 245
         }
246 246
 
247 247
         return;
Please login to merge, or discard this patch.
Braces   +42 added lines, -20 removed lines patch added patch discarded remove patch
@@ -30,16 +30,39 @@  discard block
 block discarded – undo
30 30
 require_once dirname(__FILE__).'/../../htdocs/core/lib/security.lib.php';
31 31
 require_once dirname(__FILE__).'/../../htdocs/core/lib/security2.lib.php';
32 32
 
33
-if (! defined('NOREQUIREUSER'))  define('NOREQUIREUSER','1');
34
-if (! defined('NOREQUIREDB'))    define('NOREQUIREDB','1');
35
-if (! defined('NOREQUIRESOC'))   define('NOREQUIRESOC','1');
36
-if (! defined('NOREQUIRETRAN'))  define('NOREQUIRETRAN','1');
37
-if (! defined('NOCSRFCHECK'))    define('NOCSRFCHECK','1');
38
-if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1');
39
-if (! defined('NOREQUIREMENU'))  define('NOREQUIREMENU','1'); // If there is no menu to show
40
-if (! defined('NOREQUIREHTML'))  define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php
41
-if (! defined('NOREQUIREAJAX'))  define('NOREQUIREAJAX','1');
42
-if (! defined("NOLOGIN"))        define("NOLOGIN",'1');       // If this page is public (can be called outside logged session)
33
+if (! defined('NOREQUIREUSER')) {
34
+    define('NOREQUIREUSER','1');
35
+}
36
+if (! defined('NOREQUIREDB')) {
37
+    define('NOREQUIREDB','1');
38
+}
39
+if (! defined('NOREQUIRESOC')) {
40
+    define('NOREQUIRESOC','1');
41
+}
42
+if (! defined('NOREQUIRETRAN')) {
43
+    define('NOREQUIRETRAN','1');
44
+}
45
+if (! defined('NOCSRFCHECK')) {
46
+    define('NOCSRFCHECK','1');
47
+}
48
+if (! defined('NOTOKENRENEWAL')) {
49
+    define('NOTOKENRENEWAL','1');
50
+}
51
+if (! defined('NOREQUIREMENU')) {
52
+    define('NOREQUIREMENU','1');
53
+}
54
+// If there is no menu to show
55
+if (! defined('NOREQUIREHTML')) {
56
+    define('NOREQUIREHTML','1');
57
+}
58
+// If we don't need to load the html.form.class.php
59
+if (! defined('NOREQUIREAJAX')) {
60
+    define('NOREQUIREAJAX','1');
61
+}
62
+if (! defined("NOLOGIN")) {
63
+    define("NOLOGIN",'1');
64
+}
65
+// If this page is public (can be called outside logged session)
43 66
 
44 67
 if (empty($user->id))
45 68
 {
@@ -152,8 +175,9 @@  discard block
 block discarded – undo
152 175
 
153 176
             foreach($filesarray as $key => $file)
154 177
             {
155
-                if (! preg_match('/\.sql$/',$file))
156
-                    continue;
178
+                if (! preg_match('/\.sql$/',$file)) {
179
+                                    continue;
180
+                }
157 181
 
158 182
                 print 'Check sql file '.$file."\n";
159 183
                 $filecontent=file_get_contents($dir.'/'.$file);
@@ -185,18 +209,15 @@  discard block
 block discarded – undo
185 209
                 if ($dir == DOL_DOCUMENT_ROOT.'/install/mysql/migration')
186 210
                 {
187 211
                     // Test for migration files only
188
-                }
189
-                elseif ($dir == DOL_DOCUMENT_ROOT.'/install/mysql/data')
212
+                } elseif ($dir == DOL_DOCUMENT_ROOT.'/install/mysql/data')
190 213
                 {
191 214
                     // Test for data files only
192
-                }
193
-                else
215
+                } else
194 216
                 {
195 217
                     if (preg_match('/\.key\.sql$/',$file))
196 218
                     {
197 219
                         // Test for key files only
198
-                    }
199
-                    else
220
+                    } else
200 221
                     {
201 222
                         // Test for non key files only
202 223
                         $result=(strpos($filecontent,'KEY ') && strpos($filecontent,'PRIMARY KEY') == 0);
@@ -229,8 +250,9 @@  discard block
 block discarded – undo
229 250
 
230 251
         $filesarray = scandir(DOL_DOCUMENT_ROOT.'/../dev/initdata');
231 252
         foreach($filesarray as $key => $file) {
232
-            if (! preg_match('/\.sql$/',$file))
233
-                continue;
253
+            if (! preg_match('/\.sql$/',$file)) {
254
+                            continue;
255
+            }
234 256
 
235 257
             print 'Check sql file '.$file."\n";
236 258
             $filecontent=file_get_contents(DOL_DOCUMENT_ROOT.'/../dev/initdata/'.$file);
Please login to merge, or discard this patch.
dolibarr/test/phpunit/CodingPhpTest.php 3 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -72,9 +72,9 @@  discard block
 block discarded – undo
72 72
      */
73 73
     function __construct()
74 74
     {
75
-    	parent::__construct();
75
+        parent::__construct();
76 76
 
77
-    	//$this->sharedFixture
77
+        //$this->sharedFixture
78 78
         global $conf,$user,$langs,$db;
79 79
         $this->savconf=$conf;
80 80
         $this->savuser=$user;
@@ -164,12 +164,12 @@  discard block
 block discarded – undo
164 164
             preg_match_all('/(..)\s*\.\s*\$this->db->idate\(/', $filecontent, $matches, PREG_SET_ORDER);
165 165
             foreach($matches as $key => $val)
166 166
             {
167
-            	if ($val[1] != '\'"' && $val[1] != '\'\'')
168
-            	{
169
-            		$ok=false;
170
-            		break;
171
-            	}
172
-            	//if ($reg[0] != 'db') $ok=false;
167
+                if ($val[1] != '\'"' && $val[1] != '\'\'')
168
+                {
169
+                    $ok=false;
170
+                    break;
171
+                }
172
+                //if ($reg[0] != 'db') $ok=false;
173 173
             }
174 174
             //print __METHOD__." Result for checking we don't have non escaped string in sql requests for file ".$file."\n";
175 175
             $this->assertTrue($ok, 'Found a $this->db->idate to forge a sql request without quotes around this date field '.$file['fullname'].' :: '.$val[0]);
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
             preg_match_all('/(..............)\$_SERVER\[\'QUERY_STRING\'\]/', $filecontent, $matches, PREG_SET_ORDER);
202 202
             foreach($matches as $key => $val)
203 203
             {
204
-            	if ($val[1] != 'scape_htmltag(' && $val[1] != 'ing_nohtmltag(' && $val[1] != 'dol_escape_js(')
204
+                if ($val[1] != 'scape_htmltag(' && $val[1] != 'ing_nohtmltag(' && $val[1] != 'dol_escape_js(')
205 205
                 {
206 206
                     $ok=false;
207 207
                     break;
@@ -217,8 +217,8 @@  discard block
 block discarded – undo
217 217
             preg_match_all('/print_liste_field_titre\(\$langs/', $filecontent, $matches, PREG_SET_ORDER);
218 218
             foreach($matches as $key => $val)
219 219
             {
220
-           		$ok=false;
221
-           		break;
220
+                    $ok=false;
221
+                    break;
222 222
             }
223 223
             $this->assertTrue($ok, 'Found a use of print_liste_field_titre with fist parameter that is a translated value instead of just the translation key in file '.$file['fullname'].'. Bad.');
224 224
 
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
             preg_match_all('/<br \/>/', $filecontent, $matches, PREG_SET_ORDER);
231 231
             foreach($matches as $key => $val)
232 232
             {
233
-            	if ($file['name'] != 'functions.lib.php')
233
+                if ($file['name'] != 'functions.lib.php')
234 234
                 {
235 235
                     $ok=false;
236 236
                     break;
Please login to merge, or discard this patch.
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -23,23 +23,23 @@  discard block
 block discarded – undo
23 23
  *      \remarks    To run this script as CLI:  phpunit filename.php
24 24
  */
25 25
 
26
-global $conf,$user,$langs,$db;
26
+global $conf, $user, $langs, $db;
27 27
 //define('TEST_DB_FORCE_TYPE','mysql');	// This is to force using mysql driver
28 28
 //require_once 'PHPUnit/Autoload.php';
29 29
 require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
30 30
 require_once dirname(__FILE__).'/../../htdocs/core/lib/security.lib.php';
31 31
 require_once dirname(__FILE__).'/../../htdocs/core/lib/security2.lib.php';
32 32
 
33
-if (! defined('NOREQUIREUSER'))  define('NOREQUIREUSER','1');
34
-if (! defined('NOREQUIREDB'))    define('NOREQUIREDB','1');
35
-if (! defined('NOREQUIRESOC'))   define('NOREQUIRESOC','1');
36
-if (! defined('NOREQUIRETRAN'))  define('NOREQUIRETRAN','1');
37
-if (! defined('NOCSRFCHECK'))    define('NOCSRFCHECK','1');
38
-if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1');
39
-if (! defined('NOREQUIREMENU'))  define('NOREQUIREMENU','1'); // If there is no menu to show
40
-if (! defined('NOREQUIREHTML'))  define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php
41
-if (! defined('NOREQUIREAJAX'))  define('NOREQUIREAJAX','1');
42
-if (! defined("NOLOGIN"))        define("NOLOGIN",'1');       // If this page is public (can be called outside logged session)
33
+if (!defined('NOREQUIREUSER'))  define('NOREQUIREUSER', '1');
34
+if (!defined('NOREQUIREDB'))    define('NOREQUIREDB', '1');
35
+if (!defined('NOREQUIRESOC'))   define('NOREQUIRESOC', '1');
36
+if (!defined('NOREQUIRETRAN'))  define('NOREQUIRETRAN', '1');
37
+if (!defined('NOCSRFCHECK'))    define('NOCSRFCHECK', '1');
38
+if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1');
39
+if (!defined('NOREQUIREMENU'))  define('NOREQUIREMENU', '1'); // If there is no menu to show
40
+if (!defined('NOREQUIREHTML'))  define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
41
+if (!defined('NOREQUIREAJAX'))  define('NOREQUIREAJAX', '1');
42
+if (!defined("NOLOGIN"))        define("NOLOGIN", '1'); // If this page is public (can be called outside logged session)
43 43
 
44 44
 if (empty($user->id))
45 45
 {
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
     $user->fetch(1);
48 48
     $user->getrights();
49 49
 }
50
-$conf->global->MAIN_DISABLE_ALL_MAILS=1;
50
+$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
51 51
 
52 52
 
53 53
 /**
@@ -75,11 +75,11 @@  discard block
 block discarded – undo
75 75
     	parent::__construct();
76 76
 
77 77
     	//$this->sharedFixture
78
-        global $conf,$user,$langs,$db;
79
-        $this->savconf=$conf;
80
-        $this->savuser=$user;
81
-        $this->savlangs=$langs;
82
-        $this->savdb=$db;
78
+        global $conf, $user, $langs, $db;
79
+        $this->savconf = $conf;
80
+        $this->savuser = $user;
81
+        $this->savlangs = $langs;
82
+        $this->savdb = $db;
83 83
 
84 84
         print __METHOD__." db->type=".$db->type." user->id=".$user->id;
85 85
         //print " - db ".$db->db;
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
     // Static methods
90 90
     public static function setUpBeforeClass()
91 91
     {
92
-        global $conf,$user,$langs,$db;
92
+        global $conf, $user, $langs, $db;
93 93
         $db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
94 94
 
95 95
         print __METHOD__."\n";
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
     // tear down after class
99 99
     public static function tearDownAfterClass()
100 100
     {
101
-        global $conf,$user,$langs,$db;
101
+        global $conf, $user, $langs, $db;
102 102
         $db->rollback();
103 103
 
104 104
         print __METHOD__."\n";
@@ -111,11 +111,11 @@  discard block
 block discarded – undo
111 111
      */
112 112
     protected function setUp()
113 113
     {
114
-        global $conf,$user,$langs,$db;
115
-        $conf=$this->savconf;
116
-        $user=$this->savuser;
117
-        $langs=$this->savlangs;
118
-        $db=$this->savdb;
114
+        global $conf, $user, $langs, $db;
115
+        $conf = $this->savconf;
116
+        $user = $this->savuser;
117
+        $langs = $this->savlangs;
118
+        $db = $this->savdb;
119 119
 
120 120
         print __METHOD__."\n";
121 121
     }
@@ -137,16 +137,16 @@  discard block
 block discarded – undo
137 137
      */
138 138
     public function testPHP()
139 139
     {
140
-        global $conf,$user,$langs,$db;
141
-        $conf=$this->savconf;
142
-        $user=$this->savuser;
143
-        $langs=$this->savlangs;
144
-        $db=$this->savdb;
140
+        global $conf, $user, $langs, $db;
141
+        $conf = $this->savconf;
142
+        $user = $this->savuser;
143
+        $langs = $this->savlangs;
144
+        $db = $this->savdb;
145 145
 
146 146
         include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
147 147
         $filesarray = dol_dir_list(DOL_DOCUMENT_ROOT, 'files', 1, '\.php', null, 'fullname');
148 148
 
149
-        foreach($filesarray as $key => $file)
149
+        foreach ($filesarray as $key => $file)
150 150
         {
151 151
             if (preg_match('/\/htdocs\/includes\//', $file['fullname'])) continue;
152 152
             if (preg_match('/\/htdocs\/custom\//', $file['fullname'])) continue;
@@ -155,18 +155,18 @@  discard block
 block discarded – undo
155 155
             if (preg_match('/\/htdocs\/teclib/', $file['fullname'])) continue;
156 156
 
157 157
             print 'Check php file '.$file['fullname']."\n";
158
-            $filecontent=file_get_contents($file['fullname']);
158
+            $filecontent = file_get_contents($file['fullname']);
159 159
 
160 160
 
161
-            $ok=true;
162
-            $matches=array();
161
+            $ok = true;
162
+            $matches = array();
163 163
             // Check string   ='".$this->xxx   with xxx that is not 'escape'. It means we forget a db->escape when forging sql request.
164 164
             preg_match_all('/(..)\s*\.\s*\$this->db->idate\(/', $filecontent, $matches, PREG_SET_ORDER);
165
-            foreach($matches as $key => $val)
165
+            foreach ($matches as $key => $val)
166 166
             {
167 167
             	if ($val[1] != '\'"' && $val[1] != '\'\'')
168 168
             	{
169
-            		$ok=false;
169
+            		$ok = false;
170 170
             		break;
171 171
             	}
172 172
             	//if ($reg[0] != 'db') $ok=false;
@@ -176,15 +176,15 @@  discard block
 block discarded – undo
176 176
             //exit;
177 177
 
178 178
 
179
-            $ok=true;
180
-            $matches=array();
179
+            $ok = true;
180
+            $matches = array();
181 181
             // Check string   ='".$this->xxx   with xxx that is not 'escape'. It means we forget a db->escape when forging sql request.
182 182
             preg_match_all('/(=|sql.+)\s*\'"\s*\.\s*\$this->(....)/', $filecontent, $matches, PREG_SET_ORDER);
183
-            foreach($matches as $key => $val)
183
+            foreach ($matches as $key => $val)
184 184
             {
185 185
                 if ($val[2] != 'db->' && $val[2] != 'esca')
186 186
                 {
187
-                    $ok=false;
187
+                    $ok = false;
188 188
                     break;
189 189
                 }
190 190
                 //if ($reg[0] != 'db') $ok=false;
@@ -195,15 +195,15 @@  discard block
 block discarded – undo
195 195
 
196 196
 
197 197
             // Test that output of $_SERVER\[\'QUERY_STRING\'\] is escaped.
198
-            $ok=true;
199
-            $matches=array();
198
+            $ok = true;
199
+            $matches = array();
200 200
             // Check string   ='".$this->xxx   with xxx that is not 'escape'. It means we forget a db->escape when forging sql request.
201 201
             preg_match_all('/(..............)\$_SERVER\[\'QUERY_STRING\'\]/', $filecontent, $matches, PREG_SET_ORDER);
202
-            foreach($matches as $key => $val)
202
+            foreach ($matches as $key => $val)
203 203
             {
204 204
             	if ($val[1] != 'scape_htmltag(' && $val[1] != 'ing_nohtmltag(' && $val[1] != 'dol_escape_js(')
205 205
                 {
206
-                    $ok=false;
206
+                    $ok = false;
207 207
                     break;
208 208
                 }
209 209
             }
@@ -211,28 +211,28 @@  discard block
 block discarded – undo
211 211
 
212 212
 
213 213
             // Test that first param of print_liste_field_titre is a translation key and not the translated value
214
-            $ok=true;
215
-            $matches=array();
214
+            $ok = true;
215
+            $matches = array();
216 216
             // Check string   ='".$this->xxx   with xxx that is not 'escape'. It means we forget a db->escape when forging sql request.
217 217
             preg_match_all('/print_liste_field_titre\(\$langs/', $filecontent, $matches, PREG_SET_ORDER);
218
-            foreach($matches as $key => $val)
218
+            foreach ($matches as $key => $val)
219 219
             {
220
-           		$ok=false;
220
+           		$ok = false;
221 221
            		break;
222 222
             }
223 223
             $this->assertTrue($ok, 'Found a use of print_liste_field_titre with fist parameter that is a translated value instead of just the translation key in file '.$file['fullname'].'. Bad.');
224 224
 
225 225
 
226 226
             // Test we don't have <br />
227
-            $ok=true;
228
-            $matches=array();
227
+            $ok = true;
228
+            $matches = array();
229 229
             // Check string   ='".$this->xxx   with xxx that is not 'escape'. It means we forget a db->escape when forging sql request.
230 230
             preg_match_all('/<br \/>/', $filecontent, $matches, PREG_SET_ORDER);
231
-            foreach($matches as $key => $val)
231
+            foreach ($matches as $key => $val)
232 232
             {
233 233
             	if ($file['name'] != 'functions.lib.php')
234 234
                 {
235
-                    $ok=false;
235
+                    $ok = false;
236 236
                     break;
237 237
                 }
238 238
             }
Please login to merge, or discard this patch.
Braces   +48 added lines, -15 removed lines patch added patch discarded remove patch
@@ -30,16 +30,39 @@  discard block
 block discarded – undo
30 30
 require_once dirname(__FILE__).'/../../htdocs/core/lib/security.lib.php';
31 31
 require_once dirname(__FILE__).'/../../htdocs/core/lib/security2.lib.php';
32 32
 
33
-if (! defined('NOREQUIREUSER'))  define('NOREQUIREUSER','1');
34
-if (! defined('NOREQUIREDB'))    define('NOREQUIREDB','1');
35
-if (! defined('NOREQUIRESOC'))   define('NOREQUIRESOC','1');
36
-if (! defined('NOREQUIRETRAN'))  define('NOREQUIRETRAN','1');
37
-if (! defined('NOCSRFCHECK'))    define('NOCSRFCHECK','1');
38
-if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1');
39
-if (! defined('NOREQUIREMENU'))  define('NOREQUIREMENU','1'); // If there is no menu to show
40
-if (! defined('NOREQUIREHTML'))  define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php
41
-if (! defined('NOREQUIREAJAX'))  define('NOREQUIREAJAX','1');
42
-if (! defined("NOLOGIN"))        define("NOLOGIN",'1');       // If this page is public (can be called outside logged session)
33
+if (! defined('NOREQUIREUSER')) {
34
+    define('NOREQUIREUSER','1');
35
+}
36
+if (! defined('NOREQUIREDB')) {
37
+    define('NOREQUIREDB','1');
38
+}
39
+if (! defined('NOREQUIRESOC')) {
40
+    define('NOREQUIRESOC','1');
41
+}
42
+if (! defined('NOREQUIRETRAN')) {
43
+    define('NOREQUIRETRAN','1');
44
+}
45
+if (! defined('NOCSRFCHECK')) {
46
+    define('NOCSRFCHECK','1');
47
+}
48
+if (! defined('NOTOKENRENEWAL')) {
49
+    define('NOTOKENRENEWAL','1');
50
+}
51
+if (! defined('NOREQUIREMENU')) {
52
+    define('NOREQUIREMENU','1');
53
+}
54
+// If there is no menu to show
55
+if (! defined('NOREQUIREHTML')) {
56
+    define('NOREQUIREHTML','1');
57
+}
58
+// If we don't need to load the html.form.class.php
59
+if (! defined('NOREQUIREAJAX')) {
60
+    define('NOREQUIREAJAX','1');
61
+}
62
+if (! defined("NOLOGIN")) {
63
+    define("NOLOGIN",'1');
64
+}
65
+// If this page is public (can be called outside logged session)
43 66
 
44 67
 if (empty($user->id))
45 68
 {
@@ -148,11 +171,21 @@  discard block
 block discarded – undo
148 171
 
149 172
         foreach($filesarray as $key => $file)
150 173
         {
151
-            if (preg_match('/\/htdocs\/includes\//', $file['fullname'])) continue;
152
-            if (preg_match('/\/htdocs\/custom\//', $file['fullname'])) continue;
153
-            if (preg_match('/\/htdocs\/dolimed/', $file['fullname'])) continue;
154
-            if (preg_match('/\/htdocs\/nltechno/', $file['fullname'])) continue;
155
-            if (preg_match('/\/htdocs\/teclib/', $file['fullname'])) continue;
174
+            if (preg_match('/\/htdocs\/includes\//', $file['fullname'])) {
175
+                continue;
176
+            }
177
+            if (preg_match('/\/htdocs\/custom\//', $file['fullname'])) {
178
+                continue;
179
+            }
180
+            if (preg_match('/\/htdocs\/dolimed/', $file['fullname'])) {
181
+                continue;
182
+            }
183
+            if (preg_match('/\/htdocs\/nltechno/', $file['fullname'])) {
184
+                continue;
185
+            }
186
+            if (preg_match('/\/htdocs\/teclib/', $file['fullname'])) {
187
+                continue;
188
+            }
156 189
 
157 190
             print 'Check php file '.$file['fullname']."\n";
158 191
             $filecontent=file_get_contents($file['fullname']);
Please login to merge, or discard this patch.
dolibarr/test/phpunit/NumberingModulesTest.php 2 patches
Indentation   +505 added lines, -505 removed lines patch added patch discarded remove patch
@@ -30,9 +30,9 @@  discard block
 block discarded – undo
30 30
 
31 31
 if (empty($user->id))
32 32
 {
33
-	print "Load permissions for admin user nb 1\n";
34
-	$user->fetch(1);
35
-	$user->getrights();
33
+    print "Load permissions for admin user nb 1\n";
34
+    $user->fetch(1);
35
+    $user->getrights();
36 36
 }
37 37
 $conf->global->MAIN_DISABLE_ALL_MAILS=1;
38 38
 
@@ -46,76 +46,76 @@  discard block
 block discarded – undo
46 46
  */
47 47
 class NumberingModulesTest extends PHPUnit_Framework_TestCase
48 48
 {
49
-	protected $savconf;
50
-	protected $savuser;
51
-	protected $savlangs;
52
-	protected $savdb;
53
-
54
-	/**
55
-	 * Constructor
56
-	 * We save global variables into local variables
57
-	 *
58
-	 * @return NumberingModulesTest
59
-	 */
60
-	function __construct()
61
-	{
62
-		parent::__construct();
63
-
64
-		//$this->sharedFixture
65
-		global $conf,$user,$langs,$db;
66
-		$this->savconf=$conf;
67
-		$this->savuser=$user;
68
-		$this->savlangs=$langs;
69
-		$this->savdb=$db;
70
-
71
-		print __METHOD__." db->type=".$db->type." user->id=".$user->id;
72
-		//print " - db ".$db->db;
73
-		print "\n";
74
-	}
75
-
76
-	// Static methods
77
-  	public static function setUpBeforeClass()
49
+    protected $savconf;
50
+    protected $savuser;
51
+    protected $savlangs;
52
+    protected $savdb;
53
+
54
+    /**
55
+     * Constructor
56
+     * We save global variables into local variables
57
+     *
58
+     * @return NumberingModulesTest
59
+     */
60
+    function __construct()
61
+    {
62
+        parent::__construct();
63
+
64
+        //$this->sharedFixture
65
+        global $conf,$user,$langs,$db;
66
+        $this->savconf=$conf;
67
+        $this->savuser=$user;
68
+        $this->savlangs=$langs;
69
+        $this->savdb=$db;
70
+
71
+        print __METHOD__." db->type=".$db->type." user->id=".$user->id;
72
+        //print " - db ".$db->db;
73
+        print "\n";
74
+    }
75
+
76
+    // Static methods
77
+        public static function setUpBeforeClass()
78 78
     {
79
-    	global $conf,$user,$langs,$db;
79
+        global $conf,$user,$langs,$db;
80 80
 
81
-    	$db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
81
+        $db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
82 82
 
83
-    	print __METHOD__."\n";
83
+        print __METHOD__."\n";
84 84
     }
85 85
 
86 86
     // tear down after class
87 87
     public static function tearDownAfterClass()
88 88
     {
89
-    	global $conf,$user,$langs,$db;
90
-		$db->rollback();
89
+        global $conf,$user,$langs,$db;
90
+        $db->rollback();
91 91
 
92
-		print __METHOD__."\n";
92
+        print __METHOD__."\n";
93 93
     }
94 94
 
95
-	/**
96
-	 * Init phpunit tests
97
-	 *
98
-	 * @return	void
99
-	 */
95
+    /**
96
+     * Init phpunit tests
97
+     *
98
+     * @return	void
99
+     */
100 100
     protected function setUp()
101 101
     {
102
-    	global $conf,$user,$langs,$db;
103
-		$conf=$this->savconf;
104
-		$user=$this->savuser;
105
-		$langs=$this->savlangs;
106
-		$db=$this->savdb;
102
+        global $conf,$user,$langs,$db;
103
+        $conf=$this->savconf;
104
+        $user=$this->savuser;
105
+        $langs=$this->savlangs;
106
+        $db=$this->savdb;
107 107
 
108
-		print __METHOD__."\n";
108
+        print __METHOD__."\n";
109 109
     }
110 110
 
111
-	/**
112
-	 * End phpunit tests
113
-	 *
114
-	 * @return	void
115
-	 */
116
-	protected function tearDown()
111
+    /**
112
+     * End phpunit tests
113
+     *
114
+     * @return	void
115
+     */
116
+    protected function tearDown()
117 117
     {
118
-    	print __METHOD__."\n";
118
+        print __METHOD__."\n";
119 119
     }
120 120
 
121 121
     /**
@@ -125,454 +125,454 @@  discard block
 block discarded – undo
125 125
      */
126 126
     public function testFactureMercure()
127 127
     {
128
-    	global $conf,$user,$langs,$db,$mysoc;
129
-		$conf=$this->savconf;
130
-		$user=$this->savuser;
131
-		$langs=$this->savlangs;
132
-		$db=$this->savdb;
133
-
134
-		require_once dirname(__FILE__).'/../../htdocs/compta/facture/class/facture.class.php';
135
-		require_once dirname(__FILE__).'/../../htdocs/core/modules/facture/mod_facture_mercure.php';
136
-
137
-		// First we try with a simple mask, with no reset
138
-		// and we test counter is still increase second year.
139
-		$conf->global->FACTURE_ADDON='mercure';
140
-		$conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}-{0000}';
141
-		$conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}-{0000}';
142
-		$conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED=0;
143
-
144
-		$localobject=new Facture($this->savdb);
145
-		$localobject->initAsSpecimen();
146
-		$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1915);	// we use year 1915 to be sure to not have existing invoice for this year
147
-		$numbering=new mod_facture_mercure();
148
-		$result=$numbering->getNextValue($mysoc, $localobject);
149
-		print __METHOD__." result=".$result."\n";
150
-		$this->assertEquals('1915-0001', $result, 'Test for {yyyy}-{0000}, 1st invoice');				// counter must start to 1
151
-		$result2=$localobject->create($user,1);
152
-		print __METHOD__." result2=".$result."\n";
153
-		$result3=$localobject->validate($user, $result);		// create invoice by forcing ref
154
-		print __METHOD__." result3=".$result."\n";
155
-		$this->assertEquals(1, $result3, 'Test validation of invoice with forced ref is ok');	// counter must start to 1
156
-		$result=$localobject->is_erasable();
157
-		print __METHOD__." is_erasable=".$result."\n";
158
-		$this->assertGreaterThanOrEqual(1, $result, 'Test for is_erasable, 1st invoice');						    // Can be deleted
159
-		$localobject2=new Facture($this->savdb);
160
-		$localobject2->initAsSpecimen();
161
-		$localobject2->date=dol_mktime(12, 0, 0, 1, 1, 1916);	// we use following year for second invoice (there is no reset into mask)
162
-		$numbering=new mod_facture_mercure();
163
-		$result=$numbering->getNextValue($mysoc, $localobject2, 'last');
164
-		print __METHOD__." result=".$result."\n";
165
-		$this->assertEquals('1915-0001', $result, "Test to get last value with param 'last'");
166
-		$result=$numbering->getNextValue($mysoc, $localobject2);
167
-		print __METHOD__." result=".$result."\n";
168
-		$this->assertEquals('1916-0002', $result);				// counter must be now 2 (not reseted)
169
-		$result2=$localobject2->create($user,1);
170
-		print __METHOD__." result2=".$result."\n";
171
-		$result3=$localobject2->validate($user, $result);		// create invoice by forcing ref
172
-		print __METHOD__." result3=".$result."\n";
173
-		$this->assertEquals(1, $result3, 'Test validation of invoice with forced ref is ok');	// counter must start to 1
174
-		$result=$localobject2->is_erasable();
175
-		print __METHOD__." is_erasable=".$result."\n";
176
-		$this->assertGreaterThanOrEqual(1, $result);						// Can be deleted
177
-		$result=$localobject->is_erasable();
178
-		print __METHOD__." is_erasable=".$result."\n";
179
-		$this->assertLessThanOrEqual(0, $result, 'Test for {yyyy}-{0000} that is_erasable is 0 for 1st invoice');						// 1 can no more be deleted (2 is more recent)
180
-
181
-		// Now we try with a reset
182
-		$conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}-{0000@1}';
183
-		$conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}-{0000@1}';
184
-
185
-		$localobject=new Facture($this->savdb);
186
-		$localobject->initAsSpecimen();
187
-		$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1910);	// we use year 1910 to be sure to not have existing invoice for this year
188
-		$numbering=new mod_facture_mercure();
189
-		$result=$numbering->getNextValue($mysoc, $localobject);
190
-		$result2=$localobject->create($user,1);
191
-		$result3=$localobject->validate($user, $result);
192
-		print __METHOD__." result=".$result."\n";
193
-		$this->assertEquals('1910-0001', $result, 'Test for {yyyy}-{0000@1} 1st invoice');				// counter must start to 1
194
-		$localobject2=new Facture($this->savdb);
195
-		$localobject2->initAsSpecimen();
196
-		$localobject2->date=dol_mktime(12, 0, 0, 1, 1, 1910);	// we use same year for second invoice (and there is a reset required)
197
-		$numbering=new mod_facture_mercure();
198
-		$result=$numbering->getNextValue($mysoc, $localobject2);
199
-		print __METHOD__." result=".$result."\n";
200
-		$this->assertEquals('1910-0002', $result, 'Test for {yyyy}-{0000@1} 2nd invoice, same day');	// counter must be now 2
201
-		$localobject3=new Facture($this->savdb);
202
-		$localobject3->initAsSpecimen();
203
-		$localobject3->date=dol_mktime(12, 0, 0, 1, 1, 1911);	// we use next year for third invoice (and there is a reset required)
204
-		$numbering=new mod_facture_mercure();
205
-		$result=$numbering->getNextValue($mysoc, $localobject3);
206
-		print __METHOD__." result=".$result."\n";
207
-		$this->assertEquals('1911-0001', $result, 'Test for {yyyy}-{0000@1} 3nd invoice, same day');	// counter must be now 1
208
-
209
-		// Same but we add month after year
210
-		$conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@1}';
211
-		$conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@1}';
212
-		$localobject=new Facture($this->savdb);
213
-		$localobject->initAsSpecimen();
214
-		$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1920);	// we use year 1920 to be sure to not have existing invoice for this year
215
-		$numbering=new mod_facture_mercure();
216
-		$result=$numbering->getNextValue($mysoc, $localobject);
217
-		$result2=$localobject->create($user,1);
218
-		$result3=$localobject->validate($user, $result);
219
-		print __METHOD__." result=".$result."\n";
220
-		$this->assertEquals('192001-0001', $result, 'Test for {yyyy}{mm}-{0000@1} 1st invoice');			// counter must start to 1
221
-		$result=$localobject->is_erasable();
222
-		print __METHOD__." is_erasable=".$result."\n";
223
-		$this->assertGreaterThanOrEqual(1, $result);						// Can be deleted
224
-		$localobject2=new Facture($this->savdb);
225
-		$localobject2->initAsSpecimen();
226
-		$localobject2->date=dol_mktime(12, 0, 0, 1, 1, 1921);	// we use following year for second invoice (and there is a reset required)
227
-		$numbering=new mod_facture_mercure();
228
-		$result=$numbering->getNextValue($mysoc, $localobject2);
229
-		$result2=$localobject2->create($user,1);
230
-		$result3=$localobject2->validate($user, $result);
231
-		print __METHOD__." result=".$result."\n";
232
-    	$this->assertEquals('192101-0001', $result);			// counter must be reseted to 1
233
-    	$result=$localobject2->is_erasable();
234
-    	print __METHOD__." is_erasable=".$result."\n";
235
-    	$this->assertGreaterThanOrEqual(1, $result);						// Can be deleted
236
-    	$result=$localobject->is_erasable();
237
-    	print __METHOD__." is_erasable=".$result."\n";
238
-    	$this->assertGreaterThanOrEqual(1, $result);						// Case 1 can be deleted (because there was a reset for case 2)
239
-
240
-		// Same but we add month before year and use a year on 2 digits
241
-		$conf->global->FACTURE_MERCURE_MASK_CREDIT='[mm}{yy}-{0000@1}';
242
-		$conf->global->FACTURE_MERCURE_MASK_INVOICE='{mm}{yy}-{0000@1}';
243
-		$localobject=new Facture($this->savdb);
244
-		$localobject->initAsSpecimen();
245
-		$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1925);	// we use year 1925 to be sure to not have existing invoice for this year
246
-		$numbering=new mod_facture_mercure();
247
-		$result=$numbering->getNextValue($mysoc, $localobject);
248
-		$result2=$localobject->create($user,1);
249
-		$result3=$localobject->validate($user, $result);
250
-		print __METHOD__." result=".$result."\n";
251
-		$this->assertEquals('0125-0001', $result, 'Test for {mm}{yy}-{0000@1} 1st invoice');				// counter must start to 1
252
-		$result=$localobject->is_erasable();					// This call get getNextNumRef with param 'last'
253
-		print __METHOD__." is_erasable=".$result."\n";
254
-		$this->assertGreaterThanOrEqual(1, $result);						// Can be deleted
255
-		$localobject2=new Facture($this->savdb);
256
-		$localobject2->initAsSpecimen();
257
-		$localobject2->date=dol_mktime(12, 0, 0, 1, 1, 1925);	// we use same year 1925 for second invoice (and there is a reset required)
258
-		$numbering=new mod_facture_mercure();
259
-		$result=$numbering->getNextValue($mysoc, $localobject2);
260
-		$result2=$localobject2->create($user,1);
261
-		$result3=$localobject2->validate($user, $result);
262
-		print __METHOD__." result=".$result."\n";
263
-    	$this->assertEquals('0125-0002', $result, 'Test for {mm}{yy}-{0000@1} 2st invoice');			// counter must be now 2
264
-    	$result=$localobject2->is_erasable();
265
-    	print __METHOD__." is_erasable=".$result."\n";
266
-    	$this->assertGreaterThanOrEqual(1, $result);						// Can be deleted
267
-    	$result=$localobject->is_erasable();
268
-    	print __METHOD__." is_erasable=".$result."\n";
269
-    	$this->assertLessThanOrEqual(0, $result);						// Case 1 can not be deleted (because there is an invoice 2)
270
-		$localobject3=new Facture($this->savdb);
271
-		$localobject3->initAsSpecimen();
272
-		$localobject3->date=dol_mktime(12, 0, 0, 1, 1, 1926);	// we use following year for third invoice (and there is a reset required)
273
-		$numbering=new mod_facture_mercure();
274
-		$result=$numbering->getNextValue($mysoc, $localobject3);
275
-		print __METHOD__." result=".$result."\n";
276
-    	$this->assertEquals('0126-0001', $result, 'Test for {mm}{yy}-{0000@1} 3rd invoice');			// counter must be now 1
277
-
278
-    	// Try an offset when an invoice already exists
279
-    	$conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000+9990}';
280
-    	$conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000+9990}';
281
-    	$result=$numbering->getNextValue($mysoc, $localobject2);
282
-
283
-		// Now we try with a different fiscal month (forced by mask)
284
-    	$conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@6}';
285
-    	$conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@6}';
286
-
287
-    	$localobject=new Facture($this->savdb);
288
-    	$localobject->initAsSpecimen();
289
-    	$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1930);	// we use year 1930 to be sure to not have existing invoice for this year
290
-    	$numbering=new mod_facture_mercure();
291
-    	$result=$numbering->getNextValue($mysoc, $localobject, 'last');
292
-    	print __METHOD__." result for last=".$result."\n";
293
-    	$this->assertEquals('', $result);						// no existing ref into reset range
294
-    	$result=$numbering->getNextValue($mysoc, $localobject);
295
-    	$result2=$localobject->create($user,1);
296
-    	$result3=$localobject->validate($user, $result);
297
-    	print __METHOD__." result=".$result."\n";
298
-    	$this->assertEquals('193001-0001', $result);			// counter must start to 1
299
-    	$result=$numbering->getNextValue($mysoc, $localobject, 'last');
300
-    	print __METHOD__." result for last=".$result."\n";
301
-    	$this->assertEquals('193001-0001', $result);			// last ref into reset range should be same than last created
302
-
303
-    	$localobject=new Facture($this->savdb);
304
-    	$localobject->initAsSpecimen();
305
-    	$localobject->date=dol_mktime(12, 0, 0, 12, 1, 1930);	// we use same year but fiscal month after
306
-    	$numbering=new mod_facture_mercure();
307
-    	$result=$numbering->getNextValue($mysoc, $localobject, 'last');
308
-    	print __METHOD__." result for last=".$result."\n";
309
-    	$this->assertEquals('', $result);						// last ref into reset range should be ''
310
-    	$result=$numbering->getNextValue($mysoc, $localobject);
311
-    	$result2=$localobject->create($user,1);
312
-    	$result3=$localobject->validate($user, $result);
313
-    	print __METHOD__." result=".$result."\n";
314
-    	$this->assertEquals('193012-0001', $result);	// counter must be reset to 1
315
-
316
-    	$localobject=new Facture($this->savdb);
317
-    	$localobject->initAsSpecimen();
318
-    	$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1931);	// we use same fiscal year but different year
319
-    	$numbering=new mod_facture_mercure();
320
-    	$result=$numbering->getNextValue($mysoc, $localobject);
321
-    	$result2=$localobject->create($user,1);
322
-    	$result3=$localobject->validate($user, $result);
323
-    	print __METHOD__." result=".$result."\n";
324
-    	$this->assertEquals('193101-0002', $result);	// counter must be 2
325
-
326
-    	$localobject=new Facture($this->savdb);
327
-    	$localobject->initAsSpecimen();
328
-    	$localobject->date=dol_mktime(12, 0, 0, 12, 1, 1931);	// we use different fiscal year but same year
329
-    	$numbering=new mod_facture_mercure();
330
-    	$result=$numbering->getNextValue($mysoc, $localobject);
331
-    	print __METHOD__." result=".$result."\n";
332
-    	$this->assertEquals('193112-0001', $result);	// counter must be reset to 1
333
-
334
-
335
-    	// Now we try with a different fiscal month (defined by SOCIETE_FISCAL_MONTH_START)
336
-    	$conf->global->SOCIETE_FISCAL_MONTH_START=6;
337
-    	$conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@0}';
338
-    	$conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@0}';
339
-
340
-    	$localobject=new Facture($this->savdb);
341
-    	$localobject->initAsSpecimen();
342
-    	$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1940);	// we use year 1940 to be sure to not have existing invoice for this year
343
-    	$numbering=new mod_facture_mercure();
344
-    	$result=$numbering->getNextValue($mysoc, $localobject);
345
-    	$result2=$localobject->create($user,1);
346
-    	$result3=$localobject->validate($user, $result);
347
-    	print __METHOD__." result=".$result."\n";
348
-    	$this->assertEquals('194001-0001', $result);	// counter must start to 1
349
-
350
-    	$localobject=new Facture($this->savdb);
351
-    	$localobject->initAsSpecimen();
352
-    	$localobject->date=dol_mktime(12, 0, 0, 12, 1, 1940);	// we use same year but fiscal month after
353
-    	$numbering=new mod_facture_mercure();
354
-    	$result=$numbering->getNextValue($mysoc, $localobject);
355
-    	$result2=$localobject->create($user,1);
356
-    	$result3=$localobject->validate($user, $result);
357
-    	print __METHOD__." result=".$result."\n";
358
-    	$this->assertEquals('194012-0001', $result);	// counter must be reset to 1
359
-
360
-    	$localobject=new Facture($this->savdb);
361
-    	$localobject->initAsSpecimen();
362
-    	$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1941);	// we use same fiscal year but different year
363
-    	$numbering=new mod_facture_mercure();
364
-    	$result=$numbering->getNextValue($mysoc, $localobject);
365
-    	$result2=$localobject->create($user,1);
366
-    	$result3=$localobject->validate($user, $result);
367
-    	print __METHOD__." result=".$result."\n";
368
-    	$this->assertEquals('194101-0002', $result);	// counter must be 2
369
-
370
-    	$localobject=new Facture($this->savdb);
371
-    	$localobject->initAsSpecimen();
372
-    	$localobject->date=dol_mktime(12, 0, 0, 12, 1, 1941);	// we use different discal year but same year
373
-    	$numbering=new mod_facture_mercure();
374
-    	$result=$numbering->getNextValue($mysoc, $localobject);
375
-    	print __METHOD__." result=".$result."\n";
376
-    	$this->assertEquals('194112-0001', $result);	// counter must be reset to 1
377
-
378
-
379
-    	// Now we try with a different fiscal month (defined by SOCIETE_FISCAL_MONTH_START) and we always want year of element
380
-    	$conf->global->SOCIETE_FISCAL_MONTH_START=6;
381
-    	$conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@=}';
382
-    	$conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@=}';
383
-
384
-    	$localobject=new Facture($this->savdb);
385
-    	$localobject->initAsSpecimen();
386
-    	$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1950);	// we use year 1950 to be sure to not have existing invoice for this year
387
-    	$numbering=new mod_facture_mercure();
388
-    	$result=$numbering->getNextValue($mysoc, $localobject);
389
-    	$result2=$localobject->create($user,1);
390
-    	$result3=$localobject->validate($user, $result);
391
-    	print __METHOD__." result=".$result."\n";
392
-    	$this->assertEquals('195001-0001', $result);	// counter must start to 1
393
-
394
-    	$localobject=new Facture($this->savdb);
395
-    	$localobject->initAsSpecimen();
396
-    	$localobject->date=dol_mktime(12, 0, 0, 12, 1, 1950);	// we use same year but fiscal month after
397
-    	$numbering=new mod_facture_mercure();
398
-    	$result=$numbering->getNextValue($mysoc, $localobject);
399
-    	$result2=$localobject->create($user,1);
400
-    	$result3=$localobject->validate($user, $result);
401
-    	print __METHOD__." result=".$result."\n";
402
-    	$this->assertEquals('195012-0001', $result);	// counter must be reset to 1
403
-
404
-    	$localobject=new Facture($this->savdb);
405
-    	$localobject->initAsSpecimen();
406
-    	$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1951);	// we use same fiscal year but different year
407
-    	$numbering=new mod_facture_mercure();
408
-    	$result=$numbering->getNextValue($mysoc, $localobject);
409
-    	$result2=$localobject->create($user,1);
410
-    	$result3=$localobject->validate($user, $result);
411
-    	print __METHOD__." result=".$result."\n";
412
-    	$this->assertEquals('195101-0002', $result);	// counter must be 2
413
-
414
-    	$localobject=new Facture($this->savdb);
415
-    	$localobject->initAsSpecimen();
416
-    	$localobject->date=dol_mktime(12, 0, 0, 12, 1, 1951);	// we use different discal year but same year
417
-    	$numbering=new mod_facture_mercure();
418
-    	$result=$numbering->getNextValue($mysoc, $localobject);
419
-    	print __METHOD__." result=".$result."\n";
420
-    	$this->assertEquals('195112-0001', $result);	// counter must be reset to 1
421
-
422
-
423
-    	// Now we try with a different fiscal month (defined by SOCIETE_FISCAL_MONTH_START) and we always want start year
424
-    	$conf->global->SOCIETE_FISCAL_MONTH_START=6;
425
-    	$conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@-}';
426
-    	$conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@-}';
427
-
428
-    	$localobject=new Facture($this->savdb);
429
-    	$localobject->initAsSpecimen();
430
-    	$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1960);	// we use year 1960 to be sure to not have existing invoice for this year
431
-    	$numbering=new mod_facture_mercure();
432
-    	$result=$numbering->getNextValue($mysoc, $localobject);
433
-    	$result2=$localobject->create($user,1);
434
-    	$result3=$localobject->validate($user, $result);
435
-    	print __METHOD__." result=".$result."\n";
436
-    	$this->assertEquals('195901-0001', $result);	// counter must start to 1
437
-
438
-    	$localobject=new Facture($this->savdb);
439
-    	$localobject->initAsSpecimen();
440
-    	$localobject->date=dol_mktime(12, 0, 0, 12, 1, 1960);	// we use same year but fiscal month after
441
-    	$numbering=new mod_facture_mercure();
442
-    	$result=$numbering->getNextValue($mysoc, $localobject);
443
-    	$result2=$localobject->create($user,1);
444
-    	$result3=$localobject->validate($user, $result);
445
-    	print __METHOD__." result=".$result."\n";
446
-    	$this->assertEquals('196012-0001', $result);	// counter must be reset to 1
447
-
448
-    	$localobject=new Facture($this->savdb);
449
-    	$localobject->initAsSpecimen();
450
-    	$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1961);	// we use same fiscal year but different year
451
-    	$numbering=new mod_facture_mercure();
452
-    	$result=$numbering->getNextValue($mysoc, $localobject);
453
-    	$result2=$localobject->create($user,1);
454
-    	$result3=$localobject->validate($user, $result);
455
-    	print __METHOD__." result=".$result."\n";
456
-    	$this->assertEquals('196001-0002', $result);	// counter must be 2
457
-
458
-    	$localobject=new Facture($this->savdb);
459
-    	$localobject->initAsSpecimen();
460
-    	$localobject->date=dol_mktime(12, 0, 0, 12, 1, 1961);	// we use different discal year but same year
461
-    	$numbering=new mod_facture_mercure();
462
-    	$result=$numbering->getNextValue($mysoc, $localobject);
463
-    	print __METHOD__." result=".$result."\n";
464
-    	$this->assertEquals('196112-0001', $result);	// counter must be reset to 1
465
-
466
-
467
-    	// Now we try with a different fiscal month (defined by SOCIETE_FISCAL_MONTH_START) and we always want end year
468
-    	$conf->global->SOCIETE_FISCAL_MONTH_START=6;
469
-    	$conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@+}';
470
-    	$conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@+}';
471
-
472
-    	$localobject=new Facture($this->savdb);
473
-    	$localobject->initAsSpecimen();
474
-    	$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1970);	// we use year 1970 to be sure to not have existing invoice for this year
475
-    	$numbering=new mod_facture_mercure();
476
-    	$result=$numbering->getNextValue($mysoc, $localobject);
477
-    	$result2=$localobject->create($user,1);
478
-    	$result3=$localobject->validate($user, $result);
479
-    	print __METHOD__." result=".$result."\n";
480
-    	$this->assertEquals('197001-0001', $result);	// counter must start to 1
481
-
482
-    	$localobject=new Facture($this->savdb);
483
-    	$localobject->initAsSpecimen();
484
-    	$localobject->date=dol_mktime(12, 0, 0, 12, 1, 1970);	// we use same year but fiscal month after
485
-    	$numbering=new mod_facture_mercure();
486
-    	$result=$numbering->getNextValue($mysoc, $localobject);
487
-    	$result2=$localobject->create($user,1);
488
-    	$result3=$localobject->validate($user, $result);
489
-    	print __METHOD__." result=".$result."\n";
490
-    	$this->assertEquals('197112-0001', $result);	// counter must be reset to 1
491
-
492
-    	$localobject=new Facture($this->savdb);
493
-    	$localobject->initAsSpecimen();
494
-    	$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1971);	// we use same fiscal year but different year
495
-    	$numbering=new mod_facture_mercure();
496
-    	$result=$numbering->getNextValue($mysoc, $localobject);
497
-    	$result2=$localobject->create($user,1);
498
-    	$result3=$localobject->validate($user, $result);
499
-    	print __METHOD__." result=".$result."\n";
500
-    	$this->assertEquals('197101-0002', $result);	// counter must be 2
501
-
502
-    	$localobject=new Facture($this->savdb);
503
-    	$localobject->initAsSpecimen();
504
-    	$localobject->date=dol_mktime(12, 0, 0, 12, 1, 1971);	// we use different fiscal year but same year
505
-    	$numbering=new mod_facture_mercure();
506
-    	$result=$numbering->getNextValue($mysoc, $localobject);
507
-    	print __METHOD__." result=".$result."\n";
508
-    	$this->assertEquals('197212-0001', $result);	// counter must be reset to 1
509
-
510
-    	// Now we try with a reset every month (@99)
511
-    	$conf->global->SOCIETE_FISCAL_MONTH_START=6;
512
-    	$conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@99}';
513
-    	$conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@99}';
514
-
515
-    	$localobject=new Facture($this->savdb);
516
-    	$localobject->initAsSpecimen();
517
-    	$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1980);	// we use year 1980 to be sure to not have existing invoice for this year
518
-    	$numbering=new mod_facture_mercure();
519
-    	$result=$numbering->getNextValue($mysoc, $localobject);
520
-    	$result2=$localobject->create($user,1);
521
-    	$result3=$localobject->validate($user, $result);
522
-    	print __METHOD__." result=".$result."\n";
523
-    	$this->assertEquals('198001-0001', $result);	// counter must start to 1
524
-
525
-    	$localobject=new Facture($this->savdb);
526
-    	$localobject->initAsSpecimen();
527
-    	$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1980);	// we use year 1980 to be sure to not have existing invoice for this year
528
-    	$numbering=new mod_facture_mercure();
529
-    	$result=$numbering->getNextValue($mysoc, $localobject);
530
-    	$result2=$localobject->create($user,1);
531
-    	$result3=$localobject->validate($user, $result);
532
-    	print __METHOD__." result=".$result."\n";
533
-    	$this->assertEquals('198001-0002', $result);	// counter must start to 2
534
-
535
-    	$localobject=new Facture($this->savdb);
536
-    	$localobject->initAsSpecimen();
537
-    	$localobject->date=dol_mktime(12, 0, 0, 2, 1, 1980);	// we use year 1980 to be sure to not have existing invoice for this year
538
-    	$numbering=new mod_facture_mercure();
539
-    	$result=$numbering->getNextValue($mysoc, $localobject);
540
-    	$result2=$localobject->create($user,1);
541
-    	$result3=$localobject->validate($user, $result);
542
-    	print __METHOD__." result=".$result."\n";
543
-    	$this->assertEquals('198002-0001', $result);	// counter must start to 1
544
-
545
-    	$localobject=new Facture($this->savdb);
546
-    	$localobject->initAsSpecimen();
547
-    	$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1981);	// we use year 1981 to be sure to not have existing invoice for this year
548
-    	$numbering=new mod_facture_mercure();
549
-    	$result=$numbering->getNextValue($mysoc, $localobject);
550
-    	$result2=$localobject->create($user,1);
551
-    	$result3=$localobject->validate($user, $result);
552
-    	print __METHOD__." result=".$result."\n";
553
-    	$this->assertEquals('198101-0001', $result);	// counter must start to 1
554
-
555
-    	// Test with {t} tag
556
-    	$conf->global->SOCIETE_FISCAL_MONTH_START=1;
557
-    	$conf->global->FACTURE_MERCURE_MASK_CREDIT='{t}{yyyy}{mm}-{0000}';
558
-    	$conf->global->FACTURE_MERCURE_MASK_INVOICE='{t}{yyyy}{mm}-{0000}';
559
-
560
-    	$tmpthirdparty=new Societe($this->savdb);
561
-    	$tmpthirdparty->initAsSpecimen();
562
-    	$tmpthirdparty->typent_code = 'TE_ABC';
563
-
564
-    	$localobject=new Facture($this->savdb);
565
-    	$localobject->initAsSpecimen();
566
-    	$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1982);	// we use year 1982 to be sure to not have existing invoice for this year
567
-    	$numbering=new mod_facture_mercure();
568
-    	$result=$numbering->getNextValue($tmpthirdparty, $localobject);
569
-    	$result2=$localobject->create($user,1);
570
-    	$result3=$localobject->validate($user, $result);
571
-    	print __METHOD__." result=".$result."\n";
572
-    	$this->assertEquals('A198201-0001', $result);	// counter must start to 1
573
-
574
-
575
-
576
-    	return $result;
128
+        global $conf,$user,$langs,$db,$mysoc;
129
+        $conf=$this->savconf;
130
+        $user=$this->savuser;
131
+        $langs=$this->savlangs;
132
+        $db=$this->savdb;
133
+
134
+        require_once dirname(__FILE__).'/../../htdocs/compta/facture/class/facture.class.php';
135
+        require_once dirname(__FILE__).'/../../htdocs/core/modules/facture/mod_facture_mercure.php';
136
+
137
+        // First we try with a simple mask, with no reset
138
+        // and we test counter is still increase second year.
139
+        $conf->global->FACTURE_ADDON='mercure';
140
+        $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}-{0000}';
141
+        $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}-{0000}';
142
+        $conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED=0;
143
+
144
+        $localobject=new Facture($this->savdb);
145
+        $localobject->initAsSpecimen();
146
+        $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1915);	// we use year 1915 to be sure to not have existing invoice for this year
147
+        $numbering=new mod_facture_mercure();
148
+        $result=$numbering->getNextValue($mysoc, $localobject);
149
+        print __METHOD__." result=".$result."\n";
150
+        $this->assertEquals('1915-0001', $result, 'Test for {yyyy}-{0000}, 1st invoice');				// counter must start to 1
151
+        $result2=$localobject->create($user,1);
152
+        print __METHOD__." result2=".$result."\n";
153
+        $result3=$localobject->validate($user, $result);		// create invoice by forcing ref
154
+        print __METHOD__." result3=".$result."\n";
155
+        $this->assertEquals(1, $result3, 'Test validation of invoice with forced ref is ok');	// counter must start to 1
156
+        $result=$localobject->is_erasable();
157
+        print __METHOD__." is_erasable=".$result."\n";
158
+        $this->assertGreaterThanOrEqual(1, $result, 'Test for is_erasable, 1st invoice');						    // Can be deleted
159
+        $localobject2=new Facture($this->savdb);
160
+        $localobject2->initAsSpecimen();
161
+        $localobject2->date=dol_mktime(12, 0, 0, 1, 1, 1916);	// we use following year for second invoice (there is no reset into mask)
162
+        $numbering=new mod_facture_mercure();
163
+        $result=$numbering->getNextValue($mysoc, $localobject2, 'last');
164
+        print __METHOD__." result=".$result."\n";
165
+        $this->assertEquals('1915-0001', $result, "Test to get last value with param 'last'");
166
+        $result=$numbering->getNextValue($mysoc, $localobject2);
167
+        print __METHOD__." result=".$result."\n";
168
+        $this->assertEquals('1916-0002', $result);				// counter must be now 2 (not reseted)
169
+        $result2=$localobject2->create($user,1);
170
+        print __METHOD__." result2=".$result."\n";
171
+        $result3=$localobject2->validate($user, $result);		// create invoice by forcing ref
172
+        print __METHOD__." result3=".$result."\n";
173
+        $this->assertEquals(1, $result3, 'Test validation of invoice with forced ref is ok');	// counter must start to 1
174
+        $result=$localobject2->is_erasable();
175
+        print __METHOD__." is_erasable=".$result."\n";
176
+        $this->assertGreaterThanOrEqual(1, $result);						// Can be deleted
177
+        $result=$localobject->is_erasable();
178
+        print __METHOD__." is_erasable=".$result."\n";
179
+        $this->assertLessThanOrEqual(0, $result, 'Test for {yyyy}-{0000} that is_erasable is 0 for 1st invoice');						// 1 can no more be deleted (2 is more recent)
180
+
181
+        // Now we try with a reset
182
+        $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}-{0000@1}';
183
+        $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}-{0000@1}';
184
+
185
+        $localobject=new Facture($this->savdb);
186
+        $localobject->initAsSpecimen();
187
+        $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1910);	// we use year 1910 to be sure to not have existing invoice for this year
188
+        $numbering=new mod_facture_mercure();
189
+        $result=$numbering->getNextValue($mysoc, $localobject);
190
+        $result2=$localobject->create($user,1);
191
+        $result3=$localobject->validate($user, $result);
192
+        print __METHOD__." result=".$result."\n";
193
+        $this->assertEquals('1910-0001', $result, 'Test for {yyyy}-{0000@1} 1st invoice');				// counter must start to 1
194
+        $localobject2=new Facture($this->savdb);
195
+        $localobject2->initAsSpecimen();
196
+        $localobject2->date=dol_mktime(12, 0, 0, 1, 1, 1910);	// we use same year for second invoice (and there is a reset required)
197
+        $numbering=new mod_facture_mercure();
198
+        $result=$numbering->getNextValue($mysoc, $localobject2);
199
+        print __METHOD__." result=".$result."\n";
200
+        $this->assertEquals('1910-0002', $result, 'Test for {yyyy}-{0000@1} 2nd invoice, same day');	// counter must be now 2
201
+        $localobject3=new Facture($this->savdb);
202
+        $localobject3->initAsSpecimen();
203
+        $localobject3->date=dol_mktime(12, 0, 0, 1, 1, 1911);	// we use next year for third invoice (and there is a reset required)
204
+        $numbering=new mod_facture_mercure();
205
+        $result=$numbering->getNextValue($mysoc, $localobject3);
206
+        print __METHOD__." result=".$result."\n";
207
+        $this->assertEquals('1911-0001', $result, 'Test for {yyyy}-{0000@1} 3nd invoice, same day');	// counter must be now 1
208
+
209
+        // Same but we add month after year
210
+        $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@1}';
211
+        $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@1}';
212
+        $localobject=new Facture($this->savdb);
213
+        $localobject->initAsSpecimen();
214
+        $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1920);	// we use year 1920 to be sure to not have existing invoice for this year
215
+        $numbering=new mod_facture_mercure();
216
+        $result=$numbering->getNextValue($mysoc, $localobject);
217
+        $result2=$localobject->create($user,1);
218
+        $result3=$localobject->validate($user, $result);
219
+        print __METHOD__." result=".$result."\n";
220
+        $this->assertEquals('192001-0001', $result, 'Test for {yyyy}{mm}-{0000@1} 1st invoice');			// counter must start to 1
221
+        $result=$localobject->is_erasable();
222
+        print __METHOD__." is_erasable=".$result."\n";
223
+        $this->assertGreaterThanOrEqual(1, $result);						// Can be deleted
224
+        $localobject2=new Facture($this->savdb);
225
+        $localobject2->initAsSpecimen();
226
+        $localobject2->date=dol_mktime(12, 0, 0, 1, 1, 1921);	// we use following year for second invoice (and there is a reset required)
227
+        $numbering=new mod_facture_mercure();
228
+        $result=$numbering->getNextValue($mysoc, $localobject2);
229
+        $result2=$localobject2->create($user,1);
230
+        $result3=$localobject2->validate($user, $result);
231
+        print __METHOD__." result=".$result."\n";
232
+        $this->assertEquals('192101-0001', $result);			// counter must be reseted to 1
233
+        $result=$localobject2->is_erasable();
234
+        print __METHOD__." is_erasable=".$result."\n";
235
+        $this->assertGreaterThanOrEqual(1, $result);						// Can be deleted
236
+        $result=$localobject->is_erasable();
237
+        print __METHOD__." is_erasable=".$result."\n";
238
+        $this->assertGreaterThanOrEqual(1, $result);						// Case 1 can be deleted (because there was a reset for case 2)
239
+
240
+        // Same but we add month before year and use a year on 2 digits
241
+        $conf->global->FACTURE_MERCURE_MASK_CREDIT='[mm}{yy}-{0000@1}';
242
+        $conf->global->FACTURE_MERCURE_MASK_INVOICE='{mm}{yy}-{0000@1}';
243
+        $localobject=new Facture($this->savdb);
244
+        $localobject->initAsSpecimen();
245
+        $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1925);	// we use year 1925 to be sure to not have existing invoice for this year
246
+        $numbering=new mod_facture_mercure();
247
+        $result=$numbering->getNextValue($mysoc, $localobject);
248
+        $result2=$localobject->create($user,1);
249
+        $result3=$localobject->validate($user, $result);
250
+        print __METHOD__." result=".$result."\n";
251
+        $this->assertEquals('0125-0001', $result, 'Test for {mm}{yy}-{0000@1} 1st invoice');				// counter must start to 1
252
+        $result=$localobject->is_erasable();					// This call get getNextNumRef with param 'last'
253
+        print __METHOD__." is_erasable=".$result."\n";
254
+        $this->assertGreaterThanOrEqual(1, $result);						// Can be deleted
255
+        $localobject2=new Facture($this->savdb);
256
+        $localobject2->initAsSpecimen();
257
+        $localobject2->date=dol_mktime(12, 0, 0, 1, 1, 1925);	// we use same year 1925 for second invoice (and there is a reset required)
258
+        $numbering=new mod_facture_mercure();
259
+        $result=$numbering->getNextValue($mysoc, $localobject2);
260
+        $result2=$localobject2->create($user,1);
261
+        $result3=$localobject2->validate($user, $result);
262
+        print __METHOD__." result=".$result."\n";
263
+        $this->assertEquals('0125-0002', $result, 'Test for {mm}{yy}-{0000@1} 2st invoice');			// counter must be now 2
264
+        $result=$localobject2->is_erasable();
265
+        print __METHOD__." is_erasable=".$result."\n";
266
+        $this->assertGreaterThanOrEqual(1, $result);						// Can be deleted
267
+        $result=$localobject->is_erasable();
268
+        print __METHOD__." is_erasable=".$result."\n";
269
+        $this->assertLessThanOrEqual(0, $result);						// Case 1 can not be deleted (because there is an invoice 2)
270
+        $localobject3=new Facture($this->savdb);
271
+        $localobject3->initAsSpecimen();
272
+        $localobject3->date=dol_mktime(12, 0, 0, 1, 1, 1926);	// we use following year for third invoice (and there is a reset required)
273
+        $numbering=new mod_facture_mercure();
274
+        $result=$numbering->getNextValue($mysoc, $localobject3);
275
+        print __METHOD__." result=".$result."\n";
276
+        $this->assertEquals('0126-0001', $result, 'Test for {mm}{yy}-{0000@1} 3rd invoice');			// counter must be now 1
277
+
278
+        // Try an offset when an invoice already exists
279
+        $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000+9990}';
280
+        $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000+9990}';
281
+        $result=$numbering->getNextValue($mysoc, $localobject2);
282
+
283
+        // Now we try with a different fiscal month (forced by mask)
284
+        $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@6}';
285
+        $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@6}';
286
+
287
+        $localobject=new Facture($this->savdb);
288
+        $localobject->initAsSpecimen();
289
+        $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1930);	// we use year 1930 to be sure to not have existing invoice for this year
290
+        $numbering=new mod_facture_mercure();
291
+        $result=$numbering->getNextValue($mysoc, $localobject, 'last');
292
+        print __METHOD__." result for last=".$result."\n";
293
+        $this->assertEquals('', $result);						// no existing ref into reset range
294
+        $result=$numbering->getNextValue($mysoc, $localobject);
295
+        $result2=$localobject->create($user,1);
296
+        $result3=$localobject->validate($user, $result);
297
+        print __METHOD__." result=".$result."\n";
298
+        $this->assertEquals('193001-0001', $result);			// counter must start to 1
299
+        $result=$numbering->getNextValue($mysoc, $localobject, 'last');
300
+        print __METHOD__." result for last=".$result."\n";
301
+        $this->assertEquals('193001-0001', $result);			// last ref into reset range should be same than last created
302
+
303
+        $localobject=new Facture($this->savdb);
304
+        $localobject->initAsSpecimen();
305
+        $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1930);	// we use same year but fiscal month after
306
+        $numbering=new mod_facture_mercure();
307
+        $result=$numbering->getNextValue($mysoc, $localobject, 'last');
308
+        print __METHOD__." result for last=".$result."\n";
309
+        $this->assertEquals('', $result);						// last ref into reset range should be ''
310
+        $result=$numbering->getNextValue($mysoc, $localobject);
311
+        $result2=$localobject->create($user,1);
312
+        $result3=$localobject->validate($user, $result);
313
+        print __METHOD__." result=".$result."\n";
314
+        $this->assertEquals('193012-0001', $result);	// counter must be reset to 1
315
+
316
+        $localobject=new Facture($this->savdb);
317
+        $localobject->initAsSpecimen();
318
+        $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1931);	// we use same fiscal year but different year
319
+        $numbering=new mod_facture_mercure();
320
+        $result=$numbering->getNextValue($mysoc, $localobject);
321
+        $result2=$localobject->create($user,1);
322
+        $result3=$localobject->validate($user, $result);
323
+        print __METHOD__." result=".$result."\n";
324
+        $this->assertEquals('193101-0002', $result);	// counter must be 2
325
+
326
+        $localobject=new Facture($this->savdb);
327
+        $localobject->initAsSpecimen();
328
+        $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1931);	// we use different fiscal year but same year
329
+        $numbering=new mod_facture_mercure();
330
+        $result=$numbering->getNextValue($mysoc, $localobject);
331
+        print __METHOD__." result=".$result."\n";
332
+        $this->assertEquals('193112-0001', $result);	// counter must be reset to 1
333
+
334
+
335
+        // Now we try with a different fiscal month (defined by SOCIETE_FISCAL_MONTH_START)
336
+        $conf->global->SOCIETE_FISCAL_MONTH_START=6;
337
+        $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@0}';
338
+        $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@0}';
339
+
340
+        $localobject=new Facture($this->savdb);
341
+        $localobject->initAsSpecimen();
342
+        $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1940);	// we use year 1940 to be sure to not have existing invoice for this year
343
+        $numbering=new mod_facture_mercure();
344
+        $result=$numbering->getNextValue($mysoc, $localobject);
345
+        $result2=$localobject->create($user,1);
346
+        $result3=$localobject->validate($user, $result);
347
+        print __METHOD__." result=".$result."\n";
348
+        $this->assertEquals('194001-0001', $result);	// counter must start to 1
349
+
350
+        $localobject=new Facture($this->savdb);
351
+        $localobject->initAsSpecimen();
352
+        $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1940);	// we use same year but fiscal month after
353
+        $numbering=new mod_facture_mercure();
354
+        $result=$numbering->getNextValue($mysoc, $localobject);
355
+        $result2=$localobject->create($user,1);
356
+        $result3=$localobject->validate($user, $result);
357
+        print __METHOD__." result=".$result."\n";
358
+        $this->assertEquals('194012-0001', $result);	// counter must be reset to 1
359
+
360
+        $localobject=new Facture($this->savdb);
361
+        $localobject->initAsSpecimen();
362
+        $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1941);	// we use same fiscal year but different year
363
+        $numbering=new mod_facture_mercure();
364
+        $result=$numbering->getNextValue($mysoc, $localobject);
365
+        $result2=$localobject->create($user,1);
366
+        $result3=$localobject->validate($user, $result);
367
+        print __METHOD__." result=".$result."\n";
368
+        $this->assertEquals('194101-0002', $result);	// counter must be 2
369
+
370
+        $localobject=new Facture($this->savdb);
371
+        $localobject->initAsSpecimen();
372
+        $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1941);	// we use different discal year but same year
373
+        $numbering=new mod_facture_mercure();
374
+        $result=$numbering->getNextValue($mysoc, $localobject);
375
+        print __METHOD__." result=".$result."\n";
376
+        $this->assertEquals('194112-0001', $result);	// counter must be reset to 1
377
+
378
+
379
+        // Now we try with a different fiscal month (defined by SOCIETE_FISCAL_MONTH_START) and we always want year of element
380
+        $conf->global->SOCIETE_FISCAL_MONTH_START=6;
381
+        $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@=}';
382
+        $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@=}';
383
+
384
+        $localobject=new Facture($this->savdb);
385
+        $localobject->initAsSpecimen();
386
+        $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1950);	// we use year 1950 to be sure to not have existing invoice for this year
387
+        $numbering=new mod_facture_mercure();
388
+        $result=$numbering->getNextValue($mysoc, $localobject);
389
+        $result2=$localobject->create($user,1);
390
+        $result3=$localobject->validate($user, $result);
391
+        print __METHOD__." result=".$result."\n";
392
+        $this->assertEquals('195001-0001', $result);	// counter must start to 1
393
+
394
+        $localobject=new Facture($this->savdb);
395
+        $localobject->initAsSpecimen();
396
+        $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1950);	// we use same year but fiscal month after
397
+        $numbering=new mod_facture_mercure();
398
+        $result=$numbering->getNextValue($mysoc, $localobject);
399
+        $result2=$localobject->create($user,1);
400
+        $result3=$localobject->validate($user, $result);
401
+        print __METHOD__." result=".$result."\n";
402
+        $this->assertEquals('195012-0001', $result);	// counter must be reset to 1
403
+
404
+        $localobject=new Facture($this->savdb);
405
+        $localobject->initAsSpecimen();
406
+        $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1951);	// we use same fiscal year but different year
407
+        $numbering=new mod_facture_mercure();
408
+        $result=$numbering->getNextValue($mysoc, $localobject);
409
+        $result2=$localobject->create($user,1);
410
+        $result3=$localobject->validate($user, $result);
411
+        print __METHOD__." result=".$result."\n";
412
+        $this->assertEquals('195101-0002', $result);	// counter must be 2
413
+
414
+        $localobject=new Facture($this->savdb);
415
+        $localobject->initAsSpecimen();
416
+        $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1951);	// we use different discal year but same year
417
+        $numbering=new mod_facture_mercure();
418
+        $result=$numbering->getNextValue($mysoc, $localobject);
419
+        print __METHOD__." result=".$result."\n";
420
+        $this->assertEquals('195112-0001', $result);	// counter must be reset to 1
421
+
422
+
423
+        // Now we try with a different fiscal month (defined by SOCIETE_FISCAL_MONTH_START) and we always want start year
424
+        $conf->global->SOCIETE_FISCAL_MONTH_START=6;
425
+        $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@-}';
426
+        $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@-}';
427
+
428
+        $localobject=new Facture($this->savdb);
429
+        $localobject->initAsSpecimen();
430
+        $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1960);	// we use year 1960 to be sure to not have existing invoice for this year
431
+        $numbering=new mod_facture_mercure();
432
+        $result=$numbering->getNextValue($mysoc, $localobject);
433
+        $result2=$localobject->create($user,1);
434
+        $result3=$localobject->validate($user, $result);
435
+        print __METHOD__." result=".$result."\n";
436
+        $this->assertEquals('195901-0001', $result);	// counter must start to 1
437
+
438
+        $localobject=new Facture($this->savdb);
439
+        $localobject->initAsSpecimen();
440
+        $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1960);	// we use same year but fiscal month after
441
+        $numbering=new mod_facture_mercure();
442
+        $result=$numbering->getNextValue($mysoc, $localobject);
443
+        $result2=$localobject->create($user,1);
444
+        $result3=$localobject->validate($user, $result);
445
+        print __METHOD__." result=".$result."\n";
446
+        $this->assertEquals('196012-0001', $result);	// counter must be reset to 1
447
+
448
+        $localobject=new Facture($this->savdb);
449
+        $localobject->initAsSpecimen();
450
+        $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1961);	// we use same fiscal year but different year
451
+        $numbering=new mod_facture_mercure();
452
+        $result=$numbering->getNextValue($mysoc, $localobject);
453
+        $result2=$localobject->create($user,1);
454
+        $result3=$localobject->validate($user, $result);
455
+        print __METHOD__." result=".$result."\n";
456
+        $this->assertEquals('196001-0002', $result);	// counter must be 2
457
+
458
+        $localobject=new Facture($this->savdb);
459
+        $localobject->initAsSpecimen();
460
+        $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1961);	// we use different discal year but same year
461
+        $numbering=new mod_facture_mercure();
462
+        $result=$numbering->getNextValue($mysoc, $localobject);
463
+        print __METHOD__." result=".$result."\n";
464
+        $this->assertEquals('196112-0001', $result);	// counter must be reset to 1
465
+
466
+
467
+        // Now we try with a different fiscal month (defined by SOCIETE_FISCAL_MONTH_START) and we always want end year
468
+        $conf->global->SOCIETE_FISCAL_MONTH_START=6;
469
+        $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@+}';
470
+        $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@+}';
471
+
472
+        $localobject=new Facture($this->savdb);
473
+        $localobject->initAsSpecimen();
474
+        $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1970);	// we use year 1970 to be sure to not have existing invoice for this year
475
+        $numbering=new mod_facture_mercure();
476
+        $result=$numbering->getNextValue($mysoc, $localobject);
477
+        $result2=$localobject->create($user,1);
478
+        $result3=$localobject->validate($user, $result);
479
+        print __METHOD__." result=".$result."\n";
480
+        $this->assertEquals('197001-0001', $result);	// counter must start to 1
481
+
482
+        $localobject=new Facture($this->savdb);
483
+        $localobject->initAsSpecimen();
484
+        $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1970);	// we use same year but fiscal month after
485
+        $numbering=new mod_facture_mercure();
486
+        $result=$numbering->getNextValue($mysoc, $localobject);
487
+        $result2=$localobject->create($user,1);
488
+        $result3=$localobject->validate($user, $result);
489
+        print __METHOD__." result=".$result."\n";
490
+        $this->assertEquals('197112-0001', $result);	// counter must be reset to 1
491
+
492
+        $localobject=new Facture($this->savdb);
493
+        $localobject->initAsSpecimen();
494
+        $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1971);	// we use same fiscal year but different year
495
+        $numbering=new mod_facture_mercure();
496
+        $result=$numbering->getNextValue($mysoc, $localobject);
497
+        $result2=$localobject->create($user,1);
498
+        $result3=$localobject->validate($user, $result);
499
+        print __METHOD__." result=".$result."\n";
500
+        $this->assertEquals('197101-0002', $result);	// counter must be 2
501
+
502
+        $localobject=new Facture($this->savdb);
503
+        $localobject->initAsSpecimen();
504
+        $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1971);	// we use different fiscal year but same year
505
+        $numbering=new mod_facture_mercure();
506
+        $result=$numbering->getNextValue($mysoc, $localobject);
507
+        print __METHOD__." result=".$result."\n";
508
+        $this->assertEquals('197212-0001', $result);	// counter must be reset to 1
509
+
510
+        // Now we try with a reset every month (@99)
511
+        $conf->global->SOCIETE_FISCAL_MONTH_START=6;
512
+        $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@99}';
513
+        $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@99}';
514
+
515
+        $localobject=new Facture($this->savdb);
516
+        $localobject->initAsSpecimen();
517
+        $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1980);	// we use year 1980 to be sure to not have existing invoice for this year
518
+        $numbering=new mod_facture_mercure();
519
+        $result=$numbering->getNextValue($mysoc, $localobject);
520
+        $result2=$localobject->create($user,1);
521
+        $result3=$localobject->validate($user, $result);
522
+        print __METHOD__." result=".$result."\n";
523
+        $this->assertEquals('198001-0001', $result);	// counter must start to 1
524
+
525
+        $localobject=new Facture($this->savdb);
526
+        $localobject->initAsSpecimen();
527
+        $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1980);	// we use year 1980 to be sure to not have existing invoice for this year
528
+        $numbering=new mod_facture_mercure();
529
+        $result=$numbering->getNextValue($mysoc, $localobject);
530
+        $result2=$localobject->create($user,1);
531
+        $result3=$localobject->validate($user, $result);
532
+        print __METHOD__." result=".$result."\n";
533
+        $this->assertEquals('198001-0002', $result);	// counter must start to 2
534
+
535
+        $localobject=new Facture($this->savdb);
536
+        $localobject->initAsSpecimen();
537
+        $localobject->date=dol_mktime(12, 0, 0, 2, 1, 1980);	// we use year 1980 to be sure to not have existing invoice for this year
538
+        $numbering=new mod_facture_mercure();
539
+        $result=$numbering->getNextValue($mysoc, $localobject);
540
+        $result2=$localobject->create($user,1);
541
+        $result3=$localobject->validate($user, $result);
542
+        print __METHOD__." result=".$result."\n";
543
+        $this->assertEquals('198002-0001', $result);	// counter must start to 1
544
+
545
+        $localobject=new Facture($this->savdb);
546
+        $localobject->initAsSpecimen();
547
+        $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1981);	// we use year 1981 to be sure to not have existing invoice for this year
548
+        $numbering=new mod_facture_mercure();
549
+        $result=$numbering->getNextValue($mysoc, $localobject);
550
+        $result2=$localobject->create($user,1);
551
+        $result3=$localobject->validate($user, $result);
552
+        print __METHOD__." result=".$result."\n";
553
+        $this->assertEquals('198101-0001', $result);	// counter must start to 1
554
+
555
+        // Test with {t} tag
556
+        $conf->global->SOCIETE_FISCAL_MONTH_START=1;
557
+        $conf->global->FACTURE_MERCURE_MASK_CREDIT='{t}{yyyy}{mm}-{0000}';
558
+        $conf->global->FACTURE_MERCURE_MASK_INVOICE='{t}{yyyy}{mm}-{0000}';
559
+
560
+        $tmpthirdparty=new Societe($this->savdb);
561
+        $tmpthirdparty->initAsSpecimen();
562
+        $tmpthirdparty->typent_code = 'TE_ABC';
563
+
564
+        $localobject=new Facture($this->savdb);
565
+        $localobject->initAsSpecimen();
566
+        $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1982);	// we use year 1982 to be sure to not have existing invoice for this year
567
+        $numbering=new mod_facture_mercure();
568
+        $result=$numbering->getNextValue($tmpthirdparty, $localobject);
569
+        $result2=$localobject->create($user,1);
570
+        $result3=$localobject->validate($user, $result);
571
+        print __METHOD__." result=".$result."\n";
572
+        $this->assertEquals('A198201-0001', $result);	// counter must start to 1
573
+
574
+
575
+
576
+        return $result;
577 577
     }
578 578
 }
Please login to merge, or discard this patch.
Spacing   +310 added lines, -310 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  *		\remarks	To run this script as CLI:  phpunit filename.php
24 24
  */
25 25
 
26
-global $conf,$user,$langs,$db;
26
+global $conf, $user, $langs, $db;
27 27
 //define('TEST_DB_FORCE_TYPE','mysql');	// This is to force using mysql driver
28 28
 //require_once 'PHPUnit/Autoload.php';
29 29
 require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	$user->fetch(1);
35 35
 	$user->getrights();
36 36
 }
37
-$conf->global->MAIN_DISABLE_ALL_MAILS=1;
37
+$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
38 38
 
39 39
 
40 40
 /**
@@ -62,11 +62,11 @@  discard block
 block discarded – undo
62 62
 		parent::__construct();
63 63
 
64 64
 		//$this->sharedFixture
65
-		global $conf,$user,$langs,$db;
66
-		$this->savconf=$conf;
67
-		$this->savuser=$user;
68
-		$this->savlangs=$langs;
69
-		$this->savdb=$db;
65
+		global $conf, $user, $langs, $db;
66
+		$this->savconf = $conf;
67
+		$this->savuser = $user;
68
+		$this->savlangs = $langs;
69
+		$this->savdb = $db;
70 70
 
71 71
 		print __METHOD__." db->type=".$db->type." user->id=".$user->id;
72 72
 		//print " - db ".$db->db;
@@ -76,9 +76,9 @@  discard block
 block discarded – undo
76 76
 	// Static methods
77 77
   	public static function setUpBeforeClass()
78 78
     {
79
-    	global $conf,$user,$langs,$db;
79
+    	global $conf, $user, $langs, $db;
80 80
 
81
-    	$db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
81
+    	$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
82 82
 
83 83
     	print __METHOD__."\n";
84 84
     }
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
     // tear down after class
87 87
     public static function tearDownAfterClass()
88 88
     {
89
-    	global $conf,$user,$langs,$db;
89
+    	global $conf, $user, $langs, $db;
90 90
 		$db->rollback();
91 91
 
92 92
 		print __METHOD__."\n";
@@ -99,11 +99,11 @@  discard block
 block discarded – undo
99 99
 	 */
100 100
     protected function setUp()
101 101
     {
102
-    	global $conf,$user,$langs,$db;
103
-		$conf=$this->savconf;
104
-		$user=$this->savuser;
105
-		$langs=$this->savlangs;
106
-		$db=$this->savdb;
102
+    	global $conf, $user, $langs, $db;
103
+		$conf = $this->savconf;
104
+		$user = $this->savuser;
105
+		$langs = $this->savlangs;
106
+		$db = $this->savdb;
107 107
 
108 108
 		print __METHOD__."\n";
109 109
     }
@@ -125,451 +125,451 @@  discard block
 block discarded – undo
125 125
      */
126 126
     public function testFactureMercure()
127 127
     {
128
-    	global $conf,$user,$langs,$db,$mysoc;
129
-		$conf=$this->savconf;
130
-		$user=$this->savuser;
131
-		$langs=$this->savlangs;
132
-		$db=$this->savdb;
128
+    	global $conf, $user, $langs, $db, $mysoc;
129
+		$conf = $this->savconf;
130
+		$user = $this->savuser;
131
+		$langs = $this->savlangs;
132
+		$db = $this->savdb;
133 133
 
134 134
 		require_once dirname(__FILE__).'/../../htdocs/compta/facture/class/facture.class.php';
135 135
 		require_once dirname(__FILE__).'/../../htdocs/core/modules/facture/mod_facture_mercure.php';
136 136
 
137 137
 		// First we try with a simple mask, with no reset
138 138
 		// and we test counter is still increase second year.
139
-		$conf->global->FACTURE_ADDON='mercure';
140
-		$conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}-{0000}';
141
-		$conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}-{0000}';
142
-		$conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED=0;
139
+		$conf->global->FACTURE_ADDON = 'mercure';
140
+		$conf->global->FACTURE_MERCURE_MASK_CREDIT = '{yyyy}-{0000}';
141
+		$conf->global->FACTURE_MERCURE_MASK_INVOICE = '{yyyy}-{0000}';
142
+		$conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED = 0;
143 143
 
144
-		$localobject=new Facture($this->savdb);
144
+		$localobject = new Facture($this->savdb);
145 145
 		$localobject->initAsSpecimen();
146
-		$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1915);	// we use year 1915 to be sure to not have existing invoice for this year
147
-		$numbering=new mod_facture_mercure();
148
-		$result=$numbering->getNextValue($mysoc, $localobject);
146
+		$localobject->date = dol_mktime(12, 0, 0, 1, 1, 1915); // we use year 1915 to be sure to not have existing invoice for this year
147
+		$numbering = new mod_facture_mercure();
148
+		$result = $numbering->getNextValue($mysoc, $localobject);
149 149
 		print __METHOD__." result=".$result."\n";
150
-		$this->assertEquals('1915-0001', $result, 'Test for {yyyy}-{0000}, 1st invoice');				// counter must start to 1
151
-		$result2=$localobject->create($user,1);
150
+		$this->assertEquals('1915-0001', $result, 'Test for {yyyy}-{0000}, 1st invoice'); // counter must start to 1
151
+		$result2 = $localobject->create($user, 1);
152 152
 		print __METHOD__." result2=".$result."\n";
153
-		$result3=$localobject->validate($user, $result);		// create invoice by forcing ref
153
+		$result3 = $localobject->validate($user, $result); // create invoice by forcing ref
154 154
 		print __METHOD__." result3=".$result."\n";
155
-		$this->assertEquals(1, $result3, 'Test validation of invoice with forced ref is ok');	// counter must start to 1
156
-		$result=$localobject->is_erasable();
155
+		$this->assertEquals(1, $result3, 'Test validation of invoice with forced ref is ok'); // counter must start to 1
156
+		$result = $localobject->is_erasable();
157 157
 		print __METHOD__." is_erasable=".$result."\n";
158
-		$this->assertGreaterThanOrEqual(1, $result, 'Test for is_erasable, 1st invoice');						    // Can be deleted
159
-		$localobject2=new Facture($this->savdb);
158
+		$this->assertGreaterThanOrEqual(1, $result, 'Test for is_erasable, 1st invoice'); // Can be deleted
159
+		$localobject2 = new Facture($this->savdb);
160 160
 		$localobject2->initAsSpecimen();
161
-		$localobject2->date=dol_mktime(12, 0, 0, 1, 1, 1916);	// we use following year for second invoice (there is no reset into mask)
162
-		$numbering=new mod_facture_mercure();
163
-		$result=$numbering->getNextValue($mysoc, $localobject2, 'last');
161
+		$localobject2->date = dol_mktime(12, 0, 0, 1, 1, 1916); // we use following year for second invoice (there is no reset into mask)
162
+		$numbering = new mod_facture_mercure();
163
+		$result = $numbering->getNextValue($mysoc, $localobject2, 'last');
164 164
 		print __METHOD__." result=".$result."\n";
165 165
 		$this->assertEquals('1915-0001', $result, "Test to get last value with param 'last'");
166
-		$result=$numbering->getNextValue($mysoc, $localobject2);
166
+		$result = $numbering->getNextValue($mysoc, $localobject2);
167 167
 		print __METHOD__." result=".$result."\n";
168
-		$this->assertEquals('1916-0002', $result);				// counter must be now 2 (not reseted)
169
-		$result2=$localobject2->create($user,1);
168
+		$this->assertEquals('1916-0002', $result); // counter must be now 2 (not reseted)
169
+		$result2 = $localobject2->create($user, 1);
170 170
 		print __METHOD__." result2=".$result."\n";
171
-		$result3=$localobject2->validate($user, $result);		// create invoice by forcing ref
171
+		$result3 = $localobject2->validate($user, $result); // create invoice by forcing ref
172 172
 		print __METHOD__." result3=".$result."\n";
173
-		$this->assertEquals(1, $result3, 'Test validation of invoice with forced ref is ok');	// counter must start to 1
174
-		$result=$localobject2->is_erasable();
173
+		$this->assertEquals(1, $result3, 'Test validation of invoice with forced ref is ok'); // counter must start to 1
174
+		$result = $localobject2->is_erasable();
175 175
 		print __METHOD__." is_erasable=".$result."\n";
176
-		$this->assertGreaterThanOrEqual(1, $result);						// Can be deleted
177
-		$result=$localobject->is_erasable();
176
+		$this->assertGreaterThanOrEqual(1, $result); // Can be deleted
177
+		$result = $localobject->is_erasable();
178 178
 		print __METHOD__." is_erasable=".$result."\n";
179
-		$this->assertLessThanOrEqual(0, $result, 'Test for {yyyy}-{0000} that is_erasable is 0 for 1st invoice');						// 1 can no more be deleted (2 is more recent)
179
+		$this->assertLessThanOrEqual(0, $result, 'Test for {yyyy}-{0000} that is_erasable is 0 for 1st invoice'); // 1 can no more be deleted (2 is more recent)
180 180
 
181 181
 		// Now we try with a reset
182
-		$conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}-{0000@1}';
183
-		$conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}-{0000@1}';
182
+		$conf->global->FACTURE_MERCURE_MASK_CREDIT = '{yyyy}-{0000@1}';
183
+		$conf->global->FACTURE_MERCURE_MASK_INVOICE = '{yyyy}-{0000@1}';
184 184
 
185
-		$localobject=new Facture($this->savdb);
185
+		$localobject = new Facture($this->savdb);
186 186
 		$localobject->initAsSpecimen();
187
-		$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1910);	// we use year 1910 to be sure to not have existing invoice for this year
188
-		$numbering=new mod_facture_mercure();
189
-		$result=$numbering->getNextValue($mysoc, $localobject);
190
-		$result2=$localobject->create($user,1);
191
-		$result3=$localobject->validate($user, $result);
187
+		$localobject->date = dol_mktime(12, 0, 0, 1, 1, 1910); // we use year 1910 to be sure to not have existing invoice for this year
188
+		$numbering = new mod_facture_mercure();
189
+		$result = $numbering->getNextValue($mysoc, $localobject);
190
+		$result2 = $localobject->create($user, 1);
191
+		$result3 = $localobject->validate($user, $result);
192 192
 		print __METHOD__." result=".$result."\n";
193
-		$this->assertEquals('1910-0001', $result, 'Test for {yyyy}-{0000@1} 1st invoice');				// counter must start to 1
194
-		$localobject2=new Facture($this->savdb);
193
+		$this->assertEquals('1910-0001', $result, 'Test for {yyyy}-{0000@1} 1st invoice'); // counter must start to 1
194
+		$localobject2 = new Facture($this->savdb);
195 195
 		$localobject2->initAsSpecimen();
196
-		$localobject2->date=dol_mktime(12, 0, 0, 1, 1, 1910);	// we use same year for second invoice (and there is a reset required)
197
-		$numbering=new mod_facture_mercure();
198
-		$result=$numbering->getNextValue($mysoc, $localobject2);
196
+		$localobject2->date = dol_mktime(12, 0, 0, 1, 1, 1910); // we use same year for second invoice (and there is a reset required)
197
+		$numbering = new mod_facture_mercure();
198
+		$result = $numbering->getNextValue($mysoc, $localobject2);
199 199
 		print __METHOD__." result=".$result."\n";
200
-		$this->assertEquals('1910-0002', $result, 'Test for {yyyy}-{0000@1} 2nd invoice, same day');	// counter must be now 2
201
-		$localobject3=new Facture($this->savdb);
200
+		$this->assertEquals('1910-0002', $result, 'Test for {yyyy}-{0000@1} 2nd invoice, same day'); // counter must be now 2
201
+		$localobject3 = new Facture($this->savdb);
202 202
 		$localobject3->initAsSpecimen();
203
-		$localobject3->date=dol_mktime(12, 0, 0, 1, 1, 1911);	// we use next year for third invoice (and there is a reset required)
204
-		$numbering=new mod_facture_mercure();
205
-		$result=$numbering->getNextValue($mysoc, $localobject3);
203
+		$localobject3->date = dol_mktime(12, 0, 0, 1, 1, 1911); // we use next year for third invoice (and there is a reset required)
204
+		$numbering = new mod_facture_mercure();
205
+		$result = $numbering->getNextValue($mysoc, $localobject3);
206 206
 		print __METHOD__." result=".$result."\n";
207
-		$this->assertEquals('1911-0001', $result, 'Test for {yyyy}-{0000@1} 3nd invoice, same day');	// counter must be now 1
207
+		$this->assertEquals('1911-0001', $result, 'Test for {yyyy}-{0000@1} 3nd invoice, same day'); // counter must be now 1
208 208
 
209 209
 		// Same but we add month after year
210
-		$conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@1}';
211
-		$conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@1}';
212
-		$localobject=new Facture($this->savdb);
210
+		$conf->global->FACTURE_MERCURE_MASK_CREDIT = '{yyyy}{mm}-{0000@1}';
211
+		$conf->global->FACTURE_MERCURE_MASK_INVOICE = '{yyyy}{mm}-{0000@1}';
212
+		$localobject = new Facture($this->savdb);
213 213
 		$localobject->initAsSpecimen();
214
-		$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1920);	// we use year 1920 to be sure to not have existing invoice for this year
215
-		$numbering=new mod_facture_mercure();
216
-		$result=$numbering->getNextValue($mysoc, $localobject);
217
-		$result2=$localobject->create($user,1);
218
-		$result3=$localobject->validate($user, $result);
214
+		$localobject->date = dol_mktime(12, 0, 0, 1, 1, 1920); // we use year 1920 to be sure to not have existing invoice for this year
215
+		$numbering = new mod_facture_mercure();
216
+		$result = $numbering->getNextValue($mysoc, $localobject);
217
+		$result2 = $localobject->create($user, 1);
218
+		$result3 = $localobject->validate($user, $result);
219 219
 		print __METHOD__." result=".$result."\n";
220
-		$this->assertEquals('192001-0001', $result, 'Test for {yyyy}{mm}-{0000@1} 1st invoice');			// counter must start to 1
221
-		$result=$localobject->is_erasable();
220
+		$this->assertEquals('192001-0001', $result, 'Test for {yyyy}{mm}-{0000@1} 1st invoice'); // counter must start to 1
221
+		$result = $localobject->is_erasable();
222 222
 		print __METHOD__." is_erasable=".$result."\n";
223
-		$this->assertGreaterThanOrEqual(1, $result);						// Can be deleted
224
-		$localobject2=new Facture($this->savdb);
223
+		$this->assertGreaterThanOrEqual(1, $result); // Can be deleted
224
+		$localobject2 = new Facture($this->savdb);
225 225
 		$localobject2->initAsSpecimen();
226
-		$localobject2->date=dol_mktime(12, 0, 0, 1, 1, 1921);	// we use following year for second invoice (and there is a reset required)
227
-		$numbering=new mod_facture_mercure();
228
-		$result=$numbering->getNextValue($mysoc, $localobject2);
229
-		$result2=$localobject2->create($user,1);
230
-		$result3=$localobject2->validate($user, $result);
226
+		$localobject2->date = dol_mktime(12, 0, 0, 1, 1, 1921); // we use following year for second invoice (and there is a reset required)
227
+		$numbering = new mod_facture_mercure();
228
+		$result = $numbering->getNextValue($mysoc, $localobject2);
229
+		$result2 = $localobject2->create($user, 1);
230
+		$result3 = $localobject2->validate($user, $result);
231 231
 		print __METHOD__." result=".$result."\n";
232
-    	$this->assertEquals('192101-0001', $result);			// counter must be reseted to 1
233
-    	$result=$localobject2->is_erasable();
232
+    	$this->assertEquals('192101-0001', $result); // counter must be reseted to 1
233
+    	$result = $localobject2->is_erasable();
234 234
     	print __METHOD__." is_erasable=".$result."\n";
235
-    	$this->assertGreaterThanOrEqual(1, $result);						// Can be deleted
236
-    	$result=$localobject->is_erasable();
235
+    	$this->assertGreaterThanOrEqual(1, $result); // Can be deleted
236
+    	$result = $localobject->is_erasable();
237 237
     	print __METHOD__." is_erasable=".$result."\n";
238
-    	$this->assertGreaterThanOrEqual(1, $result);						// Case 1 can be deleted (because there was a reset for case 2)
238
+    	$this->assertGreaterThanOrEqual(1, $result); // Case 1 can be deleted (because there was a reset for case 2)
239 239
 
240 240
 		// Same but we add month before year and use a year on 2 digits
241
-		$conf->global->FACTURE_MERCURE_MASK_CREDIT='[mm}{yy}-{0000@1}';
242
-		$conf->global->FACTURE_MERCURE_MASK_INVOICE='{mm}{yy}-{0000@1}';
243
-		$localobject=new Facture($this->savdb);
241
+		$conf->global->FACTURE_MERCURE_MASK_CREDIT = '[mm}{yy}-{0000@1}';
242
+		$conf->global->FACTURE_MERCURE_MASK_INVOICE = '{mm}{yy}-{0000@1}';
243
+		$localobject = new Facture($this->savdb);
244 244
 		$localobject->initAsSpecimen();
245
-		$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1925);	// we use year 1925 to be sure to not have existing invoice for this year
246
-		$numbering=new mod_facture_mercure();
247
-		$result=$numbering->getNextValue($mysoc, $localobject);
248
-		$result2=$localobject->create($user,1);
249
-		$result3=$localobject->validate($user, $result);
245
+		$localobject->date = dol_mktime(12, 0, 0, 1, 1, 1925); // we use year 1925 to be sure to not have existing invoice for this year
246
+		$numbering = new mod_facture_mercure();
247
+		$result = $numbering->getNextValue($mysoc, $localobject);
248
+		$result2 = $localobject->create($user, 1);
249
+		$result3 = $localobject->validate($user, $result);
250 250
 		print __METHOD__." result=".$result."\n";
251
-		$this->assertEquals('0125-0001', $result, 'Test for {mm}{yy}-{0000@1} 1st invoice');				// counter must start to 1
252
-		$result=$localobject->is_erasable();					// This call get getNextNumRef with param 'last'
251
+		$this->assertEquals('0125-0001', $result, 'Test for {mm}{yy}-{0000@1} 1st invoice'); // counter must start to 1
252
+		$result = $localobject->is_erasable(); // This call get getNextNumRef with param 'last'
253 253
 		print __METHOD__." is_erasable=".$result."\n";
254
-		$this->assertGreaterThanOrEqual(1, $result);						// Can be deleted
255
-		$localobject2=new Facture($this->savdb);
254
+		$this->assertGreaterThanOrEqual(1, $result); // Can be deleted
255
+		$localobject2 = new Facture($this->savdb);
256 256
 		$localobject2->initAsSpecimen();
257
-		$localobject2->date=dol_mktime(12, 0, 0, 1, 1, 1925);	// we use same year 1925 for second invoice (and there is a reset required)
258
-		$numbering=new mod_facture_mercure();
259
-		$result=$numbering->getNextValue($mysoc, $localobject2);
260
-		$result2=$localobject2->create($user,1);
261
-		$result3=$localobject2->validate($user, $result);
257
+		$localobject2->date = dol_mktime(12, 0, 0, 1, 1, 1925); // we use same year 1925 for second invoice (and there is a reset required)
258
+		$numbering = new mod_facture_mercure();
259
+		$result = $numbering->getNextValue($mysoc, $localobject2);
260
+		$result2 = $localobject2->create($user, 1);
261
+		$result3 = $localobject2->validate($user, $result);
262 262
 		print __METHOD__." result=".$result."\n";
263
-    	$this->assertEquals('0125-0002', $result, 'Test for {mm}{yy}-{0000@1} 2st invoice');			// counter must be now 2
264
-    	$result=$localobject2->is_erasable();
263
+    	$this->assertEquals('0125-0002', $result, 'Test for {mm}{yy}-{0000@1} 2st invoice'); // counter must be now 2
264
+    	$result = $localobject2->is_erasable();
265 265
     	print __METHOD__." is_erasable=".$result."\n";
266
-    	$this->assertGreaterThanOrEqual(1, $result);						// Can be deleted
267
-    	$result=$localobject->is_erasable();
266
+    	$this->assertGreaterThanOrEqual(1, $result); // Can be deleted
267
+    	$result = $localobject->is_erasable();
268 268
     	print __METHOD__." is_erasable=".$result."\n";
269
-    	$this->assertLessThanOrEqual(0, $result);						// Case 1 can not be deleted (because there is an invoice 2)
270
-		$localobject3=new Facture($this->savdb);
269
+    	$this->assertLessThanOrEqual(0, $result); // Case 1 can not be deleted (because there is an invoice 2)
270
+		$localobject3 = new Facture($this->savdb);
271 271
 		$localobject3->initAsSpecimen();
272
-		$localobject3->date=dol_mktime(12, 0, 0, 1, 1, 1926);	// we use following year for third invoice (and there is a reset required)
273
-		$numbering=new mod_facture_mercure();
274
-		$result=$numbering->getNextValue($mysoc, $localobject3);
272
+		$localobject3->date = dol_mktime(12, 0, 0, 1, 1, 1926); // we use following year for third invoice (and there is a reset required)
273
+		$numbering = new mod_facture_mercure();
274
+		$result = $numbering->getNextValue($mysoc, $localobject3);
275 275
 		print __METHOD__." result=".$result."\n";
276
-    	$this->assertEquals('0126-0001', $result, 'Test for {mm}{yy}-{0000@1} 3rd invoice');			// counter must be now 1
276
+    	$this->assertEquals('0126-0001', $result, 'Test for {mm}{yy}-{0000@1} 3rd invoice'); // counter must be now 1
277 277
 
278 278
     	// Try an offset when an invoice already exists
279
-    	$conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000+9990}';
280
-    	$conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000+9990}';
281
-    	$result=$numbering->getNextValue($mysoc, $localobject2);
279
+    	$conf->global->FACTURE_MERCURE_MASK_CREDIT = '{yyyy}{mm}-{0000+9990}';
280
+    	$conf->global->FACTURE_MERCURE_MASK_INVOICE = '{yyyy}{mm}-{0000+9990}';
281
+    	$result = $numbering->getNextValue($mysoc, $localobject2);
282 282
 
283 283
 		// Now we try with a different fiscal month (forced by mask)
284
-    	$conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@6}';
285
-    	$conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@6}';
284
+    	$conf->global->FACTURE_MERCURE_MASK_CREDIT = '{yyyy}{mm}-{0000@6}';
285
+    	$conf->global->FACTURE_MERCURE_MASK_INVOICE = '{yyyy}{mm}-{0000@6}';
286 286
 
287
-    	$localobject=new Facture($this->savdb);
287
+    	$localobject = new Facture($this->savdb);
288 288
     	$localobject->initAsSpecimen();
289
-    	$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1930);	// we use year 1930 to be sure to not have existing invoice for this year
290
-    	$numbering=new mod_facture_mercure();
291
-    	$result=$numbering->getNextValue($mysoc, $localobject, 'last');
289
+    	$localobject->date = dol_mktime(12, 0, 0, 1, 1, 1930); // we use year 1930 to be sure to not have existing invoice for this year
290
+    	$numbering = new mod_facture_mercure();
291
+    	$result = $numbering->getNextValue($mysoc, $localobject, 'last');
292 292
     	print __METHOD__." result for last=".$result."\n";
293
-    	$this->assertEquals('', $result);						// no existing ref into reset range
294
-    	$result=$numbering->getNextValue($mysoc, $localobject);
295
-    	$result2=$localobject->create($user,1);
296
-    	$result3=$localobject->validate($user, $result);
293
+    	$this->assertEquals('', $result); // no existing ref into reset range
294
+    	$result = $numbering->getNextValue($mysoc, $localobject);
295
+    	$result2 = $localobject->create($user, 1);
296
+    	$result3 = $localobject->validate($user, $result);
297 297
     	print __METHOD__." result=".$result."\n";
298
-    	$this->assertEquals('193001-0001', $result);			// counter must start to 1
299
-    	$result=$numbering->getNextValue($mysoc, $localobject, 'last');
298
+    	$this->assertEquals('193001-0001', $result); // counter must start to 1
299
+    	$result = $numbering->getNextValue($mysoc, $localobject, 'last');
300 300
     	print __METHOD__." result for last=".$result."\n";
301
-    	$this->assertEquals('193001-0001', $result);			// last ref into reset range should be same than last created
301
+    	$this->assertEquals('193001-0001', $result); // last ref into reset range should be same than last created
302 302
 
303
-    	$localobject=new Facture($this->savdb);
303
+    	$localobject = new Facture($this->savdb);
304 304
     	$localobject->initAsSpecimen();
305
-    	$localobject->date=dol_mktime(12, 0, 0, 12, 1, 1930);	// we use same year but fiscal month after
306
-    	$numbering=new mod_facture_mercure();
307
-    	$result=$numbering->getNextValue($mysoc, $localobject, 'last');
305
+    	$localobject->date = dol_mktime(12, 0, 0, 12, 1, 1930); // we use same year but fiscal month after
306
+    	$numbering = new mod_facture_mercure();
307
+    	$result = $numbering->getNextValue($mysoc, $localobject, 'last');
308 308
     	print __METHOD__." result for last=".$result."\n";
309
-    	$this->assertEquals('', $result);						// last ref into reset range should be ''
310
-    	$result=$numbering->getNextValue($mysoc, $localobject);
311
-    	$result2=$localobject->create($user,1);
312
-    	$result3=$localobject->validate($user, $result);
309
+    	$this->assertEquals('', $result); // last ref into reset range should be ''
310
+    	$result = $numbering->getNextValue($mysoc, $localobject);
311
+    	$result2 = $localobject->create($user, 1);
312
+    	$result3 = $localobject->validate($user, $result);
313 313
     	print __METHOD__." result=".$result."\n";
314
-    	$this->assertEquals('193012-0001', $result);	// counter must be reset to 1
314
+    	$this->assertEquals('193012-0001', $result); // counter must be reset to 1
315 315
 
316
-    	$localobject=new Facture($this->savdb);
316
+    	$localobject = new Facture($this->savdb);
317 317
     	$localobject->initAsSpecimen();
318
-    	$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1931);	// we use same fiscal year but different year
319
-    	$numbering=new mod_facture_mercure();
320
-    	$result=$numbering->getNextValue($mysoc, $localobject);
321
-    	$result2=$localobject->create($user,1);
322
-    	$result3=$localobject->validate($user, $result);
318
+    	$localobject->date = dol_mktime(12, 0, 0, 1, 1, 1931); // we use same fiscal year but different year
319
+    	$numbering = new mod_facture_mercure();
320
+    	$result = $numbering->getNextValue($mysoc, $localobject);
321
+    	$result2 = $localobject->create($user, 1);
322
+    	$result3 = $localobject->validate($user, $result);
323 323
     	print __METHOD__." result=".$result."\n";
324
-    	$this->assertEquals('193101-0002', $result);	// counter must be 2
324
+    	$this->assertEquals('193101-0002', $result); // counter must be 2
325 325
 
326
-    	$localobject=new Facture($this->savdb);
326
+    	$localobject = new Facture($this->savdb);
327 327
     	$localobject->initAsSpecimen();
328
-    	$localobject->date=dol_mktime(12, 0, 0, 12, 1, 1931);	// we use different fiscal year but same year
329
-    	$numbering=new mod_facture_mercure();
330
-    	$result=$numbering->getNextValue($mysoc, $localobject);
328
+    	$localobject->date = dol_mktime(12, 0, 0, 12, 1, 1931); // we use different fiscal year but same year
329
+    	$numbering = new mod_facture_mercure();
330
+    	$result = $numbering->getNextValue($mysoc, $localobject);
331 331
     	print __METHOD__." result=".$result."\n";
332
-    	$this->assertEquals('193112-0001', $result);	// counter must be reset to 1
332
+    	$this->assertEquals('193112-0001', $result); // counter must be reset to 1
333 333
 
334 334
 
335 335
     	// Now we try with a different fiscal month (defined by SOCIETE_FISCAL_MONTH_START)
336
-    	$conf->global->SOCIETE_FISCAL_MONTH_START=6;
337
-    	$conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@0}';
338
-    	$conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@0}';
336
+    	$conf->global->SOCIETE_FISCAL_MONTH_START = 6;
337
+    	$conf->global->FACTURE_MERCURE_MASK_CREDIT = '{yyyy}{mm}-{0000@0}';
338
+    	$conf->global->FACTURE_MERCURE_MASK_INVOICE = '{yyyy}{mm}-{0000@0}';
339 339
 
340
-    	$localobject=new Facture($this->savdb);
340
+    	$localobject = new Facture($this->savdb);
341 341
     	$localobject->initAsSpecimen();
342
-    	$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1940);	// we use year 1940 to be sure to not have existing invoice for this year
343
-    	$numbering=new mod_facture_mercure();
344
-    	$result=$numbering->getNextValue($mysoc, $localobject);
345
-    	$result2=$localobject->create($user,1);
346
-    	$result3=$localobject->validate($user, $result);
342
+    	$localobject->date = dol_mktime(12, 0, 0, 1, 1, 1940); // we use year 1940 to be sure to not have existing invoice for this year
343
+    	$numbering = new mod_facture_mercure();
344
+    	$result = $numbering->getNextValue($mysoc, $localobject);
345
+    	$result2 = $localobject->create($user, 1);
346
+    	$result3 = $localobject->validate($user, $result);
347 347
     	print __METHOD__." result=".$result."\n";
348
-    	$this->assertEquals('194001-0001', $result);	// counter must start to 1
348
+    	$this->assertEquals('194001-0001', $result); // counter must start to 1
349 349
 
350
-    	$localobject=new Facture($this->savdb);
350
+    	$localobject = new Facture($this->savdb);
351 351
     	$localobject->initAsSpecimen();
352
-    	$localobject->date=dol_mktime(12, 0, 0, 12, 1, 1940);	// we use same year but fiscal month after
353
-    	$numbering=new mod_facture_mercure();
354
-    	$result=$numbering->getNextValue($mysoc, $localobject);
355
-    	$result2=$localobject->create($user,1);
356
-    	$result3=$localobject->validate($user, $result);
352
+    	$localobject->date = dol_mktime(12, 0, 0, 12, 1, 1940); // we use same year but fiscal month after
353
+    	$numbering = new mod_facture_mercure();
354
+    	$result = $numbering->getNextValue($mysoc, $localobject);
355
+    	$result2 = $localobject->create($user, 1);
356
+    	$result3 = $localobject->validate($user, $result);
357 357
     	print __METHOD__." result=".$result."\n";
358
-    	$this->assertEquals('194012-0001', $result);	// counter must be reset to 1
358
+    	$this->assertEquals('194012-0001', $result); // counter must be reset to 1
359 359
 
360
-    	$localobject=new Facture($this->savdb);
360
+    	$localobject = new Facture($this->savdb);
361 361
     	$localobject->initAsSpecimen();
362
-    	$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1941);	// we use same fiscal year but different year
363
-    	$numbering=new mod_facture_mercure();
364
-    	$result=$numbering->getNextValue($mysoc, $localobject);
365
-    	$result2=$localobject->create($user,1);
366
-    	$result3=$localobject->validate($user, $result);
362
+    	$localobject->date = dol_mktime(12, 0, 0, 1, 1, 1941); // we use same fiscal year but different year
363
+    	$numbering = new mod_facture_mercure();
364
+    	$result = $numbering->getNextValue($mysoc, $localobject);
365
+    	$result2 = $localobject->create($user, 1);
366
+    	$result3 = $localobject->validate($user, $result);
367 367
     	print __METHOD__." result=".$result."\n";
368
-    	$this->assertEquals('194101-0002', $result);	// counter must be 2
368
+    	$this->assertEquals('194101-0002', $result); // counter must be 2
369 369
 
370
-    	$localobject=new Facture($this->savdb);
370
+    	$localobject = new Facture($this->savdb);
371 371
     	$localobject->initAsSpecimen();
372
-    	$localobject->date=dol_mktime(12, 0, 0, 12, 1, 1941);	// we use different discal year but same year
373
-    	$numbering=new mod_facture_mercure();
374
-    	$result=$numbering->getNextValue($mysoc, $localobject);
372
+    	$localobject->date = dol_mktime(12, 0, 0, 12, 1, 1941); // we use different discal year but same year
373
+    	$numbering = new mod_facture_mercure();
374
+    	$result = $numbering->getNextValue($mysoc, $localobject);
375 375
     	print __METHOD__." result=".$result."\n";
376
-    	$this->assertEquals('194112-0001', $result);	// counter must be reset to 1
376
+    	$this->assertEquals('194112-0001', $result); // counter must be reset to 1
377 377
 
378 378
 
379 379
     	// Now we try with a different fiscal month (defined by SOCIETE_FISCAL_MONTH_START) and we always want year of element
380
-    	$conf->global->SOCIETE_FISCAL_MONTH_START=6;
381
-    	$conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@=}';
382
-    	$conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@=}';
380
+    	$conf->global->SOCIETE_FISCAL_MONTH_START = 6;
381
+    	$conf->global->FACTURE_MERCURE_MASK_CREDIT = '{yyyy}{mm}-{0000@=}';
382
+    	$conf->global->FACTURE_MERCURE_MASK_INVOICE = '{yyyy}{mm}-{0000@=}';
383 383
 
384
-    	$localobject=new Facture($this->savdb);
384
+    	$localobject = new Facture($this->savdb);
385 385
     	$localobject->initAsSpecimen();
386
-    	$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1950);	// we use year 1950 to be sure to not have existing invoice for this year
387
-    	$numbering=new mod_facture_mercure();
388
-    	$result=$numbering->getNextValue($mysoc, $localobject);
389
-    	$result2=$localobject->create($user,1);
390
-    	$result3=$localobject->validate($user, $result);
386
+    	$localobject->date = dol_mktime(12, 0, 0, 1, 1, 1950); // we use year 1950 to be sure to not have existing invoice for this year
387
+    	$numbering = new mod_facture_mercure();
388
+    	$result = $numbering->getNextValue($mysoc, $localobject);
389
+    	$result2 = $localobject->create($user, 1);
390
+    	$result3 = $localobject->validate($user, $result);
391 391
     	print __METHOD__." result=".$result."\n";
392
-    	$this->assertEquals('195001-0001', $result);	// counter must start to 1
392
+    	$this->assertEquals('195001-0001', $result); // counter must start to 1
393 393
 
394
-    	$localobject=new Facture($this->savdb);
394
+    	$localobject = new Facture($this->savdb);
395 395
     	$localobject->initAsSpecimen();
396
-    	$localobject->date=dol_mktime(12, 0, 0, 12, 1, 1950);	// we use same year but fiscal month after
397
-    	$numbering=new mod_facture_mercure();
398
-    	$result=$numbering->getNextValue($mysoc, $localobject);
399
-    	$result2=$localobject->create($user,1);
400
-    	$result3=$localobject->validate($user, $result);
396
+    	$localobject->date = dol_mktime(12, 0, 0, 12, 1, 1950); // we use same year but fiscal month after
397
+    	$numbering = new mod_facture_mercure();
398
+    	$result = $numbering->getNextValue($mysoc, $localobject);
399
+    	$result2 = $localobject->create($user, 1);
400
+    	$result3 = $localobject->validate($user, $result);
401 401
     	print __METHOD__." result=".$result."\n";
402
-    	$this->assertEquals('195012-0001', $result);	// counter must be reset to 1
402
+    	$this->assertEquals('195012-0001', $result); // counter must be reset to 1
403 403
 
404
-    	$localobject=new Facture($this->savdb);
404
+    	$localobject = new Facture($this->savdb);
405 405
     	$localobject->initAsSpecimen();
406
-    	$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1951);	// we use same fiscal year but different year
407
-    	$numbering=new mod_facture_mercure();
408
-    	$result=$numbering->getNextValue($mysoc, $localobject);
409
-    	$result2=$localobject->create($user,1);
410
-    	$result3=$localobject->validate($user, $result);
406
+    	$localobject->date = dol_mktime(12, 0, 0, 1, 1, 1951); // we use same fiscal year but different year
407
+    	$numbering = new mod_facture_mercure();
408
+    	$result = $numbering->getNextValue($mysoc, $localobject);
409
+    	$result2 = $localobject->create($user, 1);
410
+    	$result3 = $localobject->validate($user, $result);
411 411
     	print __METHOD__." result=".$result."\n";
412
-    	$this->assertEquals('195101-0002', $result);	// counter must be 2
412
+    	$this->assertEquals('195101-0002', $result); // counter must be 2
413 413
 
414
-    	$localobject=new Facture($this->savdb);
414
+    	$localobject = new Facture($this->savdb);
415 415
     	$localobject->initAsSpecimen();
416
-    	$localobject->date=dol_mktime(12, 0, 0, 12, 1, 1951);	// we use different discal year but same year
417
-    	$numbering=new mod_facture_mercure();
418
-    	$result=$numbering->getNextValue($mysoc, $localobject);
416
+    	$localobject->date = dol_mktime(12, 0, 0, 12, 1, 1951); // we use different discal year but same year
417
+    	$numbering = new mod_facture_mercure();
418
+    	$result = $numbering->getNextValue($mysoc, $localobject);
419 419
     	print __METHOD__." result=".$result."\n";
420
-    	$this->assertEquals('195112-0001', $result);	// counter must be reset to 1
420
+    	$this->assertEquals('195112-0001', $result); // counter must be reset to 1
421 421
 
422 422
 
423 423
     	// Now we try with a different fiscal month (defined by SOCIETE_FISCAL_MONTH_START) and we always want start year
424
-    	$conf->global->SOCIETE_FISCAL_MONTH_START=6;
425
-    	$conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@-}';
426
-    	$conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@-}';
424
+    	$conf->global->SOCIETE_FISCAL_MONTH_START = 6;
425
+    	$conf->global->FACTURE_MERCURE_MASK_CREDIT = '{yyyy}{mm}-{0000@-}';
426
+    	$conf->global->FACTURE_MERCURE_MASK_INVOICE = '{yyyy}{mm}-{0000@-}';
427 427
 
428
-    	$localobject=new Facture($this->savdb);
428
+    	$localobject = new Facture($this->savdb);
429 429
     	$localobject->initAsSpecimen();
430
-    	$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1960);	// we use year 1960 to be sure to not have existing invoice for this year
431
-    	$numbering=new mod_facture_mercure();
432
-    	$result=$numbering->getNextValue($mysoc, $localobject);
433
-    	$result2=$localobject->create($user,1);
434
-    	$result3=$localobject->validate($user, $result);
430
+    	$localobject->date = dol_mktime(12, 0, 0, 1, 1, 1960); // we use year 1960 to be sure to not have existing invoice for this year
431
+    	$numbering = new mod_facture_mercure();
432
+    	$result = $numbering->getNextValue($mysoc, $localobject);
433
+    	$result2 = $localobject->create($user, 1);
434
+    	$result3 = $localobject->validate($user, $result);
435 435
     	print __METHOD__." result=".$result."\n";
436
-    	$this->assertEquals('195901-0001', $result);	// counter must start to 1
436
+    	$this->assertEquals('195901-0001', $result); // counter must start to 1
437 437
 
438
-    	$localobject=new Facture($this->savdb);
438
+    	$localobject = new Facture($this->savdb);
439 439
     	$localobject->initAsSpecimen();
440
-    	$localobject->date=dol_mktime(12, 0, 0, 12, 1, 1960);	// we use same year but fiscal month after
441
-    	$numbering=new mod_facture_mercure();
442
-    	$result=$numbering->getNextValue($mysoc, $localobject);
443
-    	$result2=$localobject->create($user,1);
444
-    	$result3=$localobject->validate($user, $result);
440
+    	$localobject->date = dol_mktime(12, 0, 0, 12, 1, 1960); // we use same year but fiscal month after
441
+    	$numbering = new mod_facture_mercure();
442
+    	$result = $numbering->getNextValue($mysoc, $localobject);
443
+    	$result2 = $localobject->create($user, 1);
444
+    	$result3 = $localobject->validate($user, $result);
445 445
     	print __METHOD__." result=".$result."\n";
446
-    	$this->assertEquals('196012-0001', $result);	// counter must be reset to 1
446
+    	$this->assertEquals('196012-0001', $result); // counter must be reset to 1
447 447
 
448
-    	$localobject=new Facture($this->savdb);
448
+    	$localobject = new Facture($this->savdb);
449 449
     	$localobject->initAsSpecimen();
450
-    	$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1961);	// we use same fiscal year but different year
451
-    	$numbering=new mod_facture_mercure();
452
-    	$result=$numbering->getNextValue($mysoc, $localobject);
453
-    	$result2=$localobject->create($user,1);
454
-    	$result3=$localobject->validate($user, $result);
450
+    	$localobject->date = dol_mktime(12, 0, 0, 1, 1, 1961); // we use same fiscal year but different year
451
+    	$numbering = new mod_facture_mercure();
452
+    	$result = $numbering->getNextValue($mysoc, $localobject);
453
+    	$result2 = $localobject->create($user, 1);
454
+    	$result3 = $localobject->validate($user, $result);
455 455
     	print __METHOD__." result=".$result."\n";
456
-    	$this->assertEquals('196001-0002', $result);	// counter must be 2
456
+    	$this->assertEquals('196001-0002', $result); // counter must be 2
457 457
 
458
-    	$localobject=new Facture($this->savdb);
458
+    	$localobject = new Facture($this->savdb);
459 459
     	$localobject->initAsSpecimen();
460
-    	$localobject->date=dol_mktime(12, 0, 0, 12, 1, 1961);	// we use different discal year but same year
461
-    	$numbering=new mod_facture_mercure();
462
-    	$result=$numbering->getNextValue($mysoc, $localobject);
460
+    	$localobject->date = dol_mktime(12, 0, 0, 12, 1, 1961); // we use different discal year but same year
461
+    	$numbering = new mod_facture_mercure();
462
+    	$result = $numbering->getNextValue($mysoc, $localobject);
463 463
     	print __METHOD__." result=".$result."\n";
464
-    	$this->assertEquals('196112-0001', $result);	// counter must be reset to 1
464
+    	$this->assertEquals('196112-0001', $result); // counter must be reset to 1
465 465
 
466 466
 
467 467
     	// Now we try with a different fiscal month (defined by SOCIETE_FISCAL_MONTH_START) and we always want end year
468
-    	$conf->global->SOCIETE_FISCAL_MONTH_START=6;
469
-    	$conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@+}';
470
-    	$conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@+}';
468
+    	$conf->global->SOCIETE_FISCAL_MONTH_START = 6;
469
+    	$conf->global->FACTURE_MERCURE_MASK_CREDIT = '{yyyy}{mm}-{0000@+}';
470
+    	$conf->global->FACTURE_MERCURE_MASK_INVOICE = '{yyyy}{mm}-{0000@+}';
471 471
 
472
-    	$localobject=new Facture($this->savdb);
472
+    	$localobject = new Facture($this->savdb);
473 473
     	$localobject->initAsSpecimen();
474
-    	$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1970);	// we use year 1970 to be sure to not have existing invoice for this year
475
-    	$numbering=new mod_facture_mercure();
476
-    	$result=$numbering->getNextValue($mysoc, $localobject);
477
-    	$result2=$localobject->create($user,1);
478
-    	$result3=$localobject->validate($user, $result);
474
+    	$localobject->date = dol_mktime(12, 0, 0, 1, 1, 1970); // we use year 1970 to be sure to not have existing invoice for this year
475
+    	$numbering = new mod_facture_mercure();
476
+    	$result = $numbering->getNextValue($mysoc, $localobject);
477
+    	$result2 = $localobject->create($user, 1);
478
+    	$result3 = $localobject->validate($user, $result);
479 479
     	print __METHOD__." result=".$result."\n";
480
-    	$this->assertEquals('197001-0001', $result);	// counter must start to 1
480
+    	$this->assertEquals('197001-0001', $result); // counter must start to 1
481 481
 
482
-    	$localobject=new Facture($this->savdb);
482
+    	$localobject = new Facture($this->savdb);
483 483
     	$localobject->initAsSpecimen();
484
-    	$localobject->date=dol_mktime(12, 0, 0, 12, 1, 1970);	// we use same year but fiscal month after
485
-    	$numbering=new mod_facture_mercure();
486
-    	$result=$numbering->getNextValue($mysoc, $localobject);
487
-    	$result2=$localobject->create($user,1);
488
-    	$result3=$localobject->validate($user, $result);
484
+    	$localobject->date = dol_mktime(12, 0, 0, 12, 1, 1970); // we use same year but fiscal month after
485
+    	$numbering = new mod_facture_mercure();
486
+    	$result = $numbering->getNextValue($mysoc, $localobject);
487
+    	$result2 = $localobject->create($user, 1);
488
+    	$result3 = $localobject->validate($user, $result);
489 489
     	print __METHOD__." result=".$result."\n";
490
-    	$this->assertEquals('197112-0001', $result);	// counter must be reset to 1
490
+    	$this->assertEquals('197112-0001', $result); // counter must be reset to 1
491 491
 
492
-    	$localobject=new Facture($this->savdb);
492
+    	$localobject = new Facture($this->savdb);
493 493
     	$localobject->initAsSpecimen();
494
-    	$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1971);	// we use same fiscal year but different year
495
-    	$numbering=new mod_facture_mercure();
496
-    	$result=$numbering->getNextValue($mysoc, $localobject);
497
-    	$result2=$localobject->create($user,1);
498
-    	$result3=$localobject->validate($user, $result);
494
+    	$localobject->date = dol_mktime(12, 0, 0, 1, 1, 1971); // we use same fiscal year but different year
495
+    	$numbering = new mod_facture_mercure();
496
+    	$result = $numbering->getNextValue($mysoc, $localobject);
497
+    	$result2 = $localobject->create($user, 1);
498
+    	$result3 = $localobject->validate($user, $result);
499 499
     	print __METHOD__." result=".$result."\n";
500
-    	$this->assertEquals('197101-0002', $result);	// counter must be 2
500
+    	$this->assertEquals('197101-0002', $result); // counter must be 2
501 501
 
502
-    	$localobject=new Facture($this->savdb);
502
+    	$localobject = new Facture($this->savdb);
503 503
     	$localobject->initAsSpecimen();
504
-    	$localobject->date=dol_mktime(12, 0, 0, 12, 1, 1971);	// we use different fiscal year but same year
505
-    	$numbering=new mod_facture_mercure();
506
-    	$result=$numbering->getNextValue($mysoc, $localobject);
504
+    	$localobject->date = dol_mktime(12, 0, 0, 12, 1, 1971); // we use different fiscal year but same year
505
+    	$numbering = new mod_facture_mercure();
506
+    	$result = $numbering->getNextValue($mysoc, $localobject);
507 507
     	print __METHOD__." result=".$result."\n";
508
-    	$this->assertEquals('197212-0001', $result);	// counter must be reset to 1
508
+    	$this->assertEquals('197212-0001', $result); // counter must be reset to 1
509 509
 
510 510
     	// Now we try with a reset every month (@99)
511
-    	$conf->global->SOCIETE_FISCAL_MONTH_START=6;
512
-    	$conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@99}';
513
-    	$conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@99}';
511
+    	$conf->global->SOCIETE_FISCAL_MONTH_START = 6;
512
+    	$conf->global->FACTURE_MERCURE_MASK_CREDIT = '{yyyy}{mm}-{0000@99}';
513
+    	$conf->global->FACTURE_MERCURE_MASK_INVOICE = '{yyyy}{mm}-{0000@99}';
514 514
 
515
-    	$localobject=new Facture($this->savdb);
515
+    	$localobject = new Facture($this->savdb);
516 516
     	$localobject->initAsSpecimen();
517
-    	$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1980);	// we use year 1980 to be sure to not have existing invoice for this year
518
-    	$numbering=new mod_facture_mercure();
519
-    	$result=$numbering->getNextValue($mysoc, $localobject);
520
-    	$result2=$localobject->create($user,1);
521
-    	$result3=$localobject->validate($user, $result);
517
+    	$localobject->date = dol_mktime(12, 0, 0, 1, 1, 1980); // we use year 1980 to be sure to not have existing invoice for this year
518
+    	$numbering = new mod_facture_mercure();
519
+    	$result = $numbering->getNextValue($mysoc, $localobject);
520
+    	$result2 = $localobject->create($user, 1);
521
+    	$result3 = $localobject->validate($user, $result);
522 522
     	print __METHOD__." result=".$result."\n";
523
-    	$this->assertEquals('198001-0001', $result);	// counter must start to 1
523
+    	$this->assertEquals('198001-0001', $result); // counter must start to 1
524 524
 
525
-    	$localobject=new Facture($this->savdb);
525
+    	$localobject = new Facture($this->savdb);
526 526
     	$localobject->initAsSpecimen();
527
-    	$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1980);	// we use year 1980 to be sure to not have existing invoice for this year
528
-    	$numbering=new mod_facture_mercure();
529
-    	$result=$numbering->getNextValue($mysoc, $localobject);
530
-    	$result2=$localobject->create($user,1);
531
-    	$result3=$localobject->validate($user, $result);
527
+    	$localobject->date = dol_mktime(12, 0, 0, 1, 1, 1980); // we use year 1980 to be sure to not have existing invoice for this year
528
+    	$numbering = new mod_facture_mercure();
529
+    	$result = $numbering->getNextValue($mysoc, $localobject);
530
+    	$result2 = $localobject->create($user, 1);
531
+    	$result3 = $localobject->validate($user, $result);
532 532
     	print __METHOD__." result=".$result."\n";
533
-    	$this->assertEquals('198001-0002', $result);	// counter must start to 2
533
+    	$this->assertEquals('198001-0002', $result); // counter must start to 2
534 534
 
535
-    	$localobject=new Facture($this->savdb);
535
+    	$localobject = new Facture($this->savdb);
536 536
     	$localobject->initAsSpecimen();
537
-    	$localobject->date=dol_mktime(12, 0, 0, 2, 1, 1980);	// we use year 1980 to be sure to not have existing invoice for this year
538
-    	$numbering=new mod_facture_mercure();
539
-    	$result=$numbering->getNextValue($mysoc, $localobject);
540
-    	$result2=$localobject->create($user,1);
541
-    	$result3=$localobject->validate($user, $result);
537
+    	$localobject->date = dol_mktime(12, 0, 0, 2, 1, 1980); // we use year 1980 to be sure to not have existing invoice for this year
538
+    	$numbering = new mod_facture_mercure();
539
+    	$result = $numbering->getNextValue($mysoc, $localobject);
540
+    	$result2 = $localobject->create($user, 1);
541
+    	$result3 = $localobject->validate($user, $result);
542 542
     	print __METHOD__." result=".$result."\n";
543
-    	$this->assertEquals('198002-0001', $result);	// counter must start to 1
543
+    	$this->assertEquals('198002-0001', $result); // counter must start to 1
544 544
 
545
-    	$localobject=new Facture($this->savdb);
545
+    	$localobject = new Facture($this->savdb);
546 546
     	$localobject->initAsSpecimen();
547
-    	$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1981);	// we use year 1981 to be sure to not have existing invoice for this year
548
-    	$numbering=new mod_facture_mercure();
549
-    	$result=$numbering->getNextValue($mysoc, $localobject);
550
-    	$result2=$localobject->create($user,1);
551
-    	$result3=$localobject->validate($user, $result);
547
+    	$localobject->date = dol_mktime(12, 0, 0, 1, 1, 1981); // we use year 1981 to be sure to not have existing invoice for this year
548
+    	$numbering = new mod_facture_mercure();
549
+    	$result = $numbering->getNextValue($mysoc, $localobject);
550
+    	$result2 = $localobject->create($user, 1);
551
+    	$result3 = $localobject->validate($user, $result);
552 552
     	print __METHOD__." result=".$result."\n";
553
-    	$this->assertEquals('198101-0001', $result);	// counter must start to 1
553
+    	$this->assertEquals('198101-0001', $result); // counter must start to 1
554 554
 
555 555
     	// Test with {t} tag
556
-    	$conf->global->SOCIETE_FISCAL_MONTH_START=1;
557
-    	$conf->global->FACTURE_MERCURE_MASK_CREDIT='{t}{yyyy}{mm}-{0000}';
558
-    	$conf->global->FACTURE_MERCURE_MASK_INVOICE='{t}{yyyy}{mm}-{0000}';
556
+    	$conf->global->SOCIETE_FISCAL_MONTH_START = 1;
557
+    	$conf->global->FACTURE_MERCURE_MASK_CREDIT = '{t}{yyyy}{mm}-{0000}';
558
+    	$conf->global->FACTURE_MERCURE_MASK_INVOICE = '{t}{yyyy}{mm}-{0000}';
559 559
 
560
-    	$tmpthirdparty=new Societe($this->savdb);
560
+    	$tmpthirdparty = new Societe($this->savdb);
561 561
     	$tmpthirdparty->initAsSpecimen();
562 562
     	$tmpthirdparty->typent_code = 'TE_ABC';
563 563
 
564
-    	$localobject=new Facture($this->savdb);
564
+    	$localobject = new Facture($this->savdb);
565 565
     	$localobject->initAsSpecimen();
566
-    	$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1982);	// we use year 1982 to be sure to not have existing invoice for this year
567
-    	$numbering=new mod_facture_mercure();
568
-    	$result=$numbering->getNextValue($tmpthirdparty, $localobject);
569
-    	$result2=$localobject->create($user,1);
570
-    	$result3=$localobject->validate($user, $result);
566
+    	$localobject->date = dol_mktime(12, 0, 0, 1, 1, 1982); // we use year 1982 to be sure to not have existing invoice for this year
567
+    	$numbering = new mod_facture_mercure();
568
+    	$result = $numbering->getNextValue($tmpthirdparty, $localobject);
569
+    	$result2 = $localobject->create($user, 1);
570
+    	$result3 = $localobject->validate($user, $result);
571 571
     	print __METHOD__." result=".$result."\n";
572
-    	$this->assertEquals('A198201-0001', $result);	// counter must start to 1
572
+    	$this->assertEquals('A198201-0001', $result); // counter must start to 1
573 573
 
574 574
 
575 575
 
Please login to merge, or discard this patch.
dolibarr/test/phpunit/ModulesTest.php 2 patches
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -30,9 +30,9 @@  discard block
 block discarded – undo
30 30
 
31 31
 if (empty($user->id))
32 32
 {
33
-	print "Load permissions for admin user nb 1\n";
34
-	$user->fetch(1);
35
-	$user->getrights();
33
+    print "Load permissions for admin user nb 1\n";
34
+    $user->fetch(1);
35
+    $user->getrights();
36 36
 }
37 37
 $conf->global->MAIN_DISABLE_ALL_MAILS=1;
38 38
 
@@ -46,74 +46,74 @@  discard block
 block discarded – undo
46 46
  */
47 47
 class ModulesTest extends PHPUnit_Framework_TestCase
48 48
 {
49
-	protected $savconf;
50
-	protected $savuser;
51
-	protected $savlangs;
52
-	protected $savdb;
53
-
54
-	/**
55
-	 * Constructor
56
-	 * We save global variables into local variables
57
-	 *
58
-	 * @return BuildDocTest
59
-	 */
60
-	function __construct()
61
-	{
62
-		parent::__construct();
63
-
64
-		//$this->sharedFixture
65
-		global $conf,$user,$langs,$db;
66
-		$this->savconf=$conf;
67
-		$this->savuser=$user;
68
-		$this->savlangs=$langs;
69
-		$this->savdb=$db;
70
-
71
-		print __METHOD__." db->type=".$db->type." user->id=".$user->id;
72
-		//print " - db ".$db->db;
73
-		print "\n";
74
-	}
75
-
76
-	// Static methods
77
-  	public static function setUpBeforeClass()
49
+    protected $savconf;
50
+    protected $savuser;
51
+    protected $savlangs;
52
+    protected $savdb;
53
+
54
+    /**
55
+     * Constructor
56
+     * We save global variables into local variables
57
+     *
58
+     * @return BuildDocTest
59
+     */
60
+    function __construct()
61
+    {
62
+        parent::__construct();
63
+
64
+        //$this->sharedFixture
65
+        global $conf,$user,$langs,$db;
66
+        $this->savconf=$conf;
67
+        $this->savuser=$user;
68
+        $this->savlangs=$langs;
69
+        $this->savdb=$db;
70
+
71
+        print __METHOD__." db->type=".$db->type." user->id=".$user->id;
72
+        //print " - db ".$db->db;
73
+        print "\n";
74
+    }
75
+
76
+    // Static methods
77
+        public static function setUpBeforeClass()
78 78
     {
79
-    	global $conf,$user,$langs,$db;
80
-		$db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
79
+        global $conf,$user,$langs,$db;
80
+        $db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
81 81
 
82
-    	print __METHOD__."\n";
82
+        print __METHOD__."\n";
83 83
     }
84 84
 
85 85
     // tear down after class
86 86
     public static function tearDownAfterClass()
87 87
     {
88
-    	global $conf,$user,$langs,$db;
89
-		$db->rollback();
88
+        global $conf,$user,$langs,$db;
89
+        $db->rollback();
90 90
 
91
-		print __METHOD__."\n";
91
+        print __METHOD__."\n";
92 92
     }
93 93
 
94
-	/**
95
-	 * Init phpunit tests
96
-	 *
97
-	 * @return	void
98
-	 */
94
+    /**
95
+     * Init phpunit tests
96
+     *
97
+     * @return	void
98
+     */
99 99
     protected function setUp()
100 100
     {
101
-    	global $conf,$user,$langs,$db;
102
-		$conf=$this->savconf;
103
-		$user=$this->savuser;
104
-		$langs=$this->savlangs;
105
-		$db=$this->savdb;
101
+        global $conf,$user,$langs,$db;
102
+        $conf=$this->savconf;
103
+        $user=$this->savuser;
104
+        $langs=$this->savlangs;
105
+        $db=$this->savdb;
106 106
 
107
-		print __METHOD__."\n";
107
+        print __METHOD__."\n";
108 108
     }
109
-	/**
110
-	 * End phpunit tests
111
-	 *
112
-	 * @return	void
113
-	 */
109
+    /**
110
+     * End phpunit tests
111
+     *
112
+     * @return	void
113
+     */
114 114
     protected function tearDown()
115 115
     {
116
-    	print __METHOD__."\n";
116
+        print __METHOD__."\n";
117 117
     }
118 118
 
119 119
     /**
@@ -123,34 +123,34 @@  discard block
 block discarded – undo
123 123
      */
124 124
     public function testModulesInit()
125 125
     {
126
-    	global $conf,$user,$langs,$db;
127
-		$conf=$this->savconf;
128
-		$user=$this->savuser;
129
-		$langs=$this->savlangs;
130
-		$db=$this->savdb;
131
-
132
-		$modulelist=array('Accounting','Adherent','Agenda','Banque','Barcode','BlockedLog','Bookmark',
133
-		'CashDesk','Categorie','ClickToDial','Collab','Commande','Comptabilite','Contrat','Cron','Deplacement','DocumentGeneration','Don','DynamicPrices',
134
-		'ECM','Expedition','ExpenseReport','Export','ExternalRss','ExternalSite',
135
-		'Facture','Fckeditor','Ficheinter','Fournisseur','FTP','GeoIPMaxmind','Gravatar','Holiday','HRM','Import','Incoterm','Label','Ldap','Loan',
136
-		'Mailing','MailmanSpip','Margin','ModuleBuilder','MultiCurrency',
137
-		'Notification','Oauth','OpenSurvey','Paybox','Paypal','Prelevement','Printing','Product','ProductBatch','Projet','Propale','ReceiptPrinter','Resource',
138
-		'Salaries','Service','Skype','Societe','Stock','Stripe','SupplierProposal','Syslog','Tax','Ticket','User','Variants','WebServices','WebServicesClient','Website','Workflow');
139
-		foreach($modulelist as $modlabel)
140
-		{
141
-    		require_once DOL_DOCUMENT_ROOT.'/core/modules/mod'.$modlabel.'.class.php';
126
+        global $conf,$user,$langs,$db;
127
+        $conf=$this->savconf;
128
+        $user=$this->savuser;
129
+        $langs=$this->savlangs;
130
+        $db=$this->savdb;
131
+
132
+        $modulelist=array('Accounting','Adherent','Agenda','Banque','Barcode','BlockedLog','Bookmark',
133
+        'CashDesk','Categorie','ClickToDial','Collab','Commande','Comptabilite','Contrat','Cron','Deplacement','DocumentGeneration','Don','DynamicPrices',
134
+        'ECM','Expedition','ExpenseReport','Export','ExternalRss','ExternalSite',
135
+        'Facture','Fckeditor','Ficheinter','Fournisseur','FTP','GeoIPMaxmind','Gravatar','Holiday','HRM','Import','Incoterm','Label','Ldap','Loan',
136
+        'Mailing','MailmanSpip','Margin','ModuleBuilder','MultiCurrency',
137
+        'Notification','Oauth','OpenSurvey','Paybox','Paypal','Prelevement','Printing','Product','ProductBatch','Projet','Propale','ReceiptPrinter','Resource',
138
+        'Salaries','Service','Skype','Societe','Stock','Stripe','SupplierProposal','Syslog','Tax','Ticket','User','Variants','WebServices','WebServicesClient','Website','Workflow');
139
+        foreach($modulelist as $modlabel)
140
+        {
141
+            require_once DOL_DOCUMENT_ROOT.'/core/modules/mod'.$modlabel.'.class.php';
142 142
             $class='mod'.$modlabel;
143
-    		$mod=new $class($db);
143
+            $mod=new $class($db);
144 144
             $result=$mod->remove();
145 145
             $result=$mod->init();
146
-        	$this->assertLessThan($result, 0, $modlabel);
147
-        	print __METHOD__." test remove/init for module ".$modlabel.", result=".$result."\n";
148
-
149
-        	if (in_array($modlabel, array('Ldap', 'MailmanSpip')))
150
-        	{
151
-        	    $result=$mod->remove();
152
-        	}
153
-		}
146
+            $this->assertLessThan($result, 0, $modlabel);
147
+            print __METHOD__." test remove/init for module ".$modlabel.", result=".$result."\n";
148
+
149
+            if (in_array($modlabel, array('Ldap', 'MailmanSpip')))
150
+            {
151
+                $result=$mod->remove();
152
+            }
153
+        }
154 154
 
155 155
         return 0;
156 156
     }
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  *		\remarks	To run this script as CLI:  phpunit filename.php
24 24
  */
25 25
 
26
-global $conf,$user,$langs,$db;
26
+global $conf, $user, $langs, $db;
27 27
 //define('TEST_DB_FORCE_TYPE','mysql');	// This is to force using mysql driver
28 28
 //require_once 'PHPUnit/Autoload.php';
29 29
 require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	$user->fetch(1);
35 35
 	$user->getrights();
36 36
 }
37
-$conf->global->MAIN_DISABLE_ALL_MAILS=1;
37
+$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
38 38
 
39 39
 
40 40
 /**
@@ -62,11 +62,11 @@  discard block
 block discarded – undo
62 62
 		parent::__construct();
63 63
 
64 64
 		//$this->sharedFixture
65
-		global $conf,$user,$langs,$db;
66
-		$this->savconf=$conf;
67
-		$this->savuser=$user;
68
-		$this->savlangs=$langs;
69
-		$this->savdb=$db;
65
+		global $conf, $user, $langs, $db;
66
+		$this->savconf = $conf;
67
+		$this->savuser = $user;
68
+		$this->savlangs = $langs;
69
+		$this->savdb = $db;
70 70
 
71 71
 		print __METHOD__." db->type=".$db->type." user->id=".$user->id;
72 72
 		//print " - db ".$db->db;
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
 	// Static methods
77 77
   	public static function setUpBeforeClass()
78 78
     {
79
-    	global $conf,$user,$langs,$db;
80
-		$db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
79
+    	global $conf, $user, $langs, $db;
80
+		$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
81 81
 
82 82
     	print __METHOD__."\n";
83 83
     }
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
     // tear down after class
86 86
     public static function tearDownAfterClass()
87 87
     {
88
-    	global $conf,$user,$langs,$db;
88
+    	global $conf, $user, $langs, $db;
89 89
 		$db->rollback();
90 90
 
91 91
 		print __METHOD__."\n";
@@ -98,11 +98,11 @@  discard block
 block discarded – undo
98 98
 	 */
99 99
     protected function setUp()
100 100
     {
101
-    	global $conf,$user,$langs,$db;
102
-		$conf=$this->savconf;
103
-		$user=$this->savuser;
104
-		$langs=$this->savlangs;
105
-		$db=$this->savdb;
101
+    	global $conf, $user, $langs, $db;
102
+		$conf = $this->savconf;
103
+		$user = $this->savuser;
104
+		$langs = $this->savlangs;
105
+		$db = $this->savdb;
106 106
 
107 107
 		print __METHOD__."\n";
108 108
     }
@@ -123,32 +123,32 @@  discard block
 block discarded – undo
123 123
      */
124 124
     public function testModulesInit()
125 125
     {
126
-    	global $conf,$user,$langs,$db;
127
-		$conf=$this->savconf;
128
-		$user=$this->savuser;
129
-		$langs=$this->savlangs;
130
-		$db=$this->savdb;
131
-
132
-		$modulelist=array('Accounting','Adherent','Agenda','Banque','Barcode','BlockedLog','Bookmark',
133
-		'CashDesk','Categorie','ClickToDial','Collab','Commande','Comptabilite','Contrat','Cron','Deplacement','DocumentGeneration','Don','DynamicPrices',
134
-		'ECM','Expedition','ExpenseReport','Export','ExternalRss','ExternalSite',
135
-		'Facture','Fckeditor','Ficheinter','Fournisseur','FTP','GeoIPMaxmind','Gravatar','Holiday','HRM','Import','Incoterm','Label','Ldap','Loan',
136
-		'Mailing','MailmanSpip','Margin','ModuleBuilder','MultiCurrency',
137
-		'Notification','Oauth','OpenSurvey','Paybox','Paypal','Prelevement','Printing','Product','ProductBatch','Projet','Propale','ReceiptPrinter','Resource',
138
-		'Salaries','Service','Skype','Societe','Stock','Stripe','SupplierProposal','Syslog','Tax','Ticket','User','Variants','WebServices','WebServicesClient','Website','Workflow');
139
-		foreach($modulelist as $modlabel)
126
+    	global $conf, $user, $langs, $db;
127
+		$conf = $this->savconf;
128
+		$user = $this->savuser;
129
+		$langs = $this->savlangs;
130
+		$db = $this->savdb;
131
+
132
+		$modulelist = array('Accounting', 'Adherent', 'Agenda', 'Banque', 'Barcode', 'BlockedLog', 'Bookmark',
133
+		'CashDesk', 'Categorie', 'ClickToDial', 'Collab', 'Commande', 'Comptabilite', 'Contrat', 'Cron', 'Deplacement', 'DocumentGeneration', 'Don', 'DynamicPrices',
134
+		'ECM', 'Expedition', 'ExpenseReport', 'Export', 'ExternalRss', 'ExternalSite',
135
+		'Facture', 'Fckeditor', 'Ficheinter', 'Fournisseur', 'FTP', 'GeoIPMaxmind', 'Gravatar', 'Holiday', 'HRM', 'Import', 'Incoterm', 'Label', 'Ldap', 'Loan',
136
+		'Mailing', 'MailmanSpip', 'Margin', 'ModuleBuilder', 'MultiCurrency',
137
+		'Notification', 'Oauth', 'OpenSurvey', 'Paybox', 'Paypal', 'Prelevement', 'Printing', 'Product', 'ProductBatch', 'Projet', 'Propale', 'ReceiptPrinter', 'Resource',
138
+		'Salaries', 'Service', 'Skype', 'Societe', 'Stock', 'Stripe', 'SupplierProposal', 'Syslog', 'Tax', 'Ticket', 'User', 'Variants', 'WebServices', 'WebServicesClient', 'Website', 'Workflow');
139
+		foreach ($modulelist as $modlabel)
140 140
 		{
141 141
     		require_once DOL_DOCUMENT_ROOT.'/core/modules/mod'.$modlabel.'.class.php';
142
-            $class='mod'.$modlabel;
143
-    		$mod=new $class($db);
144
-            $result=$mod->remove();
145
-            $result=$mod->init();
142
+            $class = 'mod'.$modlabel;
143
+    		$mod = new $class($db);
144
+            $result = $mod->remove();
145
+            $result = $mod->init();
146 146
         	$this->assertLessThan($result, 0, $modlabel);
147 147
         	print __METHOD__." test remove/init for module ".$modlabel.", result=".$result."\n";
148 148
 
149 149
         	if (in_array($modlabel, array('Ldap', 'MailmanSpip')))
150 150
         	{
151
-        	    $result=$mod->remove();
151
+        	    $result = $mod->remove();
152 152
         	}
153 153
 		}
154 154
 
Please login to merge, or discard this patch.
dolibarr/test/phpunit/FactureFournisseurTest.php 2 patches
Indentation   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -32,9 +32,9 @@  discard block
 block discarded – undo
32 32
 
33 33
 if (empty($user->id))
34 34
 {
35
-	print "Load permissions for admin user nb 1\n";
36
-	$user->fetch(1);
37
-	$user->getrights();
35
+    print "Load permissions for admin user nb 1\n";
36
+    $user->fetch(1);
37
+    $user->getrights();
38 38
 }
39 39
 $conf->global->MAIN_DISABLE_ALL_MAILS=1;
40 40
 
@@ -48,74 +48,74 @@  discard block
 block discarded – undo
48 48
  */
49 49
 class FactureFournisseurTest extends PHPUnit_Framework_TestCase
50 50
 {
51
-	protected $savconf;
52
-	protected $savuser;
53
-	protected $savlangs;
54
-	protected $savdb;
55
-
56
-	/**
57
-	 * Constructor
58
-	 * We save global variables into local variables
59
-	 *
60
-	 * @return FactureFournisseurTest
61
-	 */
62
-	function __construct()
63
-	{
64
-		parent::__construct();
65
-
66
-		//$this->sharedFixture
67
-		global $conf,$user,$langs,$db;
68
-		$this->savconf=$conf;
69
-		$this->savuser=$user;
70
-		$this->savlangs=$langs;
71
-		$this->savdb=$db;
72
-
73
-		print __METHOD__." db->type=".$db->type." user->id=".$user->id;
74
-		//print " - db ".$db->db;
75
-		print "\n";
76
-	}
77
-
78
-	// Static methods
79
-  	public static function setUpBeforeClass()
51
+    protected $savconf;
52
+    protected $savuser;
53
+    protected $savlangs;
54
+    protected $savdb;
55
+
56
+    /**
57
+     * Constructor
58
+     * We save global variables into local variables
59
+     *
60
+     * @return FactureFournisseurTest
61
+     */
62
+    function __construct()
80 63
     {
81
-    	global $conf,$user,$langs,$db;
82
-		$db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
64
+        parent::__construct();
83 65
 
84
-    	print __METHOD__."\n";
66
+        //$this->sharedFixture
67
+        global $conf,$user,$langs,$db;
68
+        $this->savconf=$conf;
69
+        $this->savuser=$user;
70
+        $this->savlangs=$langs;
71
+        $this->savdb=$db;
72
+
73
+        print __METHOD__." db->type=".$db->type." user->id=".$user->id;
74
+        //print " - db ".$db->db;
75
+        print "\n";
76
+    }
77
+
78
+    // Static methods
79
+        public static function setUpBeforeClass()
80
+    {
81
+        global $conf,$user,$langs,$db;
82
+        $db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
83
+
84
+        print __METHOD__."\n";
85 85
     }
86 86
 
87 87
     // tear down after class
88 88
     public static function tearDownAfterClass()
89 89
     {
90
-    	global $conf,$user,$langs,$db;
91
-		$db->rollback();
90
+        global $conf,$user,$langs,$db;
91
+        $db->rollback();
92 92
 
93
-		print __METHOD__."\n";
93
+        print __METHOD__."\n";
94 94
     }
95 95
 
96
-	/**
97
-	 * Init phpunit tests
98
-	 *
99
-	 * @return	void
100
-	 */
96
+    /**
97
+     * Init phpunit tests
98
+     *
99
+     * @return	void
100
+     */
101 101
     protected function setUp()
102 102
     {
103
-    	global $conf,$user,$langs,$db;
104
-		$conf=$this->savconf;
105
-		$user=$this->savuser;
106
-		$langs=$this->savlangs;
107
-		$db=$this->savdb;
103
+        global $conf,$user,$langs,$db;
104
+        $conf=$this->savconf;
105
+        $user=$this->savuser;
106
+        $langs=$this->savlangs;
107
+        $db=$this->savdb;
108 108
 
109
-		print __METHOD__."\n";
109
+        print __METHOD__."\n";
110 110
     }
111
-	/**
112
-	 * End phpunit tests
113
-	 *
114
-	 * @return	void
115
-	 */
111
+    /**
112
+     * End phpunit tests
113
+     *
114
+     * @return	void
115
+     */
116 116
     protected function tearDown()
117 117
     {
118
-    	print __METHOD__."\n";
118
+        print __METHOD__."\n";
119 119
     }
120 120
 
121 121
     /**
@@ -125,19 +125,19 @@  discard block
 block discarded – undo
125 125
      */
126 126
     public function testFactureFournisseurCreate()
127 127
     {
128
-    	global $conf,$user,$langs,$db;
129
-		$conf=$this->savconf;
130
-		$user=$this->savuser;
131
-		$langs=$this->savlangs;
132
-		$db=$this->savdb;
133
-
134
-		$localobject=new FactureFournisseur($this->savdb);
135
-    	$localobject->initAsSpecimen();
136
-    	$result=$localobject->create($user);
137
-
138
-    	$this->assertLessThan($result, 0);
139
-    	print __METHOD__." result=".$result."\n";
140
-    	return $result;
128
+        global $conf,$user,$langs,$db;
129
+        $conf=$this->savconf;
130
+        $user=$this->savuser;
131
+        $langs=$this->savlangs;
132
+        $db=$this->savdb;
133
+
134
+        $localobject=new FactureFournisseur($this->savdb);
135
+        $localobject->initAsSpecimen();
136
+        $result=$localobject->create($user);
137
+
138
+        $this->assertLessThan($result, 0);
139
+        print __METHOD__." result=".$result."\n";
140
+        return $result;
141 141
     }
142 142
 
143 143
     /**
@@ -151,18 +151,18 @@  discard block
 block discarded – undo
151 151
      */
152 152
     public function testFactureFournisseurFetch($id)
153 153
     {
154
-    	global $conf,$user,$langs,$db;
155
-		$conf=$this->savconf;
156
-		$user=$this->savuser;
157
-		$langs=$this->savlangs;
158
-		$db=$this->savdb;
159
-
160
-		$localobject=new FactureFournisseur($this->savdb);
161
-    	$result=$localobject->fetch($id);
162
-
163
-    	$this->assertLessThan($result, 0);
164
-    	print __METHOD__." id=".$id." result=".$result."\n";
165
-    	return $localobject;
154
+        global $conf,$user,$langs,$db;
155
+        $conf=$this->savconf;
156
+        $user=$this->savuser;
157
+        $langs=$this->savlangs;
158
+        $db=$this->savdb;
159
+
160
+        $localobject=new FactureFournisseur($this->savdb);
161
+        $result=$localobject->fetch($id);
162
+
163
+        $this->assertLessThan($result, 0);
164
+        print __METHOD__." id=".$id." result=".$result."\n";
165
+        return $localobject;
166 166
     }
167 167
 
168 168
     /**
@@ -176,18 +176,18 @@  discard block
 block discarded – undo
176 176
      */
177 177
     public function testFactureFournisseurUpdate($localobject)
178 178
     {
179
-    	global $conf,$user,$langs,$db;
180
-		$conf=$this->savconf;
181
-		$user=$this->savuser;
182
-		$langs=$this->savlangs;
183
-		$db=$this->savdb;
184
-
185
-		$localobject->note='New note after update';
186
-    	$result=$localobject->update($user);
187
-
188
-    	print __METHOD__." id=".$localobject->id." result=".$result."\n";
189
-    	$this->assertLessThan($result, 0);
190
-    	return $localobject;
179
+        global $conf,$user,$langs,$db;
180
+        $conf=$this->savconf;
181
+        $user=$this->savuser;
182
+        $langs=$this->savlangs;
183
+        $db=$this->savdb;
184
+
185
+        $localobject->note='New note after update';
186
+        $result=$localobject->update($user);
187
+
188
+        print __METHOD__." id=".$localobject->id." result=".$result."\n";
189
+        $this->assertLessThan($result, 0);
190
+        return $localobject;
191 191
     }
192 192
 
193 193
     /**
@@ -201,20 +201,20 @@  discard block
 block discarded – undo
201 201
      */
202 202
     public function testFactureFournisseurValid($localobject)
203 203
     {
204
-    	global $conf,$user,$langs,$db;
205
-		$conf=$this->savconf;
206
-		$user=$this->savuser;
207
-		$langs=$this->savlangs;
208
-		$db=$this->savdb;
204
+        global $conf,$user,$langs,$db;
205
+        $conf=$this->savconf;
206
+        $user=$this->savuser;
207
+        $langs=$this->savlangs;
208
+        $db=$this->savdb;
209 209
 
210
-    	$result=$localobject->validate($user);
211
-    	print __METHOD__." id=".$localobject->id." result=".$result."\n";
210
+        $result=$localobject->validate($user);
211
+        print __METHOD__." id=".$localobject->id." result=".$result."\n";
212 212
 
213
-    	$this->assertLessThan($result, 0);
214
-    	return $localobject;
213
+        $this->assertLessThan($result, 0);
214
+        return $localobject;
215 215
     }
216 216
 
217
-   /**
217
+    /**
218 218
      * testFactureFournisseurOther
219 219
      *
220 220
      * @param	Object	$localobject		Supplier invoice
@@ -254,18 +254,18 @@  discard block
 block discarded – undo
254 254
      */
255 255
     public function testFactureFournisseurDelete($id)
256 256
     {
257
-    	global $conf,$user,$langs,$db;
258
-		$conf=$this->savconf;
259
-		$user=$this->savuser;
260
-		$langs=$this->savlangs;
261
-		$db=$this->savdb;
262
-
263
-		$localobject=new FactureFournisseur($this->savdb);
264
-    	$result=$localobject->fetch($id);
265
-		$result=$localobject->delete($user);
266
-
267
-		print __METHOD__." id=".$id." result=".$result."\n";
268
-    	$this->assertLessThan($result, 0);
269
-    	return $result;
257
+        global $conf,$user,$langs,$db;
258
+        $conf=$this->savconf;
259
+        $user=$this->savuser;
260
+        $langs=$this->savlangs;
261
+        $db=$this->savdb;
262
+
263
+        $localobject=new FactureFournisseur($this->savdb);
264
+        $result=$localobject->fetch($id);
265
+        $result=$localobject->delete($user);
266
+
267
+        print __METHOD__." id=".$id." result=".$result."\n";
268
+        $this->assertLessThan($result, 0);
269
+        return $result;
270 270
     }
271 271
 }
Please login to merge, or discard this patch.
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  *		\remarks	To run this script as CLI:  phpunit filename.php
25 25
  */
26 26
 
27
-global $conf,$user,$langs,$db;
27
+global $conf, $user, $langs, $db;
28 28
 //define('TEST_DB_FORCE_TYPE','mysql');	// This is to force using mysql driver
29 29
 //require_once 'PHPUnit/Autoload.php';
30 30
 require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	$user->fetch(1);
37 37
 	$user->getrights();
38 38
 }
39
-$conf->global->MAIN_DISABLE_ALL_MAILS=1;
39
+$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
40 40
 
41 41
 
42 42
 /**
@@ -64,11 +64,11 @@  discard block
 block discarded – undo
64 64
 		parent::__construct();
65 65
 
66 66
 		//$this->sharedFixture
67
-		global $conf,$user,$langs,$db;
68
-		$this->savconf=$conf;
69
-		$this->savuser=$user;
70
-		$this->savlangs=$langs;
71
-		$this->savdb=$db;
67
+		global $conf, $user, $langs, $db;
68
+		$this->savconf = $conf;
69
+		$this->savuser = $user;
70
+		$this->savlangs = $langs;
71
+		$this->savdb = $db;
72 72
 
73 73
 		print __METHOD__." db->type=".$db->type." user->id=".$user->id;
74 74
 		//print " - db ".$db->db;
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
 	// Static methods
79 79
   	public static function setUpBeforeClass()
80 80
     {
81
-    	global $conf,$user,$langs,$db;
82
-		$db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
81
+    	global $conf, $user, $langs, $db;
82
+		$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
83 83
 
84 84
     	print __METHOD__."\n";
85 85
     }
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
     // tear down after class
88 88
     public static function tearDownAfterClass()
89 89
     {
90
-    	global $conf,$user,$langs,$db;
90
+    	global $conf, $user, $langs, $db;
91 91
 		$db->rollback();
92 92
 
93 93
 		print __METHOD__."\n";
@@ -100,11 +100,11 @@  discard block
 block discarded – undo
100 100
 	 */
101 101
     protected function setUp()
102 102
     {
103
-    	global $conf,$user,$langs,$db;
104
-		$conf=$this->savconf;
105
-		$user=$this->savuser;
106
-		$langs=$this->savlangs;
107
-		$db=$this->savdb;
103
+    	global $conf, $user, $langs, $db;
104
+		$conf = $this->savconf;
105
+		$user = $this->savuser;
106
+		$langs = $this->savlangs;
107
+		$db = $this->savdb;
108 108
 
109 109
 		print __METHOD__."\n";
110 110
     }
@@ -125,15 +125,15 @@  discard block
 block discarded – undo
125 125
      */
126 126
     public function testFactureFournisseurCreate()
127 127
     {
128
-    	global $conf,$user,$langs,$db;
129
-		$conf=$this->savconf;
130
-		$user=$this->savuser;
131
-		$langs=$this->savlangs;
132
-		$db=$this->savdb;
128
+    	global $conf, $user, $langs, $db;
129
+		$conf = $this->savconf;
130
+		$user = $this->savuser;
131
+		$langs = $this->savlangs;
132
+		$db = $this->savdb;
133 133
 
134
-		$localobject=new FactureFournisseur($this->savdb);
134
+		$localobject = new FactureFournisseur($this->savdb);
135 135
     	$localobject->initAsSpecimen();
136
-    	$result=$localobject->create($user);
136
+    	$result = $localobject->create($user);
137 137
 
138 138
     	$this->assertLessThan($result, 0);
139 139
     	print __METHOD__." result=".$result."\n";
@@ -151,14 +151,14 @@  discard block
 block discarded – undo
151 151
      */
152 152
     public function testFactureFournisseurFetch($id)
153 153
     {
154
-    	global $conf,$user,$langs,$db;
155
-		$conf=$this->savconf;
156
-		$user=$this->savuser;
157
-		$langs=$this->savlangs;
158
-		$db=$this->savdb;
154
+    	global $conf, $user, $langs, $db;
155
+		$conf = $this->savconf;
156
+		$user = $this->savuser;
157
+		$langs = $this->savlangs;
158
+		$db = $this->savdb;
159 159
 
160
-		$localobject=new FactureFournisseur($this->savdb);
161
-    	$result=$localobject->fetch($id);
160
+		$localobject = new FactureFournisseur($this->savdb);
161
+    	$result = $localobject->fetch($id);
162 162
 
163 163
     	$this->assertLessThan($result, 0);
164 164
     	print __METHOD__." id=".$id." result=".$result."\n";
@@ -176,14 +176,14 @@  discard block
 block discarded – undo
176 176
      */
177 177
     public function testFactureFournisseurUpdate($localobject)
178 178
     {
179
-    	global $conf,$user,$langs,$db;
180
-		$conf=$this->savconf;
181
-		$user=$this->savuser;
182
-		$langs=$this->savlangs;
183
-		$db=$this->savdb;
179
+    	global $conf, $user, $langs, $db;
180
+		$conf = $this->savconf;
181
+		$user = $this->savuser;
182
+		$langs = $this->savlangs;
183
+		$db = $this->savdb;
184 184
 
185
-		$localobject->note='New note after update';
186
-    	$result=$localobject->update($user);
185
+		$localobject->note = 'New note after update';
186
+    	$result = $localobject->update($user);
187 187
 
188 188
     	print __METHOD__." id=".$localobject->id." result=".$result."\n";
189 189
     	$this->assertLessThan($result, 0);
@@ -201,13 +201,13 @@  discard block
 block discarded – undo
201 201
      */
202 202
     public function testFactureFournisseurValid($localobject)
203 203
     {
204
-    	global $conf,$user,$langs,$db;
205
-		$conf=$this->savconf;
206
-		$user=$this->savuser;
207
-		$langs=$this->savlangs;
208
-		$db=$this->savdb;
204
+    	global $conf, $user, $langs, $db;
205
+		$conf = $this->savconf;
206
+		$user = $this->savuser;
207
+		$langs = $this->savlangs;
208
+		$db = $this->savdb;
209 209
 
210
-    	$result=$localobject->validate($user);
210
+    	$result = $localobject->validate($user);
211 211
     	print __METHOD__." id=".$localobject->id." result=".$result."\n";
212 212
 
213 213
     	$this->assertLessThan($result, 0);
@@ -225,11 +225,11 @@  discard block
 block discarded – undo
225 225
      */
226 226
     public function testFactureFournisseurOther($localobject)
227 227
     {
228
-        global $conf,$user,$langs,$db;
229
-        $conf=$this->savconf;
230
-        $user=$this->savuser;
231
-        $langs=$this->savlangs;
232
-        $db=$this->savdb;
228
+        global $conf, $user, $langs, $db;
229
+        $conf = $this->savconf;
230
+        $user = $this->savuser;
231
+        $langs = $this->savlangs;
232
+        $db = $this->savdb;
233 233
 
234 234
         /*$result=$localobject->setstatus(0);
235 235
         print __METHOD__." id=".$localobject->id." result=".$result."\n";
@@ -254,15 +254,15 @@  discard block
 block discarded – undo
254 254
      */
255 255
     public function testFactureFournisseurDelete($id)
256 256
     {
257
-    	global $conf,$user,$langs,$db;
258
-		$conf=$this->savconf;
259
-		$user=$this->savuser;
260
-		$langs=$this->savlangs;
261
-		$db=$this->savdb;
262
-
263
-		$localobject=new FactureFournisseur($this->savdb);
264
-    	$result=$localobject->fetch($id);
265
-		$result=$localobject->delete($user);
257
+    	global $conf, $user, $langs, $db;
258
+		$conf = $this->savconf;
259
+		$user = $this->savuser;
260
+		$langs = $this->savlangs;
261
+		$db = $this->savdb;
262
+
263
+		$localobject = new FactureFournisseur($this->savdb);
264
+    	$result = $localobject->fetch($id);
265
+		$result = $localobject->delete($user);
266 266
 
267 267
 		print __METHOD__." id=".$id." result=".$result."\n";
268 268
     	$this->assertLessThan($result, 0);
Please login to merge, or discard this patch.
dolibarr/test/phpunit/PropalTest.php 2 patches
Indentation   +126 added lines, -126 removed lines patch added patch discarded remove patch
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
 
32 32
 if (empty($user->id))
33 33
 {
34
-	print "Load permissions for admin user nb 1\n";
35
-	$user->fetch(1);
36
-	$user->getrights();
34
+    print "Load permissions for admin user nb 1\n";
35
+    $user->fetch(1);
36
+    $user->getrights();
37 37
 }
38 38
 $conf->global->MAIN_DISABLE_ALL_MAILS=1;
39 39
 
@@ -47,75 +47,75 @@  discard block
 block discarded – undo
47 47
  */
48 48
 class PropalTest extends PHPUnit_Framework_TestCase
49 49
 {
50
-	protected $savconf;
51
-	protected $savuser;
52
-	protected $savlangs;
53
-	protected $savdb;
54
-
55
-	/**
56
-	 * Constructor
57
-	 * We save global variables into local variables
58
-	 *
59
-	 * @return PropalTest
60
-	 */
61
-	function __construct()
62
-	{
63
-		parent::__construct();
64
-
65
-		//$this->sharedFixture
66
-		global $conf,$user,$langs,$db;
67
-		$this->savconf=$conf;
68
-		$this->savuser=$user;
69
-		$this->savlangs=$langs;
70
-		$this->savdb=$db;
71
-
72
-		print __METHOD__." db->type=".$db->type." user->id=".$user->id;
73
-		//print " - db ".$db->db;
74
-		print "\n";
75
-	}
76
-
77
-	// Static methods
78
-  	public static function setUpBeforeClass()
50
+    protected $savconf;
51
+    protected $savuser;
52
+    protected $savlangs;
53
+    protected $savdb;
54
+
55
+    /**
56
+     * Constructor
57
+     * We save global variables into local variables
58
+     *
59
+     * @return PropalTest
60
+     */
61
+    function __construct()
62
+    {
63
+        parent::__construct();
64
+
65
+        //$this->sharedFixture
66
+        global $conf,$user,$langs,$db;
67
+        $this->savconf=$conf;
68
+        $this->savuser=$user;
69
+        $this->savlangs=$langs;
70
+        $this->savdb=$db;
71
+
72
+        print __METHOD__." db->type=".$db->type." user->id=".$user->id;
73
+        //print " - db ".$db->db;
74
+        print "\n";
75
+    }
76
+
77
+    // Static methods
78
+        public static function setUpBeforeClass()
79 79
     {
80
-    	global $conf,$user,$langs,$db;
81
-		$db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
80
+        global $conf,$user,$langs,$db;
81
+        $db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
82 82
 
83
-    	print __METHOD__."\n";
83
+        print __METHOD__."\n";
84 84
     }
85 85
 
86 86
     // tear down after class
87 87
     public static function tearDownAfterClass()
88 88
     {
89
-    	global $conf,$user,$langs,$db;
90
-		$db->rollback();
89
+        global $conf,$user,$langs,$db;
90
+        $db->rollback();
91 91
 
92
-		print __METHOD__."\n";
92
+        print __METHOD__."\n";
93 93
     }
94 94
 
95
-	/**
96
-	 * Init phpunit tests
97
-	 *
98
-	 * @return	void
99
-	 */
95
+    /**
96
+     * Init phpunit tests
97
+     *
98
+     * @return	void
99
+     */
100 100
     protected function setUp()
101 101
     {
102
-    	global $conf,$user,$langs,$db;
103
-		$conf=$this->savconf;
104
-		$user=$this->savuser;
105
-		$langs=$this->savlangs;
106
-		$db=$this->savdb;
107
-
108
-		print __METHOD__."\n";
109
-		//print $db->getVersion()."\n";
102
+        global $conf,$user,$langs,$db;
103
+        $conf=$this->savconf;
104
+        $user=$this->savuser;
105
+        $langs=$this->savlangs;
106
+        $db=$this->savdb;
107
+
108
+        print __METHOD__."\n";
109
+        //print $db->getVersion()."\n";
110 110
     }
111
-	/**
112
-	 * End phpunit tests
113
-	 *
114
-	 * @return	void
115
-	 */
111
+    /**
112
+     * End phpunit tests
113
+     *
114
+     * @return	void
115
+     */
116 116
     protected function tearDown()
117 117
     {
118
-    	print __METHOD__."\n";
118
+        print __METHOD__."\n";
119 119
     }
120 120
 
121 121
     /**
@@ -125,19 +125,19 @@  discard block
 block discarded – undo
125 125
      */
126 126
     public function testPropalCreate()
127 127
     {
128
-    	global $conf,$user,$langs,$db;
129
-		$conf=$this->savconf;
130
-		$user=$this->savuser;
131
-		$langs=$this->savlangs;
132
-		$db=$this->savdb;
133
-
134
-		$localobject=new Propal($this->savdb);
135
-    	$localobject->initAsSpecimen();
136
-    	$result=$localobject->create($user);
137
-
138
-    	$this->assertLessThan($result, 0);
139
-    	print __METHOD__." result=".$result."\n";
140
-    	return $result;
128
+        global $conf,$user,$langs,$db;
129
+        $conf=$this->savconf;
130
+        $user=$this->savuser;
131
+        $langs=$this->savlangs;
132
+        $db=$this->savdb;
133
+
134
+        $localobject=new Propal($this->savdb);
135
+        $localobject->initAsSpecimen();
136
+        $result=$localobject->create($user);
137
+
138
+        $this->assertLessThan($result, 0);
139
+        print __METHOD__." result=".$result."\n";
140
+        return $result;
141 141
     }
142 142
 
143 143
     /**
@@ -151,18 +151,18 @@  discard block
 block discarded – undo
151 151
      */
152 152
     public function testPropalFetch($id)
153 153
     {
154
-    	global $conf,$user,$langs,$db;
155
-		$conf=$this->savconf;
156
-		$user=$this->savuser;
157
-		$langs=$this->savlangs;
158
-		$db=$this->savdb;
159
-
160
-		$localobject=new Propal($this->savdb);
161
-    	$result=$localobject->fetch($id);
162
-
163
-    	$this->assertLessThan($result, 0);
164
-    	print __METHOD__." id=".$id." result=".$result."\n";
165
-    	return $localobject;
154
+        global $conf,$user,$langs,$db;
155
+        $conf=$this->savconf;
156
+        $user=$this->savuser;
157
+        $langs=$this->savlangs;
158
+        $db=$this->savdb;
159
+
160
+        $localobject=new Propal($this->savdb);
161
+        $result=$localobject->fetch($id);
162
+
163
+        $this->assertLessThan($result, 0);
164
+        print __METHOD__." id=".$id." result=".$result."\n";
165
+        return $localobject;
166 166
     }
167 167
 
168 168
     /**
@@ -176,18 +176,18 @@  discard block
 block discarded – undo
176 176
      */
177 177
     public function testPropalUpdate($localobject)
178 178
     {
179
-    	global $conf,$user,$langs,$db;
180
-    	$conf=$this->savconf;
181
-    	$user=$this->savuser;
182
-    	$langs=$this->savlangs;
183
-    	$db=$this->savdb;
184
-
185
-    	$localobject->note_private='New note private after update';
186
-    	$result=$localobject->update($user);
187
-
188
-    	$this->assertLessThan($result, 0);
189
-    	print __METHOD__." id=".$id." result=".$result."\n";
190
-    	return $localobject;
179
+        global $conf,$user,$langs,$db;
180
+        $conf=$this->savconf;
181
+        $user=$this->savuser;
182
+        $langs=$this->savlangs;
183
+        $db=$this->savdb;
184
+
185
+        $localobject->note_private='New note private after update';
186
+        $result=$localobject->update($user);
187
+
188
+        $this->assertLessThan($result, 0);
189
+        print __METHOD__." id=".$id." result=".$result."\n";
190
+        return $localobject;
191 191
     }
192 192
 
193 193
     /**
@@ -201,18 +201,18 @@  discard block
 block discarded – undo
201 201
      */
202 202
     public function testPropalAddLine($localobject)
203 203
     {
204
-    	global $conf,$user,$langs,$db;
205
-    	$conf=$this->savconf;
206
-    	$user=$this->savuser;
207
-    	$langs=$this->savlangs;
208
-    	$db=$this->savdb;
204
+        global $conf,$user,$langs,$db;
205
+        $conf=$this->savconf;
206
+        $user=$this->savuser;
207
+        $langs=$this->savlangs;
208
+        $db=$this->savdb;
209 209
 
210 210
         $localobject->fetch_thirdparty();
211
-    	$result=$localobject->addline('Added line', 10, 2, 19.6);
211
+        $result=$localobject->addline('Added line', 10, 2, 19.6);
212 212
 
213
-    	$this->assertLessThan($result, 0);
214
-    	print __METHOD__." id=".$localobject->id." result=".$result."\n";
215
-    	return $localobject;
213
+        $this->assertLessThan($result, 0);
214
+        print __METHOD__." id=".$localobject->id." result=".$result."\n";
215
+        return $localobject;
216 216
     }
217 217
 
218 218
     /**
@@ -226,20 +226,20 @@  discard block
 block discarded – undo
226 226
      */
227 227
     public function testPropalValid($localobject)
228 228
     {
229
-    	global $conf,$user,$langs,$db;
230
-		$conf=$this->savconf;
231
-		$user=$this->savuser;
232
-		$langs=$this->savlangs;
233
-		$db=$this->savdb;
229
+        global $conf,$user,$langs,$db;
230
+        $conf=$this->savconf;
231
+        $user=$this->savuser;
232
+        $langs=$this->savlangs;
233
+        $db=$this->savdb;
234 234
 
235
-    	$result=$localobject->valid($user);
235
+        $result=$localobject->valid($user);
236 236
 
237
-    	print __METHOD__." id=".$localobject->id." result=".$result."\n";
238
-    	$this->assertLessThan($result, 0);
239
-    	return $localobject;
237
+        print __METHOD__." id=".$localobject->id." result=".$result."\n";
238
+        $this->assertLessThan($result, 0);
239
+        return $localobject;
240 240
     }
241 241
 
242
-   /**
242
+    /**
243 243
      * testPropalOther
244 244
      *
245 245
      * @param	Propal	$localobject	Proposal
@@ -279,18 +279,18 @@  discard block
 block discarded – undo
279 279
      */
280 280
     public function testPropalDelete($id)
281 281
     {
282
-    	global $conf,$user,$langs,$db;
283
-		$conf=$this->savconf;
284
-		$user=$this->savuser;
285
-		$langs=$this->savlangs;
286
-		$db=$this->savdb;
287
-
288
-		$localobject=new Propal($this->savdb);
289
-    	$result=$localobject->fetch($id);
290
-		$result=$localobject->delete($user);
291
-
292
-		print __METHOD__." id=".$id." result=".$result."\n";
293
-    	$this->assertLessThan($result, 0);
294
-    	return $result;
282
+        global $conf,$user,$langs,$db;
283
+        $conf=$this->savconf;
284
+        $user=$this->savuser;
285
+        $langs=$this->savlangs;
286
+        $db=$this->savdb;
287
+
288
+        $localobject=new Propal($this->savdb);
289
+        $result=$localobject->fetch($id);
290
+        $result=$localobject->delete($user);
291
+
292
+        print __METHOD__." id=".$id." result=".$result."\n";
293
+        $this->assertLessThan($result, 0);
294
+        return $result;
295 295
     }
296 296
 }
Please login to merge, or discard this patch.
Spacing   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  *		\remarks	To run this script as CLI:  phpunit filename.php
24 24
  */
25 25
 
26
-global $conf,$user,$langs,$db;
26
+global $conf, $user, $langs, $db;
27 27
 //define('TEST_DB_FORCE_TYPE','mysql');	// This is to force using mysql driver
28 28
 //require_once 'PHPUnit/Autoload.php';
29 29
 require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	$user->fetch(1);
36 36
 	$user->getrights();
37 37
 }
38
-$conf->global->MAIN_DISABLE_ALL_MAILS=1;
38
+$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
39 39
 
40 40
 
41 41
 /**
@@ -63,11 +63,11 @@  discard block
 block discarded – undo
63 63
 		parent::__construct();
64 64
 
65 65
 		//$this->sharedFixture
66
-		global $conf,$user,$langs,$db;
67
-		$this->savconf=$conf;
68
-		$this->savuser=$user;
69
-		$this->savlangs=$langs;
70
-		$this->savdb=$db;
66
+		global $conf, $user, $langs, $db;
67
+		$this->savconf = $conf;
68
+		$this->savuser = $user;
69
+		$this->savlangs = $langs;
70
+		$this->savdb = $db;
71 71
 
72 72
 		print __METHOD__." db->type=".$db->type." user->id=".$user->id;
73 73
 		//print " - db ".$db->db;
@@ -77,8 +77,8 @@  discard block
 block discarded – undo
77 77
 	// Static methods
78 78
   	public static function setUpBeforeClass()
79 79
     {
80
-    	global $conf,$user,$langs,$db;
81
-		$db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
80
+    	global $conf, $user, $langs, $db;
81
+		$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
82 82
 
83 83
     	print __METHOD__."\n";
84 84
     }
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
     // tear down after class
87 87
     public static function tearDownAfterClass()
88 88
     {
89
-    	global $conf,$user,$langs,$db;
89
+    	global $conf, $user, $langs, $db;
90 90
 		$db->rollback();
91 91
 
92 92
 		print __METHOD__."\n";
@@ -99,11 +99,11 @@  discard block
 block discarded – undo
99 99
 	 */
100 100
     protected function setUp()
101 101
     {
102
-    	global $conf,$user,$langs,$db;
103
-		$conf=$this->savconf;
104
-		$user=$this->savuser;
105
-		$langs=$this->savlangs;
106
-		$db=$this->savdb;
102
+    	global $conf, $user, $langs, $db;
103
+		$conf = $this->savconf;
104
+		$user = $this->savuser;
105
+		$langs = $this->savlangs;
106
+		$db = $this->savdb;
107 107
 
108 108
 		print __METHOD__."\n";
109 109
 		//print $db->getVersion()."\n";
@@ -125,15 +125,15 @@  discard block
 block discarded – undo
125 125
      */
126 126
     public function testPropalCreate()
127 127
     {
128
-    	global $conf,$user,$langs,$db;
129
-		$conf=$this->savconf;
130
-		$user=$this->savuser;
131
-		$langs=$this->savlangs;
132
-		$db=$this->savdb;
128
+    	global $conf, $user, $langs, $db;
129
+		$conf = $this->savconf;
130
+		$user = $this->savuser;
131
+		$langs = $this->savlangs;
132
+		$db = $this->savdb;
133 133
 
134
-		$localobject=new Propal($this->savdb);
134
+		$localobject = new Propal($this->savdb);
135 135
     	$localobject->initAsSpecimen();
136
-    	$result=$localobject->create($user);
136
+    	$result = $localobject->create($user);
137 137
 
138 138
     	$this->assertLessThan($result, 0);
139 139
     	print __METHOD__." result=".$result."\n";
@@ -151,14 +151,14 @@  discard block
 block discarded – undo
151 151
      */
152 152
     public function testPropalFetch($id)
153 153
     {
154
-    	global $conf,$user,$langs,$db;
155
-		$conf=$this->savconf;
156
-		$user=$this->savuser;
157
-		$langs=$this->savlangs;
158
-		$db=$this->savdb;
154
+    	global $conf, $user, $langs, $db;
155
+		$conf = $this->savconf;
156
+		$user = $this->savuser;
157
+		$langs = $this->savlangs;
158
+		$db = $this->savdb;
159 159
 
160
-		$localobject=new Propal($this->savdb);
161
-    	$result=$localobject->fetch($id);
160
+		$localobject = new Propal($this->savdb);
161
+    	$result = $localobject->fetch($id);
162 162
 
163 163
     	$this->assertLessThan($result, 0);
164 164
     	print __METHOD__." id=".$id." result=".$result."\n";
@@ -176,14 +176,14 @@  discard block
 block discarded – undo
176 176
      */
177 177
     public function testPropalUpdate($localobject)
178 178
     {
179
-    	global $conf,$user,$langs,$db;
180
-    	$conf=$this->savconf;
181
-    	$user=$this->savuser;
182
-    	$langs=$this->savlangs;
183
-    	$db=$this->savdb;
179
+    	global $conf, $user, $langs, $db;
180
+    	$conf = $this->savconf;
181
+    	$user = $this->savuser;
182
+    	$langs = $this->savlangs;
183
+    	$db = $this->savdb;
184 184
 
185
-    	$localobject->note_private='New note private after update';
186
-    	$result=$localobject->update($user);
185
+    	$localobject->note_private = 'New note private after update';
186
+    	$result = $localobject->update($user);
187 187
 
188 188
     	$this->assertLessThan($result, 0);
189 189
     	print __METHOD__." id=".$id." result=".$result."\n";
@@ -201,14 +201,14 @@  discard block
 block discarded – undo
201 201
      */
202 202
     public function testPropalAddLine($localobject)
203 203
     {
204
-    	global $conf,$user,$langs,$db;
205
-    	$conf=$this->savconf;
206
-    	$user=$this->savuser;
207
-    	$langs=$this->savlangs;
208
-    	$db=$this->savdb;
204
+    	global $conf, $user, $langs, $db;
205
+    	$conf = $this->savconf;
206
+    	$user = $this->savuser;
207
+    	$langs = $this->savlangs;
208
+    	$db = $this->savdb;
209 209
 
210 210
         $localobject->fetch_thirdparty();
211
-    	$result=$localobject->addline('Added line', 10, 2, 19.6);
211
+    	$result = $localobject->addline('Added line', 10, 2, 19.6);
212 212
 
213 213
     	$this->assertLessThan($result, 0);
214 214
     	print __METHOD__." id=".$localobject->id." result=".$result."\n";
@@ -226,13 +226,13 @@  discard block
 block discarded – undo
226 226
      */
227 227
     public function testPropalValid($localobject)
228 228
     {
229
-    	global $conf,$user,$langs,$db;
230
-		$conf=$this->savconf;
231
-		$user=$this->savuser;
232
-		$langs=$this->savlangs;
233
-		$db=$this->savdb;
229
+    	global $conf, $user, $langs, $db;
230
+		$conf = $this->savconf;
231
+		$user = $this->savuser;
232
+		$langs = $this->savlangs;
233
+		$db = $this->savdb;
234 234
 
235
-    	$result=$localobject->valid($user);
235
+    	$result = $localobject->valid($user);
236 236
 
237 237
     	print __METHOD__." id=".$localobject->id." result=".$result."\n";
238 238
     	$this->assertLessThan($result, 0);
@@ -250,11 +250,11 @@  discard block
 block discarded – undo
250 250
      */
251 251
     public function testPropalOther($localobject)
252 252
     {
253
-        global $conf,$user,$langs,$db;
254
-        $conf=$this->savconf;
255
-        $user=$this->savuser;
256
-        $langs=$this->savlangs;
257
-        $db=$this->savdb;
253
+        global $conf, $user, $langs, $db;
254
+        $conf = $this->savconf;
255
+        $user = $this->savuser;
256
+        $langs = $this->savlangs;
257
+        $db = $this->savdb;
258 258
 
259 259
         /*$result=$localobject->setstatus(0);
260 260
         print __METHOD__." id=".$localobject->id." result=".$result."\n";
@@ -279,15 +279,15 @@  discard block
 block discarded – undo
279 279
      */
280 280
     public function testPropalDelete($id)
281 281
     {
282
-    	global $conf,$user,$langs,$db;
283
-		$conf=$this->savconf;
284
-		$user=$this->savuser;
285
-		$langs=$this->savlangs;
286
-		$db=$this->savdb;
287
-
288
-		$localobject=new Propal($this->savdb);
289
-    	$result=$localobject->fetch($id);
290
-		$result=$localobject->delete($user);
282
+    	global $conf, $user, $langs, $db;
283
+		$conf = $this->savconf;
284
+		$user = $this->savuser;
285
+		$langs = $this->savlangs;
286
+		$db = $this->savdb;
287
+
288
+		$localobject = new Propal($this->savdb);
289
+    	$result = $localobject->fetch($id);
290
+		$result = $localobject->delete($user);
291 291
 
292 292
 		print __METHOD__." id=".$id." result=".$result."\n";
293 293
     	$this->assertLessThan($result, 0);
Please login to merge, or discard this patch.