Completed
Branch develop (3d98b7)
by
unknown
17:59
created
test/phpunit/SecurityTest.php 1 patch
Spacing   +282 added lines, -282 removed lines patch added patch discarded remove patch
@@ -24,32 +24,32 @@  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
 
31
-if (! defined('NOREQUIRESOC')) {
31
+if (!defined('NOREQUIRESOC')) {
32 32
 	define('NOREQUIRESOC', '1');
33 33
 }
34
-if (! defined('NOCSRFCHECK')) {
34
+if (!defined('NOCSRFCHECK')) {
35 35
 	define('NOCSRFCHECK', '1');
36 36
 }
37
-if (! defined('NOTOKENRENEWAL')) {
37
+if (!defined('NOTOKENRENEWAL')) {
38 38
 	define('NOTOKENRENEWAL', '1');
39 39
 }
40
-if (! defined('NOREQUIREMENU')) {
40
+if (!defined('NOREQUIREMENU')) {
41 41
 	define('NOREQUIREMENU', '1'); // If there is no menu to show
42 42
 }
43
-if (! defined('NOREQUIREHTML')) {
43
+if (!defined('NOREQUIREHTML')) {
44 44
 	define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
45 45
 }
46
-if (! defined('NOREQUIREAJAX')) {
46
+if (!defined('NOREQUIREAJAX')) {
47 47
 	define('NOREQUIREAJAX', '1');
48 48
 }
49
-if (! defined("NOLOGIN")) {
50
-	define("NOLOGIN", '1');       // If this page is public (can be called outside logged session)
49
+if (!defined("NOLOGIN")) {
50
+	define("NOLOGIN", '1'); // If this page is public (can be called outside logged session)
51 51
 }
52
-if (! defined("NOSESSION")) {
52
+if (!defined("NOSESSION")) {
53 53
 	define("NOSESSION", '1');
54 54
 }
55 55
 
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	$user->fetch(1);
64 64
 	$user->getrights();
65 65
 }
66
-$conf->global->MAIN_DISABLE_ALL_MAILS=1;
66
+$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
67 67
 
68 68
 
69 69
 /**
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	public function testSetLang()
84 84
 	{
85 85
 		global $conf;
86
-		$conf=$this->savconf;
86
+		$conf = $this->savconf;
87 87
 
88 88
 		$tmplangs = new Translate('', $conf);
89 89
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 		// More on https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet
106 106
 
107 107
 		// Should be OK
108
-		$expectedresult=0;
108
+		$expectedresult = 0;
109 109
 
110 110
 		/*
111 111
 		$test = '';
@@ -113,107 +113,107 @@  discard block
 block discarded – undo
113 113
 		$this->assertGreaterThanOrEqual(0, $result, 'Error on testSqlAndScriptInject kkk');
114 114
 		*/
115 115
 
116
-		$_SERVER["PHP_SELF"]='/DIR WITH SPACE/htdocs/admin/index.php';
117
-		$result=testSqlAndScriptInject($_SERVER["PHP_SELF"], 2);
116
+		$_SERVER["PHP_SELF"] = '/DIR WITH SPACE/htdocs/admin/index.php';
117
+		$result = testSqlAndScriptInject($_SERVER["PHP_SELF"], 2);
118 118
 		$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for PHP_SELF that should be ok');
119 119
 
120 120
 		$test = 'This is a < inside string with < and > also and tag like <a> before the >';
121
-		$result=testSqlAndScriptInject($test, 0);
121
+		$result = testSqlAndScriptInject($test, 0);
122 122
 		$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject expected 0b');
123 123
 
124 124
 		$test = 'This is the union of all for the selection of the best';
125
-		$result=testSqlAndScriptInject($test, 0);
125
+		$result = testSqlAndScriptInject($test, 0);
126 126
 		$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject expected 0c');
127 127
 
128
-		$test='/user/perms.php?id=1&action=addrights&entity=1&rights=123&confirm=yes&token=123456789&updatedmodulename=lmscoursetracking';
129
-		$result=testSqlAndScriptInject($test, 1);
128
+		$test = '/user/perms.php?id=1&action=addrights&entity=1&rights=123&confirm=yes&token=123456789&updatedmodulename=lmscoursetracking';
129
+		$result = testSqlAndScriptInject($test, 1);
130 130
 		print "test=".$test." result=".$result."\n";
131 131
 		$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject with a valid url');
132 132
 
133 133
 		// Should detect attack
134
-		$expectedresult=1;
134
+		$expectedresult = 1;
135 135
 
136
-		$_SERVER["PHP_SELF"]='/DIR WITH SPACE/htdocs/admin/index.php/<svg>';
137
-		$result=testSqlAndScriptInject($_SERVER["PHP_SELF"], 2);
136
+		$_SERVER["PHP_SELF"] = '/DIR WITH SPACE/htdocs/admin/index.php/<svg>';
137
+		$result = testSqlAndScriptInject($_SERVER["PHP_SELF"], 2);
138 138
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject for PHP_SELF that should detect XSS');
139 139
 
140 140
 		$test = 'select @@version';
141
-		$result=testSqlAndScriptInject($test, 0);
141
+		$result = testSqlAndScriptInject($test, 0);
142 142
 		$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for SQL1a. Should find an attack on POST param and did not.');
143 143
 
144 144
 		$test = 'select @@version';
145
-		$result=testSqlAndScriptInject($test, 1);
145
+		$result = testSqlAndScriptInject($test, 1);
146 146
 		$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for SQL1b. Should find an attack on GET param and did not.');
147 147
 
148 148
 		$test = '... update ... set ... =';
149
-		$result=testSqlAndScriptInject($test, 1);
149
+		$result = testSqlAndScriptInject($test, 1);
150 150
 		$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for SQL2a. Should find an attack on GET param and did not.');
151 151
 
152 152
 		$test = "delete\nfrom";
153
-		$result=testSqlAndScriptInject($test, 1);
153
+		$result = testSqlAndScriptInject($test, 1);
154 154
 		$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for SQL2b. Should find an attack on GET param and did not.');
155 155
 
156 156
 		$test = 'action=update& ... set ... =';
157
-		$result=testSqlAndScriptInject($test, 1);
157
+		$result = testSqlAndScriptInject($test, 1);
158 158
 		$this->assertEquals(0, $result, 'Error on testSqlAndScriptInject for SQL2b. Should not find an attack on GET param and did.');
159 159
 
160 160
 		$test = '... union ... selection ';
161
-		$result=testSqlAndScriptInject($test, 1);
161
+		$result = testSqlAndScriptInject($test, 1);
162 162
 		$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for SQL2c. Should find an attack on GET param and did not.');
163 163
 
164 164
 		$test = 'j&#x61;vascript:';
165
-		$result=testSqlAndScriptInject($test, 0);
165
+		$result = testSqlAndScriptInject($test, 0);
166 166
 		$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for javascript1. Should find an attack and did not.');
167 167
 
168 168
 		$test = 'j&#x61vascript:';
169
-		$result=testSqlAndScriptInject($test, 0);
169
+		$result = testSqlAndScriptInject($test, 0);
170 170
 		$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for javascript2. Should find an attack and did not.');
171 171
 
172 172
 		$test = 'javascript&colon&#x3B;alert(1)';
173
-		$result=testSqlAndScriptInject($test, 0);
173
+		$result = testSqlAndScriptInject($test, 0);
174 174
 		$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for javascript2');
175 175
 
176
-		$test="<img src='1.jpg' onerror =javascript:alert('XSS')>";
177
-		$result=testSqlAndScriptInject($test, 0);
176
+		$test = "<img src='1.jpg' onerror =javascript:alert('XSS')>";
177
+		$result = testSqlAndScriptInject($test, 0);
178 178
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa1');
179 179
 
180
-		$test="<img src='1.jpg' onerror =javascript:alert('XSS')>";
181
-		$result=testSqlAndScriptInject($test, 2);
180
+		$test = "<img src='1.jpg' onerror =javascript:alert('XSS')>";
181
+		$result = testSqlAndScriptInject($test, 2);
182 182
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa2');
183 183
 
184
-		$test='<IMG SRC=# onmouseover="alert(1)">';
185
-		$result=testSqlAndScriptInject($test, 0);
184
+		$test = '<IMG SRC=# onmouseover="alert(1)">';
185
+		$result = testSqlAndScriptInject($test, 0);
186 186
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa3');
187
-		$test='<IMG SRC onmouseover="alert(1)">';
188
-		$result=testSqlAndScriptInject($test, 0);
187
+		$test = '<IMG SRC onmouseover="alert(1)">';
188
+		$result = testSqlAndScriptInject($test, 0);
189 189
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa4');
190
-		$test='<IMG onmouseover="alert(1)">';
191
-		$result=testSqlAndScriptInject($test, 0);
190
+		$test = '<IMG onmouseover="alert(1)">';
191
+		$result = testSqlAndScriptInject($test, 0);
192 192
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa5');
193
-		$test='<IMG SRC=/ onerror="alert(1)">';
194
-		$result=testSqlAndScriptInject($test, 0);
193
+		$test = '<IMG SRC=/ onerror="alert(1)">';
194
+		$result = testSqlAndScriptInject($test, 0);
195 195
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa6');
196
-		$test='<IMG SRC=" &#14;  javascript:alert(1);">';
197
-		$result=testSqlAndScriptInject($test, 0);
196
+		$test = '<IMG SRC=" &#14;  javascript:alert(1);">';
197
+		$result = testSqlAndScriptInject($test, 0);
198 198
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa7');
199 199
 
200
-		$test='<IMG SRC=&#106;&#97;&#118;&#97;&#115;&#99;&#114;&#105;&#112;&#116;&#58;&#97;&#108;&#101;&#114;&#116;&#40;&#39;&#88;&#83;&#83;&#39;&#41;>';
201
-		$result=testSqlAndScriptInject($test, 0);
200
+		$test = '<IMG SRC=&#106;&#97;&#118;&#97;&#115;&#99;&#114;&#105;&#112;&#116;&#58;&#97;&#108;&#101;&#114;&#116;&#40;&#39;&#88;&#83;&#83;&#39;&#41;>';
201
+		$result = testSqlAndScriptInject($test, 0);
202 202
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject bbb');
203 203
 
204
-		$test='<SCRIPT SRC=http://xss.rocks/xss.js></SCRIPT>';
205
-		$result=testSqlAndScriptInject($test, 0);
204
+		$test = '<SCRIPT SRC=http://xss.rocks/xss.js></SCRIPT>';
205
+		$result = testSqlAndScriptInject($test, 0);
206 206
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject ccc');
207 207
 
208
-		$test='<IMG SRC="javascript:alert(\'XSS\');">';
209
-		$result=testSqlAndScriptInject($test, 1);
208
+		$test = '<IMG SRC="javascript:alert(\'XSS\');">';
209
+		$result = testSqlAndScriptInject($test, 1);
210 210
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject ddd');
211 211
 
212
-		$test='<IMG """><SCRIPT>alert("XSS")</SCRIPT>">';
213
-		$result=testSqlAndScriptInject($test, 0);
212
+		$test = '<IMG """><SCRIPT>alert("XSS")</SCRIPT>">';
213
+		$result = testSqlAndScriptInject($test, 0);
214 214
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject eee');
215 215
 
216
-		$test='<!-- Google analytics -->
216
+		$test = '<!-- Google analytics -->
217 217
 			<script>
218 218
 			  (function(i,s,o,g,r,a,m){i[\'GoogleAnalyticsObject\']=r;i[r]=i[r]||function(){
219 219
 			  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
@@ -224,60 +224,60 @@  discard block
 block discarded – undo
224 224
 			  ga(\'send\', \'pageview\');
225 225
 
226 226
 			</script>';
227
-		$result=testSqlAndScriptInject($test, 0);
227
+		$result = testSqlAndScriptInject($test, 0);
228 228
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject eee');
229 229
 
230
-		$test="<IMG SRC=\"jav\tascript:alert('XSS');\">";		// Is locked by some browser like chrome because the default directive no-referrer-when-downgrade is sent when requesting the SRC and then refused because of browser protection on img src load without referrer.
231
-		$test="<IMG SRC=\"jav&#x0D;ascript:alert('XSS');\">";	// Same
230
+		$test = "<IMG SRC=\"jav\tascript:alert('XSS');\">"; // Is locked by some browser like chrome because the default directive no-referrer-when-downgrade is sent when requesting the SRC and then refused because of browser protection on img src load without referrer.
231
+		$test = "<IMG SRC=\"jav&#x0D;ascript:alert('XSS');\">"; // Same
232 232
 
233
-		$test='<SCRIPT/XSS SRC="http://xss.rocks/xss.js"></SCRIPT>';
234
-		$result=testSqlAndScriptInject($test, 0);
233
+		$test = '<SCRIPT/XSS SRC="http://xss.rocks/xss.js"></SCRIPT>';
234
+		$result = testSqlAndScriptInject($test, 0);
235 235
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject fff1');
236
-		$test='<SCRIPT/SRC="http://xss.rocks/xss.js"></SCRIPT>';
237
-		$result=testSqlAndScriptInject($test, 0);
236
+		$test = '<SCRIPT/SRC="http://xss.rocks/xss.js"></SCRIPT>';
237
+		$result = testSqlAndScriptInject($test, 0);
238 238
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject fff2');
239 239
 
240 240
 		// This case seems to be filtered by browsers now.
241
-		$test='<BODY onload!#$%&()*~+-_.,:;?@[/|\]^`=alert(1)>';
241
+		$test = '<BODY onload!#$%&()*~+-_.,:;?@[/|\]^`=alert(1)>';
242 242
 		//$result=testSqlAndScriptInject($test, 0);
243 243
 		//$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject ggg');
244 244
 
245
-		$test='<iframe src=http://xss.rocks/scriptlet.html <';
246
-		$result=testSqlAndScriptInject($test, 0);
245
+		$test = '<iframe src=http://xss.rocks/scriptlet.html <';
246
+		$result = testSqlAndScriptInject($test, 0);
247 247
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject hhh');
248 248
 
249
-		$test='Set.constructor`alert\x281\x29```';
250
-		$result=testSqlAndScriptInject($test, 0);
249
+		$test = 'Set.constructor`alert\x281\x29```';
250
+		$result = testSqlAndScriptInject($test, 0);
251 251
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject iii');
252 252
 
253
-		$test="on<!-- ab\nc -->error=alert(1)";
254
-		$result=testSqlAndScriptInject($test, 0);
253
+		$test = "on<!-- ab\nc -->error=alert(1)";
254
+		$result = testSqlAndScriptInject($test, 0);
255 255
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject jjj');
256 256
 
257
-		$test="<img src=x one<a>rror=alert(document.location)";
258
-		$result=testSqlAndScriptInject($test, 0);
257
+		$test = "<img src=x one<a>rror=alert(document.location)";
258
+		$result = testSqlAndScriptInject($test, 0);
259 259
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject kkk');
260 260
 
261
-		$test="<a onpointerdown=alert(document.domain)>XSS</a>";
262
-		$result=testSqlAndScriptInject($test, 0);
261
+		$test = "<a onpointerdown=alert(document.domain)>XSS</a>";
262
+		$result = testSqlAndScriptInject($test, 0);
263 263
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject lll');
264 264
 
265
-		$test='<a onscrollend=alert(1) style="display:block;overflow:auto;border:1px+dashed;width:500px;height:100px;"><br><br><br><br><br><span+id=x>test</span></a>';	// Add the char %F6 into the variable
266
-		$result=testSqlAndScriptInject($test, 0);
265
+		$test = '<a onscrollend=alert(1) style="display:block;overflow:auto;border:1px+dashed;width:500px;height:100px;"><br><br><br><br><br><span+id=x>test</span></a>'; // Add the char %F6 into the variable
266
+		$result = testSqlAndScriptInject($test, 0);
267 267
 		//print "test=".$test." result=".$result."\n";
268 268
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject mmm');
269 269
 
270 270
 
271
-		$test="Text with ' encoded with the numeric html entity converted into text entity &#39; (like when submitted by CKEditor)";
272
-		$result=testSqlAndScriptInject($test, 0);	// result must be 0
271
+		$test = "Text with ' encoded with the numeric html entity converted into text entity &#39; (like when submitted by CKEditor)";
272
+		$result = testSqlAndScriptInject($test, 0); // result must be 0
273 273
 		$this->assertEquals(0, $result, 'Error on testSqlAndScriptInject mmm, result should be 0 and is not');
274 274
 
275
-		$test ='<a href="j&Tab;a&Tab;v&Tab;asc&NewLine;ri&Tab;pt:&lpar;a&Tab;l&Tab;e&Tab;r&Tab;t&Tab;(document.cookie)&rpar;">XSS</a>';
276
-		$result=testSqlAndScriptInject($test, 0);
275
+		$test = '<a href="j&Tab;a&Tab;v&Tab;asc&NewLine;ri&Tab;pt:&lpar;a&Tab;l&Tab;e&Tab;r&Tab;t&Tab;(document.cookie)&rpar;">XSS</a>';
276
+		$result = testSqlAndScriptInject($test, 0);
277 277
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject nnn, result should be >= 1 and is not');
278 278
 
279
-		$test="/dolibarr/htdocs/index.php/".chr('246')."abc";	// Add the char %F6 into the variable
280
-		$result=testSqlAndScriptInject($test, 2);
279
+		$test = "/dolibarr/htdocs/index.php/".chr('246')."abc"; // Add the char %F6 into the variable
280
+		$result = testSqlAndScriptInject($test, 2);
281 281
 		//print "test=".$test." result=".$result."\n";
282 282
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject with a non valid UTF8 char');
283 283
 	}
@@ -289,11 +289,11 @@  discard block
 block discarded – undo
289 289
 	 */
290 290
 	public function testGETPOST()
291 291
 	{
292
-		global $conf,$user,$langs,$db;
293
-		$conf=$this->savconf;
294
-		$user=$this->savuser;
295
-		$langs=$this->savlangs;
296
-		$db=$this->savdb;
292
+		global $conf, $user, $langs, $db;
293
+		$conf = $this->savconf;
294
+		$user = $this->savuser;
295
+		$langs = $this->savlangs;
296
+		$db = $this->savdb;
297 297
 
298 298
 		// Force default mode
299 299
 		$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 0;
@@ -301,211 +301,211 @@  discard block
 block discarded – undo
301 301
 		$conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = 0;
302 302
 		$conf->global->MAIN_DISALLOW_URL_INTO_DESCRIPTIONS = 0;
303 303
 
304
-		$_COOKIE["id"]=111;
305
-		$_POST["param0"]='A real string with <a href="rrr" title="aa&quot;bb">aaa</a> and " and \' and &amp; inside content';
306
-		$_GET["param1"]="222";
307
-		$_POST["param1"]="333";
308
-		$_GET["param2"]='a/b#e(pr)qq-rr\cc';
309
-		$_GET["param3"]='"&#110;a/b#e(pr)qq-rr\cc';    // Same than param2 + " and &#110;
310
-		$_GET["param4a"]='..&#47;../dir';
311
-		$_GET["param4b"]='..&#92;..\dirwindows';
312
-		$_GET["param5"]="a_1-b";
313
-		$_POST["param6"]="&quot;&gt;<svg o&#110;load='console.log(&quot;123&quot;)'&gt;";
314
-		$_POST["param6b"]='<<<../>../>../svg><<<../>../>../animate =alert(1)>abc';
315
-		$_GET["param7"]='"c:\this is a path~1\aaa&#110; &#x&#x31;&#x31;&#x30;;" abc<bad>def</bad>';
316
-		$_POST["param8a"]="Hacker<svg o&#110;load='console.log(&quot;123&quot;)'";	// html tag is not closed so it is not detected as html tag but is still harmfull
317
-		$_POST['param8b']='<img src=x onerror=alert(document.location) t=';		// this is html obfuscated by non closing tag
318
-		$_POST['param8c']='< with space after is ok';
319
-		$_POST['param8d']='<abc123 is html to clean';
320
-		$_POST['param8e']='<123abc is not html to clean';	// other similar case: '<2021-12-12'
321
-		$_POST['param8f']='abc<<svg <><<animate onbegin=alert(document.domain) a';
322
-		$_POST["param9"]='is_object($object) ? ($object->id < 10 ? round($object->id / 2, 2) : (2 * $user->id) * (int) substr($mysoc->zip, 1, 2)) : \'objnotdefined\'';
323
-		$_POST["param10"]='is_object($object) ? ($object->id < 10 ? round($object->id / 2, 2) : (2 * $user->id) * (int) substr($mysoc->zip, 1, 2)) : \'<abc>objnotdefined\'';
324
-		$_POST["param11"]=' Name <[email protected]> ';
325
-		$_POST["param12"]='<!DOCTYPE html><html>aaa</html>';
326
-		$_POST["param13"]='&#110; &#x6E; &gt; &lt; &quot; <a href=\"j&#x61;vascript:alert(document.domain)\">XSS</a>';
327
-		$_POST["param13b"]='&#110; &#x6E; &gt; &lt; &quot; <a href=\"j&#x61vascript:alert(document.domain)\">XSS</a>';
328
-		$_POST["param13c"]='aaa:<:bbb';
329
-		$_POST["param14"]="Text with ' encoded with the numeric html entity converted into text entity &#39; (like when submitted by CKEditor)";
330
-		$_POST["param15"]="<img onerror<=alert(document.domain)> src=>0xbeefed";
304
+		$_COOKIE["id"] = 111;
305
+		$_POST["param0"] = 'A real string with <a href="rrr" title="aa&quot;bb">aaa</a> and " and \' and &amp; inside content';
306
+		$_GET["param1"] = "222";
307
+		$_POST["param1"] = "333";
308
+		$_GET["param2"] = 'a/b#e(pr)qq-rr\cc';
309
+		$_GET["param3"] = '"&#110;a/b#e(pr)qq-rr\cc'; // Same than param2 + " and &#110;
310
+		$_GET["param4a"] = '..&#47;../dir';
311
+		$_GET["param4b"] = '..&#92;..\dirwindows';
312
+		$_GET["param5"] = "a_1-b";
313
+		$_POST["param6"] = "&quot;&gt;<svg o&#110;load='console.log(&quot;123&quot;)'&gt;";
314
+		$_POST["param6b"] = '<<<../>../>../svg><<<../>../>../animate =alert(1)>abc';
315
+		$_GET["param7"] = '"c:\this is a path~1\aaa&#110; &#x&#x31;&#x31;&#x30;;" abc<bad>def</bad>';
316
+		$_POST["param8a"] = "Hacker<svg o&#110;load='console.log(&quot;123&quot;)'"; // html tag is not closed so it is not detected as html tag but is still harmfull
317
+		$_POST['param8b'] = '<img src=x onerror=alert(document.location) t='; // this is html obfuscated by non closing tag
318
+		$_POST['param8c'] = '< with space after is ok';
319
+		$_POST['param8d'] = '<abc123 is html to clean';
320
+		$_POST['param8e'] = '<123abc is not html to clean'; // other similar case: '<2021-12-12'
321
+		$_POST['param8f'] = 'abc<<svg <><<animate onbegin=alert(document.domain) a';
322
+		$_POST["param9"] = 'is_object($object) ? ($object->id < 10 ? round($object->id / 2, 2) : (2 * $user->id) * (int) substr($mysoc->zip, 1, 2)) : \'objnotdefined\'';
323
+		$_POST["param10"] = 'is_object($object) ? ($object->id < 10 ? round($object->id / 2, 2) : (2 * $user->id) * (int) substr($mysoc->zip, 1, 2)) : \'<abc>objnotdefined\'';
324
+		$_POST["param11"] = ' Name <[email protected]> ';
325
+		$_POST["param12"] = '<!DOCTYPE html><html>aaa</html>';
326
+		$_POST["param13"] = '&#110; &#x6E; &gt; &lt; &quot; <a href=\"j&#x61;vascript:alert(document.domain)\">XSS</a>';
327
+		$_POST["param13b"] = '&#110; &#x6E; &gt; &lt; &quot; <a href=\"j&#x61vascript:alert(document.domain)\">XSS</a>';
328
+		$_POST["param13c"] = 'aaa:<:bbb';
329
+		$_POST["param14"] = "Text with ' encoded with the numeric html entity converted into text entity &#39; (like when submitted by CKEditor)";
330
+		$_POST["param15"] = "<img onerror<=alert(document.domain)> src=>0xbeefed";
331 331
 		//$_POST["param15b"]="<html><head><title>Example HTML</title></head><body><div><p>This is a paragraph.</div><ul><li>Item 1</li><li>Item 2</li></ol></body><html>";
332
-		$_POST["param16"]='<a style="z-index: 1000">abc</a>';
333
-		$_POST["param17"]='<span style="background-image: url(logout.php)">abc</span>';
334
-		$_POST["param18"]='<span style="background-image: url(...?...action=aaa)">abc</span>';
335
-		$_POST["param19"]='<a href="j&Tab;a&Tab;v&Tab;asc&NewLine;ri&Tab;pt:&lpar;alert(document.cookie)&rpar;">XSS</a>';
332
+		$_POST["param16"] = '<a style="z-index: 1000">abc</a>';
333
+		$_POST["param17"] = '<span style="background-image: url(logout.php)">abc</span>';
334
+		$_POST["param18"] = '<span style="background-image: url(...?...action=aaa)">abc</span>';
335
+		$_POST["param19"] = '<a href="j&Tab;a&Tab;v&Tab;asc&NewLine;ri&Tab;pt:&lpar;alert(document.cookie)&rpar;">XSS</a>';
336 336
 		//$_POST["param19"]='<a href="javascript:alert(document.cookie)">XSS</a>';
337 337
 
338 338
 
339 339
 
340
-		$result=GETPOST('id', 'int');              // Must return nothing
340
+		$result = GETPOST('id', 'int'); // Must return nothing
341 341
 		print __METHOD__." result=".$result."\n";
342 342
 		$this->assertEquals('', $result);
343 343
 
344
-		$result=GETPOST("param1", 'int');
344
+		$result = GETPOST("param1", 'int');
345 345
 		print __METHOD__." result=".$result."\n";
346 346
 		$this->assertEquals(222, $result, 'Test on param1 with no 3rd param');
347 347
 
348
-		$result=GETPOST("param1", 'int', 2);
348
+		$result = GETPOST("param1", 'int', 2);
349 349
 		print __METHOD__." result=".$result."\n";
350 350
 		$this->assertEquals(333, $result, 'Test on param1 with 3rd param = 2');
351 351
 
352 352
 		// Test with alpha
353 353
 
354
-		$result=GETPOST("param0", 'alpha');		// a simple format, so " completely removed
354
+		$result = GETPOST("param0", 'alpha'); // a simple format, so " completely removed
355 355
 		$resultexpected = 'A real string with aaa and and \' and & inside content';
356 356
 		print __METHOD__." result=".$result."\n";
357 357
 		$this->assertEquals($resultexpected, $result, 'Test on param0');
358 358
 
359
-		$result=GETPOST("param2", 'alpha');
359
+		$result = GETPOST("param2", 'alpha');
360 360
 		print __METHOD__." result=".$result."\n";
361 361
 		$this->assertEquals($result, $_GET["param2"], 'Test on param2');
362 362
 
363
-		$result=GETPOST("param3", 'alpha');  // Must return string sanitized from char "
363
+		$result = GETPOST("param3", 'alpha'); // Must return string sanitized from char "
364 364
 		print __METHOD__." result=".$result."\n";
365 365
 		$this->assertEquals($result, 'na/b#e(pr)qq-rr\cc', 'Test on param3');
366 366
 
367
-		$result=GETPOST("param4a", 'alpha');  // Must return string sanitized from ../
367
+		$result = GETPOST("param4a", 'alpha'); // Must return string sanitized from ../
368 368
 		print __METHOD__." result=".$result."\n";
369 369
 		$this->assertEquals($result, 'dir');
370 370
 
371
-		$result=GETPOST("param4b", 'alpha');  // Must return string sanitized from ../
371
+		$result = GETPOST("param4b", 'alpha'); // Must return string sanitized from ../
372 372
 		print __METHOD__." result=".$result."\n";
373 373
 		$this->assertEquals($result, 'dirwindows');
374 374
 
375 375
 		// Test with aZ09
376 376
 
377
-		$result=GETPOST("param1", 'aZ09');
377
+		$result = GETPOST("param1", 'aZ09');
378 378
 		print __METHOD__." result=".$result."\n";
379 379
 		$this->assertEquals($result, $_GET["param1"]);
380 380
 
381
-		$result=GETPOST("param2", 'aZ09');  // Must return '' as string contains car not in aZ09 definition
381
+		$result = GETPOST("param2", 'aZ09'); // Must return '' as string contains car not in aZ09 definition
382 382
 		print __METHOD__." result=".$result."\n";
383 383
 		$this->assertEquals($result, '');
384 384
 
385
-		$result=GETPOST("param3", 'aZ09');  // Must return '' as string contains car not in aZ09 definition
385
+		$result = GETPOST("param3", 'aZ09'); // Must return '' as string contains car not in aZ09 definition
386 386
 		print __METHOD__." result=".$result."\n";
387 387
 		$this->assertEquals($result, '');
388 388
 
389
-		$result=GETPOST("param4a", 'aZ09');  // Must return '' as string contains car not in aZ09 definition
389
+		$result = GETPOST("param4a", 'aZ09'); // Must return '' as string contains car not in aZ09 definition
390 390
 		print __METHOD__." result=".$result."\n";
391 391
 		$this->assertEquals('', $result);
392 392
 
393
-		$result=GETPOST("param4b", 'aZ09');  // Must return '' as string contains car not in aZ09 definition
393
+		$result = GETPOST("param4b", 'aZ09'); // Must return '' as string contains car not in aZ09 definition
394 394
 		print __METHOD__." result=".$result."\n";
395 395
 		$this->assertEquals('', $result);
396 396
 
397
-		$result=GETPOST("param5", 'aZ09');
397
+		$result = GETPOST("param5", 'aZ09');
398 398
 		print __METHOD__." result=".$result."\n";
399 399
 		$this->assertEquals($_GET["param5"], $result);
400 400
 
401 401
 		// Test with nohtml
402 402
 
403
-		$result=GETPOST("param6", 'nohtml');
403
+		$result = GETPOST("param6", 'nohtml');
404 404
 		print __METHOD__." result6=".$result."\n";
405 405
 		$this->assertEquals('">', $result);
406 406
 
407 407
 		// Test with alpha = alphanohtml. We must convert the html entities like &#110; and disable all entities
408 408
 
409
-		$result=GETPOST("param6", 'alphanohtml');
409
+		$result = GETPOST("param6", 'alphanohtml');
410 410
 		print __METHOD__." result=".$result."\n";
411 411
 		$this->assertEquals('>', $result);
412 412
 
413
-		$result=GETPOST("param6b", 'alphanohtml');
413
+		$result = GETPOST("param6b", 'alphanohtml');
414 414
 		print __METHOD__." result=".$result."\n";
415 415
 		$this->assertEquals('abc', $result);
416 416
 
417
-		$result=GETPOST("param8a", 'alphanohtml');
417
+		$result = GETPOST("param8a", 'alphanohtml');
418 418
 		print __METHOD__." result=".$result."\n";
419 419
 		$this->assertEquals("Hackersvg onload='console.log(123)'", $result);
420 420
 
421
-		$result=GETPOST("param8b", 'alphanohtml');
421
+		$result = GETPOST("param8b", 'alphanohtml');
422 422
 		print __METHOD__." result=".$result."\n";
423 423
 		$this->assertEquals('img src=x onerror=alert(document.location) t=', $result, 'Test a string with non closing html tag with alphanohtml');
424 424
 
425
-		$result=GETPOST("param8c", 'alphanohtml');
425
+		$result = GETPOST("param8c", 'alphanohtml');
426 426
 		print __METHOD__." result=".$result."\n";
427 427
 		$this->assertEquals($_POST['param8c'], $result, 'Test a string with non closing html tag with alphanohtml');
428 428
 
429
-		$result=GETPOST("param8d", 'alphanohtml');
429
+		$result = GETPOST("param8d", 'alphanohtml');
430 430
 		print __METHOD__." result=".$result."\n";
431 431
 		$this->assertEquals('abc123 is html to clean', $result, 'Test a string with non closing html tag with alphanohtml');
432 432
 
433
-		$result=GETPOST("param8e", 'alphanohtml');
433
+		$result = GETPOST("param8e", 'alphanohtml');
434 434
 		print __METHOD__." result=".$result."\n";
435 435
 		$this->assertEquals($_POST['param8e'], $result, 'Test a string with non closing html tag with alphanohtml');
436 436
 
437
-		$result=GETPOST("param8f", 'alphanohtml');
437
+		$result = GETPOST("param8f", 'alphanohtml');
438 438
 		print __METHOD__." result=".$result."\n";
439 439
 		$this->assertEquals('abcsvg animate onbegin=alert(document.domain) a', $result, 'Test a string with html tag open with several <');
440 440
 
441
-		$result=GETPOST("param9", 'alphanohtml');
441
+		$result = GETPOST("param9", 'alphanohtml');
442 442
 		print __METHOD__." result=".$result."\n";
443 443
 		$this->assertEquals($_POST["param9"], $result);
444 444
 
445
-		$result=GETPOST("param10", 'alphanohtml');
445
+		$result = GETPOST("param10", 'alphanohtml');
446 446
 		print __METHOD__." result=".$result."\n";
447 447
 		$this->assertEquals($_POST["param9"], $result, 'We should get param9 after processing param10');
448 448
 
449
-		$result=GETPOST("param11", 'alphanohtml');
449
+		$result = GETPOST("param11", 'alphanohtml');
450 450
 		print __METHOD__." result=".$result."\n";
451 451
 		$this->assertEquals("Name", $result, 'Test an email string with alphanohtml');
452 452
 
453
-		$result=GETPOST("param13", 'alphanohtml');
453
+		$result = GETPOST("param13", 'alphanohtml');
454 454
 		print __METHOD__." result=".$result."\n";
455 455
 		$this->assertEquals('n n > <  XSS', $result, 'Test that html entities are decoded with alpha');
456 456
 
457
-		$result=GETPOST("param13c", 'alphanohtml');
457
+		$result = GETPOST("param13c", 'alphanohtml');
458 458
 		print __METHOD__." result=".$result."\n";
459 459
 		$this->assertEquals('aaa:<:bbb', $result, 'Test 13c');
460 460
 
461 461
 
462 462
 		// Test with alphawithlgt
463 463
 
464
-		$result=GETPOST("param11", 'alphawithlgt');
464
+		$result = GETPOST("param11", 'alphawithlgt');
465 465
 		print __METHOD__." result=".$result."\n";
466 466
 		$this->assertEquals(trim($_POST["param11"]), $result, 'Test an email string with alphawithlgt');
467 467
 
468 468
 
469 469
 		// Test with restricthtml: we must remove html open/close tag and content but not htmlentities (we can decode html entities for ascii chars like &#110;)
470 470
 
471
-		$result=GETPOST("param0", 'restricthtml');
471
+		$result = GETPOST("param0", 'restricthtml');
472 472
 		$resultexpected = 'A real string with <a href="rrr" title="aa&quot;bb">aaa</a> and " and \' and &amp; inside content';
473 473
 		print __METHOD__." result=".$result."\n";
474 474
 		$this->assertEquals($resultexpected, $result, 'Test on param0');
475 475
 
476
-		$result=GETPOST("param6", 'restricthtml');
476
+		$result = GETPOST("param6", 'restricthtml');
477 477
 		print __METHOD__." result for param6=".$result." - before=".$_POST["param6"]."\n";
478 478
 		$this->assertEquals('&quot;&gt;', $result);
479 479
 
480
-		$result=GETPOST("param7", 'restricthtml');
480
+		$result = GETPOST("param7", 'restricthtml');
481 481
 		print __METHOD__." result param7 = ".$result."\n";
482 482
 		$this->assertEquals('"c:\this is a path~1\aaan &#x;;;;" abcdef', $result);
483 483
 
484
-		$result=GETPOST("param8e", 'restricthtml');
484
+		$result = GETPOST("param8e", 'restricthtml');
485 485
 		print __METHOD__." result param8e = ".$result."\n";
486 486
 		$this->assertEquals('', $result);
487 487
 
488
-		$result=GETPOST("param12", 'restricthtml');
488
+		$result = GETPOST("param12", 'restricthtml');
489 489
 		print __METHOD__." result=".$result."\n";
490 490
 		$this->assertEquals(trim($_POST["param12"]), $result, 'Test a string with DOCTYPE and restricthtml');
491 491
 
492
-		$result=GETPOST("param13", 'restricthtml');
492
+		$result = GETPOST("param13", 'restricthtml');
493 493
 		print __METHOD__." result=".$result."\n";
494 494
 		$this->assertEquals('n n &gt; &lt; &quot; <a href=\"alert(document.domain)\">XSS</a>', $result, 'Test 13 that HTML entities are decoded with restricthtml, but only for common alpha chars');
495 495
 
496
-		$result=GETPOST("param13b", 'restricthtml');
496
+		$result = GETPOST("param13b", 'restricthtml');
497 497
 		print __METHOD__." result=".$result."\n";
498 498
 		$this->assertEquals('n n &gt; &lt; &quot; <a href=\"alert(document.domain)\">XSS</a>', $result, 'Test 13b that HTML entities are decoded with restricthtml, but only for common alpha chars');
499 499
 
500
-		$result=GETPOST("param14", 'restricthtml');
500
+		$result = GETPOST("param14", 'restricthtml');
501 501
 		print __METHOD__." result=".$result."\n";
502 502
 		$this->assertEquals("Text with ' encoded with the numeric html entity converted into text entity &#39; (like when submitted by CKEditor)", $result, 'Test 14');
503 503
 
504
-		$result=GETPOST("param15", 'restricthtml');		// param15 = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string
504
+		$result = GETPOST("param15", 'restricthtml'); // param15 = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string
505 505
 		print __METHOD__." result=".$result."\n";
506
-		$this->assertEquals("<img onerror=alert(document.domain) src=>0xbeefed", $result, 'Test 15');	// The GETPOST return a harmull string
506
+		$this->assertEquals("<img onerror=alert(document.domain) src=>0xbeefed", $result, 'Test 15'); // The GETPOST return a harmull string
507 507
 
508
-		$result=GETPOST("param19", 'restricthtml');
508
+		$result = GETPOST("param19", 'restricthtml');
509 509
 		print __METHOD__." result=".$result."\n";
510 510
 		$this->assertEquals('<a href="&lpar;alert(document.cookie)&rpar;">XSS</a>', $result, 'Test 19');
511 511
 
@@ -515,22 +515,22 @@  discard block
 block discarded – undo
515 515
 		$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = 0;
516 516
 
517 517
 		//$_POST["param0"] = 'A real string with <a href="rrr" title="aabb">aaa</a> and " inside content';
518
-		$result=GETPOST("param0", 'restricthtml');
518
+		$result = GETPOST("param0", 'restricthtml');
519 519
 		$resultexpected = 'A real string with <a href="rrr" title=\'aa"bb\'>aaa</a> and " and \' and &amp; inside content';
520 520
 		print __METHOD__." result for param0=".$result."\n";
521 521
 		$this->assertEquals($resultexpected, $result, 'Test on param0');
522 522
 
523
-		$result=GETPOST("param15", 'restricthtml');		// param15 = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string
523
+		$result = GETPOST("param15", 'restricthtml'); // param15 = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string
524 524
 		print __METHOD__." result for param15=".$result."\n";
525 525
 		//$this->assertEquals('InvalidHTMLStringCantBeCleaned', $result, 'Test 15b');   // With some PHP and libxml version, we got this result when parsing invalid HTML, but ...
526 526
 		//$this->assertEquals('<img onerror> src=&gt;0xbeefed', $result, 'Test 15b');	// ... on other PHP and libxml versions, we got a HTML that has been cleaned
527 527
 
528
-		$result=GETPOST("param6", 'restricthtml');		// param6 = "&quot;&gt;<svg o&#110;load='console.log(&quot;123&quot;)'&gt;"
528
+		$result = GETPOST("param6", 'restricthtml'); // param6 = "&quot;&gt;<svg o&#110;load='console.log(&quot;123&quot;)'&gt;"
529 529
 		print __METHOD__." result for param6=".$result." - before=".$_POST["param6"]."\n";
530 530
 		//$this->assertEquals('InvalidHTMLStringCantBeCleaned', $result, 'Test 15b');   // With some PHP and libxml version, we got this result when parsing invalid HTML, but ...
531 531
 		//$this->assertEquals('"&gt;', $result);										// ... on other PHP and libxml versions, we got a HTML that has been cleaned
532 532
 
533
-		$result=GETPOST("param7", 'restricthtml');		// param7 = "c:\this is a path~1\aaa&#110; &#x&#x31;&#x31;&#x30;;" abc<bad>def</bad>
533
+		$result = GETPOST("param7", 'restricthtml'); // param7 = "c:\this is a path~1\aaa&#110; &#x&#x31;&#x31;&#x30;;" abc<bad>def</bad>
534 534
 		print __METHOD__." result param7 = ".$result."\n";
535 535
 		//$this->assertEquals('InvalidHTMLStringCantBeCleaned', $result, 'Test 15b');   // With some PHP and libxml version, we got this result when parsing invalid HTML, but ...
536 536
 		//$this->assertEquals('"c:\this is a path~1\aaan 110;" abcdef', $result);		// ... on other PHP and libxml versions, we got a HTML that has been cleaned
@@ -542,19 +542,19 @@  discard block
 block discarded – undo
542 542
 			$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 0;
543 543
 			$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = 1;
544 544
 
545
-			$result=GETPOST("param0", 'restricthtml');
545
+			$result = GETPOST("param0", 'restricthtml');
546 546
 			$resultexpected = 'A real string with <a href="rrr" title="aa&quot;bb">aaa</a> and " and \' and & inside content';
547 547
 			print __METHOD__." result for param0=".$result."\n";
548 548
 			$this->assertEquals($resultexpected, $result, 'Test on param0');
549 549
 
550
-			$result=GETPOST("param15", 'restricthtml');		// param15 = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string
550
+			$result = GETPOST("param15", 'restricthtml'); // param15 = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string
551 551
 			print __METHOD__." result=".$result."\n";
552 552
 
553
-			$result=GETPOST("param6", 'restricthtml');
553
+			$result = GETPOST("param6", 'restricthtml');
554 554
 			print __METHOD__." result for param6=".$result." - before=".$_POST["param6"]."\n";
555 555
 			$this->assertEquals('"&gt;', $result);
556 556
 
557
-			$result=GETPOST("param7", 'restricthtml');
557
+			$result = GETPOST("param7", 'restricthtml');
558 558
 			print __METHOD__." result param7 = ".$result."\n";
559 559
 			$this->assertEquals('"c:\this is a path~1\aaan &amp;#x110;" abcdef', $result);
560 560
 		}
@@ -566,19 +566,19 @@  discard block
 block discarded – undo
566 566
 			$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 1;
567 567
 			$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = 1;
568 568
 
569
-			$result=GETPOST("param0", 'restricthtml');
569
+			$result = GETPOST("param0", 'restricthtml');
570 570
 			$resultexpected = 'A real string with <a href="rrr" title=\'aa"bb\'>aaa</a> and " and \' and & inside content';
571 571
 			print __METHOD__." result for param0=".$result."\n";
572 572
 			$this->assertEquals($resultexpected, $result, 'Test on param0');
573 573
 
574
-			$result=GETPOST("param15", 'restricthtml');		// param15 = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string
574
+			$result = GETPOST("param15", 'restricthtml'); // param15 = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string
575 575
 			print __METHOD__." result=".$result."\n";
576 576
 
577
-			$result=GETPOST("param6", 'restricthtml');
577
+			$result = GETPOST("param6", 'restricthtml');
578 578
 			print __METHOD__." result for param6=".$result." - before=".$_POST["param6"]."\n";
579 579
 			$this->assertEquals('"&gt;', $result);
580 580
 
581
-			$result=GETPOST("param7", 'restricthtml');
581
+			$result = GETPOST("param7", 'restricthtml');
582 582
 			print __METHOD__." result param7 = ".$result."\n";
583 583
 			$this->assertEquals('"c:\this is a path~1\aaan 110;" abcdef', $result);
584 584
 		}
@@ -590,19 +590,19 @@  discard block
 block discarded – undo
590 590
 		unset($conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY);
591 591
 		$conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = 1;
592 592
 
593
-		$result=GETPOST("param15", 'restricthtml');
593
+		$result = GETPOST("param15", 'restricthtml');
594 594
 		print __METHOD__." result=".$result."\n";
595 595
 		$this->assertEquals('<img src="">0xbeefed', $result, 'Test 15c');
596 596
 
597
-		$result=GETPOST('param16', 'restricthtml');
597
+		$result = GETPOST('param16', 'restricthtml');
598 598
 		print __METHOD__." result=".$result."\n";
599 599
 		$this->assertEquals('<a style=" 1000">abc</a>', $result, 'Test tag a with forbidden attribute z-index');
600 600
 
601
-		$result=GETPOST('param17', 'restricthtml');
601
+		$result = GETPOST('param17', 'restricthtml');
602 602
 		print __METHOD__." result=".$result."\n";
603 603
 		$this->assertEquals('<span style="background-image: url()">abc</span>', $result, 'Test anytag with a forbidden value for attribute');
604 604
 
605
-		$result=GETPOST('param18', 'restricthtml');
605
+		$result = GETPOST('param18', 'restricthtml');
606 606
 		print __METHOD__." result=".$result."\n";
607 607
 		$this->assertEquals('<span style="background-image: url(...?...aaa)">abc</span>', $result, 'Test anytag with a forbidden value for attribute');
608 608
 
@@ -611,75 +611,75 @@  discard block
 block discarded – undo
611 611
 
612 612
 		// Special test for GETPOST of backtopage, backtolist or backtourl parameter
613 613
 
614
-		$_POST["backtopage"]='//www.google.com';
615
-		$result=GETPOST("backtopage");
614
+		$_POST["backtopage"] = '//www.google.com';
615
+		$result = GETPOST("backtopage");
616 616
 		print __METHOD__." result=".$result."\n";
617 617
 		$this->assertEquals('www.google.com', $result, 'Test for backtopage param');
618 618
 
619
-		$_POST["backtopage"]='https:https://www.google.com';
620
-		$result=GETPOST("backtopage");
619
+		$_POST["backtopage"] = 'https:https://www.google.com';
620
+		$result = GETPOST("backtopage");
621 621
 		print __METHOD__." result=".$result."\n";
622 622
 		$this->assertEquals('www.google.com', $result, 'Test for backtopage param');
623 623
 
624
-		$_POST["backtolist"]='::HTTPS://www.google.com';
625
-		$result=GETPOST("backtolist");
624
+		$_POST["backtolist"] = '::HTTPS://www.google.com';
625
+		$result = GETPOST("backtolist");
626 626
 		print __METHOD__." result=".$result."\n";
627 627
 		$this->assertEquals('www.google.com', $result, 'Test for backtopage param');
628 628
 
629
-		$_POST["backtopage"]='http:www.google.com';
630
-		$result=GETPOST("backtopage");
629
+		$_POST["backtopage"] = 'http:www.google.com';
630
+		$result = GETPOST("backtopage");
631 631
 		print __METHOD__." result=".$result."\n";
632 632
 		$this->assertEquals('httpwww.google.com', $result, 'Test for backtopage param');
633 633
 
634
-		$_POST["backtopage"]='/mydir/mypage.php?aa=a%10a';
635
-		$result=GETPOST("backtopage");
634
+		$_POST["backtopage"] = '/mydir/mypage.php?aa=a%10a';
635
+		$result = GETPOST("backtopage");
636 636
 		print __METHOD__." result=".$result."\n";
637 637
 		$this->assertEquals('/mydir/mypage.php?aa=a%10a', $result, 'Test for backtopage param');
638 638
 
639
-		$_POST["backtopage"]='javascripT&javascript#javascriptxjavascript3a alert(1)';
640
-		$result=GETPOST("backtopage");
639
+		$_POST["backtopage"] = 'javascripT&javascript#javascriptxjavascript3a alert(1)';
640
+		$result = GETPOST("backtopage");
641 641
 		print __METHOD__." result=".$result."\n";
642 642
 		$this->assertEquals('x3aalert(1)', $result, 'Test for backtopage param');
643 643
 
644 644
 
645 645
 		$conf->global->MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT = 3;
646
-		$_POST["pagecontentwithlinks"]='<img src="aaa"><img src="bbb"><img src="/ccc"><span style="background: url(/ddd)"></span>';
647
-		$result=GETPOST("pagecontentwithlinks", 'restricthtml');
646
+		$_POST["pagecontentwithlinks"] = '<img src="aaa"><img src="bbb"><img src="/ccc"><span style="background: url(/ddd)"></span>';
647
+		$result = GETPOST("pagecontentwithlinks", 'restricthtml');
648 648
 		print __METHOD__." result=".$result."\n";
649 649
 		$this->assertEquals('ErrorTooManyLinksIntoHTMLString', $result, 'Test on limit on GETPOST fails');
650 650
 
651 651
 		// Test that img src="data:..." is excluded from the count of external links
652 652
 		$conf->global->MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT = 3;
653
-		$_POST["pagecontentwithlinks"]='<img src="data:abc"><img src="bbb"><img src="/ccc"><span style="background: url(/ddd)"></span>';
654
-		$result=GETPOST("pagecontentwithlinks", 'restricthtml');
653
+		$_POST["pagecontentwithlinks"] = '<img src="data:abc"><img src="bbb"><img src="/ccc"><span style="background: url(/ddd)"></span>';
654
+		$result = GETPOST("pagecontentwithlinks", 'restricthtml');
655 655
 		print __METHOD__." result=".$result."\n";
656 656
 		$this->assertEquals('<img src="data:abc"><img src="bbb"><img src="/ccc"><span style="background: url(/ddd)"></span>', $result, 'Test on limit on GETPOST fails');
657 657
 
658 658
 		$conf->global->MAIN_DISALLOW_URL_INTO_DESCRIPTIONS = 2;
659 659
 
660 660
 		// Test that no links is allowed
661
-		$_POST["pagecontentwithlinks"]='<img src="data:abc"><img src="bbb"><img src="/ccc"><span style="background: url(/ddd)"></span>';
662
-		$result=GETPOST("pagecontentwithlinks", 'restricthtml');
661
+		$_POST["pagecontentwithlinks"] = '<img src="data:abc"><img src="bbb"><img src="/ccc"><span style="background: url(/ddd)"></span>';
662
+		$result = GETPOST("pagecontentwithlinks", 'restricthtml');
663 663
 		print __METHOD__." result=".$result."\n";
664 664
 		$this->assertEquals('ErrorHTMLLinksNotAllowed', $result, 'Test on limit on MAIN_DISALLOW_URL_INTO_DESCRIPTIONS = 2 (no links allowed)');
665 665
 
666 666
 		$conf->global->MAIN_DISALLOW_URL_INTO_DESCRIPTIONS = 1;
667 667
 
668 668
 		// Test that links on wrapper or local url are allowed
669
-		$_POST["pagecontentwithnowrapperlinks"]='<img src="data:abc"><img src="bbb"><img src="/ccc"><span style="background: url(/ddd)"></span>';
670
-		$result=GETPOST("pagecontentwithnowrapperlinks", 'restricthtml');
669
+		$_POST["pagecontentwithnowrapperlinks"] = '<img src="data:abc"><img src="bbb"><img src="/ccc"><span style="background: url(/ddd)"></span>';
670
+		$result = GETPOST("pagecontentwithnowrapperlinks", 'restricthtml');
671 671
 		print __METHOD__." result=".$result."\n";
672 672
 		$this->assertEquals('<img src="data:abc"><img src="bbb"><img src="/ccc"><span style="background: url(/ddd)"></span>', $result, 'Test on MAIN_DISALLOW_URL_INTO_DESCRIPTIONS = 1 (links on data or relative links ar allowed)');
673 673
 
674 674
 		// Test that links not on wrapper and not data are disallowed
675
-		$_POST["pagecontentwithnowrapperlinks"]='<img src="https://aaa">';
676
-		$result=GETPOST("pagecontentwithnowrapperlinks", 'restricthtml');
675
+		$_POST["pagecontentwithnowrapperlinks"] = '<img src="https://aaa">';
676
+		$result = GETPOST("pagecontentwithnowrapperlinks", 'restricthtml');
677 677
 		print __METHOD__." result=".$result."\n";
678 678
 		$this->assertEquals('ErrorHTMLExternalLinksNotAllowed', $result, 'Test on MAIN_DISALLOW_URL_INTO_DESCRIPTIONS = 1 (no links to http allowed)');
679 679
 
680 680
 		// Test that links not on wrapper and not data are disallowed
681
-		$_POST["pagecontentwithnowrapperlinks"]='<span style="background: url(http://ddd)"></span>';
682
-		$result=GETPOST("pagecontentwithnowrapperlinks", 'restricthtml');
681
+		$_POST["pagecontentwithnowrapperlinks"] = '<span style="background: url(http://ddd)"></span>';
682
+		$result = GETPOST("pagecontentwithnowrapperlinks", 'restricthtml');
683 683
 		print __METHOD__." result=".$result."\n";
684 684
 		$this->assertEquals('ErrorHTMLExternalLinksNotAllowed', $result, 'Test on MAIN_DISALLOW_URL_INTO_DESCRIPTIONS = 1 (no links to http allowed)');
685 685
 
@@ -693,15 +693,15 @@  discard block
 block discarded – undo
693 693
 	 */
694 694
 	public function testEncodeDecode()
695 695
 	{
696
-		$stringtotest="This is a string to test encode/decode. This is a string to test encode/decode. This is a string to test encode/decode.";
696
+		$stringtotest = "This is a string to test encode/decode. This is a string to test encode/decode. This is a string to test encode/decode.";
697 697
 
698
-		$encodedstring=dol_encode($stringtotest);
699
-		$decodedstring=dol_decode($encodedstring);
698
+		$encodedstring = dol_encode($stringtotest);
699
+		$decodedstring = dol_decode($encodedstring);
700 700
 		print __METHOD__." encodedstring=".$encodedstring." ".base64_encode($stringtotest)."\n";
701 701
 		$this->assertEquals($stringtotest, $decodedstring, 'Use dol_encode/decode with no parameter');
702 702
 
703
-		$encodedstring=dol_encode($stringtotest, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
704
-		$decodedstring=dol_decode($encodedstring, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
703
+		$encodedstring = dol_encode($stringtotest, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
704
+		$decodedstring = dol_decode($encodedstring, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
705 705
 		print __METHOD__." encodedstring=".$encodedstring." ".base64_encode($stringtotest)."\n";
706 706
 		$this->assertEquals($stringtotest, $decodedstring, 'Use dol_encode/decode with a key parameter');
707 707
 
@@ -720,7 +720,7 @@  discard block
 block discarded – undo
720 720
 		$this->assertEquals('a &colon; b " c \' d &apos; e é', $decodedstring, 'Function did not sanitize correclty');
721 721
 
722 722
 		$stringtotest = 'a &colon; b &quot; c &#039; d &apos; e &eacute;';
723
-		$decodedstring = dol_html_entity_decode($stringtotest, ENT_QUOTES|ENT_HTML5);
723
+		$decodedstring = dol_html_entity_decode($stringtotest, ENT_QUOTES | ENT_HTML5);
724 724
 		$this->assertEquals('a : b " c \' d \' e é', $decodedstring, 'Function did not sanitize correclty');
725 725
 
726 726
 		return 0;
@@ -784,21 +784,21 @@  discard block
 block discarded – undo
784 784
 	{
785 785
 		global $conf;
786 786
 
787
-		$genpass1=getRandomPassword(true);				// Should be a string return by dol_hash (if no option set, will be md5)
787
+		$genpass1 = getRandomPassword(true); // Should be a string return by dol_hash (if no option set, will be md5)
788 788
 		print __METHOD__." genpass1=".$genpass1."\n";
789 789
 		$this->assertEquals(strlen($genpass1), 32);
790 790
 
791
-		$genpass1=getRandomPassword(true, array('I'));	// Should be a string return by dol_hash (if no option set, will be md5)
791
+		$genpass1 = getRandomPassword(true, array('I')); // Should be a string return by dol_hash (if no option set, will be md5)
792 792
 		print __METHOD__." genpass1=".$genpass1."\n";
793 793
 		$this->assertEquals(strlen($genpass1), 32);
794 794
 
795
-		$conf->global->USER_PASSWORD_GENERATED='None';
796
-		$genpass2=getRandomPassword(false);				// Should return an empty string
795
+		$conf->global->USER_PASSWORD_GENERATED = 'None';
796
+		$genpass2 = getRandomPassword(false); // Should return an empty string
797 797
 		print __METHOD__." genpass2=".$genpass2."\n";
798 798
 		$this->assertEquals($genpass2, '');
799 799
 
800
-		$conf->global->USER_PASSWORD_GENERATED='Standard';
801
-		$genpass3=getRandomPassword(false);				// Should return a password of 12 chars
800
+		$conf->global->USER_PASSWORD_GENERATED = 'Standard';
801
+		$genpass3 = getRandomPassword(false); // Should return a password of 12 chars
802 802
 		print __METHOD__." genpass3=".$genpass3."\n";
803 803
 		$this->assertEquals(strlen($genpass3), 12);
804 804
 
@@ -812,16 +812,16 @@  discard block
 block discarded – undo
812 812
 	 */
813 813
 	public function testRestrictedArea()
814 814
 	{
815
-		global $conf,$user,$langs,$db;
816
-		$conf=$this->savconf;
817
-		$user=$this->savuser;
818
-		$langs=$this->savlangs;
819
-		$db=$this->savdb;
815
+		global $conf, $user, $langs, $db;
816
+		$conf = $this->savconf;
817
+		$user = $this->savuser;
818
+		$langs = $this->savlangs;
819
+		$db = $this->savdb;
820 820
 
821 821
 		//$dummyuser=new User($db);
822 822
 		//$result=restrictedArea($dummyuser,'societe');
823 823
 
824
-		$result=restrictedArea($user, 'societe');
824
+		$result = restrictedArea($user, 'societe');
825 825
 		$this->assertEquals(1, $result);
826 826
 	}
827 827
 
@@ -839,42 +839,42 @@  discard block
 block discarded – undo
839 839
 		$url = 'ftp://mydomain.com';
840 840
 		$tmp = getURLContent($url);
841 841
 		print __METHOD__." url=".$url."\n";
842
-		$this->assertRegExp("/not supported/", $tmp['curl_error_msg'], "Should disable ftp connection");	// Test error if return does not contains 'not supported'
842
+		$this->assertRegExp("/not supported/", $tmp['curl_error_msg'], "Should disable ftp connection"); // Test error if return does not contains 'not supported'
843 843
 
844
-		$url = 'https://www.dolibarr.fr';	// This is a redirect 301 page
845
-		$tmp = getURLContent($url, 'GET', '', 0);	// We do NOT follow
844
+		$url = 'https://www.dolibarr.fr'; // This is a redirect 301 page
845
+		$tmp = getURLContent($url, 'GET', '', 0); // We do NOT follow
846 846
 		print __METHOD__." url=".$url."\n";
847 847
 		$this->assertEquals(301, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Should GET url 301 response');
848 848
 
849
-		$url = 'https://www.dolibarr.fr';	// This is a redirect 301 page
850
-		$tmp = getURLContent($url);		// We DO follow a page with return 300 so result should be 200
849
+		$url = 'https://www.dolibarr.fr'; // This is a redirect 301 page
850
+		$tmp = getURLContent($url); // We DO follow a page with return 300 so result should be 200
851 851
 		print __METHOD__." url=".$url."\n";
852 852
 		$this->assertEquals(200, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Should GET url 301 with a follow -> 200 but we get '.(empty($tmp['http_code']) ? 0 : $tmp['http_code']));
853 853
 
854 854
 		$url = 'http://localhost';
855
-		$tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0);		// Only external URL
855
+		$tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL
856 856
 		print __METHOD__." url=".$url."\n";
857
-		$this->assertEquals(400, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Should GET url to '.$url.' that resolves to a local URL');	// Test we receive an error because localtest.me is not an external URL
857
+		$this->assertEquals(400, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Should GET url to '.$url.' that resolves to a local URL'); // Test we receive an error because localtest.me is not an external URL
858 858
 
859 859
 		$url = 'http://127.0.0.1';
860
-		$tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0);		// Only external URL
860
+		$tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL
861 861
 		print __METHOD__." url=".$url."\n";
862
-		$this->assertEquals(400, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Should GET url to '.$url.' that is a local URL');	// Test we receive an error because 127.0.0.1 is not an external URL
862
+		$this->assertEquals(400, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because 127.0.0.1 is not an external URL
863 863
 
864 864
 		$url = 'http://127.0.2.1';
865
-		$tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0);		// Only external URL
865
+		$tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL
866 866
 		print __METHOD__." url=".$url."\n";
867
-		$this->assertEquals(400, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Should GET url to '.$url.' that is a local URL');	// Test we receive an error because 127.0.2.1 is not an external URL
867
+		$this->assertEquals(400, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because 127.0.2.1 is not an external URL
868 868
 
869 869
 		$url = 'https://169.254.0.1';
870
-		$tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0);		// Only external URL
870
+		$tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL
871 871
 		print __METHOD__." url=".$url."\n";
872
-		$this->assertEquals(400, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Should GET url to '.$url.' that is a local URL');	// Test we receive an error because 169.254.0.1 is not an external URL
872
+		$this->assertEquals(400, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because 169.254.0.1 is not an external URL
873 873
 
874 874
 		$url = 'http://[::1]';
875
-		$tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0);		// Only external URL
875
+		$tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL
876 876
 		print __METHOD__." url=".$url."\n";
877
-		$this->assertEquals(400, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Should GET url to '.$url.' that is a local URL');	// Test we receive an error because [::1] is not an external URL
877
+		$this->assertEquals(400, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because [::1] is not an external URL
878 878
 
879 879
 		/*$url = 'localtest.me';
880 880
 		 $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0);		// Only external URL
@@ -883,9 +883,9 @@  discard block
 block discarded – undo
883 883
 		 */
884 884
 
885 885
 		$url = 'http://192.0.0.192';
886
-		$tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0);		// Only external URL but on an IP in blacklist
886
+		$tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL but on an IP in blacklist
887 887
 		print __METHOD__." url=".$url." tmp['http_code'] = ".(empty($tmp['http_code']) ? 0 : $tmp['http_code'])."\n";
888
-		$this->assertEquals(400, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Access should be refused and was not');	// Test we receive an error because ip is in blacklist
888
+		$this->assertEquals(400, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Access should be refused and was not'); // Test we receive an error because ip is in blacklist
889 889
 
890 890
 		return 0;
891 891
 	}
@@ -897,22 +897,22 @@  discard block
 block discarded – undo
897 897
 	 */
898 898
 	public function testDolSanitizeUrl()
899 899
 	{
900
-		global $conf,$user,$langs,$db;
901
-		$conf=$this->savconf;
902
-		$user=$this->savuser;
903
-		$langs=$this->savlangs;
904
-		$db=$this->savdb;
900
+		global $conf, $user, $langs, $db;
901
+		$conf = $this->savconf;
902
+		$user = $this->savuser;
903
+		$langs = $this->savlangs;
904
+		$db = $this->savdb;
905 905
 
906 906
 		$test = 'javascripT&javascript#x3a alert(1)';
907
-		$result=dol_sanitizeUrl($test);
907
+		$result = dol_sanitizeUrl($test);
908 908
 		$this->assertEquals('x3a alert(1)', $result, 'Test on dol_sanitizeUrl A');
909 909
 
910 910
 		$test = 'javajavascriptscript&cjavascriptolon;alert(1)';
911
-		$result=dol_sanitizeUrl($test);
911
+		$result = dol_sanitizeUrl($test);
912 912
 		$this->assertEquals('alert(1)', $result, 'Test on dol_sanitizeUrl B');
913 913
 
914 914
 		$test = '/javas:cript/google.com';
915
-		$result=dol_sanitizeUrl($test);
915
+		$result = dol_sanitizeUrl($test);
916 916
 		$this->assertEquals('google.com', $result, 'Test on dol_sanitizeUrl C');
917 917
 	}
918 918
 
@@ -923,26 +923,26 @@  discard block
 block discarded – undo
923 923
 	 */
924 924
 	public function testDolSanitizeEmail()
925 925
 	{
926
-		global $conf,$user,$langs,$db;
927
-		$conf=$this->savconf;
928
-		$user=$this->savuser;
929
-		$langs=$this->savlangs;
930
-		$db=$this->savdb;
926
+		global $conf, $user, $langs, $db;
927
+		$conf = $this->savconf;
928
+		$user = $this->savuser;
929
+		$langs = $this->savlangs;
930
+		$db = $this->savdb;
931 931
 
932 932
 		$test = '[email protected] <My name>, [email protected] <Another name>';
933
-		$result=dol_sanitizeEmail($test);
933
+		$result = dol_sanitizeEmail($test);
934 934
 		$this->assertEquals($test, $result, 'Test on dol_sanitizeEmail A');
935 935
 
936 936
 		$test = "[email protected] <My name>,\[email protected] <Another name>";
937
-		$result=dol_sanitizeEmail($test);
937
+		$result = dol_sanitizeEmail($test);
938 938
 		$this->assertEquals('[email protected] <My name>,[email protected] <Another name>', $result, 'Test on dol_sanitizeEmail B');
939 939
 
940 940
 		$test = '[email protected] <My name>,\[email protected] <Another name>';
941
-		$result=dol_sanitizeEmail($test);
941
+		$result = dol_sanitizeEmail($test);
942 942
 		$this->assertEquals('[email protected] <My name>,[email protected] <Another name>', $result, 'Test on dol_sanitizeEmail C');
943 943
 
944 944
 		$test = '[email protected] <My name>, "bcc:bbb"@mycompany.com <Another name>';
945
-		$result=dol_sanitizeEmail($test);
945
+		$result = dol_sanitizeEmail($test);
946 946
 		$this->assertEquals('[email protected] <My name>, [email protected] <Another name>', $result, 'Test on dol_sanitizeEmail D');
947 947
 	}
948 948
 
@@ -953,19 +953,19 @@  discard block
 block discarded – undo
953 953
 	 */
954 954
 	public function testDolSanitizeFileName()
955 955
 	{
956
-		global $conf,$user,$langs,$db;
957
-		$conf=$this->savconf;
958
-		$user=$this->savuser;
959
-		$langs=$this->savlangs;
960
-		$db=$this->savdb;
956
+		global $conf, $user, $langs, $db;
957
+		$conf = $this->savconf;
958
+		$user = $this->savuser;
959
+		$langs = $this->savlangs;
960
+		$db = $this->savdb;
961 961
 
962 962
 		//$dummyuser=new User($db);
963 963
 		//$result=restrictedArea($dummyuser,'societe');
964 964
 
965
-		$result=dol_sanitizeFileName('bad file | evilaction');
965
+		$result = dol_sanitizeFileName('bad file | evilaction');
966 966
 		$this->assertEquals('bad file _ evilaction', $result);
967 967
 
968
-		$result=dol_sanitizeFileName('bad file -evilparam --evilparam ---evilparam ----evilparam');
968
+		$result = dol_sanitizeFileName('bad file -evilparam --evilparam ---evilparam ----evilparam');
969 969
 		$this->assertEquals('bad file _evilparam _evilparam _evilparam _evilparam', $result);
970 970
 	}
971 971
 
@@ -976,17 +976,17 @@  discard block
 block discarded – undo
976 976
 	 */
977 977
 	public function testDolEval()
978 978
 	{
979
-		global $conf,$user,$langs,$db;
980
-		$conf=$this->savconf;
981
-		$user=$this->savuser;
982
-		$langs=$this->savlangs;
983
-		$db=$this->savdb;
979
+		global $conf, $user, $langs, $db;
980
+		$conf = $this->savconf;
981
+		$user = $this->savuser;
982
+		$langs = $this->savlangs;
983
+		$db = $this->savdb;
984 984
 
985
-		$result=dol_eval('1==1', 1, 0);
985
+		$result = dol_eval('1==1', 1, 0);
986 986
 		print "result1 = ".$result."\n";
987 987
 		$this->assertTrue($result);
988 988
 
989
-		$result=dol_eval('1==2', 1, 0);
989
+		$result = dol_eval('1==2', 1, 0);
990 990
 		print "result2 = ".$result."\n";
991 991
 		$this->assertFalse($result);
992 992
 
@@ -994,7 +994,7 @@  discard block
 block discarded – undo
994 994
 		include_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
995 995
 
996 996
 		$s = '(($reloadedobj = new Task($db)) && ($reloadedobj->fetchNoCompute($object->id) > 0) && ($secondloadedobj = new Project($db)) && ($secondloadedobj->fetchNoCompute($reloadedobj->fk_project) > 0)) ? $secondloadedobj->ref : "Parent project not found"';
997
-		$result=dol_eval($s, 1, 1, '2');
997
+		$result = dol_eval($s, 1, 1, '2');
998 998
 		print "result3 = ".$result."\n";
999 999
 		$this->assertEquals('Parent project not found', $result);
1000 1000
 
@@ -1035,48 +1035,48 @@  discard block
 block discarded – undo
1035 1035
 		print "result12 = ".$result."\n";
1036 1036
 		$this->assertStringContainsString('Bad string syntax to evaluate', $result);
1037 1037
 
1038
-		$result=dol_eval("90402.38+267678+0", 1, 1, 1);
1038
+		$result = dol_eval("90402.38+267678+0", 1, 1, 1);
1039 1039
 		print "result13 = ".$result."\n";
1040 1040
 		$this->assertEquals('358080.38', $result);
1041 1041
 
1042
-		global $leftmenu;	// Used into strings to eval
1042
+		global $leftmenu; // Used into strings to eval
1043 1043
 
1044 1044
 		$leftmenu = 'AAA';
1045
-		$result=dol_eval('$conf->currency && preg_match(\'/^(AAA|BBB)/\',$leftmenu)', 1, 1, '1');
1045
+		$result = dol_eval('$conf->currency && preg_match(\'/^(AAA|BBB)/\',$leftmenu)', 1, 1, '1');
1046 1046
 		print "result = ".$result."\n";
1047 1047
 		$this->assertTrue($result);
1048 1048
 
1049 1049
 		// Same with a value that does not match
1050 1050
 		$leftmenu = 'XXX';
1051
-		$result=dol_eval('$conf->currency && preg_match(\'/^(AAA|BBB)/\',$leftmenu)', 1, 1, '1');
1051
+		$result = dol_eval('$conf->currency && preg_match(\'/^(AAA|BBB)/\',$leftmenu)', 1, 1, '1');
1052 1052
 		print "result14 = ".$result."\n";
1053 1053
 		$this->assertFalse($result);
1054 1054
 
1055 1055
 		$leftmenu = 'AAA';
1056
-		$result=dol_eval('$conf->currency && isStringVarMatching(\'leftmenu\', \'(AAA|BBB)\')', 1, 1, '1');
1056
+		$result = dol_eval('$conf->currency && isStringVarMatching(\'leftmenu\', \'(AAA|BBB)\')', 1, 1, '1');
1057 1057
 		print "result15 = ".$result."\n";
1058 1058
 		$this->assertTrue($result);
1059 1059
 
1060 1060
 		$leftmenu = 'XXX';
1061
-		$result=dol_eval('$conf->currency && isStringVarMatching(\'leftmenu\', \'(AAA|BBB)\')', 1, 1, '1');
1061
+		$result = dol_eval('$conf->currency && isStringVarMatching(\'leftmenu\', \'(AAA|BBB)\')', 1, 1, '1');
1062 1062
 		print "result16 = ".$result."\n";
1063 1063
 		$this->assertFalse($result);
1064 1064
 
1065 1065
 		$string = '(isModEnabled("agenda") || isModEnabled("resource")) && getDolGlobalInt("MAIN_FEATURES_LEVEL") >= 0 && preg_match(\'/^(admintools|all|XXX)/\', $leftmenu)';
1066
-		$result=dol_eval($string, 1, 1, '1');
1066
+		$result = dol_eval($string, 1, 1, '1');
1067 1067
 		print "result17 = ".$result."\n";
1068 1068
 		$this->assertTrue($result);
1069 1069
 
1070
-		$result=dol_eval('1 && getDolGlobalInt("doesnotexist1") && $conf->global->MAIN_FEATURES_LEVEL', 1, 0);	// Should return false and not a 'Bad string syntax to evaluate ...'
1070
+		$result = dol_eval('1 && getDolGlobalInt("doesnotexist1") && $conf->global->MAIN_FEATURES_LEVEL', 1, 0); // Should return false and not a 'Bad string syntax to evaluate ...'
1071 1071
 		print "result18 = ".$result."\n";
1072 1072
 		$this->assertFalse($result);
1073 1073
 
1074
-		$a='ab';
1074
+		$a = 'ab';
1075 1075
 		$result = (string) dol_eval("(\$a.'s')", 1, 0);
1076 1076
 		print "result19 = ".$result."\n";
1077 1077
 		$this->assertStringContainsString('Bad string syntax to evaluate', $result);
1078 1078
 
1079
-		$leftmenu='abs';
1079
+		$leftmenu = 'abs';
1080 1080
 		$result = (string) dol_eval('$leftmenu(-5)', 1, 0);
1081 1081
 		print "result20 = ".$result."\n";
1082 1082
 		$this->assertStringContainsString('Bad string syntax to evaluate', $result);
@@ -1094,12 +1094,12 @@  discard block
 block discarded – undo
1094 1094
 		global $conf;
1095 1095
 
1096 1096
 		// Set options for cleaning data
1097
-		$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 0;	// disabled, does not work on HTML5 and some libxml versions
1097
+		$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 0; // disabled, does not work on HTML5 and some libxml versions
1098 1098
 		// Enabled option MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY if possible
1099 1099
 		if (extension_loaded('tidy') && class_exists("tidy")) {
1100 1100
 			$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = 1;
1101 1101
 		}
1102
-		$conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = 0;	// disabled, does not work on HTML5 and some libxml versions
1102
+		$conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = 0; // disabled, does not work on HTML5 and some libxml versions
1103 1103
 
1104 1104
 
1105 1105
 
@@ -1112,7 +1112,7 @@  discard block
 block discarded – undo
1112 1112
 		//$result = dol_escape_htmltag(dol_htmlwithnojs(dol_string_onlythesehtmltags(dol_htmlentitiesbr($stringtotest), 1, 1, 1, 0)), 1, 1, 'common', 0, 1);
1113 1113
 		$result = dolPrintHTML($stringtotest);
1114 1114
 		print __METHOD__." result=".$result."\n";
1115
-		$this->assertEquals($stringfixed, $result, 'Error');    // Expected '' because should failed because login 'auto' does not exists
1115
+		$this->assertEquals($stringfixed, $result, 'Error'); // Expected '' because should failed because login 'auto' does not exists
1116 1116
 
1117 1117
 
1118 1118
 		// For a string that is already HTML (contains HTML tags) with special tags but badly formatted
@@ -1161,24 +1161,24 @@  discard block
 block discarded – undo
1161 1161
 	 */
1162 1162
 	public function testCheckLoginPassEntity()
1163 1163
 	{
1164
-		$login=checkLoginPassEntity('loginbidon', 'passwordbidon', 1, array('dolibarr'));
1164
+		$login = checkLoginPassEntity('loginbidon', 'passwordbidon', 1, array('dolibarr'));
1165 1165
 		print __METHOD__." login=".$login."\n";
1166 1166
 		$this->assertEquals($login, '');
1167 1167
 
1168
-		$login=checkLoginPassEntity('admin', 'passwordbidon', 1, array('dolibarr'));
1168
+		$login = checkLoginPassEntity('admin', 'passwordbidon', 1, array('dolibarr'));
1169 1169
 		print __METHOD__." login=".$login."\n";
1170 1170
 		$this->assertEquals($login, '');
1171 1171
 
1172
-		$login=checkLoginPassEntity('admin', 'admin', 1, array('dolibarr'));            // Should works because admin/admin exists
1172
+		$login = checkLoginPassEntity('admin', 'admin', 1, array('dolibarr')); // Should works because admin/admin exists
1173 1173
 		print __METHOD__." login=".$login."\n";
1174 1174
 		$this->assertEquals($login, 'admin', 'The test to check if pass of user "admin" is "admin" has failed');
1175 1175
 
1176
-		$login=checkLoginPassEntity('admin', 'admin', 1, array('http','dolibarr'));    // Should work because of second authentication method
1176
+		$login = checkLoginPassEntity('admin', 'admin', 1, array('http', 'dolibarr')); // Should work because of second authentication method
1177 1177
 		print __METHOD__." login=".$login."\n";
1178 1178
 		$this->assertEquals($login, 'admin');
1179 1179
 
1180
-		$login=checkLoginPassEntity('admin', 'admin', 1, array('forceuser'));
1180
+		$login = checkLoginPassEntity('admin', 'admin', 1, array('forceuser'));
1181 1181
 		print __METHOD__." login=".$login."\n";
1182
-		$this->assertEquals('', $login, 'Error');    // Expected '' because should failed because login 'auto' does not exists
1182
+		$this->assertEquals('', $login, 'Error'); // Expected '' because should failed because login 'auto' does not exists
1183 1183
 	}
1184 1184
 }
Please login to merge, or discard this patch.
test/phpunit/StripeTest.php 1 patch
Spacing   +11 added lines, -11 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';
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	$user->fetch(1);
38 38
 	$user->getrights();
39 39
 }
40
-$conf->global->MAIN_DISABLE_ALL_MAILS=1;
40
+$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
41 41
 
42 42
 
43 43
 /**
@@ -56,14 +56,14 @@  discard block
 block discarded – undo
56 56
 	 */
57 57
 	public static function setUpBeforeClass(): void
58 58
 	{
59
-		global $conf,$user,$langs,$db;
59
+		global $conf, $user, $langs, $db;
60 60
 
61 61
 		if (!isModEnabled('stripe')) {
62 62
 			print __METHOD__." Module Stripe must be enabled.\n";
63 63
 			die(1);
64 64
 		}
65 65
 
66
-		$db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
66
+		$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
67 67
 
68 68
 		print __METHOD__."\n";
69 69
 	}
@@ -76,16 +76,16 @@  discard block
 block discarded – undo
76 76
 	 */
77 77
 	public function testStripeOk()
78 78
 	{
79
-		global $conf,$user,$langs,$db;
80
-		$conf=$this->savconf;
81
-		$user=$this->savuser;
82
-		$langs=$this->savlangs;
83
-		$db=$this->savdb;
79
+		global $conf, $user, $langs, $db;
80
+		$conf = $this->savconf;
81
+		$user = $this->savuser;
82
+		$langs = $this->savlangs;
83
+		$db = $this->savdb;
84 84
 
85
-		$urltotest=getOnlinePaymentUrl(0, 'free');
85
+		$urltotest = getOnlinePaymentUrl(0, 'free');
86 86
 		print "urltotest=".$urltotest."\n";
87 87
 
88
-		$result=getURLContent($urltotest, 'GET', '', 1, array(), array('http', 'https'), 2);
88
+		$result = getURLContent($urltotest, 'GET', '', 1, array(), array('http', 'https'), 2);
89 89
 
90 90
 		print __METHOD__." result=".$result['http_code']."\n";
91 91
 		$this->assertEquals(200, $result['http_code']);
Please login to merge, or discard this patch.
test/phpunit/UserGroupTest.php 1 patch
Spacing   +49 added lines, -49 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
 /**
@@ -55,15 +55,15 @@  discard block
 block discarded – undo
55 55
 	 */
56 56
 	public function testUserGroupCreate()
57 57
 	{
58
-		global $conf,$user,$langs,$db;
59
-		$conf=$this->savconf;
60
-		$user=$this->savuser;
61
-		$langs=$this->savlangs;
62
-		$db=$this->savdb;
58
+		global $conf, $user, $langs, $db;
59
+		$conf = $this->savconf;
60
+		$user = $this->savuser;
61
+		$langs = $this->savlangs;
62
+		$db = $this->savdb;
63 63
 
64
-		$localobject=new UserGroup($db);
64
+		$localobject = new UserGroup($db);
65 65
 		$localobject->initAsSpecimen();
66
-		$result=$localobject->create($user);
66
+		$result = $localobject->create($user);
67 67
 
68 68
 		$this->assertLessThan($result, 0);
69 69
 		print __METHOD__." result=".$result."\n";
@@ -80,14 +80,14 @@  discard block
 block discarded – undo
80 80
 	 */
81 81
 	public function testUserGroupFetch($id)
82 82
 	{
83
-		global $conf,$user,$langs,$db;
84
-		$conf=$this->savconf;
85
-		$user=$this->savuser;
86
-		$langs=$this->savlangs;
87
-		$db=$this->savdb;
83
+		global $conf, $user, $langs, $db;
84
+		$conf = $this->savconf;
85
+		$user = $this->savuser;
86
+		$langs = $this->savlangs;
87
+		$db = $this->savdb;
88 88
 
89
-		$localobject=new UserGroup($db);
90
-		$result=$localobject->fetch($id);
89
+		$localobject = new UserGroup($db);
90
+		$result = $localobject->fetch($id);
91 91
 
92 92
 		$this->assertLessThan($result, 0);
93 93
 		print __METHOD__." id=".$id." result=".$result."\n";
@@ -104,14 +104,14 @@  discard block
 block discarded – undo
104 104
 	 */
105 105
 	public function testUserGroupUpdate($localobject)
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
-		$localobject->note='New note after update';
114
-		$result=$localobject->update($user);
113
+		$localobject->note = 'New note after update';
114
+		$result = $localobject->update($user);
115 115
 
116 116
 		print __METHOD__." id=".$localobject->id." result=".$result."\n";
117 117
 		$this->assertLessThan($result, 0);
@@ -128,13 +128,13 @@  discard block
 block discarded – undo
128 128
 	 */
129 129
 	public function testUserGroupAddRight($localobject)
130 130
 	{
131
-		global $conf,$user,$langs,$db;
132
-		$conf=$this->savconf;
133
-		$user=$this->savuser;
134
-		$langs=$this->savlangs;
135
-		$db=$this->savdb;
131
+		global $conf, $user, $langs, $db;
132
+		$conf = $this->savconf;
133
+		$user = $this->savuser;
134
+		$langs = $this->savlangs;
135
+		$db = $this->savdb;
136 136
 
137
-		$result=$localobject->addrights(1, 'bookmarks');
137
+		$result = $localobject->addrights(1, 'bookmarks');
138 138
 		print __METHOD__." id=".$localobject->id." result=".$result."\n";
139 139
 
140 140
 		$this->assertLessThan($result, 0);
@@ -151,13 +151,13 @@  discard block
 block discarded – undo
151 151
 	 */
152 152
 	public function testUserGroupDelRight($localobject)
153 153
 	{
154
-		global $conf,$user,$langs,$db;
155
-		$conf=$this->savconf;
156
-		$user=$this->savuser;
157
-		$langs=$this->savlangs;
158
-		$db=$this->savdb;
154
+		global $conf, $user, $langs, $db;
155
+		$conf = $this->savconf;
156
+		$user = $this->savuser;
157
+		$langs = $this->savlangs;
158
+		$db = $this->savdb;
159 159
 
160
-		$result=$localobject->delrights(1, 'bookmarks');
160
+		$result = $localobject->delrights(1, 'bookmarks');
161 161
 		print __METHOD__." id=".$localobject->id." result=".$result."\n";
162 162
 
163 163
 		$this->assertLessThan($result, 0);
@@ -174,11 +174,11 @@  discard block
 block discarded – undo
174 174
 	 */
175 175
 	public function testUserGroupOther($localobject)
176 176
 	{
177
-		global $conf,$user,$langs,$db;
178
-		$conf=$this->savconf;
179
-		$user=$this->savuser;
180
-		$langs=$this->savlangs;
181
-		$db=$this->savdb;
177
+		global $conf, $user, $langs, $db;
178
+		$conf = $this->savconf;
179
+		$user = $this->savuser;
180
+		$langs = $this->savlangs;
181
+		$db = $this->savdb;
182 182
 
183 183
 		$result = $localobject->generateDocument('templatenamethadoesnotexist', $langs);
184 184
 		print __METHOD__." result=".$result."\n";
@@ -197,15 +197,15 @@  discard block
 block discarded – undo
197 197
 	 */
198 198
 	public function testUserGroupDelete($id)
199 199
 	{
200
-		global $conf,$user,$langs,$db;
201
-		$conf=$this->savconf;
202
-		$user=$this->savuser;
203
-		$langs=$this->savlangs;
204
-		$db=$this->savdb;
205
-
206
-		$localobject=new UserGroup($db);
207
-		$result=$localobject->fetch($id);
208
-		$result=$localobject->delete($user);
200
+		global $conf, $user, $langs, $db;
201
+		$conf = $this->savconf;
202
+		$user = $this->savuser;
203
+		$langs = $this->savlangs;
204
+		$db = $this->savdb;
205
+
206
+		$localobject = new UserGroup($db);
207
+		$result = $localobject->fetch($id);
208
+		$result = $localobject->delete($user);
209 209
 
210 210
 		print __METHOD__." id=".$id." result=".$result."\n";
211 211
 		$this->assertLessThan($result, 0);
Please login to merge, or discard this patch.
test/phpunit/BuildDocTest.php 1 patch
Spacing   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
  *      			See also PdfDocTest to test methods
27 27
  */
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';
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	$user->fetch(1);
67 67
 	$user->getrights();
68 68
 }
69
-$conf->global->MAIN_DISABLE_ALL_MAILS=1;
69
+$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
70 70
 
71 71
 
72 72
 /**
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	 */
86 86
 	public static function setUpBeforeClass(): void
87 87
 	{
88
-		global $conf,$user,$langs,$db;
88
+		global $conf, $user, $langs, $db;
89 89
 
90 90
 		if (!isModEnabled('facture')) {
91 91
 			print __METHOD__." invoice module not enabled\n";
@@ -131,20 +131,20 @@  discard block
 block discarded – undo
131 131
 	 */
132 132
 	public function testFactureBuild()
133 133
 	{
134
-		global $conf,$user,$langs,$db;
135
-		$conf=$this->savconf;
136
-		$user=$this->savuser;
137
-		$langs=$this->savlangs;
138
-		$db=$this->savdb;
134
+		global $conf, $user, $langs, $db;
135
+		$conf = $this->savconf;
136
+		$user = $this->savuser;
137
+		$langs = $this->savlangs;
138
+		$db = $this->savdb;
139 139
 
140
-		$conf->facture->dir_output.='/temp';
140
+		$conf->facture->dir_output .= '/temp';
141 141
 
142
-		$localobjectcom=new Commande($db);
142
+		$localobjectcom = new Commande($db);
143 143
 		$localobjectcom->initAsSpecimen();
144 144
 
145
-		$localobject=new Facture($db);
145
+		$localobject = new Facture($db);
146 146
 		$localobject->createFromOrder($localobjectcom, $user);
147
-		$localobject->date_lim_reglement = dol_now() + 3600 * 24 *30;
147
+		$localobject->date_lim_reglement = dol_now() + 3600 * 24 * 30;
148 148
 		$localobject->status = Facture::STATUS_DRAFT;
149 149
 
150 150
 		// To be sure we are not using the Swiss QR Code addition
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 		$conf->global->MAIN_DISABLE_TCPDI = 1;
156 156
 
157 157
 		// Crabe (english)
158
-		$localobject->model_pdf='crabe';
158
+		$localobject->model_pdf = 'crabe';
159 159
 		$result = $localobject->generateDocument($localobject->model_pdf, $langs);
160 160
 		$this->assertLessThan($result, 0);
161 161
 		print __METHOD__." result=".$result." for generation from crabe\n";
@@ -164,55 +164,55 @@  discard block
 block discarded – undo
164 164
 		$conf->global->MAIN_DISABLE_TCPDI = 0;
165 165
 
166 166
 		// Crabe (english)
167
-		$localobject->model_pdf='crabe';
167
+		$localobject->model_pdf = 'crabe';
168 168
 		$result = $localobject->generateDocument($localobject->model_pdf, $langs);
169 169
 		$this->assertLessThan($result, 0);
170 170
 		print __METHOD__." result=".$result." for generation from crabe with MAIN_DISABLE_TCPDI and a watermark\n";
171 171
 
172 172
 		// Crabe (japanese)
173
-		$newlangs1=new Translate("", $conf);
173
+		$newlangs1 = new Translate("", $conf);
174 174
 		$newlangs1->setDefaultLang('ja_JP');
175
-		$localobject->model_pdf='crabe';
175
+		$localobject->model_pdf = 'crabe';
176 176
 		$result = $localobject->generateDocument($localobject->model_pdf, $newlangs1);
177 177
 		$this->assertLessThan($result, 0);
178 178
 		print __METHOD__." result=".$result."\n";
179 179
 
180 180
 		// Crabe (saudiarabia)
181
-		$newlangs2a=new Translate("", $conf);
181
+		$newlangs2a = new Translate("", $conf);
182 182
 		$newlangs2a->setDefaultLang('sa_SA');
183
-		$localobject->model_pdf='crabe';
183
+		$localobject->model_pdf = 'crabe';
184 184
 		$result = $localobject->generateDocument($localobject->model_pdf, $newlangs2a);
185 185
 		$this->assertLessThan($result, 0);
186 186
 		print __METHOD__." result=".$result."\n";
187 187
 
188 188
 		// Crabe (english_saudiarabia)
189
-		$newlangs2b=new Translate("", $conf);
189
+		$newlangs2b = new Translate("", $conf);
190 190
 		$newlangs2b->setDefaultLang('en_SA');
191
-		$localobject->model_pdf='crabe';
191
+		$localobject->model_pdf = 'crabe';
192 192
 		$result = $localobject->generateDocument($localobject->model_pdf, $newlangs2b);
193 193
 		$this->assertLessThan($result, 0);
194 194
 		print __METHOD__." result=".$result."\n";
195 195
 
196 196
 		// Crabe (greek)
197
-		$newlangs3=new Translate("", $conf);
197
+		$newlangs3 = new Translate("", $conf);
198 198
 		$newlangs3->setDefaultLang('el_GR');
199
-		$localobject->model_pdf='crabe';
199
+		$localobject->model_pdf = 'crabe';
200 200
 		$result = $localobject->generateDocument($localobject->model_pdf, $newlangs3);
201 201
 		$this->assertLessThan($result, 0);
202 202
 		print __METHOD__." result=".$result."\n";
203 203
 
204 204
 		// Crabe (chinese)
205
-		$newlangs4=new Translate("", $conf);
205
+		$newlangs4 = new Translate("", $conf);
206 206
 		$newlangs4->setDefaultLang('zh_CN');
207
-		$localobject->model_pdf='crabe';
207
+		$localobject->model_pdf = 'crabe';
208 208
 		$result = $localobject->generateDocument($localobject->model_pdf, $newlangs4);
209 209
 		$this->assertLessThan($result, 0);
210 210
 		print __METHOD__." result=".$result."\n";
211 211
 
212 212
 		// Crabe (russian)
213
-		$newlangs5=new Translate("", $conf);
213
+		$newlangs5 = new Translate("", $conf);
214 214
 		$newlangs5->setDefaultLang('ru_RU');
215
-		$localobject->model_pdf='crabe';
215
+		$localobject->model_pdf = 'crabe';
216 216
 		$result = $localobject->generateDocument($localobject->model_pdf, $newlangs5);
217 217
 		$this->assertLessThan($result, 0);
218 218
 		print __METHOD__." result=".$result."\n";
@@ -227,18 +227,18 @@  discard block
 block discarded – undo
227 227
 	*/
228 228
 	public function testFactureFournisseurBuild()
229 229
 	{
230
-		global $conf,$user,$langs,$db;
231
-		$conf=$this->savconf;
232
-		$user=$this->savuser;
233
-		$langs=$this->savlangs;
234
-		$db=$this->savdb;
235
-
236
-		$conf->fournisseur->facture->dir_output.='/temp';
237
-		$localobject=new FactureFournisseur($db);
230
+		global $conf, $user, $langs, $db;
231
+		$conf = $this->savconf;
232
+		$user = $this->savuser;
233
+		$langs = $this->savlangs;
234
+		$db = $this->savdb;
235
+
236
+		$conf->fournisseur->facture->dir_output .= '/temp';
237
+		$localobject = new FactureFournisseur($db);
238 238
 		$localobject->initAsSpecimen();
239 239
 
240 240
 		// Canelle
241
-		$localobject->model_pdf='canelle';
241
+		$localobject->model_pdf = 'canelle';
242 242
 		$result = $localobject->generateDocument($localobject->model_pdf, $langs);
243 243
 
244 244
 		$this->assertLessThan($result, 0);
@@ -254,18 +254,18 @@  discard block
 block discarded – undo
254 254
 	 */
255 255
 	public function testCommandeBuild()
256 256
 	{
257
-		global $conf,$user,$langs,$db;
258
-		$conf=$this->savconf;
259
-		$user=$this->savuser;
260
-		$langs=$this->savlangs;
261
-		$db=$this->savdb;
262
-
263
-		$conf->commande->dir_output.='/temp';
264
-		$localobject=new Commande($db);
257
+		global $conf, $user, $langs, $db;
258
+		$conf = $this->savconf;
259
+		$user = $this->savuser;
260
+		$langs = $this->savlangs;
261
+		$db = $this->savdb;
262
+
263
+		$conf->commande->dir_output .= '/temp';
264
+		$localobject = new Commande($db);
265 265
 		$localobject->initAsSpecimen();
266 266
 
267 267
 		// Einstein
268
-		$localobject->model_pdf='einstein';
268
+		$localobject->model_pdf = 'einstein';
269 269
 		$result = $localobject->generateDocument($localobject->model_pdf, $langs);
270 270
 
271 271
 		$this->assertLessThan($result, 0);
@@ -282,19 +282,19 @@  discard block
 block discarded – undo
282 282
 	 */
283 283
 	public function testCommandeFournisseurBuild()
284 284
 	{
285
-		global $conf,$user,$langs,$db;
286
-		$conf=$this->savconf;
287
-		$user=$this->savuser;
288
-		$langs=$this->savlangs;
289
-		$db=$this->savdb;
290
-
291
-		$conf->fournisseur->commande->dir_output.='/temp';
292
-		$localobject=new CommandeFournisseur($db);
285
+		global $conf, $user, $langs, $db;
286
+		$conf = $this->savconf;
287
+		$user = $this->savuser;
288
+		$langs = $this->savlangs;
289
+		$db = $this->savdb;
290
+
291
+		$conf->fournisseur->commande->dir_output .= '/temp';
292
+		$localobject = new CommandeFournisseur($db);
293 293
 		$localobject->initAsSpecimen();
294 294
 
295 295
 		// Muscadet
296
-		$localobject->model_pdf='muscadet';
297
-		$result= $localobject->generateDocument($localobject->model_pdf, $langs);
296
+		$localobject->model_pdf = 'muscadet';
297
+		$result = $localobject->generateDocument($localobject->model_pdf, $langs);
298 298
 
299 299
 		$this->assertLessThan($result, 0);
300 300
 		print __METHOD__." result=".$result."\n";
@@ -309,18 +309,18 @@  discard block
 block discarded – undo
309 309
 	 */
310 310
 	public function testPropalBuild()
311 311
 	{
312
-		global $conf,$user,$langs,$db;
313
-		$conf=$this->savconf;
314
-		$user=$this->savuser;
315
-		$langs=$this->savlangs;
316
-		$db=$this->savdb;
317
-
318
-		$conf->propal->dir_output.='/temp';
319
-		$localobject=new Propal($db);
312
+		global $conf, $user, $langs, $db;
313
+		$conf = $this->savconf;
314
+		$user = $this->savuser;
315
+		$langs = $this->savlangs;
316
+		$db = $this->savdb;
317
+
318
+		$conf->propal->dir_output .= '/temp';
319
+		$localobject = new Propal($db);
320 320
 		$localobject->initAsSpecimen();
321 321
 
322 322
 		// Azur
323
-		$localobject->model_pdf='azur';
323
+		$localobject->model_pdf = 'azur';
324 324
 		$result = $localobject->generateDocument($localobject->model_pdf, $langs);
325 325
 
326 326
 		$this->assertLessThan($result, 0);
@@ -336,17 +336,17 @@  discard block
 block discarded – undo
336 336
 	 */
337 337
 	public function testProjectBuild()
338 338
 	{
339
-		global $conf,$user,$langs,$db;
340
-		$conf=$this->savconf;
341
-		$user=$this->savuser;
342
-		$langs=$this->savlangs;
343
-		$db=$this->savdb;
344
-		$conf->project->dir_output.='/temp';
345
-		$localobject=new Project($db);
339
+		global $conf, $user, $langs, $db;
340
+		$conf = $this->savconf;
341
+		$user = $this->savuser;
342
+		$langs = $this->savlangs;
343
+		$db = $this->savdb;
344
+		$conf->project->dir_output .= '/temp';
345
+		$localobject = new Project($db);
346 346
 		$localobject->initAsSpecimen();
347 347
 
348 348
 		// Baleine
349
-		$localobject->model_pdf='baleine';
349
+		$localobject->model_pdf = 'baleine';
350 350
 		$result = $localobject->generateDocument($localobject->model_pdf, $langs);
351 351
 
352 352
 		$this->assertLessThan($result, 0);
@@ -362,19 +362,19 @@  discard block
 block discarded – undo
362 362
 	 */
363 363
 	public function testFichinterBuild()
364 364
 	{
365
-		global $conf,$user,$langs,$db;
366
-		$conf=$this->savconf;
367
-		$user=$this->savuser;
368
-		$langs=$this->savlangs;
369
-		$db=$this->savdb;
370
-
371
-		$conf->ficheinter->dir_output.='/temp';
372
-		$localobject=new Fichinter($db);
365
+		global $conf, $user, $langs, $db;
366
+		$conf = $this->savconf;
367
+		$user = $this->savuser;
368
+		$langs = $this->savlangs;
369
+		$db = $this->savdb;
370
+
371
+		$conf->ficheinter->dir_output .= '/temp';
372
+		$localobject = new Fichinter($db);
373 373
 		$localobject->initAsSpecimen();
374 374
 
375 375
 		// Soleil
376
-		$localobject->model_pdf='soleil';
377
-		$result=fichinter_create($db, $localobject, $localobject->model_pdf, $langs);
376
+		$localobject->model_pdf = 'soleil';
377
+		$result = fichinter_create($db, $localobject, $localobject->model_pdf, $langs);
378 378
 
379 379
 		$this->assertLessThan($result, 0);
380 380
 		print __METHOD__." result=".$result."\n";
@@ -389,26 +389,26 @@  discard block
 block discarded – undo
389 389
 	 */
390 390
 	public function testExpeditionBuild()
391 391
 	{
392
-		global $conf,$user,$langs,$db;
393
-		$conf=$this->savconf;
394
-		$user=$this->savuser;
395
-		$langs=$this->savlangs;
396
-		$db=$this->savdb;
397
-
398
-		$conf->expedition->dir_output.='/temp';
399
-		$localobject=new Expedition($db);
392
+		global $conf, $user, $langs, $db;
393
+		$conf = $this->savconf;
394
+		$user = $this->savuser;
395
+		$langs = $this->savlangs;
396
+		$db = $this->savdb;
397
+
398
+		$conf->expedition->dir_output .= '/temp';
399
+		$localobject = new Expedition($db);
400 400
 		$localobject->initAsSpecimen();
401 401
 
402 402
 		// Merou
403
-		$localobject->model_pdf='merou';
404
-		$result= $localobject->generateDocument($localobject->model_pdf, $langs);
403
+		$localobject->model_pdf = 'merou';
404
+		$result = $localobject->generateDocument($localobject->model_pdf, $langs);
405 405
 
406 406
 		$this->assertLessThan($result, 0);
407 407
 		print __METHOD__." result=".$result."\n";
408 408
 
409 409
 		// Rouget
410
-		$localobject->model_pdf='rouget';
411
-		$result= $localobject->generateDocument($localobject->model_pdf, $langs);
410
+		$localobject->model_pdf = 'rouget';
411
+		$result = $localobject->generateDocument($localobject->model_pdf, $langs);
412 412
 
413 413
 		$this->assertLessThan($result, 0);
414 414
 		print __METHOD__." result=".$result."\n";
Please login to merge, or discard this patch.
test/phpunit/SocieteTest.php 1 patch
Spacing   +124 added lines, -124 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';
@@ -38,7 +38,7 @@  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 43
 
44 44
 /**
@@ -57,10 +57,10 @@  discard block
 block discarded – undo
57 57
 	 */
58 58
 	public static function setUpBeforeClass(): void
59 59
 	{
60
-		global $conf,$user,$langs,$db;
60
+		global $conf, $user, $langs, $db;
61 61
 
62 62
 		if ($conf->global->SOCIETE_CODECLIENT_ADDON != 'mod_codeclient_monkey') {
63
-			print "\n".__METHOD__." third party ref checker must be setup to 'mod_codeclient_monkey' not to '" . getDolGlobalString('SOCIETE_CODECLIENT_ADDON')."'.\n";
63
+			print "\n".__METHOD__." third party ref checker must be setup to 'mod_codeclient_monkey' not to '".getDolGlobalString('SOCIETE_CODECLIENT_ADDON')."'.\n";
64 64
 			die(1);
65 65
 		}
66 66
 
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 			die(1);
75 75
 		}
76 76
 
77
-		$db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
77
+		$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
78 78
 
79 79
 		print __METHOD__."\n";
80 80
 	}
@@ -86,15 +86,15 @@  discard block
 block discarded – undo
86 86
 	 */
87 87
 	public function testSocieteCreate()
88 88
 	{
89
-		global $conf,$user,$langs,$db;
90
-		$conf=$this->savconf;
91
-		$user=$this->savuser;
92
-		$langs=$this->savlangs;
93
-		$db=$this->savdb;
89
+		global $conf, $user, $langs, $db;
90
+		$conf = $this->savconf;
91
+		$user = $this->savuser;
92
+		$langs = $this->savlangs;
93
+		$db = $this->savdb;
94 94
 
95
-		$localobject=new Societe($db);
95
+		$localobject = new Societe($db);
96 96
 		$localobject->initAsSpecimen();
97
-		$result=$localobject->create($user);
97
+		$result = $localobject->create($user);
98 98
 
99 99
 		print __METHOD__." result=".$result."\n";
100 100
 		$this->assertLessThanOrEqual($result, 0);
@@ -113,18 +113,18 @@  discard block
 block discarded – undo
113 113
 	 */
114 114
 	public function testSocieteFetch($id)
115 115
 	{
116
-		global $conf,$user,$langs,$db;
117
-		$conf=$this->savconf;
118
-		$user=$this->savuser;
119
-		$langs=$this->savlangs;
120
-		$db=$this->savdb;
121
-
122
-		$localobject=new Societe($db);
123
-		$result=$localobject->fetch($id);
116
+		global $conf, $user, $langs, $db;
117
+		$conf = $this->savconf;
118
+		$user = $this->savuser;
119
+		$langs = $this->savlangs;
120
+		$db = $this->savdb;
121
+
122
+		$localobject = new Societe($db);
123
+		$result = $localobject->fetch($id);
124 124
 		print __METHOD__." id=".$id." result=".$result."\n";
125 125
 		$this->assertLessThan($result, 0);
126 126
 
127
-		$result=$localobject->verify();
127
+		$result = $localobject->verify();
128 128
 		print __METHOD__." id=".$id." result=".$result."\n";
129 129
 		$this->assertEquals($result, 0);
130 130
 
@@ -142,43 +142,43 @@  discard block
 block discarded – undo
142 142
 	 */
143 143
 	public function testSocieteUpdate($localobject)
144 144
 	{
145
-		global $conf,$user,$langs,$db;
146
-		$conf=$this->savconf;
147
-		$user=$this->savuser;
148
-		$langs=$this->savlangs;
149
-		$db=$this->savdb;
150
-
151
-		$localobject->note_private='New private note after update';
152
-		$localobject->note_public='New public note after update';
153
-		$localobject->name='New name';
154
-		$localobject->address='New address';
155
-		$localobject->zip='New zip';
156
-		$localobject->town='New town';
157
-		$localobject->country_id=2;
158
-		$localobject->status=0;
159
-		$localobject->phone='New tel';
160
-		$localobject->fax='New fax';
161
-		$localobject->email='[email protected]';
162
-		$localobject->url='New url';
163
-		$localobject->idprof1='new idprof1';
164
-		$localobject->idprof2='new idprof2';
165
-		$localobject->idprof3='new idprof3';
166
-		$localobject->idprof4='new idprof4';
167
-
168
-		$result=$localobject->update($localobject->id, $user);
145
+		global $conf, $user, $langs, $db;
146
+		$conf = $this->savconf;
147
+		$user = $this->savuser;
148
+		$langs = $this->savlangs;
149
+		$db = $this->savdb;
150
+
151
+		$localobject->note_private = 'New private note after update';
152
+		$localobject->note_public = 'New public note after update';
153
+		$localobject->name = 'New name';
154
+		$localobject->address = 'New address';
155
+		$localobject->zip = 'New zip';
156
+		$localobject->town = 'New town';
157
+		$localobject->country_id = 2;
158
+		$localobject->status = 0;
159
+		$localobject->phone = 'New tel';
160
+		$localobject->fax = 'New fax';
161
+		$localobject->email = '[email protected]';
162
+		$localobject->url = 'New url';
163
+		$localobject->idprof1 = 'new idprof1';
164
+		$localobject->idprof2 = 'new idprof2';
165
+		$localobject->idprof3 = 'new idprof3';
166
+		$localobject->idprof4 = 'new idprof4';
167
+
168
+		$result = $localobject->update($localobject->id, $user);
169 169
 		print __METHOD__." id=".$localobject->id." result=".$result."\n";
170 170
 		$this->assertLessThan($result, 0);
171 171
 
172
-		$result=$localobject->update_note($localobject->note_private, '_private');
172
+		$result = $localobject->update_note($localobject->note_private, '_private');
173 173
 		print __METHOD__." id=".$localobject->id." result=".$result."\n";
174 174
 		$this->assertLessThan($result, 0, 'Holiday::update_note (private) error');
175 175
 
176
-		$result=$localobject->update_note($localobject->note_public, '_public');
176
+		$result = $localobject->update_note($localobject->note_public, '_public');
177 177
 		print __METHOD__." id=".$localobject->id." result=".$result."\n";
178 178
 		$this->assertLessThan($result, 0, 'Holiday::update_note (public) error');
179 179
 
180
-		$newobject=new Societe($db);
181
-		$result=$newobject->fetch($localobject->id);
180
+		$newobject = new Societe($db);
181
+		$result = $newobject->fetch($localobject->id);
182 182
 		print __METHOD__." id=".$localobject->id." result=".$result."\n";
183 183
 		$this->assertLessThan($result, 0);
184 184
 
@@ -215,42 +215,42 @@  discard block
 block discarded – undo
215 215
 	public function testIdProfCheck($localobject)
216 216
 	{
217 217
 		// OK FR
218
-		$localobject->country_code='FR';
219
-		$localobject->idprof1=493861496;
220
-		$localobject->idprof2=49386149600021;
221
-		$result=$localobject->id_prof_check(1, $localobject);    // Must be > 0
218
+		$localobject->country_code = 'FR';
219
+		$localobject->idprof1 = 493861496;
220
+		$localobject->idprof2 = 49386149600021;
221
+		$result = $localobject->id_prof_check(1, $localobject); // Must be > 0
222 222
 		print __METHOD__." OK FR idprof1 result=".$result."\n";
223 223
 		$this->assertGreaterThanOrEqual(1, $result);
224
-		$result=$localobject->id_prof_check(2, $localobject);    // Must be > 0
224
+		$result = $localobject->id_prof_check(2, $localobject); // Must be > 0
225 225
 		print __METHOD__." OK FR idprof2 result=".$result."\n";
226 226
 		$this->assertGreaterThanOrEqual(1, $result);
227 227
 
228 228
 		// KO FR
229
-		$localobject->country_code='FR';
230
-		$localobject->idprof1='id1ko';
231
-		$localobject->idprof2='id2ko';
232
-		$result=$localobject->id_prof_check(1, $localobject);    // Must be <= 0
229
+		$localobject->country_code = 'FR';
230
+		$localobject->idprof1 = 'id1ko';
231
+		$localobject->idprof2 = 'id2ko';
232
+		$result = $localobject->id_prof_check(1, $localobject); // Must be <= 0
233 233
 		print __METHOD__." KO FR idprof1 result=".$result."\n";
234 234
 		$this->assertLessThan(1, $result);
235
-		$result=$localobject->id_prof_check(2, $localobject);    // Must be <= 0
235
+		$result = $localobject->id_prof_check(2, $localobject); // Must be <= 0
236 236
 		print __METHOD__." KO FR idprof2 result=".$result."\n";
237 237
 		$this->assertLessThan(1, $result);
238 238
 
239 239
 		// KO ES
240
-		$localobject->country_code='ES';
241
-		$localobject->idprof1='id1ko';
242
-		$result=$localobject->id_prof_check(1, $localobject);    // Must be <= 0
240
+		$localobject->country_code = 'ES';
241
+		$localobject->idprof1 = 'id1ko';
242
+		$result = $localobject->id_prof_check(1, $localobject); // Must be <= 0
243 243
 		print __METHOD__." KO ES idprof1 result=".$result."\n";
244 244
 		$this->assertLessThan(1, $result);
245 245
 
246 246
 		// OK AR
247
-		$localobject->country_code='AR';
248
-		$localobject->idprof1='id1ko';
249
-		$localobject->idprof2='id2ko';
250
-		$result=$localobject->id_prof_check(1, $localobject);    // Must be > 0
247
+		$localobject->country_code = 'AR';
248
+		$localobject->idprof1 = 'id1ko';
249
+		$localobject->idprof2 = 'id2ko';
250
+		$result = $localobject->id_prof_check(1, $localobject); // Must be > 0
251 251
 		print __METHOD__." OK AR idprof1 result=".$result."\n";
252 252
 		$this->assertGreaterThanOrEqual(0, $result);
253
-		$result=$localobject->id_prof_check(2, $localobject);    // Must be > 0
253
+		$result = $localobject->id_prof_check(2, $localobject); // Must be > 0
254 254
 		print __METHOD__." OK AR idprof2 result=".$result."\n";
255 255
 		$this->assertGreaterThanOrEqual(1, $result);
256 256
 
@@ -269,37 +269,37 @@  discard block
 block discarded – undo
269 269
 	 */
270 270
 	public function testSocieteOther($localobject)
271 271
 	{
272
-		global $conf,$user,$langs,$db;
273
-		$conf=$this->savconf;
274
-		$user=$this->savuser;
275
-		$langs=$this->savlangs;
276
-		$db=$this->savdb;
272
+		global $conf, $user, $langs, $db;
273
+		$conf = $this->savconf;
274
+		$user = $this->savuser;
275
+		$langs = $this->savlangs;
276
+		$db = $this->savdb;
277 277
 
278
-		$result=$localobject->setAsCustomer();
278
+		$result = $localobject->setAsCustomer();
279 279
 		print __METHOD__." id=".$localobject->id." result=".$result."\n";
280 280
 		$this->assertLessThan($result, 0);
281 281
 
282
-		$result=$localobject->setPriceLevel(1, $user);
282
+		$result = $localobject->setPriceLevel(1, $user);
283 283
 		print __METHOD__." id=".$localobject->id." result=".$result."\n";
284 284
 		$this->assertLessThan($result, 0);
285 285
 
286
-		$result=$localobject->set_remise_client(10, 'Gift', $user);
286
+		$result = $localobject->set_remise_client(10, 'Gift', $user);
287 287
 		print __METHOD__." id=".$localobject->id." result=".$result."\n";
288 288
 		$this->assertLessThan($result, 0);
289 289
 
290
-		$result=$localobject->getNomUrl(1);
290
+		$result = $localobject->getNomUrl(1);
291 291
 		print __METHOD__." id=".$localobject->id." result=".$result."\n";
292 292
 		$this->assertNotEquals($result, '');
293 293
 
294 294
 		$localobject->country_code = 'FR';
295 295
 
296
-		$result=$localobject->isInEEC();
296
+		$result = $localobject->isInEEC();
297 297
 		print __METHOD__." id=".$localobject->id." country_code=".$localobject->country_code." result=".$result."\n";
298 298
 		$this->assertTrue($result);
299 299
 
300 300
 		$localobject->country_code = 'US';
301 301
 
302
-		$result=$localobject->isInEEC();
302
+		$result = $localobject->isInEEC();
303 303
 		print __METHOD__." id=".$localobject->id." country_code=".$localobject->country_code." result=".$result."\n";
304 304
 		$this->assertFalse($result);
305 305
 
@@ -329,16 +329,16 @@  discard block
 block discarded – undo
329 329
 	 */
330 330
 	public function testGetOutstandingBills($id)
331 331
 	{
332
-		global $conf,$user,$langs,$db;
333
-		$conf=$this->savconf;
334
-		$user=$this->savuser;
335
-		$langs=$this->savlangs;
336
-		$db=$this->savdb;
332
+		global $conf, $user, $langs, $db;
333
+		$conf = $this->savconf;
334
+		$user = $this->savuser;
335
+		$langs = $this->savlangs;
336
+		$db = $this->savdb;
337 337
 
338
-		$localobject=new Societe($db);
338
+		$localobject = new Societe($db);
339 339
 		$localobject->fetch($id);
340 340
 
341
-		$result=$localobject->getOutstandingBills();
341
+		$result = $localobject->getOutstandingBills();
342 342
 
343 343
 		print __METHOD__." id=".$id." result=".var_export($result, true)."\n";
344 344
 		$this->assertTrue(array_key_exists('opened', $result), 'Result of getOutstandingBills failed');
@@ -358,16 +358,16 @@  discard block
 block discarded – undo
358 358
 	 */
359 359
 	public function testSocieteDelete($id)
360 360
 	{
361
-		global $conf,$user,$langs,$db;
362
-		$conf=$this->savconf;
363
-		$user=$this->savuser;
364
-		$langs=$this->savlangs;
365
-		$db=$this->savdb;
361
+		global $conf, $user, $langs, $db;
362
+		$conf = $this->savconf;
363
+		$user = $this->savuser;
364
+		$langs = $this->savlangs;
365
+		$db = $this->savdb;
366 366
 
367
-		$localobject=new Societe($db);
368
-		$result=$localobject->fetch($id);
367
+		$localobject = new Societe($db);
368
+		$result = $localobject->fetch($id);
369 369
 
370
-		$result=$localobject->delete($id, $user);
370
+		$result = $localobject->delete($id, $user);
371 371
 		print __METHOD__." id=".$id." result=".$result."\n";
372 372
 		$this->assertLessThan($result, 0);
373 373
 
@@ -382,57 +382,57 @@  discard block
 block discarded – undo
382 382
 	 */
383 383
 	public function testSocieteGetFullAddress()
384 384
 	{
385
-		global $conf,$user,$langs,$db;
386
-		$conf=$this->savconf;
387
-		$user=$this->savuser;
388
-		$langs=$this->savlangs;
389
-		$db=$this->savdb;
385
+		global $conf, $user, $langs, $db;
386
+		$conf = $this->savconf;
387
+		$user = $this->savuser;
388
+		$langs = $this->savlangs;
389
+		$db = $this->savdb;
390 390
 
391
-		$localobjectadd=new Societe($db);
391
+		$localobjectadd = new Societe($db);
392 392
 		$localobjectadd->initAsSpecimen();
393 393
 
394 394
 		// France
395 395
 		unset($localobjectadd->country_code);
396
-		$localobjectadd->country_id=1;
397
-		$localobjectadd->name='New name';
398
-		$localobjectadd->address='New address';
399
-		$localobjectadd->zip='New zip';
400
-		$localobjectadd->town='New town';
401
-		$result=$localobjectadd->getFullAddress(1);
396
+		$localobjectadd->country_id = 1;
397
+		$localobjectadd->name = 'New name';
398
+		$localobjectadd->address = 'New address';
399
+		$localobjectadd->zip = 'New zip';
400
+		$localobjectadd->town = 'New town';
401
+		$result = $localobjectadd->getFullAddress(1);
402 402
 		print __METHOD__." id=".$localobjectadd->id." result=".$result."\n";
403 403
 		$this->assertStringContainsString("New address\nNew zip New town\nFrance", $result);
404 404
 
405 405
 		// Belgium
406 406
 		unset($localobjectadd->country_code);
407
-		$localobjectadd->country_id=2;
408
-		$localobjectadd->name='New name';
409
-		$localobjectadd->address='New address';
410
-		$localobjectadd->zip='New zip';
411
-		$localobjectadd->town='New town';
412
-		$result=$localobjectadd->getFullAddress(1);
407
+		$localobjectadd->country_id = 2;
408
+		$localobjectadd->name = 'New name';
409
+		$localobjectadd->address = 'New address';
410
+		$localobjectadd->zip = 'New zip';
411
+		$localobjectadd->town = 'New town';
412
+		$result = $localobjectadd->getFullAddress(1);
413 413
 		print __METHOD__." id=".$localobjectadd->id." result=".$result."\n";
414 414
 		$this->assertStringContainsString("New address\nNew zip New town\nBelgium", $result);
415 415
 
416 416
 		// Switzerland
417 417
 		unset($localobjectadd->country_code);
418
-		$localobjectadd->country_id=6;
419
-		$localobjectadd->name='New name';
420
-		$localobjectadd->address='New address';
421
-		$localobjectadd->zip='New zip';
422
-		$localobjectadd->town='New town';
423
-		$result=$localobjectadd->getFullAddress(1);
418
+		$localobjectadd->country_id = 6;
419
+		$localobjectadd->name = 'New name';
420
+		$localobjectadd->address = 'New address';
421
+		$localobjectadd->zip = 'New zip';
422
+		$localobjectadd->town = 'New town';
423
+		$result = $localobjectadd->getFullAddress(1);
424 424
 		print __METHOD__." id=".$localobjectadd->id." result=".$result."\n";
425 425
 		$this->assertStringContainsString("New address\nNew zip New town\nSwitzerland", $result);
426 426
 
427 427
 		// USA
428 428
 		unset($localobjectadd->country_code);
429
-		$localobjectadd->country_id=11;
430
-		$localobjectadd->name='New name';
431
-		$localobjectadd->address='New address';
432
-		$localobjectadd->zip='New zip';
433
-		$localobjectadd->town='New town';
434
-		$localobjectadd->state='New state';
435
-		$result=$localobjectadd->getFullAddress(1);
429
+		$localobjectadd->country_id = 11;
430
+		$localobjectadd->name = 'New name';
431
+		$localobjectadd->address = 'New address';
432
+		$localobjectadd->zip = 'New zip';
433
+		$localobjectadd->town = 'New town';
434
+		$localobjectadd->state = 'New state';
435
+		$result = $localobjectadd->getFullAddress(1);
436 436
 		print __METHOD__." id=".$localobjectadd->id." result=".$result."\n";
437 437
 		$this->assertStringContainsString("New address\nNew town, New state, New zip\nUnited States", $result);
438 438
 
Please login to merge, or discard this patch.
test/phpunit/MarginsLibTest.php 1 patch
Spacing   +10 added lines, -10 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
 /**
@@ -55,13 +55,13 @@  discard block
 block discarded – undo
55 55
 	 */
56 56
 	public function testGetMarginInfos()
57 57
 	{
58
-		global $conf,$user,$langs,$db;
59
-		$conf=$this->savconf;
60
-		$user=$this->savuser;
61
-		$langs=$this->savlangs;
62
-		$db=$this->savdb;
58
+		global $conf, $user, $langs, $db;
59
+		$conf = $this->savconf;
60
+		$user = $this->savuser;
61
+		$langs = $this->savlangs;
62
+		$db = $this->savdb;
63 63
 
64
-		$result=getMarginInfos(10, 0, 19.6, 0, 0, 0, 8);
64
+		$result = getMarginInfos(10, 0, 19.6, 0, 0, 0, 8);
65 65
 		//var_dump($result);
66 66
 		print __METHOD__." result[0]=".$result[0]."\n";
67 67
 		$this->assertEquals(8, $result[0]);
@@ -70,13 +70,13 @@  discard block
 block discarded – undo
70 70
 		print __METHOD__." result[2]=".$result[2]."\n";
71 71
 		$this->assertEquals(20, $result[2]);
72 72
 
73
-		$result=getMarginInfos(10, 10, 19.6, 0, 0, 0, 8);
73
+		$result = getMarginInfos(10, 10, 19.6, 0, 0, 0, 8);
74 74
 		print __METHOD__." result[0]=".$result[0]."\n";
75 75
 		$this->assertEquals(8, $result[0]);
76 76
 		print __METHOD__." result[1]=".$result[1]."\n";
77 77
 		$this->assertEquals(12.5, $result[1]);
78 78
 		print __METHOD__." result[2]=".$result[2]."\n";
79
-		$this->assertEquals(1/9*100, $result[2]);
79
+		$this->assertEquals(1 / 9 * 100, $result[2]);
80 80
 
81 81
 		return 0;
82 82
 	}
Please login to merge, or discard this patch.
test/phpunit/WebservicesUserTest.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -24,12 +24,12 @@  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
-require_once NUSOAP_PATH.'/nusoap.php';        // Include SOAP
32
+require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP
33 33
 require_once dirname(__FILE__).'/CommonClassTest.class.php';
34 34
 
35 35
 if (empty($user->id)) {
@@ -37,9 +37,9 @@  discard block
 block discarded – undo
37 37
 	$user->fetch(1);
38 38
 	$user->getrights();
39 39
 }
40
-$conf->global->MAIN_DISABLE_ALL_MAILS=1;
40
+$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
41 41
 
42
-$conf->global->MAIN_UMASK='0666';
42
+$conf->global->MAIN_UMASK = '0666';
43 43
 
44 44
 
45 45
 /**
@@ -58,28 +58,28 @@  discard block
 block discarded – undo
58 58
 	 */
59 59
 	public function testWSUserGetUser()
60 60
 	{
61
-		global $conf,$user,$langs,$db;
62
-		$conf=$this->savconf;
63
-		$user=$this->savuser;
64
-		$langs=$this->savlangs;
65
-		$db=$this->savdb;
61
+		global $conf, $user, $langs, $db;
62
+		$conf = $this->savconf;
63
+		$user = $this->savuser;
64
+		$langs = $this->savlangs;
65
+		$db = $this->savdb;
66 66
 
67 67
 		$WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_user.php';
68 68
 		$WS_METHOD  = 'getUser';
69
-		$ns='http://www.dolibarr.org/ns/';
69
+		$ns = 'http://www.dolibarr.org/ns/';
70 70
 
71 71
 		// Set the WebService URL
72 72
 		print __METHOD__." Create nusoap_client for URL=".$WS_DOL_URL."\n";
73 73
 		$soapclient = new nusoap_client($WS_DOL_URL);
74 74
 		if ($soapclient) {
75
-			$soapclient->soap_defencoding='UTF-8';
75
+			$soapclient->soap_defencoding = 'UTF-8';
76 76
 			$soapclient->decodeUTF8(false);
77 77
 		}
78 78
 
79 79
 		//$soapclient->setDebugLevel(5);
80 80
 
81 81
 		// Call the WebService method and store its result in $result.
82
-		$authentication=array(
82
+		$authentication = array(
83 83
 			'dolibarrkey'=>getDolGlobalString('WEBSERVICES_KEY'),
84 84
 			'sourceapplication'=>'DEMO',
85 85
 			'login'=>'admin',
@@ -88,20 +88,20 @@  discard block
 block discarded – undo
88 88
 		);
89 89
 
90 90
 		// Test URL
91
-		$result='';
92
-		$parameters = array('authentication'=>$authentication,'id'=>0,'ref'=>'admin');
91
+		$result = '';
92
+		$parameters = array('authentication'=>$authentication, 'id'=>0, 'ref'=>'admin');
93 93
 		print __METHOD__." Call method ".$WS_METHOD."\n";
94 94
 		try {
95 95
 			$result = $soapclient->call($WS_METHOD, $parameters, $ns, '');
96 96
 		} catch (SoapFault $exception) {
97 97
 			echo $exception;
98
-			$result=0;
98
+			$result = 0;
99 99
 		}
100 100
 		if (!empty($result['faultstring'])) {
101 101
 			print $result['faultstring']."\n";
102
-			$result=0;
102
+			$result = 0;
103 103
 		}
104
-		if (! $result) {
104
+		if (!$result) {
105 105
 			//var_dump($soapclient);
106 106
 			print 'Error: '.$soapclient->error_str;
107 107
 			print "\n<br>\n";
@@ -115,16 +115,16 @@  discard block
 block discarded – undo
115 115
 		$this->assertEquals('OK', empty($result['result']['result_code']) ? '' : $result['result']['result_code'], 'Test on ref admin');
116 116
 
117 117
 		// Test URL
118
-		$result='';
119
-		$parameters = array('authentication'=>$authentication,'id'=>0,'ref'=>'refthatdoesnotexists');
118
+		$result = '';
119
+		$parameters = array('authentication'=>$authentication, 'id'=>0, 'ref'=>'refthatdoesnotexists');
120 120
 		print __METHOD__."Call method ".$WS_METHOD."\n";
121 121
 		try {
122 122
 			$result = $soapclient->call($WS_METHOD, $parameters, $ns, '');
123 123
 		} catch (SoapFault $exception) {
124 124
 			echo $exception;
125
-			$result=0;
125
+			$result = 0;
126 126
 		}
127
-		if (! $result || !empty($result['faultstring'])) {
127
+		if (!$result || !empty($result['faultstring'])) {
128 128
 			//var_dump($soapclient);
129 129
 			print $soapclient->error_str;
130 130
 			print "\n<br>\n";
Please login to merge, or discard this patch.
test/phpunit/ReceptionTest.php 1 patch
Spacing   +7 added lines, -7 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
 
28 28
 require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
29 29
 require_once dirname(__FILE__).'/../../htdocs/societe/class/societe.class.php';
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	$user->fetch(1);
38 38
 	$user->getrights();
39 39
 }
40
-$conf->global->MAIN_DISABLE_ALL_MAILS=1;
40
+$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
41 41
 
42 42
 /**
43 43
  * Class for PHPUnit tests
@@ -55,11 +55,11 @@  discard block
 block discarded – undo
55 55
 	 */
56 56
 	public function testReceptionCreate()
57 57
 	{
58
-		global $conf,$user,$langs,$db;
59
-		$conf=$this->savconf;
60
-		$user=$this->savuser;
61
-		$langs=$this->savlangs;
62
-		$db=$this->savdb;
58
+		global $conf, $user, $langs, $db;
59
+		$conf = $this->savconf;
60
+		$user = $this->savuser;
61
+		$langs = $this->savlangs;
62
+		$db = $this->savdb;
63 63
 
64 64
 		$soc = new Societe($db);
65 65
 		$soc->name = "ReceptionTest Unittest";
Please login to merge, or discard this patch.
test/phpunit/AdminLibTest.php 1 patch
Spacing   +13 added lines, -13 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
 /**
@@ -58,22 +58,22 @@  discard block
 block discarded – undo
58 58
 	 */
59 59
 	public function testVersionCompare()
60 60
 	{
61
-		global $conf,$user,$langs,$db;
62
-		$conf=$this->savconf;
63
-		$user=$this->savuser;
64
-		$langs=$this->savlangs;
65
-		$db=$this->savdb;
61
+		global $conf, $user, $langs, $db;
62
+		$conf = $this->savconf;
63
+		$user = $this->savuser;
64
+		$langs = $this->savlangs;
65
+		$db = $this->savdb;
66 66
 
67
-		$result=versioncompare(array(3,1,-4), array(3,1,1));
67
+		$result = versioncompare(array(3, 1, -4), array(3, 1, 1));
68 68
 		print __METHOD__." result=".$result."\n";
69 69
 		$this->assertEquals(-3, $result);
70
-		$result=versioncompare(array(3,1,0), array(3,1,1));
70
+		$result = versioncompare(array(3, 1, 0), array(3, 1, 1));
71 71
 		print __METHOD__." result=".$result."\n";
72 72
 		$this->assertEquals(-3, $result);
73
-		$result=versioncompare(array(3,1,0), array(3,2,0));
73
+		$result = versioncompare(array(3, 1, 0), array(3, 2, 0));
74 74
 		print __METHOD__." result=".$result."\n";
75 75
 		$this->assertEquals(-2, $result);
76
-		$result=versioncompare(array(3,1,0), array(3,1,0));
76
+		$result = versioncompare(array(3, 1, 0), array(3, 1, 0));
77 77
 		print __METHOD__." result=".$result."\n";
78 78
 		$this->assertEquals(0, $result);
79 79
 
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 
92 92
 		require_once dirname(__FILE__).'/../../htdocs/core/modules/modExpenseReport.class.php';
93 93
 		print "Enable module modExpenseReport";
94
-		$moduledescriptor=new modExpenseReport($db);
94
+		$moduledescriptor = new modExpenseReport($db);
95 95
 
96 96
 		$result = $moduledescriptor->remove();
97 97
 
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 
103 103
 		require_once dirname(__FILE__).'/../../htdocs/core/modules/modApi.class.php';
104 104
 		print "Enable module modAPI";
105
-		$moduledescriptor=new modApi($db);
105
+		$moduledescriptor = new modApi($db);
106 106
 
107 107
 		$result = $moduledescriptor->remove();
108 108
 
Please login to merge, or discard this patch.