Test Failed
Push — master ( e0c20c...b8c830 )
by Alxarafe
39:29
created
dolibarr/test/phpunit/ExportTest.php 3 patches
Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -51,74 +51,74 @@  discard block
 block discarded – undo
51 51
  */
52 52
 class ExportTest extends PHPUnit_Framework_TestCase
53 53
 {
54
-	protected $savconf;
55
-	protected $savuser;
56
-	protected $savlangs;
57
-	protected $savdb;
58
-
59
-	/**
60
-	 * Constructor
61
-	 * We save global variables into local variables
62
-	 *
63
-	 * @return ExportTest
64
-	 */
65
-	function __construct()
66
-	{
67
-		parent::__construct();
68
-
69
-		//$this->sharedFixture
70
-		global $conf,$user,$langs,$db;
71
-		$this->savconf=$conf;
72
-		$this->savuser=$user;
73
-		$this->savlangs=$langs;
74
-		$this->savdb=$db;
75
-
76
-		print __METHOD__." db->type=".$db->type." user->id=".$user->id;
77
-		//print " - db ".$db->db;
78
-		print "\n";
79
-	}
80
-
81
-	// Static methods
82
-  	public static function setUpBeforeClass()
54
+    protected $savconf;
55
+    protected $savuser;
56
+    protected $savlangs;
57
+    protected $savdb;
58
+
59
+    /**
60
+     * Constructor
61
+     * We save global variables into local variables
62
+     *
63
+     * @return ExportTest
64
+     */
65
+    function __construct()
83 66
     {
84
-    	global $conf,$user,$langs,$db;
85
-		//$db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
67
+        parent::__construct();
86 68
 
87
-    	print __METHOD__."\n";
69
+        //$this->sharedFixture
70
+        global $conf,$user,$langs,$db;
71
+        $this->savconf=$conf;
72
+        $this->savuser=$user;
73
+        $this->savlangs=$langs;
74
+        $this->savdb=$db;
75
+
76
+        print __METHOD__." db->type=".$db->type." user->id=".$user->id;
77
+        //print " - db ".$db->db;
78
+        print "\n";
79
+    }
80
+
81
+    // Static methods
82
+        public static function setUpBeforeClass()
83
+    {
84
+        global $conf,$user,$langs,$db;
85
+        //$db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
86
+
87
+        print __METHOD__."\n";
88 88
     }
89 89
 
90 90
     // tear down after class
91 91
     public static function tearDownAfterClass()
92 92
     {
93
-    	global $conf,$user,$langs,$db;
94
-		//$db->rollback();
93
+        global $conf,$user,$langs,$db;
94
+        //$db->rollback();
95 95
 
96
-		print __METHOD__."\n";
96
+        print __METHOD__."\n";
97 97
     }
98 98
 
99
-	/**
100
-	 * Init phpunit tests
101
-	 *
102
-	 * @return	void
103
-	 */
99
+    /**
100
+     * Init phpunit tests
101
+     *
102
+     * @return	void
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
-		print __METHOD__."\n";
112
+        print __METHOD__."\n";
113 113
     }
114
-	/**
115
-	 * End phpunit tests
116
-	 *
117
-	 * @return	void
118
-	 */
114
+    /**
115
+     * End phpunit tests
116
+     *
117
+     * @return	void
118
+     */
119 119
     protected function tearDown()
120 120
     {
121
-    	print __METHOD__."\n";
121
+        print __METHOD__."\n";
122 122
     }
123 123
 
124 124
 
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
      * Test export function for a personalized dataset
212 212
      *
213 213
      * @depends	testExportOther
214
-	 * @return void
214
+     * @return void
215 215
      */
216 216
     public function testExportPersonalizedExport()
217 217
     {
@@ -236,21 +236,21 @@  discard block
 block discarded – undo
236 236
 
237 237
         // Build export file
238 238
         $result=$objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql);
239
-		$expectedresult=1;
239
+        $expectedresult=1;
240 240
         $this->assertEquals($expectedresult,$result);
241 241
 
242 242
         $model='tsv';
243 243
 
244 244
         // Build export file
245 245
         $result=$objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql);
246
-		$expectedresult=1;
246
+        $expectedresult=1;
247 247
         $this->assertEquals($expectedresult,$result);
248 248
 
249 249
         $model='excel';
250 250
 
251 251
         // Build export file
252 252
         $result=$objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql);
253
-		$expectedresult=1;
253
+        $expectedresult=1;
254 254
         $this->assertEquals($expectedresult,$result);
255 255
 
256 256
         return true;
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
      */
265 265
     public function testExportPersonalizedWithFilter()
266 266
     {
267
-    	global $conf,$user,$langs,$db;
267
+        global $conf,$user,$langs,$db;
268 268
 /*
269 269
     	$sql = "SELECT f.ref as f_ref, f.total as f_total, f.tva as f_tva FROM ".MAIN_DB_PREFIX."facture f";
270 270
 
@@ -304,14 +304,14 @@  discard block
 block discarded – undo
304 304
     	$expectedresult=1;
305 305
     	$this->assertEquals($expectedresult,$result);
306 306
 */
307
-    	return true;
307
+        return true;
308 308
     }
309 309
 
310 310
     /**
311 311
      * Test export function for all dataset predefined into modules
312 312
      *
313 313
      * @depends	testExportPersonalizedWithFilter
314
-	 * @return void
314
+     * @return void
315 315
      */
316 316
     public function testExportModulesDatasets()
317 317
     {
@@ -330,26 +330,26 @@  discard block
 block discarded – undo
330 330
         // Loop on each dataset
331 331
         foreach($objexport->array_export_code as $key => $datatoexport)
332 332
         {
333
-        	$exportfile=$conf->export->dir_temp.'/'.$user->id.'/export_'.$datatoexport.'.csv';
334
-	        print "Process export for dataset ".$datatoexport." into ".$exportfile."\n";
335
-	        dol_delete_file($exportfile);
336
-
337
-	        // Generate $array_selected
338
-	        $i=0;
339
-	        $array_selected=array();
340
-			foreach($objexport->array_export_fields[$key] as $key => $val)
341
-			{
342
-				$array_selected[$key]=$i++;
343
-			}
344
-			//var_dump($array_selected);
345
-
346
-	        // Build export file
347
-        	$sql = "";
348
-			$result=$objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql);
349
-			$expectedresult=1;
350
-	        $this->assertEquals($expectedresult, $result, "Call build_file() to export ".$exportfile.' failed');
351
-	        $result=dol_is_file($exportfile);
352
-	        $this->assertTrue($result, 'File '.$exportfile.' not found');
333
+            $exportfile=$conf->export->dir_temp.'/'.$user->id.'/export_'.$datatoexport.'.csv';
334
+            print "Process export for dataset ".$datatoexport." into ".$exportfile."\n";
335
+            dol_delete_file($exportfile);
336
+
337
+            // Generate $array_selected
338
+            $i=0;
339
+            $array_selected=array();
340
+            foreach($objexport->array_export_fields[$key] as $key => $val)
341
+            {
342
+                $array_selected[$key]=$i++;
343
+            }
344
+            //var_dump($array_selected);
345
+
346
+            // Build export file
347
+            $sql = "";
348
+            $result=$objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql);
349
+            $expectedresult=1;
350
+            $this->assertEquals($expectedresult, $result, "Call build_file() to export ".$exportfile.' failed');
351
+            $result=dol_is_file($exportfile);
352
+            $this->assertTrue($result, 'File '.$exportfile.' not found');
353 353
         }
354 354
 
355 355
         return true;
Please login to merge, or discard this patch.
Spacing   +69 added lines, -69 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/exports/class/export.class.php';
31 31
 require_once dirname(__FILE__).'/../../htdocs/core/lib/files.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
 
45 45
 /**
@@ -67,11 +67,11 @@  discard block
 block discarded – undo
67 67
 		parent::__construct();
68 68
 
69 69
 		//$this->sharedFixture
70
-		global $conf,$user,$langs,$db;
71
-		$this->savconf=$conf;
72
-		$this->savuser=$user;
73
-		$this->savlangs=$langs;
74
-		$this->savdb=$db;
70
+		global $conf, $user, $langs, $db;
71
+		$this->savconf = $conf;
72
+		$this->savuser = $user;
73
+		$this->savlangs = $langs;
74
+		$this->savdb = $db;
75 75
 
76 76
 		print __METHOD__." db->type=".$db->type." user->id=".$user->id;
77 77
 		//print " - db ".$db->db;
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 	// Static methods
82 82
   	public static function setUpBeforeClass()
83 83
     {
84
-    	global $conf,$user,$langs,$db;
84
+    	global $conf, $user, $langs, $db;
85 85
 		//$db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
86 86
 
87 87
     	print __METHOD__."\n";
@@ -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,12 +129,12 @@  discard block
 block discarded – undo
129 129
      */
130 130
     public function testExportOther()
131 131
     {
132
-        global $conf,$user,$langs,$db;
132
+        global $conf, $user, $langs, $db;
133 133
 
134
-        $model='csv';
134
+        $model = 'csv';
135 135
 
136 136
         // Creation of class to export using model ExportXXX
137
-        $dir = DOL_DOCUMENT_ROOT . "/core/modules/export/";
137
+        $dir = DOL_DOCUMENT_ROOT."/core/modules/export/";
138 138
         $file = "export_".$model.".modules.php";
139 139
         $classname = "Export".$model;
140 140
         require_once $dir.$file;
@@ -143,64 +143,64 @@  discard block
 block discarded – undo
143 143
         // First test without option USE_STRICT_CSV_RULES
144 144
         unset($conf->global->USE_STRICT_CSV_RULES);
145 145
 
146
-        $valtotest='A simple string';
146
+        $valtotest = 'A simple string';
147 147
         print __METHOD__." valtotest=".$valtotest."\n";
148 148
         $result = $objmodel->csvClean($valtotest, $langs->charset_output);
149 149
         print __METHOD__." result=".$result."\n";
150 150
         $this->assertEquals($result, 'A simple string');
151 151
 
152
-        $valtotest='A string with , and ; inside';
152
+        $valtotest = 'A string with , and ; inside';
153 153
         print __METHOD__." valtotest=".$valtotest."\n";
154 154
         $result = $objmodel->csvClean($valtotest, $langs->charset_output);
155 155
         print __METHOD__." result=".$result."\n";
156 156
         $this->assertEquals($result, '"A string with , and ; inside"');
157 157
 
158
-        $valtotest='A string with " inside';
158
+        $valtotest = 'A string with " inside';
159 159
         print __METHOD__." valtotest=".$valtotest."\n";
160 160
         $result = $objmodel->csvClean($valtotest, $langs->charset_output);
161 161
         print __METHOD__." result=".$result."\n";
162 162
         $this->assertEquals($result, '"A string with "" inside"');
163 163
 
164
-        $valtotest='A string with " inside and '."\r\n".' carriage returns';
164
+        $valtotest = 'A string with " inside and '."\r\n".' carriage returns';
165 165
         print __METHOD__." valtotest=".$valtotest."\n";
166 166
         $result = $objmodel->csvClean($valtotest, $langs->charset_output);
167 167
         print __METHOD__." result=".$result."\n";
168 168
         $this->assertEquals($result, '"A string with "" inside and \n carriage returns"');
169 169
 
170
-        $valtotest='A string with <a href="aaa"><strong>html<br>content</strong></a> inside<br>'."\n";
170
+        $valtotest = 'A string with <a href="aaa"><strong>html<br>content</strong></a> inside<br>'."\n";
171 171
         print __METHOD__." valtotest=".$valtotest."\n";
172 172
         $result = $objmodel->csvClean($valtotest, $langs->charset_output);
173 173
         print __METHOD__." result=".$result."\n";
174 174
         $this->assertEquals($result, '"A string with <a href=""aaa""><strong>html<br>content</strong></a> inside"');
175 175
 
176 176
         // Same tests with strict mode
177
-        $conf->global->USE_STRICT_CSV_RULES=1;
177
+        $conf->global->USE_STRICT_CSV_RULES = 1;
178 178
 
179
-        $valtotest='A simple string';
179
+        $valtotest = 'A simple string';
180 180
         print __METHOD__." valtotest=".$valtotest."\n";
181 181
         $result = $objmodel->csvClean($valtotest, $langs->charset_output);
182 182
         print __METHOD__." result=".$result."\n";
183 183
         $this->assertEquals($result, 'A simple string');
184 184
 
185
-        $valtotest='A string with , and ; inside';
185
+        $valtotest = 'A string with , and ; inside';
186 186
         print __METHOD__." valtotest=".$valtotest."\n";
187 187
         $result = $objmodel->csvClean($valtotest, $langs->charset_output);
188 188
         print __METHOD__." result=".$result."\n";
189 189
         $this->assertEquals($result, '"A string with , and ; inside"');
190 190
 
191
-        $valtotest='A string with " inside';
191
+        $valtotest = 'A string with " inside';
192 192
         print __METHOD__." valtotest=".$valtotest."\n";
193 193
         $result = $objmodel->csvClean($valtotest, $langs->charset_output);
194 194
         print __METHOD__." result=".$result."\n";
195 195
         $this->assertEquals($result, '"A string with "" inside"');
196 196
 
197
-        $valtotest='A string with " inside and '."\r\n".' carriage returns';
197
+        $valtotest = 'A string with " inside and '."\r\n".' carriage returns';
198 198
         print __METHOD__." valtotest=".$valtotest."\n";
199 199
         $result = $objmodel->csvClean($valtotest, $langs->charset_output);
200 200
         print __METHOD__." result=".$result."\n";
201 201
         $this->assertEquals($result, "\"A string with \"\" inside and \r\n carriage returns\"");
202 202
 
203
-        $valtotest='A string with <a href="aaa"><strong>html<br>content</strong></a> inside<br>'."\n";
203
+        $valtotest = 'A string with <a href="aaa"><strong>html<br>content</strong></a> inside<br>'."\n";
204 204
         print __METHOD__." valtotest=".$valtotest."\n";
205 205
         $result = $objmodel->csvClean($valtotest, $langs->charset_output);
206 206
         print __METHOD__." result=".$result."\n";
@@ -215,43 +215,43 @@  discard block
 block discarded – undo
215 215
      */
216 216
     public function testExportPersonalizedExport()
217 217
     {
218
-        global $conf,$user,$langs,$db;
218
+        global $conf, $user, $langs, $db;
219 219
 
220 220
         $sql = "SELECT f.ref as f_ref, f.total as f_total, f.tva as f_tva FROM ".MAIN_DB_PREFIX."facture f";
221 221
 
222
-        $objexport=new Export($db);
222
+        $objexport = new Export($db);
223 223
         //$objexport->load_arrays($user,$datatoexport);
224 224
 
225 225
         // Define properties
226
-        $datatoexport='test';
226
+        $datatoexport = 'test';
227 227
         $array_selected = array("f.ref"=>1, "f.total"=>2, "f.tva"=>3);
228 228
         $array_export_fields = array("f.ref"=>"FacNumber", "f.total"=>"FacTotal", "f.tva"=>"FacVat");
229 229
         $array_alias = array("f_ref"=>"ref", "f_total"=>"total", "f_tva"=>"tva");
230
-        $objexport->array_export_fields[0]=$array_export_fields;
231
-        $objexport->array_export_alias[0]=$array_alias;
230
+        $objexport->array_export_fields[0] = $array_export_fields;
231
+        $objexport->array_export_alias[0] = $array_alias;
232 232
 
233 233
         dol_mkdir($conf->export->dir_temp);
234 234
 
235
-        $model='csv';
235
+        $model = 'csv';
236 236
 
237 237
         // Build export file
238
-        $result=$objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql);
239
-		$expectedresult=1;
240
-        $this->assertEquals($expectedresult,$result);
238
+        $result = $objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql);
239
+		$expectedresult = 1;
240
+        $this->assertEquals($expectedresult, $result);
241 241
 
242
-        $model='tsv';
242
+        $model = 'tsv';
243 243
 
244 244
         // Build export file
245
-        $result=$objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql);
246
-		$expectedresult=1;
247
-        $this->assertEquals($expectedresult,$result);
245
+        $result = $objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql);
246
+		$expectedresult = 1;
247
+        $this->assertEquals($expectedresult, $result);
248 248
 
249
-        $model='excel';
249
+        $model = 'excel';
250 250
 
251 251
         // Build export file
252
-        $result=$objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql);
253
-		$expectedresult=1;
254
-        $this->assertEquals($expectedresult,$result);
252
+        $result = $objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql);
253
+		$expectedresult = 1;
254
+        $this->assertEquals($expectedresult, $result);
255 255
 
256 256
         return true;
257 257
     }
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
      */
265 265
     public function testExportPersonalizedWithFilter()
266 266
     {
267
-    	global $conf,$user,$langs,$db;
267
+    	global $conf, $user, $langs, $db;
268 268
 /*
269 269
     	$sql = "SELECT f.ref as f_ref, f.total as f_total, f.tva as f_tva FROM ".MAIN_DB_PREFIX."facture f";
270 270
 
@@ -315,40 +315,40 @@  discard block
 block discarded – undo
315 315
      */
316 316
     public function testExportModulesDatasets()
317 317
     {
318
-        global $conf,$user,$langs,$db;
318
+        global $conf, $user, $langs, $db;
319 319
 
320
-        $model='csv';
320
+        $model = 'csv';
321 321
 
322
-        $filterdatatoexport='';
322
+        $filterdatatoexport = '';
323 323
         //$filterdatatoexport='';
324 324
         //$array_selected = array("s.rowid"=>1, "s.nom"=>2);	// Mut be fields found into declaration of dataset
325 325
 
326 326
         // Load properties of arrays to make export
327
-        $objexport=new Export($db);
328
-        $result=$objexport->load_arrays($user,$filterdatatoexport);	// This load ->array_export_xxx properties for datatoexport
327
+        $objexport = new Export($db);
328
+        $result = $objexport->load_arrays($user, $filterdatatoexport); // This load ->array_export_xxx properties for datatoexport
329 329
 
330 330
         // Loop on each dataset
331
-        foreach($objexport->array_export_code as $key => $datatoexport)
331
+        foreach ($objexport->array_export_code as $key => $datatoexport)
332 332
         {
333
-        	$exportfile=$conf->export->dir_temp.'/'.$user->id.'/export_'.$datatoexport.'.csv';
333
+        	$exportfile = $conf->export->dir_temp.'/'.$user->id.'/export_'.$datatoexport.'.csv';
334 334
 	        print "Process export for dataset ".$datatoexport." into ".$exportfile."\n";
335 335
 	        dol_delete_file($exportfile);
336 336
 
337 337
 	        // Generate $array_selected
338
-	        $i=0;
339
-	        $array_selected=array();
340
-			foreach($objexport->array_export_fields[$key] as $key => $val)
338
+	        $i = 0;
339
+	        $array_selected = array();
340
+			foreach ($objexport->array_export_fields[$key] as $key => $val)
341 341
 			{
342
-				$array_selected[$key]=$i++;
342
+				$array_selected[$key] = $i++;
343 343
 			}
344 344
 			//var_dump($array_selected);
345 345
 
346 346
 	        // Build export file
347 347
         	$sql = "";
348
-			$result=$objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql);
349
-			$expectedresult=1;
348
+			$result = $objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql);
349
+			$expectedresult = 1;
350 350
 	        $this->assertEquals($expectedresult, $result, "Call build_file() to export ".$exportfile.' failed');
351
-	        $result=dol_is_file($exportfile);
351
+	        $result = dol_is_file($exportfile);
352 352
 	        $this->assertTrue($result, 'File '.$exportfile.' not found');
353 353
         }
354 354
 
Please login to merge, or discard this patch.
Braces   +33 added lines, -10 removed lines patch added patch discarded remove patch
@@ -30,16 +30,39 @@
 block discarded – undo
30 30
 require_once dirname(__FILE__).'/../../htdocs/exports/class/export.class.php';
31 31
 require_once dirname(__FILE__).'/../../htdocs/core/lib/files.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
 
45 68
 /**
Please login to merge, or discard this patch.
dolibarr/test/phpunit/CommonObjectTest.php 2 patches
Indentation   +3 added lines, -3 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;
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
      * End phpunit tests
112 112
      *
113 113
      * @return  void
114
-    */
114
+     */
115 115
     protected function tearDown()
116 116
     {
117 117
         print __METHOD__."\n";
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 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,7 +77,7 @@  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
         $db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
82 82
 
83 83
         print __METHOD__."\n";
@@ -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,16 +125,16 @@  discard block
 block discarded – undo
125 125
      */
126 126
     public function testFetchUser()
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 Commande($this->savdb);
134
+        $localobject = new Commande($this->savdb);
135 135
         $localobject->fetch(1);
136 136
 
137
-        $result=$localobject->fetch_user(1);
137
+        $result = $localobject->fetch_user(1);
138 138
 
139 139
         print __METHOD__." result=".$result."\n";
140 140
         $this->assertLessThan($localobject->user->id, 0);
@@ -148,18 +148,18 @@  discard block
 block discarded – undo
148 148
      */
149 149
     public function testFetchProjet()
150 150
     {
151
-        global $conf,$user,$langs,$db;
152
-        $conf=$this->savconf;
153
-        $user=$this->savuser;
154
-        $langs=$this->savlangs;
155
-        $db=$this->savdb;
151
+        global $conf, $user, $langs, $db;
152
+        $conf = $this->savconf;
153
+        $user = $this->savuser;
154
+        $langs = $this->savlangs;
155
+        $db = $this->savdb;
156 156
 
157
-        $localobject=new Commande($this->savdb);
157
+        $localobject = new Commande($this->savdb);
158 158
         $localobject->fetch(1);
159
-        $result=$localobject->fetch_projet();
159
+        $result = $localobject->fetch_projet();
160 160
 
161 161
         print __METHOD__." result=".$result."\n";
162
-        $this->assertLessThanOrEqual($result,0);
162
+        $this->assertLessThanOrEqual($result, 0);
163 163
         return $result;
164 164
     }
165 165
 
@@ -170,19 +170,19 @@  discard block
 block discarded – undo
170 170
      */
171 171
     public function testFetchThirdParty()
172 172
     {
173
-        global $conf,$user,$langs,$db;
174
-        $conf=$this->savconf;
175
-        $user=$this->savuser;
176
-        $langs=$this->savlangs;
177
-        $db=$this->savdb;
173
+        global $conf, $user, $langs, $db;
174
+        $conf = $this->savconf;
175
+        $user = $this->savuser;
176
+        $langs = $this->savlangs;
177
+        $db = $this->savdb;
178 178
 
179
-        $localobject=new Commande($this->savdb);
179
+        $localobject = new Commande($this->savdb);
180 180
         $localobject->fetch(1);
181 181
 
182
-        $result=$localobject->fetch_thirdparty();
182
+        $result = $localobject->fetch_thirdparty();
183 183
 
184 184
         print __METHOD__." result=".$result."\n";
185
-        $this->assertLessThanOrEqual($result,0);
185
+        $this->assertLessThanOrEqual($result, 0);
186 186
         return $result;
187 187
     }
188 188
 }
Please login to merge, or discard this patch.
dolibarr/test/phpunit/SupplierProposalTest.php 2 patches
Indentation   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -31,12 +31,12 @@  discard block
 block discarded – undo
31 31
 
32 32
 if (empty($user->id))
33 33
 {
34
-	print "Load permissions for user nb 1 (that should be admin)\n";
35
-	$user->fetch(1);
34
+    print "Load permissions for user nb 1 (that should be admin)\n";
35
+    $user->fetch(1);
36 36
 
37
-	//$user->addrights(0, 'supplier_proposal');
37
+    //$user->addrights(0, 'supplier_proposal');
38 38
 
39
-	$user->getrights();
39
+    $user->getrights();
40 40
 }
41 41
 $conf->global->MAIN_DISABLE_ALL_MAILS=1;
42 42
 
@@ -50,82 +50,82 @@  discard block
 block discarded – undo
50 50
  */
51 51
 class SupplierProposalTest extends PHPUnit_Framework_TestCase
52 52
 {
53
-	protected $savconf;
54
-	protected $savuser;
55
-	protected $savlangs;
56
-	protected $savdb;
57
-
58
-	/**
59
-	 * Constructor
60
-	 * We save global variables into local variables
61
-	 *
62
-	 * @return PropalTest
63
-	 */
64
-	function __construct()
65
-	{
66
-    	parent::__construct();
67
-
68
-		//$this->sharedFixture
69
-		global $conf,$user,$langs,$db;
70
-		$this->savconf=$conf;
71
-		$this->savuser=$user;
72
-		$this->savlangs=$langs;
73
-		$this->savdb=$db;
74
-
75
-		print __METHOD__." db->type=".$db->type." user->id=".$user->id;
76
-		//print " - db ".$db->db;
77
-		print "\n";
78
-	}
79
-
80
-	// Static methods
81
-  	public static function setUpBeforeClass()
53
+    protected $savconf;
54
+    protected $savuser;
55
+    protected $savlangs;
56
+    protected $savdb;
57
+
58
+    /**
59
+     * Constructor
60
+     * We save global variables into local variables
61
+     *
62
+     * @return PropalTest
63
+     */
64
+    function __construct()
82 65
     {
83
-    	global $conf,$user,$langs,$db;
84
-		$db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
66
+        parent::__construct();
85 67
 
86
-		if (empty($conf->global->MAIN_MODULE_SUPPLIERPROPOSAL)) { print "\n".__METHOD__." module Supplier proposal must be enabled.\n"; die(); }
68
+        //$this->sharedFixture
69
+        global $conf,$user,$langs,$db;
70
+        $this->savconf=$conf;
71
+        $this->savuser=$user;
72
+        $this->savlangs=$langs;
73
+        $this->savdb=$db;
74
+
75
+        print __METHOD__." db->type=".$db->type." user->id=".$user->id;
76
+        //print " - db ".$db->db;
77
+        print "\n";
78
+    }
79
+
80
+    // Static methods
81
+        public static function setUpBeforeClass()
82
+    {
83
+        global $conf,$user,$langs,$db;
84
+        $db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
87 85
 
88
-    	print __METHOD__."\n";
86
+        if (empty($conf->global->MAIN_MODULE_SUPPLIERPROPOSAL)) { print "\n".__METHOD__." module Supplier proposal must be enabled.\n"; die(); }
87
+
88
+        print __METHOD__."\n";
89 89
     }
90 90
 
91 91
     // tear down after class
92 92
     public static function tearDownAfterClass()
93 93
     {
94
-    	global $conf,$user,$langs,$db;
95
-		$db->rollback();
94
+        global $conf,$user,$langs,$db;
95
+        $db->rollback();
96 96
 
97
-		print __METHOD__."\n";
97
+        print __METHOD__."\n";
98 98
     }
99 99
 
100
-	/**
101
-	 * Init phpunit tests
102
-	 *
103
-	 * @return	void
104
-	 */
100
+    /**
101
+     * Init phpunit tests
102
+     *
103
+     * @return	void
104
+     */
105 105
     protected function setUp()
106 106
     {
107
-    	global $conf,$user,$langs,$db;
108
-		$conf=$this->savconf;
109
-		$user=$this->savuser;
110
-		$langs=$this->savlangs;
111
-		$db=$this->savdb;
112
-
113
-		print __METHOD__."\n";
114
-		//print $db->getVersion()."\n";
115
-
116
-		// Set permission not set by default sql sample
117
-		$user->addrights(0, 'supplier_proposal');
118
-		$user->getrights('supplier_proposal', 1);
107
+        global $conf,$user,$langs,$db;
108
+        $conf=$this->savconf;
109
+        $user=$this->savuser;
110
+        $langs=$this->savlangs;
111
+        $db=$this->savdb;
112
+
113
+        print __METHOD__."\n";
114
+        //print $db->getVersion()."\n";
115
+
116
+        // Set permission not set by default sql sample
117
+        $user->addrights(0, 'supplier_proposal');
118
+        $user->getrights('supplier_proposal', 1);
119 119
     }
120 120
 
121
-	/**
122
-	 * End phpunit tests
123
-	 *
124
-	 * @return	void
125
-	 */
121
+    /**
122
+     * End phpunit tests
123
+     *
124
+     * @return	void
125
+     */
126 126
     protected function tearDown()
127 127
     {
128
-    	print __METHOD__."\n";
128
+        print __METHOD__."\n";
129 129
     }
130 130
 
131 131
     /**
@@ -135,19 +135,19 @@  discard block
 block discarded – undo
135 135
      */
136 136
     public function testSupplierProposalCreate()
137 137
     {
138
-    	global $conf,$user,$langs,$db;
139
-		$conf=$this->savconf;
140
-		$user=$this->savuser;
141
-		$langs=$this->savlangs;
142
-		$db=$this->savdb;
143
-
144
-		$localobject=new SupplierProposal($this->savdb);
145
-    	$localobject->initAsSpecimen();
146
-    	$result=$localobject->create($user);
147
-
148
-    	$this->assertLessThan($result, 0);
149
-    	print __METHOD__." result=".$result."\n";
150
-    	return $result;
138
+        global $conf,$user,$langs,$db;
139
+        $conf=$this->savconf;
140
+        $user=$this->savuser;
141
+        $langs=$this->savlangs;
142
+        $db=$this->savdb;
143
+
144
+        $localobject=new SupplierProposal($this->savdb);
145
+        $localobject->initAsSpecimen();
146
+        $result=$localobject->create($user);
147
+
148
+        $this->assertLessThan($result, 0);
149
+        print __METHOD__." result=".$result."\n";
150
+        return $result;
151 151
     }
152 152
 
153 153
     /**
@@ -161,18 +161,18 @@  discard block
 block discarded – undo
161 161
      */
162 162
     public function testSupplierProposalFetch($id)
163 163
     {
164
-    	global $conf,$user,$langs,$db;
165
-		$conf=$this->savconf;
166
-		$user=$this->savuser;
167
-		$langs=$this->savlangs;
168
-		$db=$this->savdb;
169
-
170
-		$localobject=new SupplierProposal($this->savdb);
171
-    	$result=$localobject->fetch($id);
172
-
173
-    	$this->assertLessThan($result, 0);
174
-    	print __METHOD__." id=".$id." result=".$result."\n";
175
-    	return $localobject;
164
+        global $conf,$user,$langs,$db;
165
+        $conf=$this->savconf;
166
+        $user=$this->savuser;
167
+        $langs=$this->savlangs;
168
+        $db=$this->savdb;
169
+
170
+        $localobject=new SupplierProposal($this->savdb);
171
+        $result=$localobject->fetch($id);
172
+
173
+        $this->assertLessThan($result, 0);
174
+        print __METHOD__." id=".$id." result=".$result."\n";
175
+        return $localobject;
176 176
     }
177 177
 
178 178
     /**
@@ -186,18 +186,18 @@  discard block
 block discarded – undo
186 186
      */
187 187
     public function testSupplierProposalAddLine($localobject)
188 188
     {
189
-    	global $conf,$user,$langs,$db;
190
-    	$conf=$this->savconf;
191
-    	$user=$this->savuser;
192
-    	$langs=$this->savlangs;
193
-    	$db=$this->savdb;
194
-
195
-    	$localobject->fetch_thirdparty();
196
-    	$result=$localobject->addline('Added line', 10, 2, 19.6);
197
-
198
-    	$this->assertLessThan($result, 0);
199
-    	print __METHOD__." id=".$localobject->id." result=".$result."\n";
200
-    	return $localobject;
189
+        global $conf,$user,$langs,$db;
190
+        $conf=$this->savconf;
191
+        $user=$this->savuser;
192
+        $langs=$this->savlangs;
193
+        $db=$this->savdb;
194
+
195
+        $localobject->fetch_thirdparty();
196
+        $result=$localobject->addline('Added line', 10, 2, 19.6);
197
+
198
+        $this->assertLessThan($result, 0);
199
+        print __METHOD__." id=".$localobject->id." result=".$result."\n";
200
+        return $localobject;
201 201
     }
202 202
 
203 203
     /**
@@ -211,20 +211,20 @@  discard block
 block discarded – undo
211 211
      */
212 212
     public function testSupplierProposalValid($localobject)
213 213
     {
214
-    	global $conf,$user,$langs,$db;
215
-		$conf=$this->savconf;
216
-		$user=$this->savuser;
217
-		$langs=$this->savlangs;
218
-		$db=$this->savdb;
214
+        global $conf,$user,$langs,$db;
215
+        $conf=$this->savconf;
216
+        $user=$this->savuser;
217
+        $langs=$this->savlangs;
218
+        $db=$this->savdb;
219 219
 
220
-		$result=$localobject->valid($user);
220
+        $result=$localobject->valid($user);
221 221
 
222
-    	print __METHOD__." id=".$localobject->id." result=".$result."\n";
223
-    	$this->assertLessThan($result, 0);
224
-    	return $localobject;
222
+        print __METHOD__." id=".$localobject->id." result=".$result."\n";
223
+        $this->assertLessThan($result, 0);
224
+        return $localobject;
225 225
     }
226 226
 
227
-   /**
227
+    /**
228 228
      * testSupplierProposalOther
229 229
      *
230 230
      * @param	Proposal	$localobject	Proposal
@@ -264,18 +264,18 @@  discard block
 block discarded – undo
264 264
      */
265 265
     public function testSupplierProposalDelete($id)
266 266
     {
267
-    	global $conf,$user,$langs,$db;
268
-		$conf=$this->savconf;
269
-		$user=$this->savuser;
270
-		$langs=$this->savlangs;
271
-		$db=$this->savdb;
272
-
273
-		$localobject=new SupplierProposal($this->savdb);
274
-    	$result=$localobject->fetch($id);
275
-		$result=$localobject->delete($user);
276
-
277
-		print __METHOD__." id=".$id." result=".$result."\n";
278
-    	$this->assertLessThan($result, 0);
279
-    	return $result;
267
+        global $conf,$user,$langs,$db;
268
+        $conf=$this->savconf;
269
+        $user=$this->savuser;
270
+        $langs=$this->savlangs;
271
+        $db=$this->savdb;
272
+
273
+        $localobject=new SupplierProposal($this->savdb);
274
+        $result=$localobject->fetch($id);
275
+        $result=$localobject->delete($user);
276
+
277
+        print __METHOD__." id=".$id." result=".$result."\n";
278
+        $this->assertLessThan($result, 0);
279
+        return $result;
280 280
     }
281 281
 }
Please login to merge, or discard this patch.
Spacing   +55 added lines, -55 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';
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 
39 39
 	$user->getrights();
40 40
 }
41
-$conf->global->MAIN_DISABLE_ALL_MAILS=1;
41
+$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
42 42
 
43 43
 
44 44
 /**
@@ -66,11 +66,11 @@  discard block
 block discarded – undo
66 66
     	parent::__construct();
67 67
 
68 68
 		//$this->sharedFixture
69
-		global $conf,$user,$langs,$db;
70
-		$this->savconf=$conf;
71
-		$this->savuser=$user;
72
-		$this->savlangs=$langs;
73
-		$this->savdb=$db;
69
+		global $conf, $user, $langs, $db;
70
+		$this->savconf = $conf;
71
+		$this->savuser = $user;
72
+		$this->savlangs = $langs;
73
+		$this->savdb = $db;
74 74
 
75 75
 		print __METHOD__." db->type=".$db->type." user->id=".$user->id;
76 76
 		//print " - db ".$db->db;
@@ -80,8 +80,8 @@  discard block
 block discarded – undo
80 80
 	// Static methods
81 81
   	public static function setUpBeforeClass()
82 82
     {
83
-    	global $conf,$user,$langs,$db;
84
-		$db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
83
+    	global $conf, $user, $langs, $db;
84
+		$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
85 85
 
86 86
 		if (empty($conf->global->MAIN_MODULE_SUPPLIERPROPOSAL)) { print "\n".__METHOD__." module Supplier proposal must be enabled.\n"; die(); }
87 87
 
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
     // tear down after class
92 92
     public static function tearDownAfterClass()
93 93
     {
94
-    	global $conf,$user,$langs,$db;
94
+    	global $conf, $user, $langs, $db;
95 95
 		$db->rollback();
96 96
 
97 97
 		print __METHOD__."\n";
@@ -104,11 +104,11 @@  discard block
 block discarded – undo
104 104
 	 */
105 105
     protected function setUp()
106 106
     {
107
-    	global $conf,$user,$langs,$db;
108
-		$conf=$this->savconf;
109
-		$user=$this->savuser;
110
-		$langs=$this->savlangs;
111
-		$db=$this->savdb;
107
+    	global $conf, $user, $langs, $db;
108
+		$conf = $this->savconf;
109
+		$user = $this->savuser;
110
+		$langs = $this->savlangs;
111
+		$db = $this->savdb;
112 112
 
113 113
 		print __METHOD__."\n";
114 114
 		//print $db->getVersion()."\n";
@@ -135,15 +135,15 @@  discard block
 block discarded – undo
135 135
      */
136 136
     public function testSupplierProposalCreate()
137 137
     {
138
-    	global $conf,$user,$langs,$db;
139
-		$conf=$this->savconf;
140
-		$user=$this->savuser;
141
-		$langs=$this->savlangs;
142
-		$db=$this->savdb;
138
+    	global $conf, $user, $langs, $db;
139
+		$conf = $this->savconf;
140
+		$user = $this->savuser;
141
+		$langs = $this->savlangs;
142
+		$db = $this->savdb;
143 143
 
144
-		$localobject=new SupplierProposal($this->savdb);
144
+		$localobject = new SupplierProposal($this->savdb);
145 145
     	$localobject->initAsSpecimen();
146
-    	$result=$localobject->create($user);
146
+    	$result = $localobject->create($user);
147 147
 
148 148
     	$this->assertLessThan($result, 0);
149 149
     	print __METHOD__." result=".$result."\n";
@@ -161,14 +161,14 @@  discard block
 block discarded – undo
161 161
      */
162 162
     public function testSupplierProposalFetch($id)
163 163
     {
164
-    	global $conf,$user,$langs,$db;
165
-		$conf=$this->savconf;
166
-		$user=$this->savuser;
167
-		$langs=$this->savlangs;
168
-		$db=$this->savdb;
164
+    	global $conf, $user, $langs, $db;
165
+		$conf = $this->savconf;
166
+		$user = $this->savuser;
167
+		$langs = $this->savlangs;
168
+		$db = $this->savdb;
169 169
 
170
-		$localobject=new SupplierProposal($this->savdb);
171
-    	$result=$localobject->fetch($id);
170
+		$localobject = new SupplierProposal($this->savdb);
171
+    	$result = $localobject->fetch($id);
172 172
 
173 173
     	$this->assertLessThan($result, 0);
174 174
     	print __METHOD__." id=".$id." result=".$result."\n";
@@ -186,14 +186,14 @@  discard block
 block discarded – undo
186 186
      */
187 187
     public function testSupplierProposalAddLine($localobject)
188 188
     {
189
-    	global $conf,$user,$langs,$db;
190
-    	$conf=$this->savconf;
191
-    	$user=$this->savuser;
192
-    	$langs=$this->savlangs;
193
-    	$db=$this->savdb;
189
+    	global $conf, $user, $langs, $db;
190
+    	$conf = $this->savconf;
191
+    	$user = $this->savuser;
192
+    	$langs = $this->savlangs;
193
+    	$db = $this->savdb;
194 194
 
195 195
     	$localobject->fetch_thirdparty();
196
-    	$result=$localobject->addline('Added line', 10, 2, 19.6);
196
+    	$result = $localobject->addline('Added line', 10, 2, 19.6);
197 197
 
198 198
     	$this->assertLessThan($result, 0);
199 199
     	print __METHOD__." id=".$localobject->id." result=".$result."\n";
@@ -211,13 +211,13 @@  discard block
 block discarded – undo
211 211
      */
212 212
     public function testSupplierProposalValid($localobject)
213 213
     {
214
-    	global $conf,$user,$langs,$db;
215
-		$conf=$this->savconf;
216
-		$user=$this->savuser;
217
-		$langs=$this->savlangs;
218
-		$db=$this->savdb;
214
+    	global $conf, $user, $langs, $db;
215
+		$conf = $this->savconf;
216
+		$user = $this->savuser;
217
+		$langs = $this->savlangs;
218
+		$db = $this->savdb;
219 219
 
220
-		$result=$localobject->valid($user);
220
+		$result = $localobject->valid($user);
221 221
 
222 222
     	print __METHOD__." id=".$localobject->id." result=".$result."\n";
223 223
     	$this->assertLessThan($result, 0);
@@ -235,11 +235,11 @@  discard block
 block discarded – undo
235 235
      */
236 236
     public function testSupplierProposalOther($localobject)
237 237
     {
238
-        global $conf,$user,$langs,$db;
239
-        $conf=$this->savconf;
240
-        $user=$this->savuser;
241
-        $langs=$this->savlangs;
242
-        $db=$this->savdb;
238
+        global $conf, $user, $langs, $db;
239
+        $conf = $this->savconf;
240
+        $user = $this->savuser;
241
+        $langs = $this->savlangs;
242
+        $db = $this->savdb;
243 243
 
244 244
         /*$result=$localobject->setstatus(0);
245 245
         print __METHOD__." id=".$localobject->id." result=".$result."\n";
@@ -264,15 +264,15 @@  discard block
 block discarded – undo
264 264
      */
265 265
     public function testSupplierProposalDelete($id)
266 266
     {
267
-    	global $conf,$user,$langs,$db;
268
-		$conf=$this->savconf;
269
-		$user=$this->savuser;
270
-		$langs=$this->savlangs;
271
-		$db=$this->savdb;
272
-
273
-		$localobject=new SupplierProposal($this->savdb);
274
-    	$result=$localobject->fetch($id);
275
-		$result=$localobject->delete($user);
267
+    	global $conf, $user, $langs, $db;
268
+		$conf = $this->savconf;
269
+		$user = $this->savuser;
270
+		$langs = $this->savlangs;
271
+		$db = $this->savdb;
272
+
273
+		$localobject = new SupplierProposal($this->savdb);
274
+    	$result = $localobject->fetch($id);
275
+		$result = $localobject->delete($user);
276 276
 
277 277
 		print __METHOD__." id=".$id." result=".$result."\n";
278 278
     	$this->assertLessThan($result, 0);
Please login to merge, or discard this patch.
dolibarr/test/phpunit/AllTests.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -40,8 +40,8 @@  discard block
 block discarded – undo
40 40
 }
41 41
 if (empty($conf->adherent->enabled))
42 42
 {
43
-	print "Error: Module member must be enabled to have significant results.\n";
44
-	exit(1);
43
+    print "Error: Module member must be enabled to have significant results.\n";
44
+    exit(1);
45 45
 }
46 46
 if (! empty($conf->ldap->enabled))
47 47
 {
@@ -215,18 +215,18 @@  discard block
 block discarded – undo
215 215
         // Test only with php7.2 or less
216 216
         //if ((float) phpversion() < 7.3)
217 217
         //{
218
-        	require_once dirname(__FILE__).'/WebservicesProductsTest.php';
219
-	        $suite->addTestSuite('WebservicesProductsTest');
220
-	        require_once dirname(__FILE__).'/WebservicesInvoicesTest.php';
221
-	        $suite->addTestSuite('WebservicesInvoicesTest');
222
-	        require_once dirname(__FILE__).'/WebservicesOrdersTest.php';
223
-	        $suite->addTestSuite('WebservicesOrdersTest');
224
-	        require_once dirname(__FILE__).'/WebservicesOtherTest.php';
225
-	        $suite->addTestSuite('WebservicesOtherTest');
226
-	        require_once dirname(__FILE__).'/WebservicesThirdpartyTest.php';
227
-	        $suite->addTestSuite('WebservicesThirdpartyTest');
228
-	        require_once dirname(__FILE__).'/WebservicesUserTest.php';
229
-	        $suite->addTestSuite('WebservicesUserTest');
218
+            require_once dirname(__FILE__).'/WebservicesProductsTest.php';
219
+            $suite->addTestSuite('WebservicesProductsTest');
220
+            require_once dirname(__FILE__).'/WebservicesInvoicesTest.php';
221
+            $suite->addTestSuite('WebservicesInvoicesTest');
222
+            require_once dirname(__FILE__).'/WebservicesOrdersTest.php';
223
+            $suite->addTestSuite('WebservicesOrdersTest');
224
+            require_once dirname(__FILE__).'/WebservicesOtherTest.php';
225
+            $suite->addTestSuite('WebservicesOtherTest');
226
+            require_once dirname(__FILE__).'/WebservicesThirdpartyTest.php';
227
+            $suite->addTestSuite('WebservicesThirdpartyTest');
228
+            require_once dirname(__FILE__).'/WebservicesUserTest.php';
229
+            $suite->addTestSuite('WebservicesUserTest');
230 230
         //}
231 231
 
232 232
         require_once dirname(__FILE__).'/ExportTest.php';
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -24,13 +24,13 @@  discard block
 block discarded – undo
24 24
  *      \remarks    To run this script as CLI:  phpunit filename.php
25 25
  */
26 26
 print "PHP Version: ".phpversion()."\n";
27
-print "Memory: ". ini_get('memory_limit')."\n";
27
+print "Memory: ".ini_get('memory_limit')."\n";
28 28
 
29
-global $conf,$user,$langs,$db;
29
+global $conf, $user, $langs, $db;
30 30
 //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver
31 31
 //require_once 'PHPUnit/Autoload.php';
32 32
 require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
33
-print 'DOL_MAIN_URL_ROOT='.DOL_MAIN_URL_ROOT."\n";  // constant will be used by other tests
33
+print 'DOL_MAIN_URL_ROOT='.DOL_MAIN_URL_ROOT."\n"; // constant will be used by other tests
34 34
 
35 35
 
36 36
 if ($langs->defaultlang != 'en_US')
@@ -43,12 +43,12 @@  discard block
 block discarded – undo
43 43
 	print "Error: Module member must be enabled to have significant results.\n";
44 44
 	exit(1);
45 45
 }
46
-if (! empty($conf->ldap->enabled))
46
+if (!empty($conf->ldap->enabled))
47 47
 {
48 48
     print "Error: LDAP module should not be enabled.\n";
49 49
     exit(1);
50 50
 }
51
-if (! empty($conf->google->enabled))
51
+if (!empty($conf->google->enabled))
52 52
 {
53 53
     print "Warning: Google module should not be enabled.\n";
54 54
 }
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
     $user->fetch(1);
59 59
     $user->getrights();
60 60
 }
61
-$conf->global->MAIN_DISABLE_ALL_MAILS=1;
61
+$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
62 62
 
63 63
 
64 64
 
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
         require_once dirname(__FILE__).'/FormAdminTest.php';
241 241
         $suite->addTestSuite('FormAdminTest');
242 242
 
243
-        require_once dirname(__FILE__).'/ModulesTest.php';  // At end because it's the longer
243
+        require_once dirname(__FILE__).'/ModulesTest.php'; // At end because it's the longer
244 244
         $suite->addTestSuite('ModulesTest');
245 245
 
246 246
 
Please login to merge, or discard this patch.
dolibarr/test/phpunit/BankAccountTest.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
      */
62 62
     function __construct()
63 63
     {
64
-    	parent::__construct();
64
+        parent::__construct();
65 65
 
66
-    	//$this->sharedFixture
66
+        //$this->sharedFixture
67 67
         global $conf,$user,$langs,$db;
68 68
         $this->savconf=$conf;
69 69
         $this->savuser=$user;
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
         return $localobject;
169 169
     }
170 170
 
171
-   /**
171
+    /**
172 172
      * testBankAccountOther
173 173
      *
174 174
      * @param   Object  $localobject    Object contract
Please login to merge, or discard this patch.
Spacing   +43 added lines, -43 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
 $langs->load("main");
40 40
 
@@ -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,7 +78,7 @@  discard block
 block discarded – undo
78 78
     // Static methods
79 79
     public static function setUpBeforeClass()
80 80
     {
81
-        global $conf,$user,$langs,$db;
81
+        global $conf, $user, $langs, $db;
82 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";
@@ -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,16 +125,16 @@  discard block
 block discarded – undo
125 125
      */
126 126
     public function testBankAccountCreate()
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 Account($this->savdb);
134
+        $localobject = new Account($this->savdb);
135 135
         $localobject->initAsSpecimen();
136
-        $localobject->date_solde=dol_now();
137
-        $result=$localobject->create($user);
136
+        $localobject->date_solde = dol_now();
137
+        $result = $localobject->create($user);
138 138
 
139 139
         print __METHOD__." result=".$result."\n";
140 140
         $this->assertLessThan($result, 0);
@@ -153,14 +153,14 @@  discard block
 block discarded – undo
153 153
      */
154 154
     public function testBankAccountFetch($id)
155 155
     {
156
-        global $conf,$user,$langs,$db;
157
-        $conf=$this->savconf;
158
-        $user=$this->savuser;
159
-        $langs=$this->savlangs;
160
-        $db=$this->savdb;
156
+        global $conf, $user, $langs, $db;
157
+        $conf = $this->savconf;
158
+        $user = $this->savuser;
159
+        $langs = $this->savlangs;
160
+        $db = $this->savdb;
161 161
 
162
-        $localobject=new Account($this->savdb);
163
-        $result=$localobject->fetch($id);
162
+        $localobject = new Account($this->savdb);
163
+        $result = $localobject->fetch($id);
164 164
 
165 165
         print __METHOD__." id=".$id." result=".$result."\n";
166 166
         $this->assertLessThan($result, 0);
@@ -179,11 +179,11 @@  discard block
 block discarded – undo
179 179
      */
180 180
     public function testBankAccountOther($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
         /*$result=$localobject->setstatus(0);
189 189
         print __METHOD__." id=".$localobject->id." result=".$result."\n";
@@ -208,15 +208,15 @@  discard block
 block discarded – undo
208 208
      */
209 209
     public function testBankAccountDelete($id)
210 210
     {
211
-        global $conf,$user,$langs,$db;
212
-        $conf=$this->savconf;
213
-        $user=$this->savuser;
214
-        $langs=$this->savlangs;
215
-        $db=$this->savdb;
216
-
217
-        $localobject=new Account($this->savdb);
218
-        $result=$localobject->fetch($id);
219
-        $result=$localobject->delete($user);
211
+        global $conf, $user, $langs, $db;
212
+        $conf = $this->savconf;
213
+        $user = $this->savuser;
214
+        $langs = $this->savlangs;
215
+        $db = $this->savdb;
216
+
217
+        $localobject = new Account($this->savdb);
218
+        $result = $localobject->fetch($id);
219
+        $result = $localobject->delete($user);
220 220
 
221 221
         print __METHOD__." id=".$id." result=".$result."\n";
222 222
         $this->assertLessThan($result, 0);
Please login to merge, or discard this patch.
dolibarr/test/phpunit/FunctionsLibTest.php 3 patches
Indentation   +368 added lines, -368 removed lines patch added patch discarded remove patch
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
      */
64 64
     function __construct()
65 65
     {
66
-    	parent::__construct();
66
+        parent::__construct();
67 67
 
68
-    	//$this->sharedFixture
68
+        //$this->sharedFixture
69 69
         global $conf,$user,$langs,$db;
70 70
         $this->savconf=$conf;
71 71
         $this->savuser=$user;
@@ -97,11 +97,11 @@  discard block
 block discarded – undo
97 97
         print __METHOD__."\n";
98 98
     }
99 99
 
100
-	/**
101
-	 * Init phpunit tests
102
-	 *
103
-	 * @return	void
104
-	 */
100
+    /**
101
+     * Init phpunit tests
102
+     *
103
+     * @return	void
104
+     */
105 105
     protected function setUp()
106 106
     {
107 107
         global $conf,$user,$langs,$db;
@@ -114,10 +114,10 @@  discard block
 block discarded – undo
114 114
     }
115 115
 
116 116
     /**
117
-	 * End phpunit tests
118
-	 *
119
-	 * @return	void
120
-	 */
117
+     * End phpunit tests
118
+     *
119
+     * @return	void
120
+     */
121 121
     protected function tearDown()
122 122
     {
123 123
         print __METHOD__."\n";
@@ -131,22 +131,22 @@  discard block
 block discarded – undo
131 131
      */
132 132
     public function testIsValidMXRecord()
133 133
     {
134
-    	// Nb of line is same than entry text
135
-
136
-    	$input="yahoo.com";
137
-    	$result=isValidMXRecord($input);
138
-    	print __METHOD__." result=".$result."\n";
139
-    	$this->assertEquals(1, $result);
140
-
141
-    	$input="yhaoo.com";
142
-    	$result=isValidMXRecord($input);
143
-    	print __METHOD__." result=".$result."\n";
144
-    	$this->assertEquals(0, $result);
145
-
146
-    	$input="dolibarr.fr";
147
-    	$result=isValidMXRecord($input);
148
-    	print __METHOD__." result=".$result."\n";
149
-    	$this->assertEquals(0, $result);
134
+        // Nb of line is same than entry text
135
+
136
+        $input="yahoo.com";
137
+        $result=isValidMXRecord($input);
138
+        print __METHOD__." result=".$result."\n";
139
+        $this->assertEquals(1, $result);
140
+
141
+        $input="yhaoo.com";
142
+        $result=isValidMXRecord($input);
143
+        print __METHOD__." result=".$result."\n";
144
+        $this->assertEquals(0, $result);
145
+
146
+        $input="dolibarr.fr";
147
+        $result=isValidMXRecord($input);
148
+        print __METHOD__." result=".$result."\n";
149
+        $this->assertEquals(0, $result);
150 150
     }
151 151
 
152 152
     /**
@@ -156,172 +156,172 @@  discard block
 block discarded – undo
156 156
      */
157 157
     public function testDolGetFirstLineOfText()
158 158
     {
159
-    	// Nb of line is same than entry text
160
-
161
-    	$input="aaaa";
162
-    	$result=dolGetFirstLineOfText($input);
163
-    	print __METHOD__." result=".$result."\n";
164
-    	$this->assertEquals("aaaa", $result);
165
-
166
-    	$input="aaaa\nbbbbbbbbbbbb\n";
167
-    	$result=dolGetFirstLineOfText($input, 2);
168
-    	print __METHOD__." result=".$result."\n";
169
-    	$this->assertEquals("aaaa\nbbbbbbbbbbbb", $result);
170
-
171
-    	$input="aaaa<br>bbbbbbbbbbbb<br>";
172
-    	$result=dolGetFirstLineOfText($input, 2);
173
-    	print __METHOD__." result=".$result."\n";
174
-    	$this->assertEquals("aaaa<br>\nbbbbbbbbbbbb", $result);
175
-
176
-    	// Nb of line is lower
177
-
178
-    	$input="aaaa\nbbbbbbbbbbbb\ncccccc\n";
179
-    	$result=dolGetFirstLineOfText($input);
180
-    	print __METHOD__." result=".$result."\n";
181
-    	$this->assertEquals("aaaa...", $result);
182
-
183
-    	$input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>";
184
-    	$result=dolGetFirstLineOfText($input);
185
-    	print __METHOD__." result=".$result."\n";
186
-    	$this->assertEquals("aaaa...", $result);
187
-
188
-    	$input="aaaa\nbbbbbbbbbbbb\ncccccc\n";
189
-    	$result=dolGetFirstLineOfText($input, 2);
190
-    	print __METHOD__." result=".$result."\n";
191
-    	$this->assertEquals("aaaa\nbbbbbbbbbbbb...", $result);
192
-
193
-    	$input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>";
194
-    	$result=dolGetFirstLineOfText($input, 2);
195
-    	print __METHOD__." result=".$result."\n";
196
-    	$this->assertEquals("aaaa<br>\nbbbbbbbbbbbb...", $result);
197
-
198
-    	// Nb of line is higher
199
-
200
-    	$input="aaaa<br>bbbbbbbbbbbb<br>cccccc";
201
-    	$result=dolGetFirstLineOfText($input, 100);
202
-    	print __METHOD__." result=".$result."\n";
203
-    	$this->assertEquals("aaaa<br>\nbbbbbbbbbbbb<br>\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 a');
204
-
205
-    	$input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>";
206
-    	$result=dolGetFirstLineOfText($input, 100);
207
-    	print __METHOD__." result=".$result."\n";
208
-    	$this->assertEquals("aaaa<br>\nbbbbbbbbbbbb<br>\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 b');
209
-
210
-    	$input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>\n";
211
-    	$result=dolGetFirstLineOfText($input, 100);
212
-    	print __METHOD__." result=".$result."\n";
213
-    	$this->assertEquals("aaaa<br>\nbbbbbbbbbbbb<br>\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 c');
159
+        // Nb of line is same than entry text
160
+
161
+        $input="aaaa";
162
+        $result=dolGetFirstLineOfText($input);
163
+        print __METHOD__." result=".$result."\n";
164
+        $this->assertEquals("aaaa", $result);
165
+
166
+        $input="aaaa\nbbbbbbbbbbbb\n";
167
+        $result=dolGetFirstLineOfText($input, 2);
168
+        print __METHOD__." result=".$result."\n";
169
+        $this->assertEquals("aaaa\nbbbbbbbbbbbb", $result);
170
+
171
+        $input="aaaa<br>bbbbbbbbbbbb<br>";
172
+        $result=dolGetFirstLineOfText($input, 2);
173
+        print __METHOD__." result=".$result."\n";
174
+        $this->assertEquals("aaaa<br>\nbbbbbbbbbbbb", $result);
175
+
176
+        // Nb of line is lower
177
+
178
+        $input="aaaa\nbbbbbbbbbbbb\ncccccc\n";
179
+        $result=dolGetFirstLineOfText($input);
180
+        print __METHOD__." result=".$result."\n";
181
+        $this->assertEquals("aaaa...", $result);
182
+
183
+        $input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>";
184
+        $result=dolGetFirstLineOfText($input);
185
+        print __METHOD__." result=".$result."\n";
186
+        $this->assertEquals("aaaa...", $result);
187
+
188
+        $input="aaaa\nbbbbbbbbbbbb\ncccccc\n";
189
+        $result=dolGetFirstLineOfText($input, 2);
190
+        print __METHOD__." result=".$result."\n";
191
+        $this->assertEquals("aaaa\nbbbbbbbbbbbb...", $result);
192
+
193
+        $input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>";
194
+        $result=dolGetFirstLineOfText($input, 2);
195
+        print __METHOD__." result=".$result."\n";
196
+        $this->assertEquals("aaaa<br>\nbbbbbbbbbbbb...", $result);
197
+
198
+        // Nb of line is higher
199
+
200
+        $input="aaaa<br>bbbbbbbbbbbb<br>cccccc";
201
+        $result=dolGetFirstLineOfText($input, 100);
202
+        print __METHOD__." result=".$result."\n";
203
+        $this->assertEquals("aaaa<br>\nbbbbbbbbbbbb<br>\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 a');
204
+
205
+        $input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>";
206
+        $result=dolGetFirstLineOfText($input, 100);
207
+        print __METHOD__." result=".$result."\n";
208
+        $this->assertEquals("aaaa<br>\nbbbbbbbbbbbb<br>\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 b');
209
+
210
+        $input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>\n";
211
+        $result=dolGetFirstLineOfText($input, 100);
212
+        print __METHOD__." result=".$result."\n";
213
+        $this->assertEquals("aaaa<br>\nbbbbbbbbbbbb<br>\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 c');
214 214
     }
215 215
 
216 216
 
217
-	/**
218
-	 * testDolBuildPath
219
-	 *
220
-	 * @return void
221
-	 */
222
-	public function testDolBuildPath()
223
-	{
224
-	    /*$tmp=dol_buildpath('/google/oauth2callback.php', 0);
217
+    /**
218
+     * testDolBuildPath
219
+     *
220
+     * @return void
221
+     */
222
+    public function testDolBuildPath()
223
+    {
224
+        /*$tmp=dol_buildpath('/google/oauth2callback.php', 0);
225 225
 	    var_dump($tmp);
226 226
 	    */
227 227
 
228
-	    /*$tmp=dol_buildpath('/google/oauth2callback.php', 1);
228
+        /*$tmp=dol_buildpath('/google/oauth2callback.php', 1);
229 229
 	    var_dump($tmp);
230 230
 	    */
231 231
 
232
-	    $result=dol_buildpath('/google/oauth2callback.php', 2);
233
-	    print __METHOD__." result=".$result."\n";
234
-	    $this->assertStringStartsWith('http', $result);
232
+        $result=dol_buildpath('/google/oauth2callback.php', 2);
233
+        print __METHOD__." result=".$result."\n";
234
+        $this->assertStringStartsWith('http', $result);
235 235
 
236
-	    $result=dol_buildpath('/google/oauth2callback.php', 3);
236
+        $result=dol_buildpath('/google/oauth2callback.php', 3);
237 237
         print __METHOD__." result=".$result."\n";
238 238
         $this->assertStringStartsWith('http', $result);
239
-	}
239
+    }
240 240
 
241 241
 
242 242
     /**
243
-    * testGetBrowserInfo
244
-    *
245
-    * @return void
246
-    */
243
+     * testGetBrowserInfo
244
+     *
245
+     * @return void
246
+     */
247 247
     public function testGetBrowserInfo()
248 248
     {
249
-		// MSIE 5.0
249
+        // MSIE 5.0
250 250
         $user_agent ='Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt; KITV4 Wanadoo; KITV5 Wanadoo)';
251 251
         $tmp=getBrowserInfo($user_agent);
252 252
         $this->assertEquals('ie',$tmp['browsername']);
253 253
         $this->assertEquals('5.0',$tmp['browserversion']);
254
-	    $this->assertEmpty($tmp['phone']);
255
-	    $this->assertFalse($tmp['tablet']);
256
-	    $this->assertEquals('classic', $tmp['layout']);
254
+        $this->assertEmpty($tmp['phone']);
255
+        $this->assertFalse($tmp['tablet']);
256
+        $this->assertEquals('classic', $tmp['layout']);
257 257
 
258
-		// Firefox 0.9.1
258
+        // Firefox 0.9.1
259 259
         $user_agent ='Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5a) Gecko/20030728 Mozilla Firefox/0.9.1';
260 260
         $tmp=getBrowserInfo($user_agent);
261 261
         $this->assertEquals('firefox',$tmp['browsername']);
262 262
         $this->assertEquals('0.9.1',$tmp['browserversion']);
263
-	    $this->assertEmpty($tmp['phone']);
264
-	    $this->assertFalse($tmp['tablet']);
265
-	    $this->assertEquals('classic', $tmp['layout']);
263
+        $this->assertEmpty($tmp['phone']);
264
+        $this->assertFalse($tmp['tablet']);
265
+        $this->assertEquals('classic', $tmp['layout']);
266 266
 
267 267
         $user_agent ='Mozilla/3.0 (Windows 98; U) Opera 6.03  [en]';
268 268
         $tmp=getBrowserInfo($user_agent);
269 269
         $this->assertEquals('opera',$tmp['browsername']);
270 270
         $this->assertEquals('6.03',$tmp['browserversion']);
271
-	    $this->assertEmpty($tmp['phone']);
272
-	    $this->assertFalse($tmp['tablet']);
273
-	    $this->assertEquals('classic', $tmp['layout']);
271
+        $this->assertEmpty($tmp['phone']);
272
+        $this->assertFalse($tmp['tablet']);
273
+        $this->assertEquals('classic', $tmp['layout']);
274 274
 
275 275
         $user_agent ='Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.21 (KHTML, like Gecko) Chrome/19.0.1042.0 Safari/535.21';
276 276
         $tmp=getBrowserInfo($user_agent);
277 277
         $this->assertEquals('chrome',$tmp['browsername']);
278 278
         $this->assertEquals('19.0.1042.0',$tmp['browserversion']);
279
-	    $this->assertEmpty($tmp['phone']);
280
-	    $this->assertFalse($tmp['tablet']);
281
-	    $this->assertEquals('classic', $tmp['layout']);
279
+        $this->assertEmpty($tmp['phone']);
280
+        $this->assertFalse($tmp['tablet']);
281
+        $this->assertEquals('classic', $tmp['layout']);
282 282
 
283 283
         $user_agent ='chrome (Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11)';
284 284
         $tmp=getBrowserInfo($user_agent);
285 285
         $this->assertEquals('chrome',$tmp['browsername']);
286 286
         $this->assertEquals('17.0.963.56',$tmp['browserversion']);
287
-	    $this->assertEmpty($tmp['phone']);
288
-	    $this->assertFalse($tmp['tablet']);
289
-	    $this->assertEquals('classic', $tmp['layout']);
287
+        $this->assertEmpty($tmp['phone']);
288
+        $this->assertFalse($tmp['tablet']);
289
+        $this->assertEquals('classic', $tmp['layout']);
290 290
 
291 291
         $user_agent ='Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; de-at) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1';
292 292
         $tmp=getBrowserInfo($user_agent);
293 293
         $this->assertEquals('safari',$tmp['browsername']);
294 294
         $this->assertEquals('533.21.1',$tmp['browserversion']);
295
-	    $this->assertEmpty($tmp['phone']);
296
-	    $this->assertFalse($tmp['tablet']);
297
-	    $this->assertEquals('classic', $tmp['layout']);
298
-
299
-	    //Internet Explorer 11
300
-	    $user_agent = 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko';
301
-	    $tmp=getBrowserInfo($user_agent);
302
-	    $this->assertEquals('ie',$tmp['browsername']);
303
-	    $this->assertEquals('11.0',$tmp['browserversion']);
304
-	    $this->assertEmpty($tmp['phone']);
305
-	    $this->assertFalse($tmp['tablet']);
306
-	    $this->assertEquals('classic', $tmp['layout']);
307
-
308
-	    //Internet Explorer 11 bis
309
-	    $user_agent = 'Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; NP06; rv:11.0) like Gecko';
310
-	    $tmp=getBrowserInfo($user_agent);
311
-	    $this->assertEquals('ie',$tmp['browsername']);
312
-	    $this->assertEquals('11.0',$tmp['browserversion']);
313
-	    $this->assertEmpty($tmp['phone']);
314
-	    $this->assertFalse($tmp['tablet']);
315
-	    $this->assertEquals('classic', $tmp['layout']);
316
-
317
-	    //iPad
318
-	    $user_agent = 'Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25';
319
-	    $tmp=getBrowserInfo($user_agent);
320
-	    $this->assertEquals('safari',$tmp['browsername']);
321
-	    $this->assertEquals('8536.25',$tmp['browserversion']);
322
-	    $this->assertEquals('ios',$tmp['browseros']);
323
-	    $this->assertEquals('tablet',$tmp['layout']);
324
-	    $this->assertEquals('iphone',$tmp['phone']);
295
+        $this->assertEmpty($tmp['phone']);
296
+        $this->assertFalse($tmp['tablet']);
297
+        $this->assertEquals('classic', $tmp['layout']);
298
+
299
+        //Internet Explorer 11
300
+        $user_agent = 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko';
301
+        $tmp=getBrowserInfo($user_agent);
302
+        $this->assertEquals('ie',$tmp['browsername']);
303
+        $this->assertEquals('11.0',$tmp['browserversion']);
304
+        $this->assertEmpty($tmp['phone']);
305
+        $this->assertFalse($tmp['tablet']);
306
+        $this->assertEquals('classic', $tmp['layout']);
307
+
308
+        //Internet Explorer 11 bis
309
+        $user_agent = 'Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; NP06; rv:11.0) like Gecko';
310
+        $tmp=getBrowserInfo($user_agent);
311
+        $this->assertEquals('ie',$tmp['browsername']);
312
+        $this->assertEquals('11.0',$tmp['browserversion']);
313
+        $this->assertEmpty($tmp['phone']);
314
+        $this->assertFalse($tmp['tablet']);
315
+        $this->assertEquals('classic', $tmp['layout']);
316
+
317
+        //iPad
318
+        $user_agent = 'Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25';
319
+        $tmp=getBrowserInfo($user_agent);
320
+        $this->assertEquals('safari',$tmp['browsername']);
321
+        $this->assertEquals('8536.25',$tmp['browserversion']);
322
+        $this->assertEquals('ios',$tmp['browseros']);
323
+        $this->assertEquals('tablet',$tmp['layout']);
324
+        $this->assertEquals('iphone',$tmp['phone']);
325 325
     }
326 326
 
327 327
 
@@ -332,48 +332,48 @@  discard block
 block discarded – undo
332 332
      */
333 333
     public function testGetLanguageCodeFromCountryCode()
334 334
     {
335
-    	global $mysoc;
335
+        global $mysoc;
336 336
 
337
-    	$language = getLanguageCodeFromCountryCode('US');
338
-    	$this->assertEquals('en_US', $language, 'US');
337
+        $language = getLanguageCodeFromCountryCode('US');
338
+        $this->assertEquals('en_US', $language, 'US');
339 339
 
340
-    	$language = getLanguageCodeFromCountryCode('ES');
341
-    	$this->assertEquals('es_ES', $language, 'ES');
340
+        $language = getLanguageCodeFromCountryCode('ES');
341
+        $this->assertEquals('es_ES', $language, 'ES');
342 342
 
343
-    	$language = getLanguageCodeFromCountryCode('CL');
344
-    	$this->assertEquals('es_CL', $language, 'CL');
343
+        $language = getLanguageCodeFromCountryCode('CL');
344
+        $this->assertEquals('es_CL', $language, 'CL');
345 345
 
346
-    	$language = getLanguageCodeFromCountryCode('CA');
347
-    	$this->assertEquals('en_CA', $language, 'CA');
346
+        $language = getLanguageCodeFromCountryCode('CA');
347
+        $this->assertEquals('en_CA', $language, 'CA');
348 348
 
349
-    	$language = getLanguageCodeFromCountryCode('MQ');
350
-    	$this->assertEquals('fr_CA', $language);
349
+        $language = getLanguageCodeFromCountryCode('MQ');
350
+        $this->assertEquals('fr_CA', $language);
351 351
 
352
-    	$language = getLanguageCodeFromCountryCode('FR');
353
-    	$this->assertEquals('fr_FR', $language);
352
+        $language = getLanguageCodeFromCountryCode('FR');
353
+        $this->assertEquals('fr_FR', $language);
354 354
 
355
-    	$language = getLanguageCodeFromCountryCode('BE');
356
-    	$this->assertEquals('fr_BE', $language);
355
+        $language = getLanguageCodeFromCountryCode('BE');
356
+        $this->assertEquals('fr_BE', $language);
357 357
 
358
-    	$mysoc->country_code = 'FR';
359
-    	$language = getLanguageCodeFromCountryCode('CH');
360
-    	$this->assertEquals('fr_CH', $language);
358
+        $mysoc->country_code = 'FR';
359
+        $language = getLanguageCodeFromCountryCode('CH');
360
+        $this->assertEquals('fr_CH', $language);
361 361
 
362
-    	$mysoc->country_code = 'DE';
363
-    	$language = getLanguageCodeFromCountryCode('CH');
364
-    	$this->assertEquals('de_CH', $language);
362
+        $mysoc->country_code = 'DE';
363
+        $language = getLanguageCodeFromCountryCode('CH');
364
+        $this->assertEquals('de_CH', $language);
365 365
 
366
-    	$language = getLanguageCodeFromCountryCode('DE');
367
-    	$this->assertEquals('de_DE', $language);
366
+        $language = getLanguageCodeFromCountryCode('DE');
367
+        $this->assertEquals('de_DE', $language);
368 368
 
369
-    	$language = getLanguageCodeFromCountryCode('SA');
370
-    	$this->assertEquals('ar_SA', $language);
369
+        $language = getLanguageCodeFromCountryCode('SA');
370
+        $this->assertEquals('ar_SA', $language);
371 371
 
372
-    	$language = getLanguageCodeFromCountryCode('SE');
373
-    	$this->assertEquals('sv_SE', $language);
372
+        $language = getLanguageCodeFromCountryCode('SE');
373
+        $this->assertEquals('sv_SE', $language);
374 374
 
375
-    	$language = getLanguageCodeFromCountryCode('DK');
376
-    	$this->assertEquals('da_DK', $language);
375
+        $language = getLanguageCodeFromCountryCode('DK');
376
+        $this->assertEquals('da_DK', $language);
377 377
     }
378 378
 
379 379
     /**
@@ -570,9 +570,9 @@  discard block
 block discarded – undo
570 570
      */
571 571
     public function testDolHtmlEntitiesBr()
572 572
     {
573
-    	// Text not already HTML
573
+        // Text not already HTML
574 574
 
575
-    	$input="A string\nwith a é, &, < and >.";
575
+        $input="A string\nwith a é, &, < and >.";
576 576
         $after=dol_htmlentitiesbr($input,0);    // Add <br> before \n
577 577
         $this->assertEquals("A string<br>\nwith a &eacute;, &amp;, &lt; and &gt;.",$after);
578 578
 
@@ -645,9 +645,9 @@  discard block
 block discarded – undo
645 645
      */
646 646
     public function testDolUnaccent()
647 647
     {
648
-    	// Text not already HTML
648
+        // Text not already HTML
649 649
 
650
-    	$input="A string\nwith a à ä é è ë ï ü ö ÿ, &, < and >.";
650
+        $input="A string\nwith a à ä é è ë ï ü ö ÿ, &, < and >.";
651 651
         $after=dol_string_unaccent($input);
652 652
         $this->assertEquals("A string\nwith a a a e e e i u o y, &, < and >.",$after);
653 653
     }
@@ -738,14 +738,14 @@  discard block
 block discarded – undo
738 738
      */
739 739
     public function testDolMkTime()
740 740
     {
741
-    	global $conf;
741
+        global $conf;
742 742
 
743
-    	$savtz=date_default_timezone_get();
743
+        $savtz=date_default_timezone_get();
744 744
 
745
-		// Some test for UTC TZ
746
-    	date_default_timezone_set('UTC');
745
+        // Some test for UTC TZ
746
+        date_default_timezone_set('UTC');
747 747
 
748
-    	// Check bad hours
748
+        // Check bad hours
749 749
         $result=dol_mktime(25,0,0,1,1,1970,1,1);    // Error (25 hours)
750 750
         print __METHOD__." result=".$result."\n";
751 751
         $this->assertEquals('',$result);
@@ -808,10 +808,10 @@  discard block
 block discarded – undo
808 808
 
809 809
 
810 810
     /**
811
-    * testDolEscapeHtmlTag
812
-    *
813
-    * @return	void
814
-    */
811
+     * testDolEscapeHtmlTag
812
+     *
813
+     * @return	void
814
+     */
815 815
     public function testDolEscapeHtmlTag()
816 816
     {
817 817
         $input='x&<b>#</b>,"';    // & and " are converted into html entities, <b> are removed
@@ -831,30 +831,30 @@  discard block
 block discarded – undo
831 831
      */
832 832
     public function testDolFormatAddress()
833 833
     {
834
-    	global $conf,$user,$langs,$db;
835
-		$conf=$this->savconf;
836
-		$user=$this->savuser;
837
-		$langs=$this->savlangs;
838
-		$db=$this->savdb;
839
-
840
-		$object=new Societe($db);
841
-		$object->initAsSpecimen();
842
-
843
-		$object->country_code='FR';
844
-    	$address=dol_format_address($object);
845
-    	$this->assertEquals("21 jump street\n99999 MyTown",$address);
846
-
847
-		$object->country_code='GB';
848
-    	$address=dol_format_address($object);
849
-    	$this->assertEquals("21 jump street\nMyTown, MyState\n99999",$address);
850
-
851
-		$object->country_code='US';
852
-    	$address=dol_format_address($object);
853
-    	$this->assertEquals("21 jump street\nMyTown, MyState, 99999",$address);
854
-
855
-		$object->country_code='AU';
856
-    	$address=dol_format_address($object);
857
-    	$this->assertEquals("21 jump street\nMyTown, MyState, 99999",$address);
834
+        global $conf,$user,$langs,$db;
835
+        $conf=$this->savconf;
836
+        $user=$this->savuser;
837
+        $langs=$this->savlangs;
838
+        $db=$this->savdb;
839
+
840
+        $object=new Societe($db);
841
+        $object->initAsSpecimen();
842
+
843
+        $object->country_code='FR';
844
+        $address=dol_format_address($object);
845
+        $this->assertEquals("21 jump street\n99999 MyTown",$address);
846
+
847
+        $object->country_code='GB';
848
+        $address=dol_format_address($object);
849
+        $this->assertEquals("21 jump street\nMyTown, MyState\n99999",$address);
850
+
851
+        $object->country_code='US';
852
+        $address=dol_format_address($object);
853
+        $this->assertEquals("21 jump street\nMyTown, MyState, 99999",$address);
854
+
855
+        $object->country_code='AU';
856
+        $address=dol_format_address($object);
857
+        $this->assertEquals("21 jump street\nMyTown, MyState, 99999",$address);
858 858
     }
859 859
 
860 860
 
@@ -903,7 +903,7 @@  discard block
 block discarded – undo
903 903
         print __METHOD__." s=".$s."\n";
904 904
         $this->assertContains('theme',$s,'testImgPicto1');
905 905
 
906
-    	$s=img_picto('title','img.png','style="float: right"',0);
906
+        $s=img_picto('title','img.png','style="float: right"',0);
907 907
         print __METHOD__." s=".$s."\n";
908 908
         $this->assertContains('theme',$s,'testImgPicto2');
909 909
         $this->assertContains('style="float: right"',$s,'testImgPicto2');
@@ -978,13 +978,13 @@  discard block
 block discarded – undo
978 978
         $companyfr=new Societe($db);
979 979
         $companyfr->country_code='FR';
980 980
         $companyfr->tva_assuj=1;
981
-		$companyfr->tva_intra='FR9999';
981
+        $companyfr->tva_intra='FR9999';
982 982
 
983 983
         // Buyers
984 984
         $companymc=new Societe($db);
985 985
         $companymc->country_code='MC';
986 986
         $companymc->tva_assuj=1;
987
-		$companyfr->tva_intra='MC9999';
987
+        $companyfr->tva_intra='MC9999';
988 988
 
989 989
         $companyit=new Societe($db);
990 990
         $companyit->country_code='IT';
@@ -1068,84 +1068,84 @@  discard block
 block discarded – undo
1068 1068
      */
1069 1069
     public function testGetDefaultLocalTax()
1070 1070
     {
1071
-    	global $conf,$user,$langs,$db;
1072
-    	$this->savconf=$conf;
1073
-    	$this->savuser=$user;
1074
-    	$this->savlangs=$langs;
1075
-    	$this->savdb=$db;
1076
-
1077
-    	$companyfrnovat=new Societe($db);
1078
-    	$companyfrnovat->country_code='FR';
1079
-    	$companyfrnovat->tva_assuj=0;
1080
-    	$companyfrnovat->localtax1_assuj=0;
1081
-    	$companyfrnovat->localtax2_assuj=0;
1082
-
1083
-    	$companyes=new Societe($db);
1084
-    	$companyes->country_code='ES';
1085
-    	$companyes->tva_assuj=1;
1086
-    	$companyes->localtax1_assuj=1;
1087
-    	$companyes->localtax2_assuj=1;
1088
-
1089
-    	$companymc=new Societe($db);
1090
-    	$companymc->country_code='MC';
1091
-    	$companymc->tva_assuj=1;
1092
-    	$companymc->localtax1_assuj=0;
1093
-    	$companymc->localtax2_assuj=0;
1094
-
1095
-    	$companyit=new Societe($db);
1096
-    	$companyit->country_code='IT';
1097
-    	$companyit->tva_assuj=1;
1098
-    	$companyit->tva_intra='IT99999';
1099
-    	$companyit->localtax1_assuj=0;
1100
-    	$companyit->localtax2_assuj=0;
1101
-
1102
-    	$notcompanyit=new Societe($db);
1103
-    	$notcompanyit->country_code='IT';
1104
-    	$notcompanyit->tva_assuj=1;
1105
-    	$notcompanyit->tva_intra='';
1106
-    	$notcompanyit->typent_code='TE_PRIVATE';
1107
-    	$notcompanyit->localtax1_assuj=0;
1108
-    	$notcompanyit->localtax2_assuj=0;
1109
-
1110
-    	$companyus=new Societe($db);
1111
-    	$companyus->country_code='US';
1112
-    	$companyus->tva_assuj=1;
1113
-    	$companyus->tva_intra='';
1114
-    	$companyus->localtax1_assuj=0;
1115
-    	$companyus->localtax2_assuj=0;
1116
-
1117
-    	// Test RULE FR-MC
1118
-    	$vat1=get_default_localtax($companyfrnovat,$companymc,1,0);
1119
-    	$vat2=get_default_localtax($companyfrnovat,$companymc,2,0);
1120
-    	$this->assertEquals(0,$vat1);
1121
-    	$this->assertEquals(0,$vat2);
1122
-
1123
-    	// Test RULE ES-ES
1124
-    	$vat1=get_default_localtax($companyes,$companyes,1,0);
1125
-    	$vat2=get_default_localtax($companyes,$companyes,2,0);
1126
-    	$this->assertEquals($vat1, 5.2);
1127
-    	$this->assertStringStartsWith((string) $vat2, '-19:-15:-9');       // Can be -19 (old version) or '-19:-15:-9' (new setup)
1128
-
1129
-    	// Test RULE ES-IT
1130
-    	$vat1=get_default_localtax($companyes,$companyit,1,0);
1131
-    	$vat2=get_default_localtax($companyes,$companyit,2,0);
1132
-    	$this->assertEquals(0,$vat1);
1133
-    	$this->assertEquals(0,$vat2);
1134
-
1135
-    	// Test RULE ES-IT
1136
-    	$vat1=get_default_localtax($companyes,$notcompanyit,1,0);
1137
-    	$vat2=get_default_localtax($companyes,$notcompanyit,2,0);
1138
-    	$this->assertEquals(0,$vat1);
1139
-    	$this->assertEquals(0,$vat2);
1140
-
1141
-    	// Test RULE FR-IT
1142
-    	// Not tested
1143
-
1144
-    	// Test RULE ES-US
1145
-    	$vat1=get_default_localtax($companyes,$companyus,1,0);
1146
-    	$vat2=get_default_localtax($companyes,$companyus,2,0);
1147
-    	$this->assertEquals(0,$vat1);
1148
-    	$this->assertEquals(0,$vat2);
1071
+        global $conf,$user,$langs,$db;
1072
+        $this->savconf=$conf;
1073
+        $this->savuser=$user;
1074
+        $this->savlangs=$langs;
1075
+        $this->savdb=$db;
1076
+
1077
+        $companyfrnovat=new Societe($db);
1078
+        $companyfrnovat->country_code='FR';
1079
+        $companyfrnovat->tva_assuj=0;
1080
+        $companyfrnovat->localtax1_assuj=0;
1081
+        $companyfrnovat->localtax2_assuj=0;
1082
+
1083
+        $companyes=new Societe($db);
1084
+        $companyes->country_code='ES';
1085
+        $companyes->tva_assuj=1;
1086
+        $companyes->localtax1_assuj=1;
1087
+        $companyes->localtax2_assuj=1;
1088
+
1089
+        $companymc=new Societe($db);
1090
+        $companymc->country_code='MC';
1091
+        $companymc->tva_assuj=1;
1092
+        $companymc->localtax1_assuj=0;
1093
+        $companymc->localtax2_assuj=0;
1094
+
1095
+        $companyit=new Societe($db);
1096
+        $companyit->country_code='IT';
1097
+        $companyit->tva_assuj=1;
1098
+        $companyit->tva_intra='IT99999';
1099
+        $companyit->localtax1_assuj=0;
1100
+        $companyit->localtax2_assuj=0;
1101
+
1102
+        $notcompanyit=new Societe($db);
1103
+        $notcompanyit->country_code='IT';
1104
+        $notcompanyit->tva_assuj=1;
1105
+        $notcompanyit->tva_intra='';
1106
+        $notcompanyit->typent_code='TE_PRIVATE';
1107
+        $notcompanyit->localtax1_assuj=0;
1108
+        $notcompanyit->localtax2_assuj=0;
1109
+
1110
+        $companyus=new Societe($db);
1111
+        $companyus->country_code='US';
1112
+        $companyus->tva_assuj=1;
1113
+        $companyus->tva_intra='';
1114
+        $companyus->localtax1_assuj=0;
1115
+        $companyus->localtax2_assuj=0;
1116
+
1117
+        // Test RULE FR-MC
1118
+        $vat1=get_default_localtax($companyfrnovat,$companymc,1,0);
1119
+        $vat2=get_default_localtax($companyfrnovat,$companymc,2,0);
1120
+        $this->assertEquals(0,$vat1);
1121
+        $this->assertEquals(0,$vat2);
1122
+
1123
+        // Test RULE ES-ES
1124
+        $vat1=get_default_localtax($companyes,$companyes,1,0);
1125
+        $vat2=get_default_localtax($companyes,$companyes,2,0);
1126
+        $this->assertEquals($vat1, 5.2);
1127
+        $this->assertStringStartsWith((string) $vat2, '-19:-15:-9');       // Can be -19 (old version) or '-19:-15:-9' (new setup)
1128
+
1129
+        // Test RULE ES-IT
1130
+        $vat1=get_default_localtax($companyes,$companyit,1,0);
1131
+        $vat2=get_default_localtax($companyes,$companyit,2,0);
1132
+        $this->assertEquals(0,$vat1);
1133
+        $this->assertEquals(0,$vat2);
1134
+
1135
+        // Test RULE ES-IT
1136
+        $vat1=get_default_localtax($companyes,$notcompanyit,1,0);
1137
+        $vat2=get_default_localtax($companyes,$notcompanyit,2,0);
1138
+        $this->assertEquals(0,$vat1);
1139
+        $this->assertEquals(0,$vat2);
1140
+
1141
+        // Test RULE FR-IT
1142
+        // Not tested
1143
+
1144
+        // Test RULE ES-US
1145
+        $vat1=get_default_localtax($companyes,$companyus,1,0);
1146
+        $vat2=get_default_localtax($companyes,$companyus,2,0);
1147
+        $this->assertEquals(0,$vat1);
1148
+        $this->assertEquals(0,$vat2);
1149 1149
     }
1150 1150
 
1151 1151
 
@@ -1156,108 +1156,108 @@  discard block
 block discarded – undo
1156 1156
      */
1157 1157
     public function testDolExplodeIntoArray()
1158 1158
     {
1159
-    	$stringtoexplode='AA=B/B.CC=.EE=FF.HH=GG;.';
1160
-    	$tmp=dolExplodeIntoArray($stringtoexplode,'.','=');
1159
+        $stringtoexplode='AA=B/B.CC=.EE=FF.HH=GG;.';
1160
+        $tmp=dolExplodeIntoArray($stringtoexplode,'.','=');
1161 1161
 
1162 1162
         print __METHOD__." tmp=".json_encode($tmp)."\n";
1163 1163
         $this->assertEquals('{"AA":"B\/B","CC":"","EE":"FF","HH":"GG;"}',json_encode($tmp));
1164 1164
     }
1165 1165
 
1166
-	/**
1167
-	 * dol_nl2br
1168
-	 *
1169
-	 * @return void
1170
-	 */
1166
+    /**
1167
+     * dol_nl2br
1168
+     *
1169
+     * @return void
1170
+     */
1171 1171
     public function testDolNl2Br()
1172 1172
     {
1173 1173
 
1174
-		//String to encode
1175
-		$string = "a\na";
1174
+        //String to encode
1175
+        $string = "a\na";
1176 1176
 
1177
-		$this->assertEquals(dol_nl2br($string), "a<br>\na");
1177
+        $this->assertEquals(dol_nl2br($string), "a<br>\na");
1178 1178
 
1179
-		//With $forxml parameter
1180
-		$this->assertEquals(dol_nl2br($string, 0, 1), "a<br />\na");
1179
+        //With $forxml parameter
1180
+        $this->assertEquals(dol_nl2br($string, 0, 1), "a<br />\na");
1181 1181
 
1182
-		//Replacing \n by br
1183
-		$this->assertEquals(dol_nl2br($string, 1), "a<br>a");
1182
+        //Replacing \n by br
1183
+        $this->assertEquals(dol_nl2br($string, 1), "a<br>a");
1184 1184
 
1185
-		//With $forxml parameter
1186
-		$this->assertEquals(dol_nl2br($string, 1, 1), "a<br />a");
1187
-	}
1185
+        //With $forxml parameter
1186
+        $this->assertEquals(dol_nl2br($string, 1, 1), "a<br />a");
1187
+    }
1188 1188
 
1189
-	/**
1190
-	 * testDolPrice2Num
1191
-	 *
1192
-	 * @return boolean
1193
-	 */
1194
-	public function testDolPrice2Num()
1195
-	{
1196
-		$this->assertEquals(1000, price2num('1 000.0'));
1197
-		$this->assertEquals(1000, price2num('1 000','MT'));
1198
-		$this->assertEquals(1000, price2num('1 000','MU'));
1189
+    /**
1190
+     * testDolPrice2Num
1191
+     *
1192
+     * @return boolean
1193
+     */
1194
+    public function testDolPrice2Num()
1195
+    {
1196
+        $this->assertEquals(1000, price2num('1 000.0'));
1197
+        $this->assertEquals(1000, price2num('1 000','MT'));
1198
+        $this->assertEquals(1000, price2num('1 000','MU'));
1199 1199
 
1200
-		$this->assertEquals(1000.123456, price2num('1 000.123456'));
1200
+        $this->assertEquals(1000.123456, price2num('1 000.123456'));
1201 1201
 
1202
-		// Round down
1203
-		$this->assertEquals(1000.12, price2num('1 000.123452','MT'));
1204
-		$this->assertEquals(1000.12345, price2num('1 000.123452','MU'),"Test MU");
1202
+        // Round down
1203
+        $this->assertEquals(1000.12, price2num('1 000.123452','MT'));
1204
+        $this->assertEquals(1000.12345, price2num('1 000.123452','MU'),"Test MU");
1205 1205
 
1206
-		// Round up
1207
-		$this->assertEquals(1000.13, price2num('1 000.125456','MT'));
1208
-		$this->assertEquals(1000.12546, price2num('1 000.125456','MU'),"Test MU");
1206
+        // Round up
1207
+        $this->assertEquals(1000.13, price2num('1 000.125456','MT'));
1208
+        $this->assertEquals(1000.12546, price2num('1 000.125456','MU'),"Test MU");
1209 1209
 
1210
-		// Text can't be converted
1211
-		$this->assertEquals('12.4$',price2num('12.4$'));
1212
-		$this->assertEquals('12r.4$',price2num('12r.4$'));
1210
+        // Text can't be converted
1211
+        $this->assertEquals('12.4$',price2num('12.4$'));
1212
+        $this->assertEquals('12r.4$',price2num('12r.4$'));
1213 1213
 
1214
-		return true;
1215
-	}
1214
+        return true;
1215
+    }
1216 1216
 
1217
-	/**
1218
-	 * testDolGetDate
1219
-	 *
1220
-	 * @return boolean
1221
-	 */
1222
-	public function testDolGetDate()
1223
-	{
1224
-		global $conf;
1217
+    /**
1218
+     * testDolGetDate
1219
+     *
1220
+     * @return boolean
1221
+     */
1222
+    public function testDolGetDate()
1223
+    {
1224
+        global $conf;
1225 1225
 
1226
-		$conf->global->MAIN_START_WEEK = 0;
1226
+        $conf->global->MAIN_START_WEEK = 0;
1227 1227
 
1228
-		$tmp=dol_getdate(1);				// 1/1/1970 and 1 second = thirday
1229
-		$this->assertEquals(4, $tmp['wday']);
1228
+        $tmp=dol_getdate(1);				// 1/1/1970 and 1 second = thirday
1229
+        $this->assertEquals(4, $tmp['wday']);
1230 1230
 
1231
-		$tmp=dol_getdate(24*60*60+1);		// 2/1/1970 and 1 second = friday
1232
-		$this->assertEquals(5, $tmp['wday']);
1231
+        $tmp=dol_getdate(24*60*60+1);		// 2/1/1970 and 1 second = friday
1232
+        $this->assertEquals(5, $tmp['wday']);
1233 1233
 
1234
-		$conf->global->MAIN_START_WEEK = 1;
1234
+        $conf->global->MAIN_START_WEEK = 1;
1235 1235
 
1236
-		$tmp=dol_getdate(1);				// 1/1/1970 and 1 second = thirday
1237
-		$this->assertEquals(4, $tmp['wday']);
1236
+        $tmp=dol_getdate(1);				// 1/1/1970 and 1 second = thirday
1237
+        $this->assertEquals(4, $tmp['wday']);
1238 1238
 
1239
-		$tmp=dol_getdate(24*60*60+1);		// 2/1/1970 and 1 second = friday
1240
-		$this->assertEquals(5, $tmp['wday']);
1239
+        $tmp=dol_getdate(24*60*60+1);		// 2/1/1970 and 1 second = friday
1240
+        $this->assertEquals(5, $tmp['wday']);
1241 1241
 
1242
-		return true;
1243
-	}
1242
+        return true;
1243
+    }
1244 1244
 
1245 1245
 
1246
-	/**
1247
-	 * testDolGetDate
1248
-	 *
1249
-	 * @return boolean
1250
-	 */
1251
-	public function testMakeSubstitutions()
1252
-	{
1253
-		global $conf, $langs;
1254
-		$langs->load("main");
1246
+    /**
1247
+     * testDolGetDate
1248
+     *
1249
+     * @return boolean
1250
+     */
1251
+    public function testMakeSubstitutions()
1252
+    {
1253
+        global $conf, $langs;
1254
+        $langs->load("main");
1255 1255
 
1256
-		$substit=array("AAA"=>'Not used', "BBB"=>'Not used', "CCC"=>"C replaced");
1257
-		$chaine='This is a string with __[MAIN_THEME]__ and __(DIRECTION)__ and __CCC__';
1258
-		$newstring = make_substitutions($chaine, $substit);
1259
-		$this->assertEquals($newstring, 'This is a string with eldy and ltr and __C replaced__');
1256
+        $substit=array("AAA"=>'Not used', "BBB"=>'Not used', "CCC"=>"C replaced");
1257
+        $chaine='This is a string with __[MAIN_THEME]__ and __(DIRECTION)__ and __CCC__';
1258
+        $newstring = make_substitutions($chaine, $substit);
1259
+        $this->assertEquals($newstring, 'This is a string with eldy and ltr and __C replaced__');
1260 1260
 
1261
-		return true;
1262
-	}
1261
+        return true;
1262
+    }
1263 1263
 }
Please login to merge, or discard this patch.
Spacing   +500 added lines, -500 removed lines patch added patch discarded remove patch
@@ -24,22 +24,22 @@  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';
31 31
 require_once dirname(__FILE__).'/../../htdocs/core/lib/date.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
 /**
45 45
  * Class for PHPUnit tests
@@ -66,11 +66,11 @@  discard block
 block discarded – undo
66 66
     	parent::__construct();
67 67
 
68 68
     	//$this->sharedFixture
69
-        global $conf,$user,$langs,$db;
70
-        $this->savconf=$conf;
71
-        $this->savuser=$user;
72
-        $this->savlangs=$langs;
73
-        $this->savdb=$db;
69
+        global $conf, $user, $langs, $db;
70
+        $this->savconf = $conf;
71
+        $this->savuser = $user;
72
+        $this->savlangs = $langs;
73
+        $this->savdb = $db;
74 74
 
75 75
         print __METHOD__." db->type=".$db->type." user->id=".$user->id;
76 76
         //print " - db ".$db->db;
@@ -80,10 +80,10 @@  discard block
 block discarded – undo
80 80
     // Static methods
81 81
     public static function setUpBeforeClass()
82 82
     {
83
-        global $conf,$user,$langs,$db;
83
+        global $conf, $user, $langs, $db;
84 84
         //$db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
85 85
 
86
-        if (! function_exists('mb_substr')) { print "\n".__METHOD__." function mb_substr must be enabled.\n"; die(); }
86
+        if (!function_exists('mb_substr')) { print "\n".__METHOD__." function mb_substr must be enabled.\n"; die(); }
87 87
 
88 88
         print __METHOD__."\n";
89 89
     }
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
     // tear down after class
92 92
     public static function tearDownAfterClass()
93 93
     {
94
-        global $conf,$user,$langs,$db;
94
+        global $conf, $user, $langs, $db;
95 95
         //$db->rollback();
96 96
 
97 97
         print __METHOD__."\n";
@@ -104,11 +104,11 @@  discard block
 block discarded – undo
104 104
 	 */
105 105
     protected function setUp()
106 106
     {
107
-        global $conf,$user,$langs,$db;
108
-        $conf=$this->savconf;
109
-        $user=$this->savuser;
110
-        $langs=$this->savlangs;
111
-        $db=$this->savdb;
107
+        global $conf, $user, $langs, $db;
108
+        $conf = $this->savconf;
109
+        $user = $this->savuser;
110
+        $langs = $this->savlangs;
111
+        $db = $this->savdb;
112 112
 
113 113
         print __METHOD__."\n";
114 114
     }
@@ -133,18 +133,18 @@  discard block
 block discarded – undo
133 133
     {
134 134
     	// Nb of line is same than entry text
135 135
 
136
-    	$input="yahoo.com";
137
-    	$result=isValidMXRecord($input);
136
+    	$input = "yahoo.com";
137
+    	$result = isValidMXRecord($input);
138 138
     	print __METHOD__." result=".$result."\n";
139 139
     	$this->assertEquals(1, $result);
140 140
 
141
-    	$input="yhaoo.com";
142
-    	$result=isValidMXRecord($input);
141
+    	$input = "yhaoo.com";
142
+    	$result = isValidMXRecord($input);
143 143
     	print __METHOD__." result=".$result."\n";
144 144
     	$this->assertEquals(0, $result);
145 145
 
146
-    	$input="dolibarr.fr";
147
-    	$result=isValidMXRecord($input);
146
+    	$input = "dolibarr.fr";
147
+    	$result = isValidMXRecord($input);
148 148
     	print __METHOD__." result=".$result."\n";
149 149
     	$this->assertEquals(0, $result);
150 150
     }
@@ -158,57 +158,57 @@  discard block
 block discarded – undo
158 158
     {
159 159
     	// Nb of line is same than entry text
160 160
 
161
-    	$input="aaaa";
162
-    	$result=dolGetFirstLineOfText($input);
161
+    	$input = "aaaa";
162
+    	$result = dolGetFirstLineOfText($input);
163 163
     	print __METHOD__." result=".$result."\n";
164 164
     	$this->assertEquals("aaaa", $result);
165 165
 
166
-    	$input="aaaa\nbbbbbbbbbbbb\n";
167
-    	$result=dolGetFirstLineOfText($input, 2);
166
+    	$input = "aaaa\nbbbbbbbbbbbb\n";
167
+    	$result = dolGetFirstLineOfText($input, 2);
168 168
     	print __METHOD__." result=".$result."\n";
169 169
     	$this->assertEquals("aaaa\nbbbbbbbbbbbb", $result);
170 170
 
171
-    	$input="aaaa<br>bbbbbbbbbbbb<br>";
172
-    	$result=dolGetFirstLineOfText($input, 2);
171
+    	$input = "aaaa<br>bbbbbbbbbbbb<br>";
172
+    	$result = dolGetFirstLineOfText($input, 2);
173 173
     	print __METHOD__." result=".$result."\n";
174 174
     	$this->assertEquals("aaaa<br>\nbbbbbbbbbbbb", $result);
175 175
 
176 176
     	// Nb of line is lower
177 177
 
178
-    	$input="aaaa\nbbbbbbbbbbbb\ncccccc\n";
179
-    	$result=dolGetFirstLineOfText($input);
178
+    	$input = "aaaa\nbbbbbbbbbbbb\ncccccc\n";
179
+    	$result = dolGetFirstLineOfText($input);
180 180
     	print __METHOD__." result=".$result."\n";
181 181
     	$this->assertEquals("aaaa...", $result);
182 182
 
183
-    	$input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>";
184
-    	$result=dolGetFirstLineOfText($input);
183
+    	$input = "aaaa<br>bbbbbbbbbbbb<br>cccccc<br>";
184
+    	$result = dolGetFirstLineOfText($input);
185 185
     	print __METHOD__." result=".$result."\n";
186 186
     	$this->assertEquals("aaaa...", $result);
187 187
 
188
-    	$input="aaaa\nbbbbbbbbbbbb\ncccccc\n";
189
-    	$result=dolGetFirstLineOfText($input, 2);
188
+    	$input = "aaaa\nbbbbbbbbbbbb\ncccccc\n";
189
+    	$result = dolGetFirstLineOfText($input, 2);
190 190
     	print __METHOD__." result=".$result."\n";
191 191
     	$this->assertEquals("aaaa\nbbbbbbbbbbbb...", $result);
192 192
 
193
-    	$input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>";
194
-    	$result=dolGetFirstLineOfText($input, 2);
193
+    	$input = "aaaa<br>bbbbbbbbbbbb<br>cccccc<br>";
194
+    	$result = dolGetFirstLineOfText($input, 2);
195 195
     	print __METHOD__." result=".$result."\n";
196 196
     	$this->assertEquals("aaaa<br>\nbbbbbbbbbbbb...", $result);
197 197
 
198 198
     	// Nb of line is higher
199 199
 
200
-    	$input="aaaa<br>bbbbbbbbbbbb<br>cccccc";
201
-    	$result=dolGetFirstLineOfText($input, 100);
200
+    	$input = "aaaa<br>bbbbbbbbbbbb<br>cccccc";
201
+    	$result = dolGetFirstLineOfText($input, 100);
202 202
     	print __METHOD__." result=".$result."\n";
203 203
     	$this->assertEquals("aaaa<br>\nbbbbbbbbbbbb<br>\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 a');
204 204
 
205
-    	$input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>";
206
-    	$result=dolGetFirstLineOfText($input, 100);
205
+    	$input = "aaaa<br>bbbbbbbbbbbb<br>cccccc<br>";
206
+    	$result = dolGetFirstLineOfText($input, 100);
207 207
     	print __METHOD__." result=".$result."\n";
208 208
     	$this->assertEquals("aaaa<br>\nbbbbbbbbbbbb<br>\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 b');
209 209
 
210
-    	$input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>\n";
211
-    	$result=dolGetFirstLineOfText($input, 100);
210
+    	$input = "aaaa<br>bbbbbbbbbbbb<br>cccccc<br>\n";
211
+    	$result = dolGetFirstLineOfText($input, 100);
212 212
     	print __METHOD__." result=".$result."\n";
213 213
     	$this->assertEquals("aaaa<br>\nbbbbbbbbbbbb<br>\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 c');
214 214
     }
@@ -229,11 +229,11 @@  discard block
 block discarded – undo
229 229
 	    var_dump($tmp);
230 230
 	    */
231 231
 
232
-	    $result=dol_buildpath('/google/oauth2callback.php', 2);
232
+	    $result = dol_buildpath('/google/oauth2callback.php', 2);
233 233
 	    print __METHOD__." result=".$result."\n";
234 234
 	    $this->assertStringStartsWith('http', $result);
235 235
 
236
-	    $result=dol_buildpath('/google/oauth2callback.php', 3);
236
+	    $result = dol_buildpath('/google/oauth2callback.php', 3);
237 237
         print __METHOD__." result=".$result."\n";
238 238
         $this->assertStringStartsWith('http', $result);
239 239
 	}
@@ -247,81 +247,81 @@  discard block
 block discarded – undo
247 247
     public function testGetBrowserInfo()
248 248
     {
249 249
 		// MSIE 5.0
250
-        $user_agent ='Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt; KITV4 Wanadoo; KITV5 Wanadoo)';
251
-        $tmp=getBrowserInfo($user_agent);
252
-        $this->assertEquals('ie',$tmp['browsername']);
253
-        $this->assertEquals('5.0',$tmp['browserversion']);
250
+        $user_agent = 'Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt; KITV4 Wanadoo; KITV5 Wanadoo)';
251
+        $tmp = getBrowserInfo($user_agent);
252
+        $this->assertEquals('ie', $tmp['browsername']);
253
+        $this->assertEquals('5.0', $tmp['browserversion']);
254 254
 	    $this->assertEmpty($tmp['phone']);
255 255
 	    $this->assertFalse($tmp['tablet']);
256 256
 	    $this->assertEquals('classic', $tmp['layout']);
257 257
 
258 258
 		// Firefox 0.9.1
259
-        $user_agent ='Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5a) Gecko/20030728 Mozilla Firefox/0.9.1';
260
-        $tmp=getBrowserInfo($user_agent);
261
-        $this->assertEquals('firefox',$tmp['browsername']);
262
-        $this->assertEquals('0.9.1',$tmp['browserversion']);
259
+        $user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5a) Gecko/20030728 Mozilla Firefox/0.9.1';
260
+        $tmp = getBrowserInfo($user_agent);
261
+        $this->assertEquals('firefox', $tmp['browsername']);
262
+        $this->assertEquals('0.9.1', $tmp['browserversion']);
263 263
 	    $this->assertEmpty($tmp['phone']);
264 264
 	    $this->assertFalse($tmp['tablet']);
265 265
 	    $this->assertEquals('classic', $tmp['layout']);
266 266
 
267
-        $user_agent ='Mozilla/3.0 (Windows 98; U) Opera 6.03  [en]';
268
-        $tmp=getBrowserInfo($user_agent);
269
-        $this->assertEquals('opera',$tmp['browsername']);
270
-        $this->assertEquals('6.03',$tmp['browserversion']);
267
+        $user_agent = 'Mozilla/3.0 (Windows 98; U) Opera 6.03  [en]';
268
+        $tmp = getBrowserInfo($user_agent);
269
+        $this->assertEquals('opera', $tmp['browsername']);
270
+        $this->assertEquals('6.03', $tmp['browserversion']);
271 271
 	    $this->assertEmpty($tmp['phone']);
272 272
 	    $this->assertFalse($tmp['tablet']);
273 273
 	    $this->assertEquals('classic', $tmp['layout']);
274 274
 
275
-        $user_agent ='Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.21 (KHTML, like Gecko) Chrome/19.0.1042.0 Safari/535.21';
276
-        $tmp=getBrowserInfo($user_agent);
277
-        $this->assertEquals('chrome',$tmp['browsername']);
278
-        $this->assertEquals('19.0.1042.0',$tmp['browserversion']);
275
+        $user_agent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.21 (KHTML, like Gecko) Chrome/19.0.1042.0 Safari/535.21';
276
+        $tmp = getBrowserInfo($user_agent);
277
+        $this->assertEquals('chrome', $tmp['browsername']);
278
+        $this->assertEquals('19.0.1042.0', $tmp['browserversion']);
279 279
 	    $this->assertEmpty($tmp['phone']);
280 280
 	    $this->assertFalse($tmp['tablet']);
281 281
 	    $this->assertEquals('classic', $tmp['layout']);
282 282
 
283
-        $user_agent ='chrome (Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11)';
284
-        $tmp=getBrowserInfo($user_agent);
285
-        $this->assertEquals('chrome',$tmp['browsername']);
286
-        $this->assertEquals('17.0.963.56',$tmp['browserversion']);
283
+        $user_agent = 'chrome (Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11)';
284
+        $tmp = getBrowserInfo($user_agent);
285
+        $this->assertEquals('chrome', $tmp['browsername']);
286
+        $this->assertEquals('17.0.963.56', $tmp['browserversion']);
287 287
 	    $this->assertEmpty($tmp['phone']);
288 288
 	    $this->assertFalse($tmp['tablet']);
289 289
 	    $this->assertEquals('classic', $tmp['layout']);
290 290
 
291
-        $user_agent ='Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; de-at) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1';
292
-        $tmp=getBrowserInfo($user_agent);
293
-        $this->assertEquals('safari',$tmp['browsername']);
294
-        $this->assertEquals('533.21.1',$tmp['browserversion']);
291
+        $user_agent = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; de-at) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1';
292
+        $tmp = getBrowserInfo($user_agent);
293
+        $this->assertEquals('safari', $tmp['browsername']);
294
+        $this->assertEquals('533.21.1', $tmp['browserversion']);
295 295
 	    $this->assertEmpty($tmp['phone']);
296 296
 	    $this->assertFalse($tmp['tablet']);
297 297
 	    $this->assertEquals('classic', $tmp['layout']);
298 298
 
299 299
 	    //Internet Explorer 11
300 300
 	    $user_agent = 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko';
301
-	    $tmp=getBrowserInfo($user_agent);
302
-	    $this->assertEquals('ie',$tmp['browsername']);
303
-	    $this->assertEquals('11.0',$tmp['browserversion']);
301
+	    $tmp = getBrowserInfo($user_agent);
302
+	    $this->assertEquals('ie', $tmp['browsername']);
303
+	    $this->assertEquals('11.0', $tmp['browserversion']);
304 304
 	    $this->assertEmpty($tmp['phone']);
305 305
 	    $this->assertFalse($tmp['tablet']);
306 306
 	    $this->assertEquals('classic', $tmp['layout']);
307 307
 
308 308
 	    //Internet Explorer 11 bis
309 309
 	    $user_agent = 'Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; NP06; rv:11.0) like Gecko';
310
-	    $tmp=getBrowserInfo($user_agent);
311
-	    $this->assertEquals('ie',$tmp['browsername']);
312
-	    $this->assertEquals('11.0',$tmp['browserversion']);
310
+	    $tmp = getBrowserInfo($user_agent);
311
+	    $this->assertEquals('ie', $tmp['browsername']);
312
+	    $this->assertEquals('11.0', $tmp['browserversion']);
313 313
 	    $this->assertEmpty($tmp['phone']);
314 314
 	    $this->assertFalse($tmp['tablet']);
315 315
 	    $this->assertEquals('classic', $tmp['layout']);
316 316
 
317 317
 	    //iPad
318 318
 	    $user_agent = 'Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25';
319
-	    $tmp=getBrowserInfo($user_agent);
320
-	    $this->assertEquals('safari',$tmp['browsername']);
321
-	    $this->assertEquals('8536.25',$tmp['browserversion']);
322
-	    $this->assertEquals('ios',$tmp['browseros']);
323
-	    $this->assertEquals('tablet',$tmp['layout']);
324
-	    $this->assertEquals('iphone',$tmp['phone']);
319
+	    $tmp = getBrowserInfo($user_agent);
320
+	    $this->assertEquals('safari', $tmp['browsername']);
321
+	    $this->assertEquals('8536.25', $tmp['browserversion']);
322
+	    $this->assertEquals('ios', $tmp['browseros']);
323
+	    $this->assertEquals('tablet', $tmp['layout']);
324
+	    $this->assertEquals('iphone', $tmp['phone']);
325 325
     }
326 326
 
327 327
 
@@ -384,64 +384,64 @@  discard block
 block discarded – undo
384 384
     public function testDolTextIsHtml()
385 385
     {
386 386
         // True
387
-        $input='<html>xxx</html>';
388
-        $after=dol_textishtml($input);
387
+        $input = '<html>xxx</html>';
388
+        $after = dol_textishtml($input);
389 389
         $this->assertTrue($after, 'Test with html tag');
390
-        $input='<body>xxx</body>';
391
-        $after=dol_textishtml($input);
390
+        $input = '<body>xxx</body>';
391
+        $after = dol_textishtml($input);
392 392
         $this->assertTrue($after, 'Test with body tag');
393
-        $input='xxx <b>yyy</b> zzz';
394
-        $after=dol_textishtml($input);
393
+        $input = 'xxx <b>yyy</b> zzz';
394
+        $after = dol_textishtml($input);
395 395
         $this->assertTrue($after, 'Test with b tag');
396
-        $input='xxx <u>yyy</u> zzz';
397
-        $after=dol_textishtml($input);
396
+        $input = 'xxx <u>yyy</u> zzz';
397
+        $after = dol_textishtml($input);
398 398
         $this->assertTrue($after, 'Test with u tag');
399
-        $input='text with <div>some div</div>';
400
-        $after=dol_textishtml($input);
399
+        $input = 'text with <div>some div</div>';
400
+        $after = dol_textishtml($input);
401 401
         $this->assertTrue($after, 'Test with div tag');
402
-        $input='text with HTML &nbsp; entities';
403
-        $after=dol_textishtml($input);
402
+        $input = 'text with HTML &nbsp; entities';
403
+        $after = dol_textishtml($input);
404 404
         $this->assertTrue($after, 'Test with entities tag');
405
-        $input='xxx<br>';
406
-        $after=dol_textishtml($input);
405
+        $input = 'xxx<br>';
406
+        $after = dol_textishtml($input);
407 407
         $this->assertTrue($after, 'Test with entities br');
408
-        $input='xxx<br >';
409
-        $after=dol_textishtml($input);
408
+        $input = 'xxx<br >';
409
+        $after = dol_textishtml($input);
410 410
         $this->assertTrue($after, 'Test with entities br');
411
-        $input='xxx<br style="eee">';
412
-        $after=dol_textishtml($input);
411
+        $input = 'xxx<br style="eee">';
412
+        $after = dol_textishtml($input);
413 413
         $this->assertTrue($after, 'Test with entities br and attributes');
414
-        $input='xxx<br style="eee" >';
415
-        $after=dol_textishtml($input);
414
+        $input = 'xxx<br style="eee" >';
415
+        $after = dol_textishtml($input);
416 416
         $this->assertTrue($after, 'Test with entities br and attributes bis');
417
-        $input='<h2>abc</h2>';
418
-        $after=dol_textishtml($input);
417
+        $input = '<h2>abc</h2>';
418
+        $after = dol_textishtml($input);
419 419
         $this->assertTrue($after, 'Test with entities h2');
420
-        $input='<img id="abc" src="https://xxx.com/aaa/image.png" />';
421
-        $after=dol_textishtml($input);
420
+        $input = '<img id="abc" src="https://xxx.com/aaa/image.png" />';
421
+        $after = dol_textishtml($input);
422 422
         $this->assertTrue($after, 'Test with img tag');
423
-        $input='<a class="azerty" href="https://xxx.com/aaa/image.png" />';
424
-        $after=dol_textishtml($input);
423
+        $input = '<a class="azerty" href="https://xxx.com/aaa/image.png" />';
424
+        $after = dol_textishtml($input);
425 425
         $this->assertTrue($after, 'Test with a tag');
426
-        $input='This is a text with&nbsp;html spaces';
427
-        $after=dol_textishtml($input);
426
+        $input = 'This is a text with&nbsp;html spaces';
427
+        $after = dol_textishtml($input);
428 428
         $this->assertTrue($after, 'Test with a &nbsp;');
429
-        $input='This is a text with accent &eacute;';
430
-        $after=dol_textishtml($input);
429
+        $input = 'This is a text with accent &eacute;';
430
+        $after = dol_textishtml($input);
431 431
         $this->assertTrue($after, 'Test with a &eacute;');
432 432
 
433 433
         // False
434
-        $input='xxx < br>';
435
-        $after=dol_textishtml($input);
434
+        $input = 'xxx < br>';
435
+        $after = dol_textishtml($input);
436 436
         $this->assertFalse($after);
437
-        $input='xxx <[email protected]>';	// <em> is html, <em... is not
438
-        $after=dol_textishtml($input);
437
+        $input = 'xxx <[email protected]>'; // <em> is html, <em... is not
438
+        $after = dol_textishtml($input);
439 439
         $this->assertFalse($after);
440
-        $input='xxx <brstyle="ee">';
441
-        $after=dol_textishtml($input);
440
+        $input = 'xxx <brstyle="ee">';
441
+        $after = dol_textishtml($input);
442 442
         $this->assertFalse($after);
443
-        $input='This is a text with html comments <!-- comment -->';	// we suppose this is not enough to be html content
444
-        $after=dol_textishtml($input);
443
+        $input = 'This is a text with html comments <!-- comment -->'; // we suppose this is not enough to be html content
444
+        $after = dol_textishtml($input);
445 445
         $this->assertFalse($after);
446 446
     }
447 447
 
@@ -453,33 +453,33 @@  discard block
 block discarded – undo
453 453
      */
454 454
     public function testDolHtmlCleanLastBr()
455 455
     {
456
-        $input="A string\n";
457
-        $after=dol_htmlcleanlastbr($input);
458
-        $this->assertEquals("A string",$after);
456
+        $input = "A string\n";
457
+        $after = dol_htmlcleanlastbr($input);
458
+        $this->assertEquals("A string", $after);
459 459
 
460
-        $input="A string first\nA string second\n";
461
-        $after=dol_htmlcleanlastbr($input);
462
-        $this->assertEquals("A string first\nA string second",$after);
460
+        $input = "A string first\nA string second\n";
461
+        $after = dol_htmlcleanlastbr($input);
462
+        $this->assertEquals("A string first\nA string second", $after);
463 463
 
464
-        $input="A string\n\n\n";
465
-        $after=dol_htmlcleanlastbr($input);
466
-        $this->assertEquals("A string",$after);
464
+        $input = "A string\n\n\n";
465
+        $after = dol_htmlcleanlastbr($input);
466
+        $this->assertEquals("A string", $after);
467 467
 
468
-        $input="A string<br>";
469
-        $after=dol_htmlcleanlastbr($input);
470
-        $this->assertEquals("A string",$after);
468
+        $input = "A string<br>";
469
+        $after = dol_htmlcleanlastbr($input);
470
+        $this->assertEquals("A string", $after);
471 471
 
472
-        $input="A string first<br>\nA string second<br>";
473
-        $after=dol_htmlcleanlastbr($input);
474
-        $this->assertEquals("A string first<br>\nA string second",$after);
472
+        $input = "A string first<br>\nA string second<br>";
473
+        $after = dol_htmlcleanlastbr($input);
474
+        $this->assertEquals("A string first<br>\nA string second", $after);
475 475
 
476
-        $input="A string\n<br type=\"_moz\" />\n";
477
-        $after=dol_htmlcleanlastbr($input);
478
-        $this->assertEquals("A string",$after);
476
+        $input = "A string\n<br type=\"_moz\" />\n";
477
+        $after = dol_htmlcleanlastbr($input);
478
+        $this->assertEquals("A string", $after);
479 479
 
480
-        $input="A string\n<br><br />\n\n";
481
-        $after=dol_htmlcleanlastbr($input);
482
-        $this->assertEquals("A string",$after);
480
+        $input = "A string\n<br><br />\n\n";
481
+        $after = dol_htmlcleanlastbr($input);
482
+        $this->assertEquals("A string", $after);
483 483
 
484 484
         return true;
485 485
     }
@@ -491,17 +491,17 @@  discard block
 block discarded – undo
491 491
      */
492 492
     public function testDolConcat()
493 493
     {
494
-        $text1="A string 1"; $text2="A string 2";	// text 1 and 2 are text, concat need only \n
495
-        $after=dol_concatdesc($text1, $text2);
496
-        $this->assertEquals("A string 1\nA string 2",$after);
494
+        $text1 = "A string 1"; $text2 = "A string 2"; // text 1 and 2 are text, concat need only \n
495
+        $after = dol_concatdesc($text1, $text2);
496
+        $this->assertEquals("A string 1\nA string 2", $after);
497 497
 
498
-        $text1="A<br>string 1"; $text2="A string 2";	// text 1 is html, concat need <br>\n
499
-        $after=dol_concatdesc($text1, $text2);
500
-        $this->assertEquals("A<br>string 1<br>\nA string 2",$after);
498
+        $text1 = "A<br>string 1"; $text2 = "A string 2"; // text 1 is html, concat need <br>\n
499
+        $after = dol_concatdesc($text1, $text2);
500
+        $this->assertEquals("A<br>string 1<br>\nA string 2", $after);
501 501
 
502
-        $text1="A string 1"; $text2="A <b>string</b> 2";	// text 2 is html, concat need <br>\n
503
-        $after=dol_concatdesc($text1, $text2);
504
-        $this->assertEquals("A string 1<br>\nA <b>string</b> 2",$after);
502
+        $text1 = "A string 1"; $text2 = "A <b>string</b> 2"; // text 2 is html, concat need <br>\n
503
+        $after = dol_concatdesc($text1, $text2);
504
+        $this->assertEquals("A string 1<br>\nA <b>string</b> 2", $after);
505 505
 
506 506
         return true;
507 507
     }
@@ -514,49 +514,49 @@  discard block
 block discarded – undo
514 514
      */
515 515
     public function testDolStringNohtmltag()
516 516
     {
517
-        $text="A\nstring\n\nand more\n";
518
-        $after=dol_string_nohtmltag($text,0);
519
-        $this->assertEquals("A\nstring\n\nand more",$after,"test1a");
517
+        $text = "A\nstring\n\nand more\n";
518
+        $after = dol_string_nohtmltag($text, 0);
519
+        $this->assertEquals("A\nstring\n\nand more", $after, "test1a");
520 520
 
521
-        $text="A <b>string<b><br>\n<br>\n\nwith html tag<br>\n";
522
-        $after=dol_string_nohtmltag($text, 0);
523
-        $this->assertEquals("A string\n\n\n\n\nwith html tag",$after,"test2a 2 br and 3 \n give 5 \n");
521
+        $text = "A <b>string<b><br>\n<br>\n\nwith html tag<br>\n";
522
+        $after = dol_string_nohtmltag($text, 0);
523
+        $this->assertEquals("A string\n\n\n\n\nwith html tag", $after, "test2a 2 br and 3 \n give 5 \n");
524 524
 
525
-        $text="A <b>string<b><br>\n<br>\n\nwith html tag<br>\n";
526
-        $after=dol_string_nohtmltag($text, 1);
527
-        $this->assertEquals("A string with html tag",$after,"test2b 2 br and 3 \n give 1 space");
525
+        $text = "A <b>string<b><br>\n<br>\n\nwith html tag<br>\n";
526
+        $after = dol_string_nohtmltag($text, 1);
527
+        $this->assertEquals("A string with html tag", $after, "test2b 2 br and 3 \n give 1 space");
528 528
 
529
-        $text="A <b>string<b><br>\n<br>\n\nwith html tag<br>\n";
530
-        $after=dol_string_nohtmltag($text, 2);
531
-        $this->assertEquals("A string\n\nwith html tag",$after,"test2c 2 br and 3 \n give 2 \n");
529
+        $text = "A <b>string<b><br>\n<br>\n\nwith html tag<br>\n";
530
+        $after = dol_string_nohtmltag($text, 2);
531
+        $this->assertEquals("A string\n\nwith html tag", $after, "test2c 2 br and 3 \n give 2 \n");
532 532
 
533
-        $text="A string<br>Another string";
534
-        $after=dol_string_nohtmltag($text,0);
535
-        $this->assertEquals("A string\nAnother string",$after,"test4");
533
+        $text = "A string<br>Another string";
534
+        $after = dol_string_nohtmltag($text, 0);
535
+        $this->assertEquals("A string\nAnother string", $after, "test4");
536 536
 
537
-        $text="A string<br>Another string";
538
-        $after=dol_string_nohtmltag($text,1);
539
-        $this->assertEquals("A string Another string",$after,"test5");
537
+        $text = "A string<br>Another string";
538
+        $after = dol_string_nohtmltag($text, 1);
539
+        $this->assertEquals("A string Another string", $after, "test5");
540 540
 
541
-        $text='<a href="/myurl" title="<u>Afficher projet</u>">ABC</a>';
542
-        $after=dol_string_nohtmltag($text,1);
543
-        $this->assertEquals("ABC",$after,"test6");
541
+        $text = '<a href="/myurl" title="<u>Afficher projet</u>">ABC</a>';
542
+        $after = dol_string_nohtmltag($text, 1);
543
+        $this->assertEquals("ABC", $after, "test6");
544 544
 
545
-        $text='<a href="/myurl" title="&lt;u&gt;Afficher projet&lt;/u&gt;">DEF</a>';
546
-        $after=dol_string_nohtmltag($text,1);
547
-        $this->assertEquals("DEF",$after,"test7");
545
+        $text = '<a href="/myurl" title="&lt;u&gt;Afficher projet&lt;/u&gt;">DEF</a>';
546
+        $after = dol_string_nohtmltag($text, 1);
547
+        $this->assertEquals("DEF", $after, "test7");
548 548
 
549
-        $text='<a href="/myurl" title="<u>A title</u>">HIJ</a>';
550
-        $after=dol_string_nohtmltag($text,0);
551
-        $this->assertEquals("HIJ",$after,"test8");
549
+        $text = '<a href="/myurl" title="<u>A title</u>">HIJ</a>';
550
+        $after = dol_string_nohtmltag($text, 0);
551
+        $this->assertEquals("HIJ", $after, "test8");
552 552
 
553
-        $text="A <b>string<b>\n\nwith html tag and '<' chars<br>\n";
554
-        $after=dol_string_nohtmltag($text, 0);
555
-        $this->assertEquals("A string\n\nwith html tag and '<' chars",$after,"test9");
553
+        $text = "A <b>string<b>\n\nwith html tag and '<' chars<br>\n";
554
+        $after = dol_string_nohtmltag($text, 0);
555
+        $this->assertEquals("A string\n\nwith html tag and '<' chars", $after, "test9");
556 556
 
557
-        $text="A <b>string<b>\n\nwith tag with < chars<br>\n";
558
-        $after=dol_string_nohtmltag($text, 1);
559
-        $this->assertEquals("A string with tag with < chars",$after,"test10");
557
+        $text = "A <b>string<b>\n\nwith tag with < chars<br>\n";
558
+        $after = dol_string_nohtmltag($text, 1);
559
+        $this->assertEquals("A string with tag with < chars", $after, "test10");
560 560
 
561 561
         return true;
562 562
     }
@@ -572,39 +572,39 @@  discard block
 block discarded – undo
572 572
     {
573 573
     	// Text not already HTML
574 574
 
575
-    	$input="A string\nwith a é, &, < and >.";
576
-        $after=dol_htmlentitiesbr($input,0);    // Add <br> before \n
577
-        $this->assertEquals("A string<br>\nwith a &eacute;, &amp;, &lt; and &gt;.",$after);
575
+    	$input = "A string\nwith a é, &, < and >.";
576
+        $after = dol_htmlentitiesbr($input, 0); // Add <br> before \n
577
+        $this->assertEquals("A string<br>\nwith a &eacute;, &amp;, &lt; and &gt;.", $after);
578 578
 
579
-        $input="A string\nwith a é, &, < and >.";
580
-        $after=dol_htmlentitiesbr($input,1);    // Replace \n with <br>
581
-        $this->assertEquals("A string<br>with a &eacute;, &amp;, &lt; and &gt;.",$after);
579
+        $input = "A string\nwith a é, &, < and >.";
580
+        $after = dol_htmlentitiesbr($input, 1); // Replace \n with <br>
581
+        $this->assertEquals("A string<br>with a &eacute;, &amp;, &lt; and &gt;.", $after);
582 582
 
583
-        $input="A string\nwith a é, &, < and >.\n\n";	// With some \n at end that should be cleaned
584
-        $after=dol_htmlentitiesbr($input,0);    // Add <br> before \n
585
-        $this->assertEquals("A string<br>\nwith a &eacute;, &amp;, &lt; and &gt;.",$after);
583
+        $input = "A string\nwith a é, &, < and >.\n\n"; // With some \n at end that should be cleaned
584
+        $after = dol_htmlentitiesbr($input, 0); // Add <br> before \n
585
+        $this->assertEquals("A string<br>\nwith a &eacute;, &amp;, &lt; and &gt;.", $after);
586 586
 
587
-        $input="A string\nwith a é, &, < and >.\n\n";	// With some \n at end that should be cleaned
588
-        $after=dol_htmlentitiesbr($input,1);    // Replace \n with <br>
589
-        $this->assertEquals("A string<br>with a &eacute;, &amp;, &lt; and &gt;.",$after);
587
+        $input = "A string\nwith a é, &, < and >.\n\n"; // With some \n at end that should be cleaned
588
+        $after = dol_htmlentitiesbr($input, 1); // Replace \n with <br>
589
+        $this->assertEquals("A string<br>with a &eacute;, &amp;, &lt; and &gt;.", $after);
590 590
 
591 591
         // Text already HTML, so &,<,> should not be converted
592 592
 
593
-        $input="A string<br>\nwith a é, &, < and >.";
594
-        $after=dol_htmlentitiesbr($input);
595
-        $this->assertEquals("A string<br>\nwith a &eacute;, &, < and >.",$after);
593
+        $input = "A string<br>\nwith a é, &, < and >.";
594
+        $after = dol_htmlentitiesbr($input);
595
+        $this->assertEquals("A string<br>\nwith a &eacute;, &, < and >.", $after);
596 596
 
597
-        $input="<li>\nA string with a é, &, < and >.</li>\nAnother string";
598
-        $after=dol_htmlentitiesbr($input);
599
-        $this->assertEquals("<li>\nA string with a &eacute;, &, < and >.</li>\nAnother string",$after);
597
+        $input = "<li>\nA string with a é, &, < and >.</li>\nAnother string";
598
+        $after = dol_htmlentitiesbr($input);
599
+        $this->assertEquals("<li>\nA string with a &eacute;, &, < and >.</li>\nAnother string", $after);
600 600
 
601
-        $input="A string<br>\nwith a é, &, < and >.<br>";	// With some <br> at end that should be cleaned
602
-        $after=dol_htmlentitiesbr($input);
603
-        $this->assertEquals("A string<br>\nwith a &eacute;, &, < and >.",$after);
601
+        $input = "A string<br>\nwith a é, &, < and >.<br>"; // With some <br> at end that should be cleaned
602
+        $after = dol_htmlentitiesbr($input);
603
+        $this->assertEquals("A string<br>\nwith a &eacute;, &, < and >.", $after);
604 604
 
605
-        $input="<li>\nA string with a é, &, < and >.</li>\nAnother string<br>";	// With some <br> at end that should be cleaned
606
-        $after=dol_htmlentitiesbr($input);
607
-        $this->assertEquals("<li>\nA string with a &eacute;, &, < and >.</li>\nAnother string",$after);
605
+        $input = "<li>\nA string with a é, &, < and >.</li>\nAnother string<br>"; // With some <br> at end that should be cleaned
606
+        $after = dol_htmlentitiesbr($input);
607
+        $this->assertEquals("<li>\nA string with a &eacute;, &, < and >.</li>\nAnother string", $after);
608 608
 
609 609
         // TODO Add test with param $removelasteolbr = 0
610 610
 
@@ -620,19 +620,19 @@  discard block
 block discarded – undo
620 620
     public function testDolNbOfLinesBis()
621 621
     {
622 622
         // This is not a html string so nb of lines depends on \n
623
-        $input="A string\nwith a é, &, < and > and bold tag.\nThird line";
624
-        $after=dol_nboflines_bis($input,0);
625
-        $this->assertEquals($after,3);
623
+        $input = "A string\nwith a é, &, < and > and bold tag.\nThird line";
624
+        $after = dol_nboflines_bis($input, 0);
625
+        $this->assertEquals($after, 3);
626 626
 
627 627
         // This is a html string so nb of lines depends on <br>
628
-        $input="A string\nwith a é, &, < and > and <b>bold</b> tag.\nThird line";
629
-        $after=dol_nboflines_bis($input,0);
630
-        $this->assertEquals($after,1);
628
+        $input = "A string\nwith a é, &, < and > and <b>bold</b> tag.\nThird line";
629
+        $after = dol_nboflines_bis($input, 0);
630
+        $this->assertEquals($after, 1);
631 631
 
632 632
         // This is a html string so nb of lines depends on <br>
633
-        $input="A string<br>with a é, &, < and > and <b>bold</b> tag.<br>Third line";
634
-        $after=dol_nboflines_bis($input,0);
635
-        $this->assertEquals($after,3);
633
+        $input = "A string<br>with a é, &, < and > and <b>bold</b> tag.<br>Third line";
634
+        $after = dol_nboflines_bis($input, 0);
635
+        $this->assertEquals($after, 3);
636 636
 
637 637
         return true;
638 638
     }
@@ -647,9 +647,9 @@  discard block
 block discarded – undo
647 647
     {
648 648
     	// Text not already HTML
649 649
 
650
-    	$input="A string\nwith a à ä é è ë ï ü ö ÿ, &, < and >.";
651
-        $after=dol_string_unaccent($input);
652
-        $this->assertEquals("A string\nwith a a a e e e i u o y, &, < and >.",$after);
650
+    	$input = "A string\nwith a à ä é è ë ï ü ö ÿ, &, < and >.";
651
+        $after = dol_string_unaccent($input);
652
+        $this->assertEquals("A string\nwith a a a e e e i u o y, &, < and >.", $after);
653 653
     }
654 654
 
655 655
 
@@ -661,17 +661,17 @@  discard block
 block discarded – undo
661 661
     public function testDolUtf8Check()
662 662
     {
663 663
         // True
664
-        $result=utf8_check('azerty');
664
+        $result = utf8_check('azerty');
665 665
         $this->assertTrue($result);
666 666
 
667
-        $file=dirname(__FILE__).'/textutf8.txt';
668
-        $filecontent=file_get_contents($file);
669
-        $result=utf8_check($filecontent);
667
+        $file = dirname(__FILE__).'/textutf8.txt';
668
+        $filecontent = file_get_contents($file);
669
+        $result = utf8_check($filecontent);
670 670
         $this->assertTrue($result);
671 671
 
672
-        $file=dirname(__FILE__).'/textiso.txt';
673
-        $filecontent=file_get_contents($file);
674
-        $result=utf8_check($filecontent);
672
+        $file = dirname(__FILE__).'/textiso.txt';
673
+        $filecontent = file_get_contents($file);
674
+        $result = utf8_check($filecontent);
675 675
         $this->assertFalse($result);
676 676
     }
677 677
 
@@ -683,50 +683,50 @@  discard block
 block discarded – undo
683 683
     public function testDolTrunc()
684 684
     {
685 685
         // Default trunc (will add ... if truncation truncation or keep last char if only one char)
686
-        $input="éeéeéeàa";
687
-        $after=dol_trunc($input,3);
688
-        $this->assertEquals("éeé...",$after,'Test A1');
689
-        $after=dol_trunc($input,2);
690
-        $this->assertEquals("ée...",$after,'Test A2');
691
-        $after=dol_trunc($input,1);
692
-        $this->assertEquals("é...",$after,'Test A3');
693
-        $input="éeéeé";
694
-        $after=dol_trunc($input,3);
695
-        $this->assertEquals("éeéeé",$after,'Test B1');
696
-        $after=dol_trunc($input,2);
697
-        $this->assertEquals("éeéeé",$after,'Test B2');
698
-        $after=dol_trunc($input,1);
699
-        $this->assertEquals("é...",$after,'Test B3');
700
-        $input="éeée";
701
-        $after=dol_trunc($input,3);
702
-        $this->assertEquals("éeée",$after,'Test C1');
703
-        $after=dol_trunc($input,2);
704
-        $this->assertEquals("éeée",$after,'Test C2');
705
-        $after=dol_trunc($input,1);
706
-        $this->assertEquals("éeée",$after,'Test C3');
707
-        $input="éeé";
708
-        $after=dol_trunc($input,3);
709
-        $this->assertEquals("éeé",$after,'Test C');
710
-        $after=dol_trunc($input,2);
711
-        $this->assertEquals("éeé",$after,'Test D');
712
-        $after=dol_trunc($input,1);
713
-        $this->assertEquals("éeé",$after,'Test E');
686
+        $input = "éeéeéeàa";
687
+        $after = dol_trunc($input, 3);
688
+        $this->assertEquals("éeé...", $after, 'Test A1');
689
+        $after = dol_trunc($input, 2);
690
+        $this->assertEquals("ée...", $after, 'Test A2');
691
+        $after = dol_trunc($input, 1);
692
+        $this->assertEquals("é...", $after, 'Test A3');
693
+        $input = "éeéeé";
694
+        $after = dol_trunc($input, 3);
695
+        $this->assertEquals("éeéeé", $after, 'Test B1');
696
+        $after = dol_trunc($input, 2);
697
+        $this->assertEquals("éeéeé", $after, 'Test B2');
698
+        $after = dol_trunc($input, 1);
699
+        $this->assertEquals("é...", $after, 'Test B3');
700
+        $input = "éeée";
701
+        $after = dol_trunc($input, 3);
702
+        $this->assertEquals("éeée", $after, 'Test C1');
703
+        $after = dol_trunc($input, 2);
704
+        $this->assertEquals("éeée", $after, 'Test C2');
705
+        $after = dol_trunc($input, 1);
706
+        $this->assertEquals("éeée", $after, 'Test C3');
707
+        $input = "éeé";
708
+        $after = dol_trunc($input, 3);
709
+        $this->assertEquals("éeé", $after, 'Test C');
710
+        $after = dol_trunc($input, 2);
711
+        $this->assertEquals("éeé", $after, 'Test D');
712
+        $after = dol_trunc($input, 1);
713
+        $this->assertEquals("éeé", $after, 'Test E');
714 714
         // Trunc with no ...
715
-        $input="éeéeéeàa";
716
-        $after=dol_trunc($input,3,'right','UTF-8',1);
717
-        $this->assertEquals("éeé",$after,'Test F');
718
-        $after=dol_trunc($input,2,'right','UTF-8',1);
719
-        $this->assertEquals("ée",$after,'Test G');
720
-        $input="éeé";
721
-        $after=dol_trunc($input,3,'right','UTF-8',1);
722
-        $this->assertEquals("éeé",$after,'Test H');
723
-        $after=dol_trunc($input,2,'right','UTF-8',1);
724
-        $this->assertEquals("ée",$after,'Test I');
725
-        $after=dol_trunc($input,1,'right','UTF-8',1);
726
-        $this->assertEquals("é",$after,'Test J');
727
-        $input="éeéeéeàa";
728
-        $after=dol_trunc($input,4,'middle');
729
-        $this->assertEquals("ée...àa",$after,'Test K');
715
+        $input = "éeéeéeàa";
716
+        $after = dol_trunc($input, 3, 'right', 'UTF-8', 1);
717
+        $this->assertEquals("éeé", $after, 'Test F');
718
+        $after = dol_trunc($input, 2, 'right', 'UTF-8', 1);
719
+        $this->assertEquals("ée", $after, 'Test G');
720
+        $input = "éeé";
721
+        $after = dol_trunc($input, 3, 'right', 'UTF-8', 1);
722
+        $this->assertEquals("éeé", $after, 'Test H');
723
+        $after = dol_trunc($input, 2, 'right', 'UTF-8', 1);
724
+        $this->assertEquals("ée", $after, 'Test I');
725
+        $after = dol_trunc($input, 1, 'right', 'UTF-8', 1);
726
+        $this->assertEquals("é", $after, 'Test J');
727
+        $input = "éeéeéeàa";
728
+        $after = dol_trunc($input, 4, 'middle');
729
+        $this->assertEquals("ée...àa", $after, 'Test K');
730 730
 
731 731
         return true;
732 732
     }
@@ -740,49 +740,49 @@  discard block
 block discarded – undo
740 740
     {
741 741
     	global $conf;
742 742
 
743
-    	$savtz=date_default_timezone_get();
743
+    	$savtz = date_default_timezone_get();
744 744
 
745 745
 		// Some test for UTC TZ
746 746
     	date_default_timezone_set('UTC');
747 747
 
748 748
     	// Check bad hours
749
-        $result=dol_mktime(25,0,0,1,1,1970,1,1);    // Error (25 hours)
749
+        $result = dol_mktime(25, 0, 0, 1, 1, 1970, 1, 1); // Error (25 hours)
750 750
         print __METHOD__." result=".$result."\n";
751
-        $this->assertEquals('',$result);
752
-        $result=dol_mktime(2,61,0,1,1,1970,1,1);    // Error (61 minutes)
751
+        $this->assertEquals('', $result);
752
+        $result = dol_mktime(2, 61, 0, 1, 1, 1970, 1, 1); // Error (61 minutes)
753 753
         print __METHOD__." result=".$result."\n";
754
-        $this->assertEquals('',$result);
755
-        $result=dol_mktime(2,1,61,1,1,1970,1,1);    // Error (61 seconds)
754
+        $this->assertEquals('', $result);
755
+        $result = dol_mktime(2, 1, 61, 1, 1, 1970, 1, 1); // Error (61 seconds)
756 756
         print __METHOD__." result=".$result."\n";
757
-        $this->assertEquals('',$result);
758
-        $result=dol_mktime(2,1,1,1,32,1970,1,1);    // Error (day 32)
757
+        $this->assertEquals('', $result);
758
+        $result = dol_mktime(2, 1, 1, 1, 32, 1970, 1, 1); // Error (day 32)
759 759
         print __METHOD__." result=".$result."\n";
760
-        $this->assertEquals('',$result);
761
-        $result=dol_mktime(2,1,1,13,1,1970,1,1);    // Error (month 13)
760
+        $this->assertEquals('', $result);
761
+        $result = dol_mktime(2, 1, 1, 13, 1, 1970, 1, 1); // Error (month 13)
762 762
         print __METHOD__." result=".$result."\n";
763
-        $this->assertEquals('',$result);
763
+        $this->assertEquals('', $result);
764 764
 
765
-        $result=dol_mktime(2,1,1,1,1,1970,1);    // 1970-01-01 02:01:01 in GMT area -> 7261
765
+        $result = dol_mktime(2, 1, 1, 1, 1, 1970, 1); // 1970-01-01 02:01:01 in GMT area -> 7261
766 766
         print __METHOD__." result=".$result."\n";
767
-        $this->assertEquals(7261,$result);
767
+        $this->assertEquals(7261, $result);
768 768
 
769
-        $result=dol_mktime(2,0,0,1,1,1970,0);                // 1970-01-01 02:00:00 = 7200 in local area Europe/Paris = 3600 GMT
769
+        $result = dol_mktime(2, 0, 0, 1, 1, 1970, 0); // 1970-01-01 02:00:00 = 7200 in local area Europe/Paris = 3600 GMT
770 770
         print __METHOD__." result=".$result."\n";
771
-        $tz=getServerTimeZoneInt('winter');                  // +1 in Europe/Paris at this time (this time is winter)
772
-        $this->assertEquals(7200-($tz*3600),$result);        // 7200 if we are at greenwich winter, 7200-($tz*3600) at local winter
771
+        $tz = getServerTimeZoneInt('winter'); // +1 in Europe/Paris at this time (this time is winter)
772
+        $this->assertEquals(7200 - ($tz * 3600), $result); // 7200 if we are at greenwich winter, 7200-($tz*3600) at local winter
773 773
 
774 774
         // Some test for local TZ Europe/Paris
775 775
         date_default_timezone_set('Europe/Paris');
776 776
 
777 777
         // Check that tz for paris in winter is used
778
-        $result=dol_mktime(2,0,0,1,1,1970,'server');         // 1970-01-01 02:00:00 = 7200 in local area Europe/Paris = 3600 GMT
778
+        $result = dol_mktime(2, 0, 0, 1, 1, 1970, 'server'); // 1970-01-01 02:00:00 = 7200 in local area Europe/Paris = 3600 GMT
779 779
         print __METHOD__." result=".$result."\n";
780
-        $this->assertEquals(3600,$result);        			 // 7200 if we are at greenwich winter, 3600 at Europe/Paris
780
+        $this->assertEquals(3600, $result); // 7200 if we are at greenwich winter, 3600 at Europe/Paris
781 781
 
782 782
         // Check that daylight saving time is used
783
-        $result=dol_mktime(2,0,0,6,1,2014,0);         		// 2014-06-01 02:00:00 = 1401588000-3600(location)-3600(daylight) in local area Europe/Paris = 1401588000 GMT
783
+        $result = dol_mktime(2, 0, 0, 6, 1, 2014, 0); // 2014-06-01 02:00:00 = 1401588000-3600(location)-3600(daylight) in local area Europe/Paris = 1401588000 GMT
784 784
         print __METHOD__." result=".$result."\n";
785
-        $this->assertEquals(1401588000-3600-3600,$result);  // 1401588000 are at greenwich summer, 1401588000-3600(location)-3600(daylight) at Europe/Paris summer
785
+        $this->assertEquals(1401588000 - 3600 - 3600, $result); // 1401588000 are at greenwich summer, 1401588000-3600(location)-3600(daylight) at Europe/Paris summer
786 786
 
787 787
         date_default_timezone_set($savtz);
788 788
     }
@@ -795,15 +795,15 @@  discard block
 block discarded – undo
795 795
      */
796 796
     public function testDolEscapeJs()
797 797
     {
798
-        $input="x&<b>#</b>,\"'";    // " will be converted into '
799
-        $result=dol_escape_js($input);
800
-        $this->assertEquals("x&<b>#</b>,\'\'",$result,"Test mode=0");
798
+        $input = "x&<b>#</b>,\"'"; // " will be converted into '
799
+        $result = dol_escape_js($input);
800
+        $this->assertEquals("x&<b>#</b>,\'\'", $result, "Test mode=0");
801 801
 
802
-        $result=dol_escape_js($input,1);
803
-        $this->assertEquals("x&<b>#</b>,\"\'",$result,"Test mode=1");
802
+        $result = dol_escape_js($input, 1);
803
+        $this->assertEquals("x&<b>#</b>,\"\'", $result, "Test mode=1");
804 804
 
805
-        $result=dol_escape_js($input,2);
806
-        $this->assertEquals("x&<b>#</b>,\\\"'",$result,"Test mode=2");
805
+        $result = dol_escape_js($input, 2);
806
+        $this->assertEquals("x&<b>#</b>,\\\"'", $result, "Test mode=2");
807 807
     }
808 808
 
809 809
 
@@ -814,13 +814,13 @@  discard block
 block discarded – undo
814 814
     */
815 815
     public function testDolEscapeHtmlTag()
816 816
     {
817
-        $input='x&<b>#</b>,"';    // & and " are converted into html entities, <b> are removed
818
-        $result=dol_escape_htmltag($input);
819
-        $this->assertEquals('x&amp;#,&quot;',$result);
817
+        $input = 'x&<b>#</b>,"'; // & and " are converted into html entities, <b> are removed
818
+        $result = dol_escape_htmltag($input);
819
+        $this->assertEquals('x&amp;#,&quot;', $result);
820 820
 
821
-        $input='x&<b>#</b>,"';    // & and " are converted into html entities, <b> are not removed
822
-        $result=dol_escape_htmltag($input,1);
823
-        $this->assertEquals('x&amp;&lt;b&gt;#&lt;/b&gt;,&quot;',$result);
821
+        $input = 'x&<b>#</b>,"'; // & and " are converted into html entities, <b> are not removed
822
+        $result = dol_escape_htmltag($input, 1);
823
+        $this->assertEquals('x&amp;&lt;b&gt;#&lt;/b&gt;,&quot;', $result);
824 824
     }
825 825
 
826 826
 
@@ -831,30 +831,30 @@  discard block
 block discarded – undo
831 831
      */
832 832
     public function testDolFormatAddress()
833 833
     {
834
-    	global $conf,$user,$langs,$db;
835
-		$conf=$this->savconf;
836
-		$user=$this->savuser;
837
-		$langs=$this->savlangs;
838
-		$db=$this->savdb;
834
+    	global $conf, $user, $langs, $db;
835
+		$conf = $this->savconf;
836
+		$user = $this->savuser;
837
+		$langs = $this->savlangs;
838
+		$db = $this->savdb;
839 839
 
840
-		$object=new Societe($db);
840
+		$object = new Societe($db);
841 841
 		$object->initAsSpecimen();
842 842
 
843
-		$object->country_code='FR';
844
-    	$address=dol_format_address($object);
845
-    	$this->assertEquals("21 jump street\n99999 MyTown",$address);
843
+		$object->country_code = 'FR';
844
+    	$address = dol_format_address($object);
845
+    	$this->assertEquals("21 jump street\n99999 MyTown", $address);
846 846
 
847
-		$object->country_code='GB';
848
-    	$address=dol_format_address($object);
849
-    	$this->assertEquals("21 jump street\nMyTown, MyState\n99999",$address);
847
+		$object->country_code = 'GB';
848
+    	$address = dol_format_address($object);
849
+    	$this->assertEquals("21 jump street\nMyTown, MyState\n99999", $address);
850 850
 
851
-		$object->country_code='US';
852
-    	$address=dol_format_address($object);
853
-    	$this->assertEquals("21 jump street\nMyTown, MyState, 99999",$address);
851
+		$object->country_code = 'US';
852
+    	$address = dol_format_address($object);
853
+    	$this->assertEquals("21 jump street\nMyTown, MyState, 99999", $address);
854 854
 
855
-		$object->country_code='AU';
856
-    	$address=dol_format_address($object);
857
-    	$this->assertEquals("21 jump street\nMyTown, MyState, 99999",$address);
855
+		$object->country_code = 'AU';
856
+    	$address = dol_format_address($object);
857
+    	$this->assertEquals("21 jump street\nMyTown, MyState, 99999", $address);
858 858
     }
859 859
 
860 860
 
@@ -865,29 +865,29 @@  discard block
 block discarded – undo
865 865
      */
866 866
     public function testDolPrintPhone()
867 867
     {
868
-        global $conf,$user,$langs,$db;
869
-        $conf=$this->savconf;
870
-        $user=$this->savuser;
871
-        $langs=$this->savlangs;
872
-        $db=$this->savdb;
868
+        global $conf, $user, $langs, $db;
869
+        $conf = $this->savconf;
870
+        $user = $this->savuser;
871
+        $langs = $this->savlangs;
872
+        $db = $this->savdb;
873 873
 
874
-        $object=new Societe($db);
874
+        $object = new Societe($db);
875 875
         $object->initAsSpecimen();
876 876
 
877
-        $object->country_code='FR';
878
-        $phone=dol_print_phone('1234567890', $object->country_code);
877
+        $object->country_code = 'FR';
878
+        $phone = dol_print_phone('1234567890', $object->country_code);
879 879
         $this->assertEquals('<span style="margin-right: 10px;">12&nbsp;34&nbsp;56&nbsp;78&nbsp;90</span>', $phone, 'Phone for FR 1');
880 880
 
881
-        $object->country_code='FR';
882
-        $phone=dol_print_phone('1234567890', $object->country_code, 0, 0, 0, '');
881
+        $object->country_code = 'FR';
882
+        $phone = dol_print_phone('1234567890', $object->country_code, 0, 0, 0, '');
883 883
         $this->assertEquals('<span style="margin-right: 10px;">1234567890</span>', $phone, 'Phone for FR 2');
884 884
 
885
-        $object->country_code='FR';
886
-        $phone=dol_print_phone('1234567890', $object->country_code, 0, 0, 0, ' ');
885
+        $object->country_code = 'FR';
886
+        $phone = dol_print_phone('1234567890', $object->country_code, 0, 0, 0, ' ');
887 887
         $this->assertEquals('<span style="margin-right: 10px;">12 34 56 78 90</span>', $phone, 'Phone for FR 3');
888 888
 
889
-        $object->country_code='CA';
890
-        $phone=dol_print_phone('1234567890', $object->country_code, 0, 0, 0, ' ');
889
+        $object->country_code = 'CA';
890
+        $phone = dol_print_phone('1234567890', $object->country_code, 0, 0, 0, ' ');
891 891
         $this->assertEquals('<span style="margin-right: 10px;">(123) 456-7890</span>', $phone, 'Phone for CA 1');
892 892
     }
893 893
 
@@ -899,26 +899,26 @@  discard block
 block discarded – undo
899 899
      */
900 900
     public function testImgPicto()
901 901
     {
902
-        $s=img_picto('title','user');
902
+        $s = img_picto('title', 'user');
903 903
         print __METHOD__." s=".$s."\n";
904
-        $this->assertContains('theme',$s,'testImgPicto1');
904
+        $this->assertContains('theme', $s, 'testImgPicto1');
905 905
 
906
-    	$s=img_picto('title','img.png','style="float: right"',0);
906
+    	$s = img_picto('title', 'img.png', 'style="float: right"', 0);
907 907
         print __METHOD__." s=".$s."\n";
908
-        $this->assertContains('theme',$s,'testImgPicto2');
909
-        $this->assertContains('style="float: right"',$s,'testImgPicto2');
908
+        $this->assertContains('theme', $s, 'testImgPicto2');
909
+        $this->assertContains('style="float: right"', $s, 'testImgPicto2');
910 910
 
911
-        $s=img_picto('title', '/fullpath/img.png', '', 1);
911
+        $s = img_picto('title', '/fullpath/img.png', '', 1);
912 912
         print __METHOD__." s=".$s."\n";
913
-        $this->assertEquals('<img src="/fullpath/img.png" alt="" title="title" class="inline-block">',$s,'testImgPicto3');
913
+        $this->assertEquals('<img src="/fullpath/img.png" alt="" title="title" class="inline-block">', $s, 'testImgPicto3');
914 914
 
915
-        $s=img_picto('title', '/fullpath/img.png', '', true);
915
+        $s = img_picto('title', '/fullpath/img.png', '', true);
916 916
         print __METHOD__." s=".$s."\n";
917
-        $this->assertEquals('<img src="/fullpath/img.png" alt="" title="title" class="inline-block">',$s,'testImgPicto4');
917
+        $this->assertEquals('<img src="/fullpath/img.png" alt="" title="title" class="inline-block">', $s, 'testImgPicto4');
918 918
 
919
-        $s=img_picto('title', 'delete', '', 0, 1);
919
+        $s = img_picto('title', 'delete', '', 0, 1);
920 920
         print __METHOD__." s=".$s."\n";
921
-        $this->assertEquals(DOL_URL_ROOT.'/theme/eldy/img/delete.png',$s,'testImgPicto5');
921
+        $this->assertEquals(DOL_URL_ROOT.'/theme/eldy/img/delete.png', $s, 'testImgPicto5');
922 922
     }
923 923
 
924 924
     /**
@@ -928,10 +928,10 @@  discard block
 block discarded – undo
928 928
      */
929 929
     public function testDolNow()
930 930
     {
931
-        $now=dol_now('gmt');
932
-        $nowtzserver=dol_now('tzserver');
933
-        print __METHOD__." getServerTimeZoneInt=".(getServerTimeZoneInt('now')*3600)."\n";
934
-        $this->assertEquals(getServerTimeZoneInt('now')*3600,($nowtzserver-$now));
931
+        $now = dol_now('gmt');
932
+        $nowtzserver = dol_now('tzserver');
933
+        print __METHOD__." getServerTimeZoneInt=".(getServerTimeZoneInt('now') * 3600)."\n";
934
+        $this->assertEquals(getServerTimeZoneInt('now') * 3600, ($nowtzserver - $now));
935 935
     }
936 936
 
937 937
     /**
@@ -941,19 +941,19 @@  discard block
 block discarded – undo
941 941
      */
942 942
     public function testVerifCond()
943 943
     {
944
-        $verifcond=verifCond('1==1');
945
-        $this->assertTrue($verifcond,'Test a true comparison');
944
+        $verifcond = verifCond('1==1');
945
+        $this->assertTrue($verifcond, 'Test a true comparison');
946 946
 
947
-        $verifcond=verifCond('1==2');
948
-        $this->assertFalse($verifcond,'Test a false comparison');
947
+        $verifcond = verifCond('1==2');
948
+        $this->assertFalse($verifcond, 'Test a false comparison');
949 949
 
950
-        $verifcond=verifCond('$conf->facture->enabled');
951
-        $this->assertTrue($verifcond,'Test that conf property of a module report true when enabled');
950
+        $verifcond = verifCond('$conf->facture->enabled');
951
+        $this->assertTrue($verifcond, 'Test that conf property of a module report true when enabled');
952 952
 
953
-        $verifcond=verifCond('$conf->moduledummy->enabled');
954
-        $this->assertFalse($verifcond,'Test that conf property of a module report false when disabled');
953
+        $verifcond = verifCond('$conf->moduledummy->enabled');
954
+        $this->assertFalse($verifcond, 'Test that conf property of a module report false when disabled');
955 955
 
956
-        $verifcond=verifCond('');
956
+        $verifcond = verifCond('');
957 957
         $this->assertTrue($verifcond);
958 958
     }
959 959
 
@@ -964,76 +964,76 @@  discard block
 block discarded – undo
964 964
      */
965 965
     public function testGetDefaultTva()
966 966
     {
967
-        global $conf,$user,$langs,$db;
968
-        $this->savconf=$conf;
969
-        $this->savuser=$user;
970
-        $this->savlangs=$langs;
971
-        $this->savdb=$db;
967
+        global $conf, $user, $langs, $db;
968
+        $this->savconf = $conf;
969
+        $this->savuser = $user;
970
+        $this->savlangs = $langs;
971
+        $this->savdb = $db;
972 972
 
973 973
         // Sellers
974
-        $companyfrnovat=new Societe($db);
975
-        $companyfrnovat->country_code='FR';
976
-        $companyfrnovat->tva_assuj=0;
974
+        $companyfrnovat = new Societe($db);
975
+        $companyfrnovat->country_code = 'FR';
976
+        $companyfrnovat->tva_assuj = 0;
977 977
 
978
-        $companyfr=new Societe($db);
979
-        $companyfr->country_code='FR';
980
-        $companyfr->tva_assuj=1;
981
-		$companyfr->tva_intra='FR9999';
978
+        $companyfr = new Societe($db);
979
+        $companyfr->country_code = 'FR';
980
+        $companyfr->tva_assuj = 1;
981
+		$companyfr->tva_intra = 'FR9999';
982 982
 
983 983
         // Buyers
984
-        $companymc=new Societe($db);
985
-        $companymc->country_code='MC';
986
-        $companymc->tva_assuj=1;
987
-		$companyfr->tva_intra='MC9999';
984
+        $companymc = new Societe($db);
985
+        $companymc->country_code = 'MC';
986
+        $companymc->tva_assuj = 1;
987
+		$companyfr->tva_intra = 'MC9999';
988 988
 
989
-        $companyit=new Societe($db);
990
-        $companyit->country_code='IT';
991
-        $companyit->tva_assuj=1;
992
-        $companyit->tva_intra='IT99999';
989
+        $companyit = new Societe($db);
990
+        $companyit->country_code = 'IT';
991
+        $companyit->tva_assuj = 1;
992
+        $companyit->tva_intra = 'IT99999';
993 993
 
994
-        $companyde=new Societe($db);
995
-        $companyde->country_code='DE';
996
-        $companyde->tva_assuj=1;
997
-        $companyde->tva_intra='DE99999';
994
+        $companyde = new Societe($db);
995
+        $companyde->country_code = 'DE';
996
+        $companyde->tva_assuj = 1;
997
+        $companyde->tva_intra = 'DE99999';
998 998
 
999
-        $notcompanyde=new Societe($db);
1000
-        $notcompanyde->country_code='DE';
1001
-        $notcompanyde->tva_assuj=0;
1002
-        $notcompanyde->tva_intra='';
1003
-        $notcompanyde->typent_code='TE_PRIVATE';
999
+        $notcompanyde = new Societe($db);
1000
+        $notcompanyde->country_code = 'DE';
1001
+        $notcompanyde->tva_assuj = 0;
1002
+        $notcompanyde->tva_intra = '';
1003
+        $notcompanyde->typent_code = 'TE_PRIVATE';
1004 1004
 
1005
-        $companyus=new Societe($db);
1006
-        $companyus->country_code='US';
1007
-        $companyus->tva_assuj=1;
1008
-        $companyus->tva_intra='';
1005
+        $companyus = new Societe($db);
1006
+        $companyus->country_code = 'US';
1007
+        $companyus->tva_assuj = 1;
1008
+        $companyus->tva_intra = '';
1009 1009
 
1010 1010
 
1011 1011
         // Test RULE 0 (FR-DE)
1012 1012
         // Not tested
1013 1013
 
1014 1014
         // Test RULE 1
1015
-        $vat=get_default_tva($companyfrnovat,$companymc,0);
1016
-        $this->assertEquals(0,$vat,'RULE 1');
1015
+        $vat = get_default_tva($companyfrnovat, $companymc, 0);
1016
+        $this->assertEquals(0, $vat, 'RULE 1');
1017 1017
 
1018 1018
         // Test RULE 2 (FR-FR)
1019
-        $vat=get_default_tva($companyfr,$companyfr,0);
1020
-        $this->assertEquals(20,$vat,'RULE 2');
1019
+        $vat = get_default_tva($companyfr, $companyfr, 0);
1020
+        $this->assertEquals(20, $vat, 'RULE 2');
1021 1021
 
1022 1022
         // Test RULE 2 (FR-MC)
1023
-        $vat=get_default_tva($companyfr,$companymc,0);
1024
-        $this->assertEquals(20,$vat,'RULE 2');
1023
+        $vat = get_default_tva($companyfr, $companymc, 0);
1024
+        $this->assertEquals(20, $vat, 'RULE 2');
1025 1025
 
1026 1026
         // Test RULE 3 (FR-DE company)
1027
-        $vat=get_default_tva($companyfr,$companyit,0);
1028
-        $this->assertEquals(0,$vat,'RULE 3');
1027
+        $vat = get_default_tva($companyfr, $companyit, 0);
1028
+        $this->assertEquals(0, $vat, 'RULE 3');
1029 1029
 
1030 1030
         // Test RULE 4 (FR-DE not a company)
1031
-        $vat=get_default_tva($companyfr,$notcompanyde,0);
1032
-        $this->assertEquals(20,$vat,'RULE 4');
1031
+        $vat = get_default_tva($companyfr, $notcompanyde, 0);
1032
+        $this->assertEquals(20, $vat, 'RULE 4');
1033 1033
 
1034 1034
         // Test RULE 5 (FR-US)
1035
-        $vat=get_default_tva($companyfr,$companyus,0);
1036
-        $this->assertEquals(0,$vat,'RULE 5');
1035
+        $vat = get_default_tva($companyfr, $companyus, 0);
1036
+        $this->assertEquals(0, $vat, 'RULE 5');
1037 1037
 
1038 1038
 
1039 1039
         // We do same tests but with option SERVICE_ARE_ECOMMERCE_200238EC on.
@@ -1041,24 +1041,24 @@  discard block
 block discarded – undo
1041 1041
 
1042 1042
 
1043 1043
         // Test RULE 1 (FR-US)
1044
-        $vat=get_default_tva($companyfr,$companyus,0);
1045
-        $this->assertEquals(0,$vat,'RULE 1 ECOMMERCE_200238EC');
1044
+        $vat = get_default_tva($companyfr, $companyus, 0);
1045
+        $this->assertEquals(0, $vat, 'RULE 1 ECOMMERCE_200238EC');
1046 1046
 
1047 1047
         // Test RULE 2 (FR-FR)
1048
-        $vat=get_default_tva($companyfr,$companyfr,0);
1049
-        $this->assertEquals(20,$vat,'RULE 2 ECOMMERCE_200238EC');
1048
+        $vat = get_default_tva($companyfr, $companyfr, 0);
1049
+        $this->assertEquals(20, $vat, 'RULE 2 ECOMMERCE_200238EC');
1050 1050
 
1051 1051
         // Test RULE 3 (FR-DE company)
1052
-        $vat=get_default_tva($companyfr,$companyde,0);
1053
-        $this->assertEquals(0,$vat,'RULE 3 ECOMMERCE_200238EC');
1052
+        $vat = get_default_tva($companyfr, $companyde, 0);
1053
+        $this->assertEquals(0, $vat, 'RULE 3 ECOMMERCE_200238EC');
1054 1054
 
1055 1055
         // Test RULE 4 (FR-DE not a company)
1056
-        $vat=get_default_tva($companyfr,$notcompanyde,0);
1057
-        $this->assertEquals(19,$vat,'RULE 4 ECOMMERCE_200238EC');
1056
+        $vat = get_default_tva($companyfr, $notcompanyde, 0);
1057
+        $this->assertEquals(19, $vat, 'RULE 4 ECOMMERCE_200238EC');
1058 1058
 
1059 1059
         // Test RULE 5 (FR-US)
1060
-        $vat=get_default_tva($companyfr,$companyus,0);
1061
-        $this->assertEquals(0,$vat,'RULE 5 ECOMMERCE_200238EC');
1060
+        $vat = get_default_tva($companyfr, $companyus, 0);
1061
+        $this->assertEquals(0, $vat, 'RULE 5 ECOMMERCE_200238EC');
1062 1062
     }
1063 1063
 
1064 1064
     /**
@@ -1068,84 +1068,84 @@  discard block
 block discarded – undo
1068 1068
      */
1069 1069
     public function testGetDefaultLocalTax()
1070 1070
     {
1071
-    	global $conf,$user,$langs,$db;
1072
-    	$this->savconf=$conf;
1073
-    	$this->savuser=$user;
1074
-    	$this->savlangs=$langs;
1075
-    	$this->savdb=$db;
1076
-
1077
-    	$companyfrnovat=new Societe($db);
1078
-    	$companyfrnovat->country_code='FR';
1079
-    	$companyfrnovat->tva_assuj=0;
1080
-    	$companyfrnovat->localtax1_assuj=0;
1081
-    	$companyfrnovat->localtax2_assuj=0;
1082
-
1083
-    	$companyes=new Societe($db);
1084
-    	$companyes->country_code='ES';
1085
-    	$companyes->tva_assuj=1;
1086
-    	$companyes->localtax1_assuj=1;
1087
-    	$companyes->localtax2_assuj=1;
1088
-
1089
-    	$companymc=new Societe($db);
1090
-    	$companymc->country_code='MC';
1091
-    	$companymc->tva_assuj=1;
1092
-    	$companymc->localtax1_assuj=0;
1093
-    	$companymc->localtax2_assuj=0;
1094
-
1095
-    	$companyit=new Societe($db);
1096
-    	$companyit->country_code='IT';
1097
-    	$companyit->tva_assuj=1;
1098
-    	$companyit->tva_intra='IT99999';
1099
-    	$companyit->localtax1_assuj=0;
1100
-    	$companyit->localtax2_assuj=0;
1101
-
1102
-    	$notcompanyit=new Societe($db);
1103
-    	$notcompanyit->country_code='IT';
1104
-    	$notcompanyit->tva_assuj=1;
1105
-    	$notcompanyit->tva_intra='';
1106
-    	$notcompanyit->typent_code='TE_PRIVATE';
1107
-    	$notcompanyit->localtax1_assuj=0;
1108
-    	$notcompanyit->localtax2_assuj=0;
1109
-
1110
-    	$companyus=new Societe($db);
1111
-    	$companyus->country_code='US';
1112
-    	$companyus->tva_assuj=1;
1113
-    	$companyus->tva_intra='';
1114
-    	$companyus->localtax1_assuj=0;
1115
-    	$companyus->localtax2_assuj=0;
1071
+    	global $conf, $user, $langs, $db;
1072
+    	$this->savconf = $conf;
1073
+    	$this->savuser = $user;
1074
+    	$this->savlangs = $langs;
1075
+    	$this->savdb = $db;
1076
+
1077
+    	$companyfrnovat = new Societe($db);
1078
+    	$companyfrnovat->country_code = 'FR';
1079
+    	$companyfrnovat->tva_assuj = 0;
1080
+    	$companyfrnovat->localtax1_assuj = 0;
1081
+    	$companyfrnovat->localtax2_assuj = 0;
1082
+
1083
+    	$companyes = new Societe($db);
1084
+    	$companyes->country_code = 'ES';
1085
+    	$companyes->tva_assuj = 1;
1086
+    	$companyes->localtax1_assuj = 1;
1087
+    	$companyes->localtax2_assuj = 1;
1088
+
1089
+    	$companymc = new Societe($db);
1090
+    	$companymc->country_code = 'MC';
1091
+    	$companymc->tva_assuj = 1;
1092
+    	$companymc->localtax1_assuj = 0;
1093
+    	$companymc->localtax2_assuj = 0;
1094
+
1095
+    	$companyit = new Societe($db);
1096
+    	$companyit->country_code = 'IT';
1097
+    	$companyit->tva_assuj = 1;
1098
+    	$companyit->tva_intra = 'IT99999';
1099
+    	$companyit->localtax1_assuj = 0;
1100
+    	$companyit->localtax2_assuj = 0;
1101
+
1102
+    	$notcompanyit = new Societe($db);
1103
+    	$notcompanyit->country_code = 'IT';
1104
+    	$notcompanyit->tva_assuj = 1;
1105
+    	$notcompanyit->tva_intra = '';
1106
+    	$notcompanyit->typent_code = 'TE_PRIVATE';
1107
+    	$notcompanyit->localtax1_assuj = 0;
1108
+    	$notcompanyit->localtax2_assuj = 0;
1109
+
1110
+    	$companyus = new Societe($db);
1111
+    	$companyus->country_code = 'US';
1112
+    	$companyus->tva_assuj = 1;
1113
+    	$companyus->tva_intra = '';
1114
+    	$companyus->localtax1_assuj = 0;
1115
+    	$companyus->localtax2_assuj = 0;
1116 1116
 
1117 1117
     	// Test RULE FR-MC
1118
-    	$vat1=get_default_localtax($companyfrnovat,$companymc,1,0);
1119
-    	$vat2=get_default_localtax($companyfrnovat,$companymc,2,0);
1120
-    	$this->assertEquals(0,$vat1);
1121
-    	$this->assertEquals(0,$vat2);
1118
+    	$vat1 = get_default_localtax($companyfrnovat, $companymc, 1, 0);
1119
+    	$vat2 = get_default_localtax($companyfrnovat, $companymc, 2, 0);
1120
+    	$this->assertEquals(0, $vat1);
1121
+    	$this->assertEquals(0, $vat2);
1122 1122
 
1123 1123
     	// Test RULE ES-ES
1124
-    	$vat1=get_default_localtax($companyes,$companyes,1,0);
1125
-    	$vat2=get_default_localtax($companyes,$companyes,2,0);
1124
+    	$vat1 = get_default_localtax($companyes, $companyes, 1, 0);
1125
+    	$vat2 = get_default_localtax($companyes, $companyes, 2, 0);
1126 1126
     	$this->assertEquals($vat1, 5.2);
1127
-    	$this->assertStringStartsWith((string) $vat2, '-19:-15:-9');       // Can be -19 (old version) or '-19:-15:-9' (new setup)
1127
+    	$this->assertStringStartsWith((string) $vat2, '-19:-15:-9'); // Can be -19 (old version) or '-19:-15:-9' (new setup)
1128 1128
 
1129 1129
     	// Test RULE ES-IT
1130
-    	$vat1=get_default_localtax($companyes,$companyit,1,0);
1131
-    	$vat2=get_default_localtax($companyes,$companyit,2,0);
1132
-    	$this->assertEquals(0,$vat1);
1133
-    	$this->assertEquals(0,$vat2);
1130
+    	$vat1 = get_default_localtax($companyes, $companyit, 1, 0);
1131
+    	$vat2 = get_default_localtax($companyes, $companyit, 2, 0);
1132
+    	$this->assertEquals(0, $vat1);
1133
+    	$this->assertEquals(0, $vat2);
1134 1134
 
1135 1135
     	// Test RULE ES-IT
1136
-    	$vat1=get_default_localtax($companyes,$notcompanyit,1,0);
1137
-    	$vat2=get_default_localtax($companyes,$notcompanyit,2,0);
1138
-    	$this->assertEquals(0,$vat1);
1139
-    	$this->assertEquals(0,$vat2);
1136
+    	$vat1 = get_default_localtax($companyes, $notcompanyit, 1, 0);
1137
+    	$vat2 = get_default_localtax($companyes, $notcompanyit, 2, 0);
1138
+    	$this->assertEquals(0, $vat1);
1139
+    	$this->assertEquals(0, $vat2);
1140 1140
 
1141 1141
     	// Test RULE FR-IT
1142 1142
     	// Not tested
1143 1143
 
1144 1144
     	// Test RULE ES-US
1145
-    	$vat1=get_default_localtax($companyes,$companyus,1,0);
1146
-    	$vat2=get_default_localtax($companyes,$companyus,2,0);
1147
-    	$this->assertEquals(0,$vat1);
1148
-    	$this->assertEquals(0,$vat2);
1145
+    	$vat1 = get_default_localtax($companyes, $companyus, 1, 0);
1146
+    	$vat2 = get_default_localtax($companyes, $companyus, 2, 0);
1147
+    	$this->assertEquals(0, $vat1);
1148
+    	$this->assertEquals(0, $vat2);
1149 1149
     }
1150 1150
 
1151 1151
 
@@ -1156,11 +1156,11 @@  discard block
 block discarded – undo
1156 1156
      */
1157 1157
     public function testDolExplodeIntoArray()
1158 1158
     {
1159
-    	$stringtoexplode='AA=B/B.CC=.EE=FF.HH=GG;.';
1160
-    	$tmp=dolExplodeIntoArray($stringtoexplode,'.','=');
1159
+    	$stringtoexplode = 'AA=B/B.CC=.EE=FF.HH=GG;.';
1160
+    	$tmp = dolExplodeIntoArray($stringtoexplode, '.', '=');
1161 1161
 
1162 1162
         print __METHOD__." tmp=".json_encode($tmp)."\n";
1163
-        $this->assertEquals('{"AA":"B\/B","CC":"","EE":"FF","HH":"GG;"}',json_encode($tmp));
1163
+        $this->assertEquals('{"AA":"B\/B","CC":"","EE":"FF","HH":"GG;"}', json_encode($tmp));
1164 1164
     }
1165 1165
 
1166 1166
 	/**
@@ -1194,22 +1194,22 @@  discard block
 block discarded – undo
1194 1194
 	public function testDolPrice2Num()
1195 1195
 	{
1196 1196
 		$this->assertEquals(1000, price2num('1 000.0'));
1197
-		$this->assertEquals(1000, price2num('1 000','MT'));
1198
-		$this->assertEquals(1000, price2num('1 000','MU'));
1197
+		$this->assertEquals(1000, price2num('1 000', 'MT'));
1198
+		$this->assertEquals(1000, price2num('1 000', 'MU'));
1199 1199
 
1200 1200
 		$this->assertEquals(1000.123456, price2num('1 000.123456'));
1201 1201
 
1202 1202
 		// Round down
1203
-		$this->assertEquals(1000.12, price2num('1 000.123452','MT'));
1204
-		$this->assertEquals(1000.12345, price2num('1 000.123452','MU'),"Test MU");
1203
+		$this->assertEquals(1000.12, price2num('1 000.123452', 'MT'));
1204
+		$this->assertEquals(1000.12345, price2num('1 000.123452', 'MU'), "Test MU");
1205 1205
 
1206 1206
 		// Round up
1207
-		$this->assertEquals(1000.13, price2num('1 000.125456','MT'));
1208
-		$this->assertEquals(1000.12546, price2num('1 000.125456','MU'),"Test MU");
1207
+		$this->assertEquals(1000.13, price2num('1 000.125456', 'MT'));
1208
+		$this->assertEquals(1000.12546, price2num('1 000.125456', 'MU'), "Test MU");
1209 1209
 
1210 1210
 		// Text can't be converted
1211
-		$this->assertEquals('12.4$',price2num('12.4$'));
1212
-		$this->assertEquals('12r.4$',price2num('12r.4$'));
1211
+		$this->assertEquals('12.4$', price2num('12.4$'));
1212
+		$this->assertEquals('12r.4$', price2num('12r.4$'));
1213 1213
 
1214 1214
 		return true;
1215 1215
 	}
@@ -1225,18 +1225,18 @@  discard block
 block discarded – undo
1225 1225
 
1226 1226
 		$conf->global->MAIN_START_WEEK = 0;
1227 1227
 
1228
-		$tmp=dol_getdate(1);				// 1/1/1970 and 1 second = thirday
1228
+		$tmp = dol_getdate(1); // 1/1/1970 and 1 second = thirday
1229 1229
 		$this->assertEquals(4, $tmp['wday']);
1230 1230
 
1231
-		$tmp=dol_getdate(24*60*60+1);		// 2/1/1970 and 1 second = friday
1231
+		$tmp = dol_getdate(24 * 60 * 60 + 1); // 2/1/1970 and 1 second = friday
1232 1232
 		$this->assertEquals(5, $tmp['wday']);
1233 1233
 
1234 1234
 		$conf->global->MAIN_START_WEEK = 1;
1235 1235
 
1236
-		$tmp=dol_getdate(1);				// 1/1/1970 and 1 second = thirday
1236
+		$tmp = dol_getdate(1); // 1/1/1970 and 1 second = thirday
1237 1237
 		$this->assertEquals(4, $tmp['wday']);
1238 1238
 
1239
-		$tmp=dol_getdate(24*60*60+1);		// 2/1/1970 and 1 second = friday
1239
+		$tmp = dol_getdate(24 * 60 * 60 + 1); // 2/1/1970 and 1 second = friday
1240 1240
 		$this->assertEquals(5, $tmp['wday']);
1241 1241
 
1242 1242
 		return true;
@@ -1253,8 +1253,8 @@  discard block
 block discarded – undo
1253 1253
 		global $conf, $langs;
1254 1254
 		$langs->load("main");
1255 1255
 
1256
-		$substit=array("AAA"=>'Not used', "BBB"=>'Not used', "CCC"=>"C replaced");
1257
-		$chaine='This is a string with __[MAIN_THEME]__ and __(DIRECTION)__ and __CCC__';
1256
+		$substit = array("AAA"=>'Not used', "BBB"=>'Not used', "CCC"=>"C replaced");
1257
+		$chaine = 'This is a string with __[MAIN_THEME]__ and __(DIRECTION)__ and __CCC__';
1258 1258
 		$newstring = make_substitutions($chaine, $substit);
1259 1259
 		$this->assertEquals($newstring, 'This is a string with eldy and ltr and __C replaced__');
1260 1260
 
Please login to merge, or discard this patch.
Braces   +33 added lines, -10 removed lines patch added patch discarded remove patch
@@ -30,16 +30,39 @@
 block discarded – undo
30 30
 require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
31 31
 require_once dirname(__FILE__).'/../../htdocs/core/lib/date.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
 /**
45 68
  * Class for PHPUnit tests
Please login to merge, or discard this patch.
dolibarr/test/phpunit/GetUrlLibTest.php 2 patches
Indentation   +98 added lines, -98 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,123 +48,123 @@  discard block
 block discarded – undo
48 48
  */
49 49
 class GetUrlLibTest 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 FilesLibTest
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 FilesLibTest
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()
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
-    	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
-	/**
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
 
122
-	/**
122
+    /**
123 123
      * testGetRootURLFromURL
124 124
      *
125 125
      * @return	int
126 126
      */
127 127
     public function testGetRootURLFromURL()
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
-		$result=getRootURLFromURL('http://www.dolimed.com/screenshots/afile');
136
-    	print __METHOD__." result=".$result."\n";
137
-		$this->assertEquals('http://www.dolimed.com',$result,'Test 1');
135
+        $result=getRootURLFromURL('http://www.dolimed.com/screenshots/afile');
136
+        print __METHOD__." result=".$result."\n";
137
+        $this->assertEquals('http://www.dolimed.com',$result,'Test 1');
138 138
 
139
-		$result=getRootURLFromURL('https://www.dolimed.com/screenshots/afile');
140
-		print __METHOD__." result=".$result."\n";
141
-		$this->assertEquals('https://www.dolimed.com',$result,'Test 2');
139
+        $result=getRootURLFromURL('https://www.dolimed.com/screenshots/afile');
140
+        print __METHOD__." result=".$result."\n";
141
+        $this->assertEquals('https://www.dolimed.com',$result,'Test 2');
142 142
 
143
-		$result=getRootURLFromURL('http://www.dolimed.com/screenshots');
144
-		print __METHOD__." result=".$result."\n";
145
-		$this->assertEquals('http://www.dolimed.com',$result);
143
+        $result=getRootURLFromURL('http://www.dolimed.com/screenshots');
144
+        print __METHOD__." result=".$result."\n";
145
+        $this->assertEquals('http://www.dolimed.com',$result);
146 146
 
147
-		$result=getRootURLFromURL('https://www.dolimed.com/screenshots');
148
-		print __METHOD__." result=".$result."\n";
149
-		$this->assertEquals('https://www.dolimed.com',$result);
147
+        $result=getRootURLFromURL('https://www.dolimed.com/screenshots');
148
+        print __METHOD__." result=".$result."\n";
149
+        $this->assertEquals('https://www.dolimed.com',$result);
150 150
 
151
-		$result=getRootURLFromURL('http://www.dolimed.com/');
152
-		print __METHOD__." result=".$result."\n";
153
-		$this->assertEquals('http://www.dolimed.com',$result);
151
+        $result=getRootURLFromURL('http://www.dolimed.com/');
152
+        print __METHOD__." result=".$result."\n";
153
+        $this->assertEquals('http://www.dolimed.com',$result);
154 154
 
155
-		$result=getRootURLFromURL('https://www.dolimed.com/');
156
-		print __METHOD__." result=".$result."\n";
157
-		$this->assertEquals('https://www.dolimed.com',$result);
155
+        $result=getRootURLFromURL('https://www.dolimed.com/');
156
+        print __METHOD__." result=".$result."\n";
157
+        $this->assertEquals('https://www.dolimed.com',$result);
158 158
 
159
-		$result=getRootURLFromURL('http://www.dolimed.com');
160
-		print __METHOD__." result=".$result."\n";
161
-		$this->assertEquals('http://www.dolimed.com',$result);
159
+        $result=getRootURLFromURL('http://www.dolimed.com');
160
+        print __METHOD__." result=".$result."\n";
161
+        $this->assertEquals('http://www.dolimed.com',$result);
162 162
 
163
-		$result=getRootURLFromURL('https://www.dolimed.com');
164
-		print __METHOD__." result=".$result."\n";
165
-		$this->assertEquals('https://www.dolimed.com',$result);
163
+        $result=getRootURLFromURL('https://www.dolimed.com');
164
+        print __METHOD__." result=".$result."\n";
165
+        $this->assertEquals('https://www.dolimed.com',$result);
166 166
 
167
-		return 1;
167
+        return 1;
168 168
     }
169 169
 
170 170
 
@@ -175,20 +175,20 @@  discard block
 block discarded – undo
175 175
      */
176 176
     public function testRemoveHtmlComment()
177 177
     {
178
-    	global $conf,$user,$langs,$db;
179
-    	$conf=$this->savconf;
180
-    	$user=$this->savuser;
181
-    	$langs=$this->savlangs;
182
-    	$db=$this->savdb;
178
+        global $conf,$user,$langs,$db;
179
+        $conf=$this->savconf;
180
+        $user=$this->savuser;
181
+        $langs=$this->savlangs;
182
+        $db=$this->savdb;
183 183
 
184
-    	$result=removeHtmlComment('abc<!--[if lt IE 8]>aaaa<![endif]-->def');
185
-    	print __METHOD__." result=".$result."\n";
186
-    	$this->assertEquals('abcdef',$result,'Test 1');
184
+        $result=removeHtmlComment('abc<!--[if lt IE 8]>aaaa<![endif]-->def');
185
+        print __METHOD__." result=".$result."\n";
186
+        $this->assertEquals('abcdef',$result,'Test 1');
187 187
 
188
-    	$result=removeHtmlComment('abc<!--[if lt IE 8]>aa-->bb<!--aa<![endif]-->def');
189
-    	print __METHOD__." result=".$result."\n";
190
-    	$this->assertEquals('abcbbdef',$result,'Test 1');
188
+        $result=removeHtmlComment('abc<!--[if lt IE 8]>aa-->bb<!--aa<![endif]-->def');
189
+        print __METHOD__." result=".$result."\n";
190
+        $this->assertEquals('abcbbdef',$result,'Test 1');
191 191
 
192
-    	return 1;
192
+        return 1;
193 193
     }
194 194
 }
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 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
     }
@@ -126,43 +126,43 @@  discard block
 block discarded – undo
126 126
      */
127 127
     public function testGetRootURLFromURL()
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
-		$result=getRootURLFromURL('http://www.dolimed.com/screenshots/afile');
135
+		$result = getRootURLFromURL('http://www.dolimed.com/screenshots/afile');
136 136
     	print __METHOD__." result=".$result."\n";
137
-		$this->assertEquals('http://www.dolimed.com',$result,'Test 1');
137
+		$this->assertEquals('http://www.dolimed.com', $result, 'Test 1');
138 138
 
139
-		$result=getRootURLFromURL('https://www.dolimed.com/screenshots/afile');
139
+		$result = getRootURLFromURL('https://www.dolimed.com/screenshots/afile');
140 140
 		print __METHOD__." result=".$result."\n";
141
-		$this->assertEquals('https://www.dolimed.com',$result,'Test 2');
141
+		$this->assertEquals('https://www.dolimed.com', $result, 'Test 2');
142 142
 
143
-		$result=getRootURLFromURL('http://www.dolimed.com/screenshots');
143
+		$result = getRootURLFromURL('http://www.dolimed.com/screenshots');
144 144
 		print __METHOD__." result=".$result."\n";
145
-		$this->assertEquals('http://www.dolimed.com',$result);
145
+		$this->assertEquals('http://www.dolimed.com', $result);
146 146
 
147
-		$result=getRootURLFromURL('https://www.dolimed.com/screenshots');
147
+		$result = getRootURLFromURL('https://www.dolimed.com/screenshots');
148 148
 		print __METHOD__." result=".$result."\n";
149
-		$this->assertEquals('https://www.dolimed.com',$result);
149
+		$this->assertEquals('https://www.dolimed.com', $result);
150 150
 
151
-		$result=getRootURLFromURL('http://www.dolimed.com/');
151
+		$result = getRootURLFromURL('http://www.dolimed.com/');
152 152
 		print __METHOD__." result=".$result."\n";
153
-		$this->assertEquals('http://www.dolimed.com',$result);
153
+		$this->assertEquals('http://www.dolimed.com', $result);
154 154
 
155
-		$result=getRootURLFromURL('https://www.dolimed.com/');
155
+		$result = getRootURLFromURL('https://www.dolimed.com/');
156 156
 		print __METHOD__." result=".$result."\n";
157
-		$this->assertEquals('https://www.dolimed.com',$result);
157
+		$this->assertEquals('https://www.dolimed.com', $result);
158 158
 
159
-		$result=getRootURLFromURL('http://www.dolimed.com');
159
+		$result = getRootURLFromURL('http://www.dolimed.com');
160 160
 		print __METHOD__." result=".$result."\n";
161
-		$this->assertEquals('http://www.dolimed.com',$result);
161
+		$this->assertEquals('http://www.dolimed.com', $result);
162 162
 
163
-		$result=getRootURLFromURL('https://www.dolimed.com');
163
+		$result = getRootURLFromURL('https://www.dolimed.com');
164 164
 		print __METHOD__." result=".$result."\n";
165
-		$this->assertEquals('https://www.dolimed.com',$result);
165
+		$this->assertEquals('https://www.dolimed.com', $result);
166 166
 
167 167
 		return 1;
168 168
     }
@@ -175,19 +175,19 @@  discard block
 block discarded – undo
175 175
      */
176 176
     public function testRemoveHtmlComment()
177 177
     {
178
-    	global $conf,$user,$langs,$db;
179
-    	$conf=$this->savconf;
180
-    	$user=$this->savuser;
181
-    	$langs=$this->savlangs;
182
-    	$db=$this->savdb;
178
+    	global $conf, $user, $langs, $db;
179
+    	$conf = $this->savconf;
180
+    	$user = $this->savuser;
181
+    	$langs = $this->savlangs;
182
+    	$db = $this->savdb;
183 183
 
184
-    	$result=removeHtmlComment('abc<!--[if lt IE 8]>aaaa<![endif]-->def');
184
+    	$result = removeHtmlComment('abc<!--[if lt IE 8]>aaaa<![endif]-->def');
185 185
     	print __METHOD__." result=".$result."\n";
186
-    	$this->assertEquals('abcdef',$result,'Test 1');
186
+    	$this->assertEquals('abcdef', $result, 'Test 1');
187 187
 
188
-    	$result=removeHtmlComment('abc<!--[if lt IE 8]>aa-->bb<!--aa<![endif]-->def');
188
+    	$result = removeHtmlComment('abc<!--[if lt IE 8]>aa-->bb<!--aa<![endif]-->def');
189 189
     	print __METHOD__." result=".$result."\n";
190
-    	$this->assertEquals('abcbbdef',$result,'Test 1');
190
+    	$this->assertEquals('abcbbdef', $result, 'Test 1');
191 191
 
192 192
     	return 1;
193 193
     }
Please login to merge, or discard this patch.
dolibarr/test/phpunit/WebservicesUserTest.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
      */
64 64
     function __construct()
65 65
     {
66
-    	parent::__construct();
66
+        parent::__construct();
67 67
 
68
-    	//$this->sharedFixture
68
+        //$this->sharedFixture
69 69
         global $conf,$user,$langs,$db;
70 70
         $this->savconf=$conf;
71 71
         $this->savuser=$user;
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
      * Init phpunit tests
100 100
      *
101 101
      * @return  void
102
-    */
102
+     */
103 103
     protected function setUp()
104 104
     {
105 105
         global $conf,$user,$langs,$db;
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -23,12 +23,12 @@  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/date.lib.php';
31
-require_once NUSOAP_PATH.'/nusoap.php';        // Include SOAP
31
+require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP
32 32
 
33 33
 
34 34
 if (empty($user->id)) {
@@ -36,9 +36,9 @@  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
-$conf->global->MAIN_UMASK='0666';
41
+$conf->global->MAIN_UMASK = '0666';
42 42
 
43 43
 
44 44
 /**
@@ -66,11 +66,11 @@  discard block
 block discarded – undo
66 66
     	parent::__construct();
67 67
 
68 68
     	//$this->sharedFixture
69
-        global $conf,$user,$langs,$db;
70
-        $this->savconf=$conf;
71
-        $this->savuser=$user;
72
-        $this->savlangs=$langs;
73
-        $this->savdb=$db;
69
+        global $conf, $user, $langs, $db;
70
+        $this->savconf = $conf;
71
+        $this->savuser = $user;
72
+        $this->savlangs = $langs;
73
+        $this->savdb = $db;
74 74
 
75 75
         print __METHOD__." db->type=".$db->type." user->id=".$user->id;
76 76
         //print " - db ".$db->db;
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
     // Static methods
81 81
     public static function setUpBeforeClass()
82 82
     {
83
-        global $conf,$user,$langs,$db;
83
+        global $conf, $user, $langs, $db;
84 84
         $db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
85 85
 
86 86
         print __METHOD__."\n";
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
     // tear down after class
90 90
     public static function tearDownAfterClass()
91 91
     {
92
-        global $conf,$user,$langs,$db;
92
+        global $conf, $user, $langs, $db;
93 93
         $db->rollback();
94 94
 
95 95
         print __METHOD__."\n";
@@ -102,11 +102,11 @@  discard block
 block discarded – undo
102 102
     */
103 103
     protected function setUp()
104 104
     {
105
-        global $conf,$user,$langs,$db;
106
-        $conf=$this->savconf;
107
-        $user=$this->savuser;
108
-        $langs=$this->savlangs;
109
-        $db=$this->savdb;
105
+        global $conf, $user, $langs, $db;
106
+        $conf = $this->savconf;
107
+        $user = $this->savuser;
108
+        $langs = $this->savlangs;
109
+        $db = $this->savdb;
110 110
 
111 111
         print __METHOD__."\n";
112 112
     }
@@ -129,26 +129,26 @@  discard block
 block discarded – undo
129 129
      */
130 130
     public function testWSUserGetUser()
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 138
         $WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_user.php';
139 139
         $WS_METHOD  = 'getUser';
140
-        $ns='http://www.dolibarr.org/ns/';
140
+        $ns = 'http://www.dolibarr.org/ns/';
141 141
 
142 142
         // Set the WebService URL
143 143
         print __METHOD__."Create nusoap_client for URL=".$WS_DOL_URL."\n";
144 144
         $soapclient = new nusoap_client($WS_DOL_URL);
145 145
         if ($soapclient) {
146
-            $soapclient->soap_defencoding='UTF-8';
146
+            $soapclient->soap_defencoding = 'UTF-8';
147 147
             $soapclient->decodeUTF8(false);
148 148
         }
149 149
 
150 150
         // Call the WebService method and store its result in $result.
151
-        $authentication=array(
151
+        $authentication = array(
152 152
             'dolibarrkey'=>$conf->global->WEBSERVICES_KEY,
153 153
             'sourceapplication'=>'DEMO',
154 154
             'login'=>'admin',
@@ -157,20 +157,20 @@  discard block
 block discarded – undo
157 157
         );
158 158
 
159 159
         // Test URL
160
-        $result='';
161
-        $parameters = array('authentication'=>$authentication,'id'=>0,'ref'=>'admin');
160
+        $result = '';
161
+        $parameters = array('authentication'=>$authentication, 'id'=>0, 'ref'=>'admin');
162 162
         print __METHOD__."Call method ".$WS_METHOD."\n";
163 163
         try {
164
-            $result = $soapclient->call($WS_METHOD,$parameters,$ns,'');
165
-        } catch(SoapFault $exception) {
164
+            $result = $soapclient->call($WS_METHOD, $parameters, $ns, '');
165
+        } catch (SoapFault $exception) {
166 166
             echo $exception;
167
-            $result=0;
167
+            $result = 0;
168 168
         }
169
-        if (! empty($result['faultstring'])) {
169
+        if (!empty($result['faultstring'])) {
170 170
             print $result['faultstring']."\n";
171
-            $result=0;
171
+            $result = 0;
172 172
         }
173
-        if (! $result) {
173
+        if (!$result) {
174 174
             //var_dump($soapclient);
175 175
             print $soapclient->error_str;
176 176
             print "\n<br>\n";
@@ -184,16 +184,16 @@  discard block
 block discarded – undo
184 184
         $this->assertEquals('OK', $result['result']['result_code'], 'Test on ref admin');
185 185
 
186 186
         // Test URL
187
-        $result='';
188
-        $parameters = array('authentication'=>$authentication,'id'=>0,'ref'=>'refthatdoesnotexists');
187
+        $result = '';
188
+        $parameters = array('authentication'=>$authentication, 'id'=>0, 'ref'=>'refthatdoesnotexists');
189 189
         print __METHOD__."Call method ".$WS_METHOD."\n";
190 190
         try {
191
-            $result = $soapclient->call($WS_METHOD,$parameters,$ns,'');
192
-        } catch(SoapFault $exception) {
191
+            $result = $soapclient->call($WS_METHOD, $parameters, $ns, '');
192
+        } catch (SoapFault $exception) {
193 193
             echo $exception;
194
-            $result=0;
194
+            $result = 0;
195 195
         }
196
-        if (! $result || ! empty($result['faultstring'])) {
196
+        if (!$result || !empty($result['faultstring'])) {
197 197
             //var_dump($soapclient);
198 198
             print $soapclient->error_str;
199 199
             print "\n<br>\n";
Please login to merge, or discard this patch.
dolibarr/test/phpunit/WebservicesProductsTest.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
44 44
 
45 45
 if (empty($conf->service->enabled))
46 46
 {
47
-	print "Error: Module service must be enabled.\n";
48
-	exit(1);
47
+    print "Error: Module service must be enabled.\n";
48
+    exit(1);
49 49
 }
50 50
 
51 51
 /**
@@ -70,9 +70,9 @@  discard block
 block discarded – undo
70 70
      */
71 71
     function __construct()
72 72
     {
73
-    	parent::__construct();
73
+        parent::__construct();
74 74
 
75
-    	//$this->sharedFixture
75
+        //$this->sharedFixture
76 76
         global $conf,$user,$langs,$db;
77 77
         $this->savconf=$conf;
78 78
         $this->savuser=$user;
Please login to merge, or discard this patch.
Spacing   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -25,12 +25,12 @@  discard block
 block discarded – undo
25 25
  *      \remarks    To run this script as CLI:  phpunit filename.php
26 26
  */
27 27
 
28
-global $conf,$user,$langs,$db;
28
+global $conf, $user, $langs, $db;
29 29
 //define('TEST_DB_FORCE_TYPE','mysql');	// This is to force using mysql driver
30 30
 //require_once 'PHPUnit/Autoload.php';
31 31
 require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
32 32
 require_once dirname(__FILE__).'/../../htdocs/core/lib/date.lib.php';
33
-require_once NUSOAP_PATH.'/nusoap.php';        // Include SOAP
33
+require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP
34 34
 
35 35
 
36 36
 if (empty($user->id)) {
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
     $user->fetch(1);
39 39
     $user->getrights();
40 40
 }
41
-$conf->global->MAIN_DISABLE_ALL_MAILS=1;
41
+$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
42 42
 
43
-$conf->global->MAIN_UMASK='0666';
43
+$conf->global->MAIN_UMASK = '0666';
44 44
 
45 45
 if (empty($conf->service->enabled))
46 46
 {
@@ -73,11 +73,11 @@  discard block
 block discarded – undo
73 73
     	parent::__construct();
74 74
 
75 75
     	//$this->sharedFixture
76
-        global $conf,$user,$langs,$db;
77
-        $this->savconf=$conf;
78
-        $this->savuser=$user;
79
-        $this->savlangs=$langs;
80
-        $this->savdb=$db;
76
+        global $conf, $user, $langs, $db;
77
+        $this->savconf = $conf;
78
+        $this->savuser = $user;
79
+        $this->savlangs = $langs;
80
+        $this->savdb = $db;
81 81
 
82 82
         print __METHOD__." db->type=".$db->type." user->id=".$user->id;
83 83
         //print " - db ".$db->db;
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
     // Static methods
88 88
     public static function setUpBeforeClass()
89 89
     {
90
-        global $conf,$user,$langs,$db;
90
+        global $conf, $user, $langs, $db;
91 91
         $db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
92 92
 
93 93
         print __METHOD__."\n";
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
     // tear down after class
96 96
     public static function tearDownAfterClass()
97 97
     {
98
-        global $conf,$user,$langs,$db;
98
+        global $conf, $user, $langs, $db;
99 99
         $db->rollback();
100 100
 
101 101
         print __METHOD__."\n";
@@ -108,11 +108,11 @@  discard block
 block discarded – undo
108 108
      */
109 109
     protected function setUp()
110 110
     {
111
-        global $conf,$user,$langs,$db;
112
-        $conf=$this->savconf;
113
-        $user=$this->savuser;
114
-        $langs=$this->savlangs;
115
-        $db=$this->savdb;
111
+        global $conf, $user, $langs, $db;
112
+        $conf = $this->savconf;
113
+        $user = $this->savuser;
114
+        $langs = $this->savlangs;
115
+        $db = $this->savdb;
116 116
 
117 117
         print __METHOD__."\n";
118 118
     }
@@ -135,28 +135,28 @@  discard block
 block discarded – undo
135 135
      */
136 136
     public function testWSProductsCreateProductOrService()
137 137
     {
138
-        global $conf,$user,$langs,$db;
139
-        $conf=$this->savconf;
140
-        $user=$this->savuser;
141
-        $langs=$this->savlangs;
142
-        $db=$this->savdb;
138
+        global $conf, $user, $langs, $db;
139
+        $conf = $this->savconf;
140
+        $user = $this->savuser;
141
+        $langs = $this->savlangs;
142
+        $db = $this->savdb;
143 143
 
144
-        $datestring=dol_print_date(dol_now(),'dayhourlog');
144
+        $datestring = dol_print_date(dol_now(), 'dayhourlog');
145 145
 
146 146
         $WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_productorservice.php';
147 147
         $WS_METHOD  = 'createProductOrService';
148
-        $ns='http://www.dolibarr.org/ns/';
148
+        $ns = 'http://www.dolibarr.org/ns/';
149 149
 
150 150
         // Set the WebService URL
151 151
         print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n";
152 152
         $soapclient = new nusoap_client($WS_DOL_URL);
153 153
         if ($soapclient) {
154
-            $soapclient->soap_defencoding='UTF-8';
154
+            $soapclient->soap_defencoding = 'UTF-8';
155 155
             $soapclient->decodeUTF8(false);
156 156
         }
157 157
 
158 158
         // Call the WebService method and store its result in $result.
159
-        $authentication=array(
159
+        $authentication = array(
160 160
             'dolibarrkey'=>$conf->global->WEBSERVICES_KEY,
161 161
             'sourceapplication'=>'DEMO',
162 162
             'login'=>'admin',
@@ -165,9 +165,9 @@  discard block
 block discarded – undo
165 165
         );
166 166
 
167 167
         // Test URL
168
-        $result='';
168
+        $result = '';
169 169
         $parameters = array(
170
-            'authentication'=>$authentication,'product'=>array(
170
+            'authentication'=>$authentication, 'product'=>array(
171 171
                 'ref'=>'NewProductFromWS'.$datestring,
172 172
                 'label'=>'New Product From WS '.$datestring,
173 173
                 'type'=>1,
@@ -178,12 +178,12 @@  discard block
 block discarded – undo
178 178
         );
179 179
         print __METHOD__." call method ".$WS_METHOD."\n";
180 180
         try {
181
-            $result = $soapclient->call($WS_METHOD,$parameters,$ns,'');
182
-        } catch(SoapFault $exception) {
181
+            $result = $soapclient->call($WS_METHOD, $parameters, $ns, '');
182
+        } catch (SoapFault $exception) {
183 183
             echo $exception;
184
-            $result=0;
184
+            $result = 0;
185 185
         }
186
-        if (! $result || ! empty($result['faultstring']) || $result['result']['result_code'] != 'OK') {
186
+        if (!$result || !empty($result['faultstring']) || $result['result']['result_code'] != 'OK') {
187 187
             //var_dump($soapclient);
188 188
             print $soapclient->error_str;
189 189
             print "\n<br>\n";
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
         }
195 195
 
196 196
         print __METHOD__." result=".$result."\n";
197
-        $this->assertEquals('OK',$result['result']['result_code']);
197
+        $this->assertEquals('OK', $result['result']['result_code']);
198 198
 
199 199
         return $result['id'];
200 200
     }
@@ -209,26 +209,26 @@  discard block
 block discarded – undo
209 209
      */
210 210
     public function testWSProductsGetProductOrService($id)
211 211
     {
212
-        global $conf,$user,$langs,$db;
213
-        $conf=$this->savconf;
214
-        $user=$this->savuser;
215
-        $langs=$this->savlangs;
216
-        $db=$this->savdb;
212
+        global $conf, $user, $langs, $db;
213
+        $conf = $this->savconf;
214
+        $user = $this->savuser;
215
+        $langs = $this->savlangs;
216
+        $db = $this->savdb;
217 217
 
218 218
         $WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_productorservice.php';
219 219
         $WS_METHOD  = 'getProductOrService';
220
-        $ns='http://www.dolibarr.org/ns/';
220
+        $ns = 'http://www.dolibarr.org/ns/';
221 221
 
222 222
         // Set the WebService URL
223 223
         print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n";
224 224
         $soapclient = new nusoap_client($WS_DOL_URL);
225 225
         if ($soapclient) {
226
-            $soapclient->soap_defencoding='UTF-8';
226
+            $soapclient->soap_defencoding = 'UTF-8';
227 227
             $soapclient->decodeUTF8(false);
228 228
         }
229 229
 
230 230
         // Call the WebService method and store its result in $result.
231
-        $authentication=array(
231
+        $authentication = array(
232 232
             'dolibarrkey'=>$conf->global->WEBSERVICES_KEY,
233 233
             'sourceapplication'=>'DEMO',
234 234
             'login'=>'admin',
@@ -237,16 +237,16 @@  discard block
 block discarded – undo
237 237
         );
238 238
 
239 239
         // Test URL
240
-        $result='';
241
-        $parameters = array('authentication'=>$authentication,'id'=>$id,'ref'=>'');
240
+        $result = '';
241
+        $parameters = array('authentication'=>$authentication, 'id'=>$id, 'ref'=>'');
242 242
         print __METHOD__." call method ".$WS_METHOD."\n";
243 243
         try {
244
-            $result = $soapclient->call($WS_METHOD,$parameters,$ns,'');
245
-        } catch(SoapFault $exception) {
244
+            $result = $soapclient->call($WS_METHOD, $parameters, $ns, '');
245
+        } catch (SoapFault $exception) {
246 246
             echo $exception;
247
-            $result=0;
247
+            $result = 0;
248 248
         }
249
-        if (! $result || ! empty($result['faultstring'])) {
249
+        if (!$result || !empty($result['faultstring'])) {
250 250
             //var_dump($soapclient);
251 251
             print $soapclient->error_str;
252 252
             print "\n<br>\n";
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
         }
258 258
 
259 259
         print __METHOD__." result=".$result."\n";
260
-        $this->assertEquals('OK',$result['result']['result_code']);
260
+        $this->assertEquals('OK', $result['result']['result_code']);
261 261
 
262 262
         return $id;
263 263
     }
@@ -272,26 +272,26 @@  discard block
 block discarded – undo
272 272
      */
273 273
     public function testWSProductsDeleteProductOrService($id)
274 274
     {
275
-        global $conf,$user,$langs,$db;
276
-        $conf=$this->savconf;
277
-        $user=$this->savuser;
278
-        $langs=$this->savlangs;
279
-        $db=$this->savdb;
275
+        global $conf, $user, $langs, $db;
276
+        $conf = $this->savconf;
277
+        $user = $this->savuser;
278
+        $langs = $this->savlangs;
279
+        $db = $this->savdb;
280 280
 
281 281
         $WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_productorservice.php';
282 282
         $WS_METHOD  = 'deleteProductOrService';
283
-        $ns='http://www.dolibarr.org/ns/';
283
+        $ns = 'http://www.dolibarr.org/ns/';
284 284
 
285 285
         // Set the WebService URL
286 286
         print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n";
287 287
         $soapclient = new nusoap_client($WS_DOL_URL);
288 288
         if ($soapclient) {
289
-            $soapclient->soap_defencoding='UTF-8';
289
+            $soapclient->soap_defencoding = 'UTF-8';
290 290
             $soapclient->decodeUTF8(false);
291 291
         }
292 292
 
293 293
         // Call the WebService method and store its result in $result.
294
-        $authentication=array(
294
+        $authentication = array(
295 295
             'dolibarrkey'=>$conf->global->WEBSERVICES_KEY,
296 296
             'sourceapplication'=>'DEMO',
297 297
             'login'=>'admin',
@@ -300,16 +300,16 @@  discard block
 block discarded – undo
300 300
         );
301 301
 
302 302
         // Test URL
303
-        $result='';
304
-        $parameters = array('authentication'=>$authentication,'listofid'=>$id);
303
+        $result = '';
304
+        $parameters = array('authentication'=>$authentication, 'listofid'=>$id);
305 305
         print __METHOD__." call method ".$WS_METHOD."\n";
306 306
         try {
307
-            $result = $soapclient->call($WS_METHOD,$parameters,$ns,'');
308
-        } catch(SoapFault $exception) {
307
+            $result = $soapclient->call($WS_METHOD, $parameters, $ns, '');
308
+        } catch (SoapFault $exception) {
309 309
             echo $exception;
310
-            $result=0;
310
+            $result = 0;
311 311
         }
312
-        if (! $result || ! empty($result['faultstring']) || $result['result']['result_code'] != 'OK') {
312
+        if (!$result || !empty($result['faultstring']) || $result['result']['result_code'] != 'OK') {
313 313
             //var_dump($soapclient);
314 314
             print $soapclient->error_str;
315 315
             print "\n<br>\n";
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
         }
321 321
 
322 322
         print __METHOD__." result=".$result."\n";
323
-        $this->assertEquals('OK',$result['result']['result_code']);
323
+        $this->assertEquals('OK', $result['result']['result_code']);
324 324
 
325 325
         return 0;
326 326
     }
Please login to merge, or discard this patch.