Completed
Branch develop (3d98b7)
by
unknown
17:59
created
test/phpunit/RestAPIUserTest.php 1 patch
Spacing   +26 added lines, -26 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,8 +37,8 @@  discard block
 block discarded – undo
37 37
 	$user->fetch(1);
38 38
 	$user->getrights();
39 39
 }
40
-$conf->global->MAIN_DISABLE_ALL_MAILS=1;
41
-$conf->global->MAIN_UMASK='0666';
40
+$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
41
+$conf->global->MAIN_UMASK = '0666';
42 42
 
43 43
 
44 44
 /**
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	 */
61 61
 	public static function setUpBeforeClass(): void
62 62
 	{
63
-		global $conf,$user,$langs,$db;
63
+		global $conf, $user, $langs, $db;
64 64
 		$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
65 65
 
66 66
 		if (!isModEnabled('api')) {
@@ -78,24 +78,24 @@  discard block
 block discarded – undo
78 78
 	*/
79 79
 	protected function setUp(): void
80 80
 	{
81
-		global $conf,$user,$langs,$db;
82
-		$conf=$this->savconf;
83
-		$user=$this->savuser;
84
-		$langs=$this->savlangs;
85
-		$db=$this->savdb;
81
+		global $conf, $user, $langs, $db;
82
+		$conf = $this->savconf;
83
+		$user = $this->savuser;
84
+		$langs = $this->savlangs;
85
+		$db = $this->savdb;
86 86
 
87 87
 		$this->api_url = DOL_MAIN_URL_ROOT.'/api/index.php';
88 88
 
89
-		$login='admin';
90
-		$password='admin';
91
-		$url=$this->api_url.'/login?login='.$login.'&password='.$password;
89
+		$login = 'admin';
90
+		$password = 'admin';
91
+		$url = $this->api_url.'/login?login='.$login.'&password='.$password;
92 92
 		// Call the API login method to save api_key for this test class.
93 93
 		// At first call, if token is not defined a random value is generated and returned.
94
-		$result=getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2);
94
+		$result = getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2);
95 95
 		print __METHOD__." result = ".var_export($result, true)."\n";
96 96
 		print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n";
97 97
 		$this->assertEquals($result['curl_error_no'], '');
98
-		$object = json_decode($result['content'], true);	// If success content is just an id, if not an array
98
+		$object = json_decode($result['content'], true); // If success content is just an id, if not an array
99 99
 
100 100
 		$this->assertNotNull($object, "Parsing of json result must not be null");
101 101
 		$this->assertNotEquals(500, (empty($object['error']['code']) ? 0 : $object['error']['code']), 'Error'.(empty($object['error']['message']) ? '' : ' '.$object['error']['message']));
@@ -114,28 +114,28 @@  discard block
 block discarded – undo
114 114
 	 */
115 115
 	public function testRestGetUser()
116 116
 	{
117
-		global $conf,$user,$langs,$db;
117
+		global $conf, $user, $langs, $db;
118 118
 
119 119
 		$url = $this->api_url.'/users/123456789?api_key='.$this->api_key;
120 120
 		//$addheaders=array('Content-Type: application/json');
121 121
 
122 122
 		print __METHOD__." Request GET url=".$url."\n";
123
-		$result=getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2);
123
+		$result = getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2);
124 124
 		//print __METHOD__." result for get on unexisting user: ".var_export($result, true)."\n";
125 125
 		print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n";
126 126
 		$this->assertEquals($result['curl_error_no'], '');
127
-		$object=json_decode($result['content'], true);
127
+		$object = json_decode($result['content'], true);
128 128
 		$this->assertNotNull($object, "Parsing of json result must not be null");
129 129
 		$this->assertEquals(404, (empty($object['error']['code']) ? 0 : $object['error']['code']), 'Error code is not 404');
130 130
 
131 131
 		$url = $this->api_url.'/users/1?api_key='.$this->api_key;
132 132
 
133 133
 		print __METHOD__." Request GET url=".$url."\n";
134
-		$result=getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2);
134
+		$result = getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2);
135 135
 		print __METHOD__." result for get on an existing user: ".var_export($result, true)."\n";
136 136
 		print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n";
137 137
 		$this->assertEquals($result['curl_error_no'], '');
138
-		$object=json_decode($result['content'], true);
138
+		$object = json_decode($result['content'], true);
139 139
 		$this->assertNotNull($object, "Parsing of json result must not be null");
140 140
 		$this->assertEquals(1, $object['statut']);
141 141
 
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 	{
155 155
 		// attempt to create without mandatory fields :
156 156
 		$url = $this->api_url.'/users?api_key='.$this->api_key;
157
-		$addheaders=array('Content-Type: application/json');
157
+		$addheaders = array('Content-Type: application/json');
158 158
 
159 159
 		$bodyobj = array(
160 160
 			"lastname"=>"testRestUser",
@@ -164,11 +164,11 @@  discard block
 block discarded – undo
164 164
 		$body = json_encode($bodyobj);
165 165
 
166 166
 		print __METHOD__." Request POST url=".$url."\n";
167
-		$result=getURLContent($url, 'POST', $body, 1, $addheaders, array('http', 'https'), 2);
167
+		$result = getURLContent($url, 'POST', $body, 1, $addheaders, array('http', 'https'), 2);
168 168
 		//print __METHOD__." Result for creating incomplete user".var_export($result, true)."\n";
169 169
 		print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n";
170 170
 		$this->assertEquals($result['curl_error_no'], '');
171
-		$object=json_decode($result['content'], true);
171
+		$object = json_decode($result['content'], true);
172 172
 		$this->assertNotNull($object, "Parsing of json result must no be null");
173 173
 		$this->assertEquals(500, (empty($object['error']['code']) ? 0 : $object['error']['code']), 'Error'.(empty($object['error']['message']) ? '' : ' '.$object['error']['message']));
174 174
 
@@ -182,11 +182,11 @@  discard block
 block discarded – undo
182 182
 		);
183 183
 		$body = json_encode($bodyobj);
184 184
 		print __METHOD__." Request POST url=".$url."\n";
185
-		$result=getURLContent($url, 'POST', $body, 1, $addheaders, array('http', 'https'), 2);
185
+		$result = getURLContent($url, 'POST', $body, 1, $addheaders, array('http', 'https'), 2);
186 186
 		print __METHOD__." result code for creating non existing user = ".var_export($result, true)."\n";
187 187
 		print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n";
188 188
 		$this->assertEquals($result['curl_error_no'], '');
189
-		$object = json_decode($result['content'], true);	// If success content is just an id, if not an array
189
+		$object = json_decode($result['content'], true); // If success content is just an id, if not an array
190 190
 
191 191
 		$this->assertNotNull($object, "Parsing of json result must no be null");
192 192
 		$this->assertNotEquals(500, ((is_scalar($object) || empty($object['error']) || empty($object['error']['code'])) ? 0 : $object['error']['code']), 'Error'.(empty($object['error']['message']) ? '' : ' '.$object['error']['message']));
@@ -194,11 +194,11 @@  discard block
 block discarded – undo
194 194
 
195 195
 		// attempt to create duplicated user
196 196
 		print __METHOD__." Request POST url=".$url."\n";
197
-		$result=getURLContent($url, 'POST', $body, 1, $addheaders, array('http', 'https'), 2);
197
+		$result = getURLContent($url, 'POST', $body, 1, $addheaders, array('http', 'https'), 2);
198 198
 		//print __METHOD__." Result for creating duplicate user".var_export($result, true)."\n";
199 199
 		print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n";
200 200
 		$this->assertEquals($result['curl_error_no'], '');
201
-		$object=json_decode($result['content'], true);
201
+		$object = json_decode($result['content'], true);
202 202
 		$this->assertNotNull($object, "Parsing of json result must no be null");
203 203
 		$this->assertEquals(500, (empty($object['error']['code']) ? 0 : $object['error']['code']), 'Error'.(empty($object['error']['message']) ? '' : ' '.$object['error']['message']));
204 204
 	}
Please login to merge, or discard this patch.
test/phpunit/JsonLibTest.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -24,41 +24,41 @@  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__).'/CommonClassTest.class.php';
32 32
 
33
-if (! defined('NOREQUIREUSER')) {
33
+if (!defined('NOREQUIREUSER')) {
34 34
 	define('NOREQUIREUSER', '1');
35 35
 }
36
-if (! defined('NOREQUIREDB')) {
36
+if (!defined('NOREQUIREDB')) {
37 37
 	define('NOREQUIREDB', '1');
38 38
 }
39
-if (! defined('NOREQUIRESOC')) {
39
+if (!defined('NOREQUIRESOC')) {
40 40
 	define('NOREQUIRESOC', '1');
41 41
 }
42
-if (! defined('NOREQUIRETRAN')) {
42
+if (!defined('NOREQUIRETRAN')) {
43 43
 	define('NOREQUIRETRAN', '1');
44 44
 }
45
-if (! defined('NOCSRFCHECK')) {
45
+if (!defined('NOCSRFCHECK')) {
46 46
 	define('NOCSRFCHECK', '1');
47 47
 }
48
-if (! defined('NOTOKENRENEWAL')) {
48
+if (!defined('NOTOKENRENEWAL')) {
49 49
 	define('NOTOKENRENEWAL', '1');
50 50
 }
51
-if (! defined('NOREQUIREMENU')) {
51
+if (!defined('NOREQUIREMENU')) {
52 52
 	define('NOREQUIREMENU', '1'); // If there is no menu to show
53 53
 }
54
-if (! defined('NOREQUIREHTML')) {
54
+if (!defined('NOREQUIREHTML')) {
55 55
 	define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
56 56
 }
57
-if (! defined('NOREQUIREAJAX')) {
57
+if (!defined('NOREQUIREAJAX')) {
58 58
 	define('NOREQUIREAJAX', '1');
59 59
 }
60
-if (! defined("NOLOGIN")) {
61
-	define("NOLOGIN", '1');       // If this page is public (can be called outside logged session)
60
+if (!defined("NOLOGIN")) {
61
+	define("NOLOGIN", '1'); // If this page is public (can be called outside logged session)
62 62
 }
63 63
 
64 64
 
@@ -79,56 +79,56 @@  discard block
 block discarded – undo
79 79
 	public function testJsonEncode()
80 80
 	{
81 81
 		//$this->sharedFixture
82
-		global $conf,$user,$langs,$db;
83
-		$this->savconf=$conf;
84
-		$this->savuser=$user;
85
-		$this->savlangs=$langs;
86
-		$this->savdb=$db;
82
+		global $conf, $user, $langs, $db;
83
+		$this->savconf = $conf;
84
+		$this->savuser = $user;
85
+		$this->savlangs = $langs;
86
+		$this->savdb = $db;
87 87
 
88 88
 		// Try to decode a string encoded with serialize
89 89
 		$encoded = 'a:1:{s:7:"options";a:3:{s:3:"app";s:11:"Application";s:6:"system";s:6:"System";s:6:"option";s:6:"Option";}}';
90
-		$decoded=json_decode($encoded, true);
90
+		$decoded = json_decode($encoded, true);
91 91
 		$this->assertEquals(null, $decoded, 'test to json_decode() a string that was encoded with serialize()');
92 92
 
93 93
 		$encoded = 'rubishstring!aa{bcd';
94
-		$decoded=json_decode($encoded, true);
94
+		$decoded = json_decode($encoded, true);
95 95
 		$this->assertEquals(null, $decoded, 'test to json_decode() a string that was encoded with serialize()');
96 96
 
97 97
 		// Do a test with an array starting with 0
98
-		$arraytotest=array(0=>array('key'=>1,'value'=>'PRODREF','label'=>'Product ref with é and special chars \\ \' "'));
99
-		$arrayencodedexpected='[{"key":1,"value":"PRODREF","label":"Product ref with \u00e9 and special chars \\\\ \' \""}]';
98
+		$arraytotest = array(0=>array('key'=>1, 'value'=>'PRODREF', 'label'=>'Product ref with é and special chars \\ \' "'));
99
+		$arrayencodedexpected = '[{"key":1,"value":"PRODREF","label":"Product ref with \u00e9 and special chars \\\\ \' \""}]';
100 100
 
101
-		$encoded=json_encode($arraytotest);
101
+		$encoded = json_encode($arraytotest);
102 102
 		$this->assertEquals($arrayencodedexpected, $encoded);
103
-		$decoded=json_decode($encoded, true);
103
+		$decoded = json_decode($encoded, true);
104 104
 		$this->assertEquals($arraytotest, $decoded, 'test for json_xxx');
105 105
 
106
-		$encoded=dol_json_encode($arraytotest);
106
+		$encoded = dol_json_encode($arraytotest);
107 107
 		$this->assertEquals($arrayencodedexpected, $encoded);
108
-		$decoded=dol_json_decode($encoded, true);
108
+		$decoded = dol_json_decode($encoded, true);
109 109
 		$this->assertEquals($arraytotest, $decoded, 'test for dol_json_xxx');
110 110
 
111 111
 		// Same test but array start with 2 instead of 0
112
-		$arraytotest=array(2=>array('key'=>1,'value'=>'PRODREF','label'=>'Product ref with é and special chars \\ \' "'));
113
-		$arrayencodedexpected='{"2":{"key":1,"value":"PRODREF","label":"Product ref with \u00e9 and special chars \\\\ \' \""}}';
112
+		$arraytotest = array(2=>array('key'=>1, 'value'=>'PRODREF', 'label'=>'Product ref with é and special chars \\ \' "'));
113
+		$arrayencodedexpected = '{"2":{"key":1,"value":"PRODREF","label":"Product ref with \u00e9 and special chars \\\\ \' \""}}';
114 114
 
115
-		$encoded=json_encode($arraytotest);
115
+		$encoded = json_encode($arraytotest);
116 116
 		$this->assertEquals($arrayencodedexpected, $encoded);
117
-		$decoded=json_decode($encoded, true);
117
+		$decoded = json_decode($encoded, true);
118 118
 		$this->assertEquals($arraytotest, $decoded, 'test for json_xxx');
119 119
 
120
-		$encoded=dol_json_encode($arraytotest);
120
+		$encoded = dol_json_encode($arraytotest);
121 121
 		$this->assertEquals($arrayencodedexpected, $encoded);
122
-		$decoded=dol_json_decode($encoded, true);
122
+		$decoded = dol_json_decode($encoded, true);
123 123
 		$this->assertEquals($arraytotest, $decoded, 'test for dol_json_xxx');
124 124
 
125 125
 		// Test with object
126
-		$now=gmmktime(12, 0, 0, 1, 1, 1970);
127
-		$objecttotest=new stdClass();
128
-		$objecttotest->property1='abc';
129
-		$objecttotest->property2=1234;
130
-		$objecttotest->property3=$now;
131
-		$encoded=dol_json_encode($objecttotest);
126
+		$now = gmmktime(12, 0, 0, 1, 1, 1970);
127
+		$objecttotest = new stdClass();
128
+		$objecttotest->property1 = 'abc';
129
+		$objecttotest->property2 = 1234;
130
+		$objecttotest->property3 = $now;
131
+		$encoded = dol_json_encode($objecttotest);
132 132
 		$this->assertEquals('{"property1":"abc","property2":1234,"property3":43200}', $encoded);
133 133
 	}
134 134
 }
Please login to merge, or discard this patch.
test/phpunit/CMailFileTest.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -27,9 +27,9 @@  discard block
 block discarded – undo
27 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
-require_once dirname(__FILE__) . '/../../htdocs/master.inc.php';
31
-require_once dirname(__FILE__) . '/../../htdocs/core/class/CMailFile.class.php';
32
-require_once dirname(__FILE__) . '/../../htdocs/core/lib/files.lib.php';
30
+require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
31
+require_once dirname(__FILE__).'/../../htdocs/core/class/CMailFile.class.php';
32
+require_once dirname(__FILE__).'/../../htdocs/core/lib/files.lib.php';
33 33
 require_once dirname(__FILE__).'/CommonClassTest.class.php';
34 34
 
35 35
 if (empty($user->id)) {
@@ -65,8 +65,8 @@  discard block
 block discarded – undo
65 65
 		$localobject = new CMailFile('Test', '[email protected]', '[email protected]', 'Message txt', array(), array(), array(), '', '', 1, 0);
66 66
 
67 67
 		$result = $localobject->sendfile();
68
-		print __METHOD__ . " result=" . $result . "\n";
69
-		$this->assertFalse($result);   // False because mail send disabled
68
+		print __METHOD__." result=".$result."\n";
69
+		$this->assertFalse($result); // False because mail send disabled
70 70
 
71 71
 		return $result;
72 72
 	}
@@ -88,42 +88,42 @@  discard block
 block discarded – undo
88 88
 
89 89
 		$src = 'John Doe <[email protected]>';
90 90
 		$result = $localobject->getValidAddress($src, 0);
91
-		print __METHOD__ . " result=" . $result . "\n";
91
+		print __METHOD__." result=".$result."\n";
92 92
 		$this->assertEquals($result, 'John Doe <[email protected]>');
93 93
 
94 94
 		$src = 'John Doe <[email protected]>';
95 95
 		$result = $localobject->getValidAddress($src, 1);
96
-		print __METHOD__ . " result=" . $result . "\n";
96
+		print __METHOD__." result=".$result."\n";
97 97
 		$this->assertEquals($result, '<[email protected]>');
98 98
 
99 99
 		$src = 'John Doe <[email protected]>';
100 100
 		$result = $localobject->getValidAddress($src, 2);
101
-		print __METHOD__ . " result=" . $result . "\n";
101
+		print __METHOD__." result=".$result."\n";
102 102
 		$this->assertEquals($result, '[email protected]');
103 103
 
104 104
 		$src = 'John Doe <[email protected]>';
105 105
 		$result = $localobject->getValidAddress($src, 3, 0);
106
-		print __METHOD__ . " result=" . $result . "\n";
106
+		print __METHOD__." result=".$result."\n";
107 107
 		$this->assertEquals($result, '"John Doe" <[email protected]>');
108 108
 
109 109
 		$src = 'John Doe <[email protected]>';
110 110
 		$result = $localobject->getValidAddress($src, 3, 1);
111
-		print __METHOD__ . " result=" . $result . "\n";
111
+		print __METHOD__." result=".$result."\n";
112 112
 		$this->assertEquals($result, '"=?UTF-8?B?Sm9obiBEb2U=?=" <[email protected]>');
113 113
 
114 114
 		$src = 'John Doe <[email protected]>';
115 115
 		$result = $localobject->getValidAddress($src, 4);
116
-		print __METHOD__ . " result=" . $result . "\n";
116
+		print __METHOD__." result=".$result."\n";
117 117
 		$this->assertEquals($result, 'John Doe');
118 118
 
119 119
 		$src = 'John Doe <[email protected]>, John Doe2 <[email protected]>, John Doe3 <[email protected]>';
120 120
 		$result = $localobject->getValidAddress($src, 4);
121
-		print __METHOD__ . " result=" . $result . "\n";
121
+		print __METHOD__." result=".$result."\n";
122 122
 		$this->assertEquals($result, 'John Doe,John Doe2,John Doe3');
123 123
 
124 124
 		$src = 'John Doe <[email protected]>, John Doe2 <[email protected]>, John Doe3 <[email protected]>';
125 125
 		$result = $localobject->getValidAddress($src, 4, 0, 2);
126
-		print __METHOD__ . " result=" . $result . "\n";
126
+		print __METHOD__." result=".$result."\n";
127 127
 		$this->assertEquals($result, 'John Doe,John Doe2...');
128 128
 
129 129
 		return $result;
@@ -146,9 +146,9 @@  discard block
 block discarded – undo
146 146
 		$conf->global->MAIN_MAIL_ADD_INLINE_IMAGES_IF_IN_MEDIAS = 1;
147 147
 		$conf->global->MAIN_MAIL_ADD_INLINE_IMAGES_IF_DATA = 1;
148 148
 
149
-		dol_delete_dir_recursive(DOL_DATA_ROOT . '/medias/image');
150
-		dol_mkdir(DOL_DATA_ROOT . '/medias/image');
151
-		dol_copy(dirname(__FILE__) . '/img250x20.png', DOL_DATA_ROOT . '/medias/image/img250x20.png');
149
+		dol_delete_dir_recursive(DOL_DATA_ROOT.'/medias/image');
150
+		dol_mkdir(DOL_DATA_ROOT.'/medias/image');
151
+		dol_copy(dirname(__FILE__).'/img250x20.png', DOL_DATA_ROOT.'/medias/image/img250x20.png');
152 152
 
153 153
 		$msg = '<html><body>';
154 154
 		$msg .= '<img alt="" src="/viewimage.php?modulepart=medias&amp;entity=1&amp;file=image/img250x20.png" style="height:39px; width:150px" />';
@@ -159,31 +159,31 @@  discard block
 block discarded – undo
159 159
 		$localobject = new CMailFile('Test', '[email protected]', '[email protected]', $msg, array(), array(), array(), '', '', 0, -1, '', '', '', '', 'standard', '', '/tmp');
160 160
 
161 161
 		$result = count($localobject->html_images);
162
-		print __METHOD__ . " result count image detected in the mail=" . $result . "\n";
162
+		print __METHOD__." result count image detected in the mail=".$result."\n";
163 163
 		$this->assertEquals($result, 2);
164 164
 
165 165
 
166 166
 		foreach ($localobject->html_images as $i => $val)
167 167
 		if ($localobject->html_images[$i]) {
168 168
 			if (preg_match('/img250x20\.png/i', $localobject->html_images[$i]['fullpath'])) {
169
-				print __METHOD__ . " content type must be image png =" . $localobject->html_images[$i]['content_type'] . "\n";
169
+				print __METHOD__." content type must be image png =".$localobject->html_images[$i]['content_type']."\n";
170 170
 				$this->assertEquals($localobject->html_images[$i]['content_type'], 'image/png');
171 171
 
172
-				print __METHOD__ . " type must be cidfromurl =" . $localobject->html_images[$i]['type'] . "\n";
172
+				print __METHOD__." type must be cidfromurl =".$localobject->html_images[$i]['type']."\n";
173 173
 				$this->assertEquals($localobject->html_images[$i]['type'], 'cidfromurl');
174 174
 
175 175
 				$fileSize = 9744;
176
-				print __METHOD__ . " File size must be =" . $fileSize . "\n";
176
+				print __METHOD__." File size must be =".$fileSize."\n";
177 177
 				$this->assertEquals(dol_filesize($localobject->html_images[$i]['fullpath']), $fileSize);
178 178
 			} elseif (preg_match('/\.png/i', $localobject->html_images[$i]['fullpath'])) {
179
-				print __METHOD__ . " content type must be image png =" . $localobject->html_images[$i]['content_type'] . "\n";
179
+				print __METHOD__." content type must be image png =".$localobject->html_images[$i]['content_type']."\n";
180 180
 				$this->assertEquals($localobject->html_images[$i]['content_type'], 'image/png');
181 181
 
182
-				print __METHOD__ . " type must be cidfromdata =" . $localobject->html_images[$i]['type'] . "\n";
182
+				print __METHOD__." type must be cidfromdata =".$localobject->html_images[$i]['type']."\n";
183 183
 				$this->assertEquals($localobject->html_images[$i]['type'], 'cidfromdata');
184 184
 
185 185
 				$fileSize = 85;
186
-				print __METHOD__ . " File size must be =" . $fileSize . "\n";
186
+				print __METHOD__." File size must be =".$fileSize."\n";
187 187
 				$this->assertEquals(dol_filesize($localobject->html_images[$i]['fullpath']), $fileSize);
188 188
 			}
189 189
 		}
Please login to merge, or discard this patch.
test/phpunit/ModulesTest.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  *		\remarks	To run this script as CLI:  phpunit filename.php
25 25
  */
26 26
 
27
-global $conf,$user,$langs,$db;
27
+global $conf, $user, $langs, $db;
28 28
 //define('TEST_DB_FORCE_TYPE','mysql');	// This is to force using mysql driver
29 29
 //require_once 'PHPUnit/Autoload.php';
30 30
 require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	$user->fetch(1);
36 36
 	$user->getrights();
37 37
 }
38
-$conf->global->MAIN_DISABLE_ALL_MAILS=1;
38
+$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
39 39
 
40 40
 
41 41
 /**
@@ -54,35 +54,35 @@  discard block
 block discarded – undo
54 54
 	 */
55 55
 	public function testModulesInit()
56 56
 	{
57
-		global $conf,$user,$langs,$db;
58
-		$conf=$this->savconf;
59
-		$user=$this->savuser;
60
-		$langs=$this->savlangs;
61
-		$db=$this->savdb;
57
+		global $conf, $user, $langs, $db;
58
+		$conf = $this->savconf;
59
+		$user = $this->savuser;
60
+		$langs = $this->savlangs;
61
+		$db = $this->savdb;
62 62
 
63
-		$modulelist=array('Accounting','Adherent','Agenda','Api','Asset','Banque','Barcode','BlockedLog','Bom','Bookmark',
64
-		'Categorie','ClickToDial','Collab','Commande','Comptabilite','Contrat','Cron','DataPolicy','Dav','DebugBar','Deplacement','DocumentGeneration','Don','DynamicPrices',
65
-		'ECM','EmailCollector','EventOrganization','Expedition','ExpenseReport','Export','ExternalRss','ExternalSite',
66
-		'Facture','Fckeditor','Ficheinter','Fournisseur','FTP','GeoIPMaxmind','Gravatar','Holiday','HRM','Import','Incoterm','Intracommreport',
67
-		'KnowledgeManagement','Label','Ldap','Loan',
68
-		'Mailing','MailmanSpip','Margin','ModuleBuilder','Mrp','MultiCurrency',
69
-		'Notification','Oauth','OpenSurvey','Paybox','PaymentByBankTransfer','Paypal','Prelevement','Printing','Product','ProductBatch','Projet','Propale',
70
-		'ReceiptPrinter','Reception','Recruitment','Resource',
71
-		'Salaries','Service','SocialNetworks','Societe','Stock','Stripe','SupplierProposal','Syslog',
72
-		'TakePos','Tax','Ticket','User','Variants','WebServices','WebServicesClient','Website','Workflow','Workstation','Zapier');
63
+		$modulelist = array('Accounting', 'Adherent', 'Agenda', 'Api', 'Asset', 'Banque', 'Barcode', 'BlockedLog', 'Bom', 'Bookmark',
64
+		'Categorie', 'ClickToDial', 'Collab', 'Commande', 'Comptabilite', 'Contrat', 'Cron', 'DataPolicy', 'Dav', 'DebugBar', 'Deplacement', 'DocumentGeneration', 'Don', 'DynamicPrices',
65
+		'ECM', 'EmailCollector', 'EventOrganization', 'Expedition', 'ExpenseReport', 'Export', 'ExternalRss', 'ExternalSite',
66
+		'Facture', 'Fckeditor', 'Ficheinter', 'Fournisseur', 'FTP', 'GeoIPMaxmind', 'Gravatar', 'Holiday', 'HRM', 'Import', 'Incoterm', 'Intracommreport',
67
+		'KnowledgeManagement', 'Label', 'Ldap', 'Loan',
68
+		'Mailing', 'MailmanSpip', 'Margin', 'ModuleBuilder', 'Mrp', 'MultiCurrency',
69
+		'Notification', 'Oauth', 'OpenSurvey', 'Paybox', 'PaymentByBankTransfer', 'Paypal', 'Prelevement', 'Printing', 'Product', 'ProductBatch', 'Projet', 'Propale',
70
+		'ReceiptPrinter', 'Reception', 'Recruitment', 'Resource',
71
+		'Salaries', 'Service', 'SocialNetworks', 'Societe', 'Stock', 'Stripe', 'SupplierProposal', 'Syslog',
72
+		'TakePos', 'Tax', 'Ticket', 'User', 'Variants', 'WebServices', 'WebServicesClient', 'Website', 'Workflow', 'Workstation', 'Zapier');
73 73
 		foreach ($modulelist as $modlabel) {
74 74
 			require_once DOL_DOCUMENT_ROOT.'/core/modules/mod'.$modlabel.'.class.php';
75
-			$class='mod'.$modlabel;
76
-			$mod=new $class($db);
75
+			$class = 'mod'.$modlabel;
76
+			$mod = new $class($db);
77 77
 
78
-			$result=$mod->remove();
79
-			$result=$mod->init();
78
+			$result = $mod->remove();
79
+			$result = $mod->init();
80 80
 
81 81
 			$this->assertLessThan($result, 0, $modlabel." ".$mod->error);
82 82
 			print __METHOD__." test remove/init for module ".$modlabel.", result=".$result."\n";
83 83
 
84 84
 			if (in_array($modlabel, array('Ldap', 'MailmanSpip'))) {
85
-				$result=$mod->remove();
85
+				$result = $mod->remove();
86 86
 			}
87 87
 		}
88 88
 
Please login to merge, or discard this patch.
test/phpunit/PropalTest.php 1 patch
Spacing   +47 added lines, -47 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 testPropalCreate()
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 Propal($db);
64
+		$localobject = new Propal($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";
@@ -81,14 +81,14 @@  discard block
 block discarded – undo
81 81
 	 */
82 82
 	public function testPropalFetch($id)
83 83
 	{
84
-		global $conf,$user,$langs,$db;
85
-		$conf=$this->savconf;
86
-		$user=$this->savuser;
87
-		$langs=$this->savlangs;
88
-		$db=$this->savdb;
84
+		global $conf, $user, $langs, $db;
85
+		$conf = $this->savconf;
86
+		$user = $this->savuser;
87
+		$langs = $this->savlangs;
88
+		$db = $this->savdb;
89 89
 
90
-		$localobject=new Propal($db);
91
-		$result=$localobject->fetch($id);
90
+		$localobject = new Propal($db);
91
+		$result = $localobject->fetch($id);
92 92
 
93 93
 		$this->assertLessThan($result, 0);
94 94
 		print __METHOD__." id=".$id." result=".$result."\n";
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
 	 */
107 107
 	public function testPropalUpdate($localobject)
108 108
 	{
109
-		global $conf,$user,$langs,$db;
110
-		$conf=$this->savconf;
111
-		$user=$this->savuser;
112
-		$langs=$this->savlangs;
113
-		$db=$this->savdb;
109
+		global $conf, $user, $langs, $db;
110
+		$conf = $this->savconf;
111
+		$user = $this->savuser;
112
+		$langs = $this->savlangs;
113
+		$db = $this->savdb;
114 114
 
115 115
 		$localobject->note_private = 'New note private after update';
116 116
 		$result = $localobject->update($user);
@@ -131,14 +131,14 @@  discard block
 block discarded – undo
131 131
 	 */
132 132
 	public function testPropalAddLine($localobject)
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 140
 		$localobject->fetch_thirdparty();
141
-		$result=$localobject->addline('Added line', 10, 2, 19.6);
141
+		$result = $localobject->addline('Added line', 10, 2, 19.6);
142 142
 
143 143
 		$this->assertLessThan($result, 0);
144 144
 		print __METHOD__." id=".$localobject->id." result=".$result."\n";
@@ -156,13 +156,13 @@  discard block
 block discarded – undo
156 156
 	 */
157 157
 	public function testPropalValid($localobject)
158 158
 	{
159
-		global $conf,$user,$langs,$db;
160
-		$conf=$this->savconf;
161
-		$user=$this->savuser;
162
-		$langs=$this->savlangs;
163
-		$db=$this->savdb;
159
+		global $conf, $user, $langs, $db;
160
+		$conf = $this->savconf;
161
+		$user = $this->savuser;
162
+		$langs = $this->savlangs;
163
+		$db = $this->savdb;
164 164
 
165
-		$result=$localobject->valid($user);
165
+		$result = $localobject->valid($user);
166 166
 
167 167
 		print __METHOD__." id=".$localobject->id." result=".$result."\n";
168 168
 		$this->assertLessThan($result, 0);
@@ -180,11 +180,11 @@  discard block
 block discarded – undo
180 180
 	 */
181 181
 	public function testPropalOther($localobject)
182 182
 	{
183
-		global $conf,$user,$langs,$db;
184
-		$conf=$this->savconf;
185
-		$user=$this->savuser;
186
-		$langs=$this->savlangs;
187
-		$db=$this->savdb;
183
+		global $conf, $user, $langs, $db;
184
+		$conf = $this->savconf;
185
+		$user = $this->savuser;
186
+		$langs = $this->savlangs;
187
+		$db = $this->savdb;
188 188
 
189 189
 		/*$result=$localobject->setstatus(0);
190 190
 		print __METHOD__." id=".$localobject->id." result=".$result."\n";
@@ -209,15 +209,15 @@  discard block
 block discarded – undo
209 209
 	 */
210 210
 	public function testPropalDelete($id)
211 211
 	{
212
-		global $conf,$user,$langs,$db;
213
-		$conf=$this->savconf;
214
-		$user=$this->savuser;
215
-		$langs=$this->savlangs;
216
-		$db=$this->savdb;
217
-
218
-		$localobject=new Propal($db);
219
-		$result=$localobject->fetch($id);
220
-		$result=$localobject->delete($user);
212
+		global $conf, $user, $langs, $db;
213
+		$conf = $this->savconf;
214
+		$user = $this->savuser;
215
+		$langs = $this->savlangs;
216
+		$db = $this->savdb;
217
+
218
+		$localobject = new Propal($db);
219
+		$result = $localobject->fetch($id);
220
+		$result = $localobject->delete($user);
221 221
 
222 222
 		print __METHOD__." id=".$id." result=".$result."\n";
223 223
 		$this->assertLessThan($result, 0);
Please login to merge, or discard this patch.
test/phpunit/AccountingAccountTest.php 1 patch
Spacing   +33 added lines, -33 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,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	 */
56 56
 	public static function setUpBeforeClass(): void
57 57
 	{
58
-		global $conf,$user,$langs,$db;
58
+		global $conf, $user, $langs, $db;
59 59
 		$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
60 60
 
61 61
 		if (!isModEnabled('accounting')) {
@@ -74,13 +74,13 @@  discard block
 block discarded – undo
74 74
 	 */
75 75
 	public function testAccountingAccountCreate()
76 76
 	{
77
-		global $conf,$user,$langs,$db;
78
-		$conf=$this->savconf;
79
-		$user=$this->savuser;
80
-		$langs=$this->savlangs;
81
-		$db=$this->savdb;
77
+		global $conf, $user, $langs, $db;
78
+		$conf = $this->savconf;
79
+		$user = $this->savuser;
80
+		$langs = $this->savlangs;
81
+		$db = $this->savdb;
82 82
 
83
-		$localobject=new AccountingAccount($db);
83
+		$localobject = new AccountingAccount($db);
84 84
 		$localobject->fk_pcg_version = 'PCG99-ABREGE';
85 85
 		$localobject->account_category = 0;
86 86
 		$localobject->pcg_type = 'XXXXX';
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 		$localobject->account_parent = 0;
90 90
 		$localobject->label = 'Account specimen';
91 91
 		$localobject->active = 0;
92
-		$result=$localobject->create($user);
92
+		$result = $localobject->create($user);
93 93
 
94 94
 		print __METHOD__." result=".$result."\n";
95 95
 		$this->assertLessThan($result, 0);
@@ -108,14 +108,14 @@  discard block
 block discarded – undo
108 108
 	 */
109 109
 	public function testAccountingAccountFetch($id)
110 110
 	{
111
-		global $conf,$user,$langs,$db;
112
-		$conf=$this->savconf;
113
-		$user=$this->savuser;
114
-		$langs=$this->savlangs;
115
-		$db=$this->savdb;
111
+		global $conf, $user, $langs, $db;
112
+		$conf = $this->savconf;
113
+		$user = $this->savuser;
114
+		$langs = $this->savlangs;
115
+		$db = $this->savdb;
116 116
 
117
-		$localobject=new AccountingAccount($db);
118
-		$result=$localobject->fetch($id);
117
+		$localobject = new AccountingAccount($db);
118
+		$result = $localobject->fetch($id);
119 119
 
120 120
 		print __METHOD__." id=".$id." result=".$result."\n";
121 121
 		$this->assertLessThan($result, 0);
@@ -134,14 +134,14 @@  discard block
 block discarded – undo
134 134
 	 */
135 135
 	public function testAccountingAccountUpdate($localobject)
136 136
 	{
137
-		global $conf,$user,$langs,$db;
138
-		$conf=$this->savconf;
139
-		$user=$this->savuser;
140
-		$langs=$this->savlangs;
141
-		$db=$this->savdb;
137
+		global $conf, $user, $langs, $db;
138
+		$conf = $this->savconf;
139
+		$user = $this->savuser;
140
+		$langs = $this->savlangs;
141
+		$db = $this->savdb;
142 142
 
143
-		$localobject->label='New label';
144
-		$result=$localobject->update($user);
143
+		$localobject->label = 'New label';
144
+		$result = $localobject->update($user);
145 145
 
146 146
 		print __METHOD__." id=".$localobject->id." result=".$result."\n";
147 147
 		$this->assertLessThan($result, 0);
@@ -160,15 +160,15 @@  discard block
 block discarded – undo
160 160
 	 */
161 161
 	public function testAccountingAccountDelete($id)
162 162
 	{
163
-		global $conf,$user,$langs,$db;
164
-		$conf=$this->savconf;
165
-		$user=$this->savuser;
166
-		$langs=$this->savlangs;
167
-		$db=$this->savdb;
168
-
169
-		$localobject=new AccountingAccount($db);
170
-		$result=$localobject->fetch($id);
171
-		$result=$localobject->delete($user);
163
+		global $conf, $user, $langs, $db;
164
+		$conf = $this->savconf;
165
+		$user = $this->savuser;
166
+		$langs = $this->savlangs;
167
+		$db = $this->savdb;
168
+
169
+		$localobject = new AccountingAccount($db);
170
+		$result = $localobject->fetch($id);
171
+		$result = $localobject->delete($user);
172 172
 
173 173
 		print __METHOD__." id=".$id." result=".$result."\n";
174 174
 		$this->assertLessThan($result, 0);
Please login to merge, or discard this patch.
test/phpunit/WebservicesOtherTest.php 1 patch
Spacing   +20 added lines, -20 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,26 +58,26 @@  discard block
 block discarded – undo
58 58
 	 */
59 59
 	public function testWSOtherGetVersions()
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_other.php';
68 68
 		$WS_METHOD  = 'getVersions';
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
 		// Call the WebService method and store its result in $result.
80
-		$authentication=array(
80
+		$authentication = array(
81 81
 			'dolibarrkey'=>getDolGlobalString('WEBSERVICES_KEY'),
82 82
 			'sourceapplication'=>'DEMO',
83 83
 			'login'=>'admin',
@@ -86,20 +86,20 @@  discard block
 block discarded – undo
86 86
 		);
87 87
 
88 88
 		// Test URL
89
-		$result='';
89
+		$result = '';
90 90
 		$parameters = array('authentication'=>$authentication);
91 91
 		print __METHOD__." call method ".$WS_METHOD."\n";
92 92
 		try {
93 93
 			$result = $soapclient->call($WS_METHOD, $parameters, $ns, '');
94 94
 		} catch (SoapFault $exception) {
95 95
 			echo $exception;
96
-			$result=0;
96
+			$result = 0;
97 97
 		}
98 98
 		if (!empty($result['faultstring'])) {
99 99
 			print $result['faultstring']."\n";
100
-			$result=0;
100
+			$result = 0;
101 101
 		}
102
-		if (! $result) {
102
+		if (!$result) {
103 103
 			//var_dump($soapclient);
104 104
 			print 'Error: '.$soapclient->error_str;
105 105
 			print "\n<br>\n";
@@ -113,17 +113,17 @@  discard block
 block discarded – undo
113 113
 		$this->assertEquals('OK', $result['result']['result_code']);
114 114
 
115 115
 		// Test method that does not exists
116
-		$WS_METHOD='methodthatdoesnotexists';
117
-		$result='';
116
+		$WS_METHOD = 'methodthatdoesnotexists';
117
+		$result = '';
118 118
 		$parameters = array('authentication'=>$authentication);
119 119
 		print __METHOD__." call method ".$WS_METHOD."\n";
120 120
 		try {
121 121
 			$result = $soapclient->call($WS_METHOD, $parameters, $ns, '');
122 122
 		} catch (SoapFault $exception) {
123 123
 			echo $exception;
124
-			$result=0;
124
+			$result = 0;
125 125
 		}
126
-		if (! $result || !empty($result['faultstring'])) {
126
+		if (!$result || !empty($result['faultstring'])) {
127 127
 			//var_dump($soapclient);
128 128
 			print $soapclient->error_str;
129 129
 			print "\n<br>\n";
Please login to merge, or discard this patch.
test/phpunit/WebservicesOrdersTest.php 1 patch
Spacing   +15 added lines, -15 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,26 +58,26 @@  discard block
 block discarded – undo
58 58
 	 */
59 59
 	public function testWSOrderGetOrder()
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_order.php';
68 68
 		$WS_METHOD  = 'getOrder';
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
 		// Call the WebService method and store its result in $result.
80
-		$authentication=array(
80
+		$authentication = array(
81 81
 			'dolibarrkey'=>getDolGlobalString('WEBSERVICES_KEY'),
82 82
 			'sourceapplication'=>'DEMO',
83 83
 			'login'=>'admin',
@@ -86,15 +86,15 @@  discard block
 block discarded – undo
86 86
 		);
87 87
 
88 88
 		// Test URL
89
-		$parameters = array('authentication'=>$authentication,'id'=>1);
89
+		$parameters = array('authentication'=>$authentication, 'id'=>1);
90 90
 		print __METHOD__." call method ".$WS_METHOD."\n";
91 91
 		try {
92 92
 			$result = $soapclient->call($WS_METHOD, $parameters, $ns, '');
93 93
 		} catch (SoapFault $exception) {
94 94
 			echo $exception;
95
-			$result=0;
95
+			$result = 0;
96 96
 		}
97
-		if (! $result || !empty($result['faultstring'])) {
97
+		if (!$result || !empty($result['faultstring'])) {
98 98
 			//var_dump($soapclient);
99 99
 			print 'Error: '.$soapclient->error_str;
100 100
 			print "\n<br>\n";
Please login to merge, or discard this patch.
test/phpunit/CodingPhpTest.php 1 patch
Spacing   +106 added lines, -106 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';
@@ -32,35 +32,35 @@  discard block
 block discarded – undo
32 32
 require_once dirname(__FILE__).'/../../htdocs/core/lib/security2.lib.php';
33 33
 require_once dirname(__FILE__).'/CommonClassTest.class.php';
34 34
 
35
-if (! defined('NOREQUIREUSER')) {
35
+if (!defined('NOREQUIREUSER')) {
36 36
 	define('NOREQUIREUSER', '1');
37 37
 }
38
-if (! defined('NOREQUIREDB')) {
38
+if (!defined('NOREQUIREDB')) {
39 39
 	define('NOREQUIREDB', '1');
40 40
 }
41
-if (! defined('NOREQUIRESOC')) {
41
+if (!defined('NOREQUIRESOC')) {
42 42
 	define('NOREQUIRESOC', '1');
43 43
 }
44
-if (! defined('NOREQUIRETRAN')) {
44
+if (!defined('NOREQUIRETRAN')) {
45 45
 	define('NOREQUIRETRAN', '1');
46 46
 }
47
-if (! defined('NOCSRFCHECK')) {
47
+if (!defined('NOCSRFCHECK')) {
48 48
 	define('NOCSRFCHECK', '1');
49 49
 }
50
-if (! defined('NOTOKENRENEWAL')) {
50
+if (!defined('NOTOKENRENEWAL')) {
51 51
 	define('NOTOKENRENEWAL', '1');
52 52
 }
53
-if (! defined('NOREQUIREMENU')) {
53
+if (!defined('NOREQUIREMENU')) {
54 54
 	define('NOREQUIREMENU', '1'); // If there is no menu to show
55 55
 }
56
-if (! defined('NOREQUIREHTML')) {
56
+if (!defined('NOREQUIREHTML')) {
57 57
 	define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
58 58
 }
59
-if (! defined('NOREQUIREAJAX')) {
59
+if (!defined('NOREQUIREAJAX')) {
60 60
 	define('NOREQUIREAJAX', '1');
61 61
 }
62
-if (! defined("NOLOGIN")) {
63
-	define("NOLOGIN", '1');       // If this page is public (can be called outside logged session)
62
+if (!defined("NOLOGIN")) {
63
+	define("NOLOGIN", '1'); // If this page is public (can be called outside logged session)
64 64
 }
65 65
 
66 66
 if (empty($user->id)) {
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	$user->fetch(1);
69 69
 	$user->getrights();
70 70
 }
71
-$conf->global->MAIN_DISABLE_ALL_MAILS=1;
71
+$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
72 72
 
73 73
 
74 74
 /**
@@ -87,11 +87,11 @@  discard block
 block discarded – undo
87 87
 	 */
88 88
 	public function testPHP()
89 89
 	{
90
-		global $conf,$user,$langs,$db;
91
-		$conf=$this->savconf;
92
-		$user=$this->savuser;
93
-		$langs=$this->savlangs;
94
-		$db=$this->savdb;
90
+		global $conf, $user, $langs, $db;
91
+		$conf = $this->savconf;
92
+		$user = $this->savuser;
93
+		$langs = $this->savlangs;
94
+		$db = $this->savdb;
95 95
 
96 96
 		include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
97 97
 		$filesarray = dol_dir_list(DOL_DOCUMENT_ROOT, 'files', 1, '\.php', null, 'fullname', SORT_ASC, 0, 1, '', 1);
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 			}
118 118
 
119 119
 			//print 'Check php file '.$file['relativename']."\n";
120
-			$filecontent=file_get_contents($file['fullname']);
120
+			$filecontent = file_get_contents($file['fullname']);
121 121
 
122 122
 			if (preg_match('/\.class\.php/', $file['relativename'])
123 123
 				|| preg_match('/boxes\/box_/', $file['relativename'])
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 				|| preg_match('/modules\/(import|mailings|printing)\//', $file['relativename'])
126 126
 				|| in_array($file['name'], array('modules_boxes.php', 'TraceableDB.php'))) {
127 127
 				// Check into Class files
128
-				if (! in_array($file['name'], array(
128
+				if (!in_array($file['name'], array(
129 129
 					'api.class.php',
130 130
 					'commonobject.class.php',
131 131
 					'conf.class.php',
@@ -136,12 +136,12 @@  discard block
 block discarded – undo
136 136
 					'multicurrency.class.php'
137 137
 				))) {
138 138
 					// Must not find $db->
139
-					$ok=true;
140
-					$matches=array();
139
+					$ok = true;
140
+					$matches = array();
141 141
 					// Check string $db-> inside a class.php file (it should be $this->db-> into such classes)
142 142
 					preg_match_all('/'.preg_quote('$db->', '/').'/', $filecontent, $matches, PREG_SET_ORDER);
143 143
 					foreach ($matches as $key => $val) {
144
-						$ok=false;
144
+						$ok = false;
145 145
 						break;
146 146
 					}
147 147
 					//print __METHOD__." Result for checking we don't have non escaped string in sql requests for file ".$file."\n";
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 					//exit;
150 150
 				}
151 151
 
152
-				if (preg_match('/\.class\.php/', $file['relativename']) && ! in_array($file['relativename'], array(
152
+				if (preg_match('/\.class\.php/', $file['relativename']) && !in_array($file['relativename'], array(
153 153
 					'adherents/canvas/actions_adherentcard_common.class.php',
154 154
 					'contact/canvas/actions_contactcard_common.class.php',
155 155
 					'compta/facture/class/facture.class.php',
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 				}
193 193
 			} else {
194 194
 				// Check into Include files
195
-				if (! in_array($file['name'], array(
195
+				if (!in_array($file['name'], array(
196 196
 					'objectline_view.tpl.php',
197 197
 					'extrafieldsinexport.inc.php',
198 198
 					'extrafieldsinimport.inc.php',
@@ -200,12 +200,12 @@  discard block
 block discarded – undo
200 200
 					'DoliStorage.php'
201 201
 				))) {
202 202
 					// Must not found $this->db->
203
-					$ok=true;
204
-					$matches=array();
203
+					$ok = true;
204
+					$matches = array();
205 205
 					// Check string $this->db-> into a non class.php file (it should be $db-> into such classes)
206 206
 					preg_match_all('/'.preg_quote('$this->db->', '/').'/', $filecontent, $matches, PREG_SET_ORDER);
207 207
 					foreach ($matches as $key => $val) {
208
-						$ok=false;
208
+						$ok = false;
209 209
 						break;
210 210
 					}
211 211
 					//print __METHOD__." Result for checking we don't have non escaped string in sql requests for file ".$file."\n";
@@ -217,11 +217,11 @@  discard block
 block discarded – undo
217 217
 			// Check we don't miss top_httphead() into any ajax pages
218 218
 			if (preg_match('/ajax\//', $file['relativename'])) {
219 219
 				print "Analyze ajax page ".$file['relativename']."\n";
220
-				$ok=true;
221
-				$matches=array();
220
+				$ok = true;
221
+				$matches = array();
222 222
 				preg_match_all('/top_httphead/', $filecontent, $matches, PREG_SET_ORDER);
223 223
 				if (count($matches) == 0) {
224
-					$ok=false;
224
+					$ok = false;
225 225
 				}
226 226
 				//print __METHOD__." Result for checking we don't have non escaped string in sql requests for file ".$file."\n";
227 227
 				$this->assertTrue($ok, 'Did not find top_httphead into the ajax page '.$file['relativename']);
@@ -230,14 +230,14 @@  discard block
 block discarded – undo
230 230
 
231 231
 			// Check if a var_dump has been forgotten
232 232
 			if (!preg_match('/test\/phpunit/', $file['fullname'])) {
233
-				if (! in_array($file['name'], array('class.nusoap_base.php'))) {
234
-					$ok=true;
235
-					$matches=array();
233
+				if (!in_array($file['name'], array('class.nusoap_base.php'))) {
234
+					$ok = true;
235
+					$matches = array();
236 236
 					preg_match_all('/(.)\s*var_dump\(/', $filecontent, $matches, PREG_SET_ORDER);
237 237
 					//var_dump($matches);
238 238
 					foreach ($matches as $key => $val) {
239 239
 						if ($val[1] != '/' && $val[1] != '*') {
240
-							$ok=false;
240
+							$ok = false;
241 241
 							break;
242 242
 						}
243 243
 						break;
@@ -249,11 +249,11 @@  discard block
 block discarded – undo
249 249
 			}
250 250
 
251 251
 			// Check get_class followed by __METHOD__
252
-			$ok=true;
253
-			$matches=array();
252
+			$ok = true;
253
+			$matches = array();
254 254
 			preg_match_all('/'.preg_quote('get_class($this)."::".__METHOD__', '/').'/', $filecontent, $matches, PREG_SET_ORDER);
255 255
 			foreach ($matches as $key => $val) {
256
-				$ok=false;
256
+				$ok = false;
257 257
 				break;
258 258
 			}
259 259
 			//print __METHOD__." Result for checking we don't have non escaped string in sql requests for file ".$file."\n";
@@ -261,12 +261,12 @@  discard block
 block discarded – undo
261 261
 			//exit;
262 262
 
263 263
 			// Check string $this->db->idate without quotes
264
-			$ok=true;
265
-			$matches=array();
264
+			$ok = true;
265
+			$matches = array();
266 266
 			preg_match_all('/(..)\s*\.\s*\$this->db->idate\(/', $filecontent, $matches, PREG_SET_ORDER);
267 267
 			foreach ($matches as $key => $val) {
268 268
 				if ($val[1] != '\'"' && $val[1] != '\'\'') {
269
-					$ok=false;
269
+					$ok = false;
270 270
 					break;
271 271
 				}
272 272
 				//if ($reg[0] != 'db') $ok=false;
@@ -278,8 +278,8 @@  discard block
 block discarded – undo
278 278
 
279 279
 			// Check sql string DELETE|OR|AND|WHERE|INSERT ... yyy = ".$xxx
280 280
 			//  with xxx that is not 'thi' (for $this->db->sanitize) and 'db-' (for $db->sanitize). It means we forget a ' if string, or an (int) if int, when forging sql request.
281
-			$ok=true;
282
-			$matches=array();
281
+			$ok = true;
282
+			$matches = array();
283 283
 			preg_match_all('/(DELETE|OR|AND|WHERE|INSERT)\s.*([^\s][^\s][^\s])\s*=\s*(\'|")\s*\.\s*\$(...)/', $filecontent, $matches, PREG_SET_ORDER);
284 284
 			foreach ($matches as $key => $val) {
285 285
 				if ($val[2] == 'ity' && $val[4] == 'con') {		// exclude entity = ".$conf->entity
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 					continue;
293 293
 				}
294 294
 				var_dump($matches);
295
-				$ok=false;
295
+				$ok = false;
296 296
 				break;
297 297
 			}
298 298
 			//print __METHOD__." Result for checking we don't have non escaped string in sql requests for file ".$file."\n";
@@ -300,13 +300,13 @@  discard block
 block discarded – undo
300 300
 			//exit;
301 301
 
302 302
 			// Check that forged sql string is using ' instead of " as string PHP quotes
303
-			$ok=true;
304
-			$matches=array();
303
+			$ok = true;
304
+			$matches = array();
305 305
 			preg_match_all('/\$sql \.= \'\s*VALUES.*\$/', $filecontent, $matches, PREG_SET_ORDER);
306 306
 			foreach ($matches as $key => $val) {
307 307
 				//if ($val[1] != '\'"' && $val[1] != '\'\'') {
308 308
 				var_dump($matches);
309
-				$ok=false;
309
+				$ok = false;
310 310
 				break;
311 311
 				//}
312 312
 				//if ($reg[0] != 'db') $ok=false;
@@ -316,20 +316,20 @@  discard block
 block discarded – undo
316 316
 			//exit;
317 317
 
318 318
 			// Check that forged sql string is using ' instead of " as string PHP quotes
319
-			$ok=true;
320
-			$matches=array();
319
+			$ok = true;
320
+			$matches = array();
321 321
 			preg_match_all('/\$sql \.?= \'SELECT.*\$/', $filecontent, $matches, PREG_SET_ORDER);
322 322
 			foreach ($matches as $key => $val) {
323 323
 				var_dump($matches);
324
-				$ok=false;
324
+				$ok = false;
325 325
 				break;
326 326
 			}
327 327
 			$this->assertTrue($ok, 'Found a forged SQL string that mix on same line the use of \' for PHP string and PHP variables into file '.$file['relativename'].' Use " to forge PHP string like this: $sql = "SELECT ".$myvar...');
328 328
 
329 329
 			// Check sql string VALUES ... , ".$xxx
330 330
 			//  with xxx that is not 'db-' (for $db->escape). It means we forget a ' if string, or an (int) if int, when forging sql request.
331
-			$ok=true;
332
-			$matches=array();
331
+			$ok = true;
332
+			$matches = array();
333 333
 			preg_match_all('/(VALUES).*,\s*"\s*\.\s*\$(...)/', $filecontent, $matches, PREG_SET_ORDER);
334 334
 			foreach ($matches as $key => $val) {
335 335
 				if ($val[1] == 'VALUES' && $val[2] == 'db-') {		// exclude $db->escape(
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
 					continue;
340 340
 				}
341 341
 				var_dump($matches);
342
-				$ok=false;
342
+				$ok = false;
343 343
 				break;
344 344
 			}
345 345
 			//print __METHOD__." Result for checking we don't have non escaped string in sql requests for file ".$file."\n";
@@ -349,12 +349,12 @@  discard block
 block discarded – undo
349 349
 			// Check '".$xxx non escaped
350 350
 
351 351
 			// Check string   ='".$this->xxx   with xxx that is not 'escape'. It means we forget a db->escape when forging sql request.
352
-			$ok=true;
353
-			$matches=array();
352
+			$ok = true;
353
+			$matches = array();
354 354
 			preg_match_all('/=\s*\'"\s*\.\s*\$this->(....)/', $filecontent, $matches, PREG_SET_ORDER);
355 355
 			foreach ($matches as $key => $val) {
356 356
 				if ($val[1] != 'db->' && $val[1] != 'esca') {
357
-					$ok=false;
357
+					$ok = false;
358 358
 					break;
359 359
 				}
360 360
 			}
@@ -362,12 +362,12 @@  discard block
 block discarded – undo
362 362
 			$this->assertTrue($ok, 'Found non escaped string in building of a sql request (case 1) in '.$file['relativename'].' - Bad.');
363 363
 
364 364
 			// Check string sql|set|WHERE|...'".$yyy->xxx   with xxx that is not 'escape', 'idate', .... It means we forget a db->escape when forging sql request.
365
-			$ok=true;
366
-			$matches=array();
365
+			$ok = true;
366
+			$matches = array();
367 367
 			preg_match_all('/(sql|SET|WHERE|INSERT|VALUES|LIKE).+\s*\'"\s*\.\s*\$(.......)/', $filecontent, $matches, PREG_SET_ORDER);
368 368
 			foreach ($matches as $key => $val) {
369
-				if (! in_array($val[2], array('this->d', 'this->e', 'db->esc', 'dbs->es', 'dbs->id', 'mydb->e', 'dbsessi', 'db->ida', 'escaped', 'exclude', 'include'))) {
370
-					$ok=false;	// This will generate error
369
+				if (!in_array($val[2], array('this->d', 'this->e', 'db->esc', 'dbs->es', 'dbs->id', 'mydb->e', 'dbsessi', 'db->ida', 'escaped', 'exclude', 'include'))) {
370
+					$ok = false; // This will generate error
371 371
 					break;
372 372
 				}
373 373
 				//if ($reg[0] != 'db') $ok=false;
@@ -377,12 +377,12 @@  discard block
 block discarded – undo
377 377
 			//exit;
378 378
 
379 379
 			// Check string sql|set...'.$yyy->xxx   with xxx that is not 'escape', 'idate', .... It means we forget a db->escape when forging sql request.
380
-			$ok=true;
381
-			$matches=array();
380
+			$ok = true;
381
+			$matches = array();
382 382
 			preg_match_all('/(\$sql|SET\s|WHERE\s|INSERT\s|VALUES\s|VALUES\().+\s*\'\s*\.\s*\$(.........)/', $filecontent, $matches, PREG_SET_ORDER);
383 383
 			foreach ($matches as $key => $val) {
384
-				if (! in_array($val[2], array('this->db-', 'db->prefi', 'db->sanit', 'dbs->pref', 'dbs->sani', 'conf->ent', 'key : \'\')', 'key])."\')', 'excludefi', 'regexstri', ''))) {
385
-					$ok=false;
384
+				if (!in_array($val[2], array('this->db-', 'db->prefi', 'db->sanit', 'dbs->pref', 'dbs->sani', 'conf->ent', 'key : \'\')', 'key])."\')', 'excludefi', 'regexstri', ''))) {
385
+					$ok = false;
386 386
 					var_dump($matches);
387 387
 					break;
388 388
 				}
@@ -395,13 +395,13 @@  discard block
 block discarded – undo
395 395
 			// Checks with IN
396 396
 
397 397
 			// Check string ' IN (".xxx' or ' IN (\'.xxx'  with xxx that is not '$this->db->sanitize' and not '$db->sanitize'. It means we forget a db->sanitize when forging sql request.
398
-			$ok=true;
399
-			$matches=array();
398
+			$ok = true;
399
+			$matches = array();
400 400
 			preg_match_all('/\s+IN\s*\([\'"]\s*\.\s*(.........)/i', $filecontent, $matches, PREG_SET_ORDER);
401 401
 			foreach ($matches as $key => $val) {
402 402
 				//var_dump($val);
403 403
 				if (!in_array($val[1], array('$db->sani', '$this->db', 'getEntity', 'WON\',\'L', 'self::STA', 'Commande:', 'CommandeF', 'Entrepot:', 'Facture::', 'FactureFo', 'ExpenseRe', 'Societe::', 'Ticket::S'))) {
404
-					$ok=false;
404
+					$ok = false;
405 405
 					break;
406 406
 				}
407 407
 				//if ($reg[0] != 'db') $ok=false;
@@ -411,13 +411,13 @@  discard block
 block discarded – undo
411 411
 			//exit;
412 412
 
413 413
 			// Check string ' IN (\'".xxx'   with xxx that is not '$this->db->sanitize' and not '$db->sanitize'. It means we forget a db->sanitize when forging sql request.
414
-			$ok=true;
415
-			$matches=array();
414
+			$ok = true;
415
+			$matches = array();
416 416
 			preg_match_all('/\s+IN\s*\(\'"\s*\.\s*(.........)/i', $filecontent, $matches, PREG_SET_ORDER);
417 417
 			foreach ($matches as $key => $val) {
418 418
 				//var_dump($val);
419 419
 				if (!in_array($val[1], array('$db->sani', '$this->db', 'getEntity', 'WON\',\'L', 'self::STA', 'Commande:', 'CommandeF', 'Entrepot:', 'Facture::', 'FactureFo', 'ExpenseRe', 'Societe::', 'Ticket::S'))) {
420
-					$ok=false;
420
+					$ok = false;
421 421
 					break;
422 422
 				}
423 423
 				//if ($reg[0] != 'db') $ok=false;
@@ -427,12 +427,12 @@  discard block
 block discarded – undo
427 427
 			//exit;
428 428
 
429 429
 			// Test that output of $_SERVER\[\'QUERY_STRING\'\] is escaped.
430
-			$ok=true;
431
-			$matches=array();
430
+			$ok = true;
431
+			$matches = array();
432 432
 			preg_match_all('/(..............)\$_SERVER\[\'QUERY_STRING\'\]/', $filecontent, $matches, PREG_SET_ORDER);
433 433
 			foreach ($matches as $key => $val) {
434 434
 				if ($val[1] != 'scape_htmltag(' && $val[1] != 'ing_nohtmltag(' && $val[1] != 'dol_escape_js(') {
435
-					$ok=false;
435
+					$ok = false;
436 436
 					break;
437 437
 				}
438 438
 			}
@@ -440,8 +440,8 @@  discard block
 block discarded – undo
440 440
 
441 441
 
442 442
 			// Check GETPOST(... 'none');
443
-			$ok=true;
444
-			$matches=array();
443
+			$ok = true;
444
+			$matches = array();
445 445
 			preg_match_all('/GETPOST\s*\(([^\)]+),\s*["\']none["\']/i', $filecontent, $matches, PREG_SET_ORDER);
446 446
 			foreach ($matches as $key => $val) {
447 447
 				//var_dump($val);
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
 						'"mysqldump"', '"postgresqldump"',
451 451
 						"'db_pass_root'", "'db_pass'", '"pass"', '"pass1"', '"pass2"', '"password"', "'password'",
452 452
 						'"MAIN_MAIL_SMTPS_PW"', '"MAIN_MAIL_SMTPS_PW_EMAILING"', '"MAIN_MAIL_SMTPS_PW_TICKET"'))) {
453
-					$ok=false;
453
+					$ok = false;
454 454
 					break;
455 455
 				}
456 456
 				//if ($reg[0] != 'db') $ok=false;
@@ -461,24 +461,24 @@  discard block
 block discarded – undo
461 461
 
462 462
 
463 463
 			// Test that first param of print_liste_field_titre is a translation key and not the translated value
464
-			$ok=true;
465
-			$matches=array();
464
+			$ok = true;
465
+			$matches = array();
466 466
 			// Check string ='print_liste_field_titre\(\$langs'.
467 467
 			preg_match_all('/print_liste_field_titre\(\$langs/', $filecontent, $matches, PREG_SET_ORDER);
468 468
 			foreach ($matches as $key => $val) {
469
-				$ok=false;
469
+				$ok = false;
470 470
 				break;
471 471
 			}
472 472
 			$this->assertTrue($ok, 'Found a use of print_liste_field_titre with first parameter that is a translated value instead of just the translation key in file '.$file['relativename'].'. Bad.');
473 473
 
474 474
 
475 475
 			// Test we don't have <br />
476
-			$ok=true;
477
-			$matches=array();
476
+			$ok = true;
477
+			$matches = array();
478 478
 			preg_match_all('/<br\s+\/>/', $filecontent, $matches, PREG_SET_ORDER);
479 479
 			foreach ($matches as $key => $val) {
480 480
 				if ($file['name'] != 'functions.lib.php') {
481
-					$ok=false;
481
+					$ok = false;
482 482
 					break;
483 483
 				}
484 484
 			}
@@ -486,12 +486,12 @@  discard block
 block discarded – undo
486 486
 
487 487
 
488 488
 			// Test we don't have name="token" value="'.$_SESSION['newtoken'], we must use name="token" value="'.newToken() instead.
489
-			$ok=true;
490
-			$matches=array();
489
+			$ok = true;
490
+			$matches = array();
491 491
 			preg_match_all('/name="token" value="\'\s*\.\s*\$_SESSION/', $filecontent, $matches, PREG_SET_ORDER);
492 492
 			foreach ($matches as $key => $val) {
493 493
 				if ($file['name'] != 'excludefile.php') {
494
-					$ok=false;
494
+					$ok = false;
495 495
 					break;
496 496
 				}
497 497
 			}
@@ -499,12 +499,12 @@  discard block
 block discarded – undo
499 499
 
500 500
 
501 501
 			// Test we don't have preg_grep with a param without preg_quote
502
-			$ok=true;
503
-			$matches=array();
502
+			$ok = true;
503
+			$matches = array();
504 504
 			preg_match_all('/preg_grep\(.*\$/', $filecontent, $matches, PREG_SET_ORDER);
505 505
 			foreach ($matches as $key => $val) {
506 506
 				if (strpos($val[0], 'preg_quote') === false) {
507
-					$ok=false;
507
+					$ok = false;
508 508
 					break;
509 509
 				}
510 510
 			}
@@ -512,62 +512,62 @@  discard block
 block discarded – undo
512 512
 
513 513
 
514 514
 			// Test we don't have "if ($resql >"
515
-			$ok=true;
516
-			$matches=array();
515
+			$ok = true;
516
+			$matches = array();
517 517
 			preg_match_all('/if \(\$resql >/', $filecontent, $matches, PREG_SET_ORDER);
518 518
 			foreach ($matches as $key => $val) {
519
-				$ok=false;
519
+				$ok = false;
520 520
 				break;
521 521
 			}
522 522
 			$this->assertTrue($ok, 'Found a if $resql with a > operator (when $resql is a boolean or resource) in file '.$file['relativename'].'. Please remove the > ... part.');
523 523
 
524 524
 			// Test we don't have empty($user->hasRight
525
-			$ok=true;
526
-			$matches=array();
525
+			$ok = true;
526
+			$matches = array();
527 527
 			preg_match_all('/empty\(\$user->hasRight/', $filecontent, $matches, PREG_SET_ORDER);
528 528
 			foreach ($matches as $key => $val) {
529
-				$ok=false;
529
+				$ok = false;
530 530
 				break;
531 531
 			}
532 532
 			$this->assertTrue($ok, 'Found code empty($user->hasRight in file '.$file['relativename'].'. empty() must not be used on a var not on a function.');
533 533
 
534 534
 			// Test we don't have empty(DolibarrApiAccess::$user->hasRight
535
-			$ok=true;
536
-			$matches=array();
535
+			$ok = true;
536
+			$matches = array();
537 537
 			preg_match_all('/empty\(DolibarrApiAccess::\$user->hasRight/', $filecontent, $matches, PREG_SET_ORDER);
538 538
 			foreach ($matches as $key => $val) {
539
-				$ok=false;
539
+				$ok = false;
540 540
 				break;
541 541
 			}
542 542
 			$this->assertTrue($ok, 'Found code empty(DolibarrApiAccess::$user->hasRight in file '.$file['relativename'].'. empty() must not be used on a var not on a function.');
543 543
 
544 544
 			// Test we don't have empty($user->hasRight
545
-			$ok=true;
546
-			$matches=array();
545
+			$ok = true;
546
+			$matches = array();
547 547
 			preg_match_all('/empty\(getDolGlobal/', $filecontent, $matches, PREG_SET_ORDER);
548 548
 			foreach ($matches as $key => $val) {
549
-				$ok=false;
549
+				$ok = false;
550 550
 				break;
551 551
 			}
552 552
 			$this->assertTrue($ok, 'Found code empty(getDolGlobal... in file '.$file['relativename'].'. empty() must be used on a var not on a function.');
553 553
 
554 554
 			// Test we don't have @var array(
555
-			$ok=true;
556
-			$matches=array();
555
+			$ok = true;
556
+			$matches = array();
557 557
 			preg_match_all('/@var\s+array\(/', $filecontent, $matches, PREG_SET_ORDER);
558 558
 			foreach ($matches as $key => $val) {
559
-				$ok=false;
559
+				$ok = false;
560 560
 				break;
561 561
 			}
562 562
 			$this->assertTrue($ok, 'Found a declaration @var array() instead of @var array in file '.$file['relativename'].'.');
563 563
 
564 564
 
565 565
 			// Test we don't have CURDATE()
566
-			$ok=true;
567
-			$matches=array();
566
+			$ok = true;
567
+			$matches = array();
568 568
 			preg_match_all('/CURDATE\(\)/', $filecontent, $matches, PREG_SET_ORDER);
569 569
 			foreach ($matches as $key => $val) {
570
-				$ok=false;
570
+				$ok = false;
571 571
 				break;
572 572
 			}
573 573
 			$this->assertTrue($ok, 'Found a CURDATE\(\) into code. Do not use this SQL method in file '.$file['relativename'].'. You must use the PHP function dol_now() instead.');
Please login to merge, or discard this patch.