Completed
Branch develop (3d98b7)
by
unknown
17:59
created
test/phpunit/ActionCommTest.php 1 patch
Spacing   +36 added lines, -36 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('agenda')) {
@@ -74,28 +74,28 @@  discard block
 block discarded – undo
74 74
 	 */
75 75
 	public function testActionCommCreate()
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 83
 		$now = dol_now();
84 84
 
85
-		$localobject=new ActionComm($db);
85
+		$localobject = new ActionComm($db);
86 86
 
87
-		$localobject->type_code   = 'AC_OTH_AUTO';		// Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...)
87
+		$localobject->type_code   = 'AC_OTH_AUTO'; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...)
88 88
 		$localobject->code        = 'AC_PHPUNITTEST';
89 89
 		$localobject->label       = 'This is a description';
90 90
 		$localobject->note_private = 'This is note';
91 91
 		$localobject->fk_project  = 0;
92 92
 		$localobject->datep       = $now;
93 93
 		$localobject->datef       = $now;
94
-		$localobject->percentage  = -1;   // Not applicable
94
+		$localobject->percentage  = -1; // Not applicable
95 95
 		$localobject->socid       = 0;
96 96
 		$localobject->contactid   = 0;
97
-		$localobject->authorid    = $user->id;   // User saving action
98
-		$localobject->userownerid = $user->id;	// Owner of action
97
+		$localobject->authorid    = $user->id; // User saving action
98
+		$localobject->userownerid = $user->id; // Owner of action
99 99
 		// Fields when action is en email (content should be added into note)
100 100
 		/*$localobject->email_msgid = $object->email_msgid;
101 101
 		 $localobject->email_from  = $object->email_from;
@@ -127,14 +127,14 @@  discard block
 block discarded – undo
127 127
 	 */
128 128
 	public function testActionCommFetch($id)
129 129
 	{
130
-		global $conf,$user,$langs,$db;
131
-		$conf=$this->savconf;
132
-		$user=$this->savuser;
133
-		$langs=$this->savlangs;
134
-		$db=$this->savdb;
130
+		global $conf, $user, $langs, $db;
131
+		$conf = $this->savconf;
132
+		$user = $this->savuser;
133
+		$langs = $this->savlangs;
134
+		$db = $this->savdb;
135 135
 
136
-		$localobject=new ActionComm($db);
137
-		$result=$localobject->fetch($id);
136
+		$localobject = new ActionComm($db);
137
+		$result = $localobject->fetch($id);
138 138
 
139 139
 		$this->assertLessThan($result, 0);
140 140
 		print __METHOD__." id=".$id." result=".$result."\n";
@@ -152,14 +152,14 @@  discard block
 block discarded – undo
152 152
 	 */
153 153
 	public function testActionCommUpdate($localobject)
154 154
 	{
155
-		global $conf,$user,$langs,$db;
156
-		$conf=$this->savconf;
157
-		$user=$this->savuser;
158
-		$langs=$this->savlangs;
159
-		$db=$this->savdb;
155
+		global $conf, $user, $langs, $db;
156
+		$conf = $this->savconf;
157
+		$user = $this->savuser;
158
+		$langs = $this->savlangs;
159
+		$db = $this->savdb;
160 160
 
161
-		$localobject->label='New label';
162
-		$result=$localobject->update($user);
161
+		$localobject->label = 'New label';
162
+		$result = $localobject->update($user);
163 163
 
164 164
 		$this->assertLessThan($result, 0);
165 165
 		print __METHOD__." id=".$localobject->id." result=".$result."\n";
@@ -177,15 +177,15 @@  discard block
 block discarded – undo
177 177
 	 */
178 178
 	public function testActionCommDelete($id)
179 179
 	{
180
-		global $conf,$user,$langs,$db;
181
-		$conf=$this->savconf;
182
-		$user=$this->savuser;
183
-		$langs=$this->savlangs;
184
-		$db=$this->savdb;
185
-
186
-		$localobject=new ActionComm($db);
187
-		$result=$localobject->fetch($id);
188
-		$result=$localobject->delete($user);
180
+		global $conf, $user, $langs, $db;
181
+		$conf = $this->savconf;
182
+		$user = $this->savuser;
183
+		$langs = $this->savlangs;
184
+		$db = $this->savdb;
185
+
186
+		$localobject = new ActionComm($db);
187
+		$result = $localobject->fetch($id);
188
+		$result = $localobject->delete($user);
189 189
 
190 190
 		print __METHOD__." id=".$id." result=".$result."\n";
191 191
 		$this->assertLessThan($result, 0);
Please login to merge, or discard this patch.
test/phpunit/LangTest.php 1 patch
Spacing   +43 added lines, -43 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,47 +87,47 @@  discard block
 block discarded – undo
87 87
 	 */
88 88
 	public function testLang()
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/class/translate.class.php';
97 97
 
98 98
 		$filesarray = scandir(DOL_DOCUMENT_ROOT.'/langs');
99 99
 		foreach ($filesarray as $key => $code) {
100
-			if (! preg_match('/^[a-z]+_[A-Z]+$/', $code)) {
100
+			if (!preg_match('/^[a-z]+_[A-Z]+$/', $code)) {
101 101
 				continue;
102 102
 			}
103 103
 
104 104
 			print 'Check language file for lang code='.$code."\n";
105
-			$tmplangs=new Translate('', $conf);
106
-			$langcode=$code;
105
+			$tmplangs = new Translate('', $conf);
106
+			$langcode = $code;
107 107
 			$tmplangs->setDefaultLang($langcode);
108 108
 			$tmplangs->load("main");
109 109
 
110
-			$result=$tmplangs->transnoentitiesnoconv("FONTFORPDF");
110
+			$result = $tmplangs->transnoentitiesnoconv("FONTFORPDF");
111 111
 			print __METHOD__." FONTFORPDF=".$result."\n";
112 112
 			$this->assertTrue(in_array($result, array('msungstdlight', 'stsongstdlight', 'helvetica', 'DejaVuSans', 'cid0jp', 'cid0kr', 'freemono', 'freeserif')), 'Error bad value '.$result.' for FONTFORPDF in main.lang file '.$code);
113 113
 
114
-			$result=$tmplangs->transnoentitiesnoconv("DIRECTION");
114
+			$result = $tmplangs->transnoentitiesnoconv("DIRECTION");
115 115
 			print __METHOD__." DIRECTION=".$result."\n";
116 116
 			$this->assertTrue(in_array($result, array('rtl', 'ltr')), 'Error bad value for DIRECTION in main.lang file '.$code);
117 117
 
118
-			$result=$tmplangs->transnoentitiesnoconv("SeparatorDecimal");
118
+			$result = $tmplangs->transnoentitiesnoconv("SeparatorDecimal");
119 119
 			print __METHOD__." SeparatorDecimal=".$result."\n";
120
-			$this->assertTrue(in_array($result, array('.',',','/',' ','','None')), 'Error on decimal separator for lang code '.$code);	// Note that ، that is coma for RTL languages is not supported
120
+			$this->assertTrue(in_array($result, array('.', ',', '/', ' ', '', 'None')), 'Error on decimal separator for lang code '.$code); // Note that ، that is coma for RTL languages is not supported
121 121
 
122
-			$result=$tmplangs->transnoentitiesnoconv("SeparatorThousand");
122
+			$result = $tmplangs->transnoentitiesnoconv("SeparatorThousand");
123 123
 			print __METHOD__." SeparatorThousand=".$result."\n";
124
-			$this->assertTrue(in_array($result, array('.',',','/',' ','','\'','None','Space')), 'Error on thousand separator for lang code '.$code);	// Note that ، that is coma for RTL languages is not supported
124
+			$this->assertTrue(in_array($result, array('.', ',', '/', ' ', '', '\'', 'None', 'Space')), 'Error on thousand separator for lang code '.$code); // Note that ، that is coma for RTL languages is not supported
125 125
 
126 126
 			// Test java string contains only d,M,y,/,-,. and not m,...
127
-			$result=$tmplangs->transnoentitiesnoconv("FormatDateShortJava");
127
+			$result = $tmplangs->transnoentitiesnoconv("FormatDateShortJava");
128 128
 			print __METHOD__." FormatDateShortJava=".$result."\n";
129 129
 			$this->assertRegExp('/^[dMy\/\-\.]+$/', $result, 'FormatDateShortJava KO for lang code '.$code);
130
-			$result=$tmplangs->trans("FormatDateShortJavaInput");
130
+			$result = $tmplangs->trans("FormatDateShortJavaInput");
131 131
 			print __METHOD__." FormatDateShortJavaInput=".$result."\n";
132 132
 			$this->assertRegExp('/^[dMy\/\-\.]+$/', $result, 'FormatDateShortJavaInput KO for lang code '.$code);
133 133
 
@@ -136,26 +136,26 @@  discard block
 block discarded – undo
136 136
 			print "Check also some syntax rules into the language file\n";
137 137
 			$filesarray2 = scandir(DOL_DOCUMENT_ROOT.'/langs/'.$code);
138 138
 			foreach ($filesarray2 as $key => $file) {
139
-				if (! preg_match('/\.lang$/', $file)) {
139
+				if (!preg_match('/\.lang$/', $file)) {
140 140
 					continue;
141 141
 				}
142 142
 
143 143
 				//print 'Check lang file '.$file."\n";
144
-				$filecontent=file_get_contents(DOL_DOCUMENT_ROOT.'/langs/'.$code.'/'.$file);
144
+				$filecontent = file_get_contents(DOL_DOCUMENT_ROOT.'/langs/'.$code.'/'.$file);
145 145
 
146
-				$result=preg_match('/=--$/m', $filecontent);	// A special % char we don't want. We want the common one.
146
+				$result = preg_match('/=--$/m', $filecontent); // A special % char we don't want. We want the common one.
147 147
 				//print __METHOD__." Result for checking we don't have bad percent char = ".$result."\n";
148 148
 				$this->assertTrue($result == 0, 'Found a translation KEY=-- into file '.$code.'/'.$file.'. We probably want Key=- instead.');
149 149
 
150
-				$result=strpos($filecontent, '%');	// A special % char we don't want. We want the common one.
150
+				$result = strpos($filecontent, '%'); // A special % char we don't want. We want the common one.
151 151
 				//print __METHOD__." Result for checking we don't have bad percent char = ".$result."\n";
152 152
 				$this->assertTrue($result === false, 'Found a bad percent char % instead of % into file '.$code.'/'.$file);
153 153
 
154
-				$result=preg_match('/%n/m', $filecontent);	// A sequence of char we don't want
154
+				$result = preg_match('/%n/m', $filecontent); // A sequence of char we don't want
155 155
 				//print __METHOD__." Result for checking we don't have bad percent char = ".$result."\n";
156 156
 				$this->assertTrue($result == 0, 'Found a sequence %n into the translation file '.$code.'/'.$file.'. We probably want %s');
157 157
 
158
-				$result=preg_match('/<<<<</m', $filecontent);	// A sequence of char we don't want
158
+				$result = preg_match('/<<<<</m', $filecontent); // A sequence of char we don't want
159 159
 				//print __METHOD__." Result for checking we don't have bad percent char = ".$result."\n";
160 160
 				$this->assertTrue($result == 0, 'Found a sequence <<<<< into the translation file '.$code.'/'.$file.'. Probably a bad merge of code were done.');
161 161
 			}
@@ -171,14 +171,14 @@  discard block
 block discarded – undo
171 171
 	 */
172 172
 	public function testTrans()
173 173
 	{
174
-		global $conf,$user,$langs,$db;
175
-		$conf=$this->savconf;
176
-		$user=$this->savuser;
177
-		$langs=$this->savlangs;
178
-		$db=$this->savdb;
179
-
180
-		$tmplangs=new Translate('', $conf);
181
-		$langcode='en_US';
174
+		global $conf, $user, $langs, $db;
175
+		$conf = $this->savconf;
176
+		$user = $this->savuser;
177
+		$langs = $this->savlangs;
178
+		$db = $this->savdb;
179
+
180
+		$tmplangs = new Translate('', $conf);
181
+		$langcode = 'en_US';
182 182
 		$tmplangs->setDefaultLang($langcode);
183 183
 		$tmplangs->load("main");
184 184
 
Please login to merge, or discard this patch.
test/phpunit/FilesLibTest.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
  *		\remarks	To run this script as CLI:  phpunit filename.php
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';
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 	 */
58 58
 	public function testDolBasename()
59 59
 	{
60
-		global $conf,$user,$langs,$db;
60
+		global $conf, $user, $langs, $db;
61 61
 		$conf = $this->savconf;
62 62
 		$user = $this->savuser;
63 63
 		$langs = $this->savlangs;
@@ -71,11 +71,11 @@  discard block
 block discarded – undo
71 71
 		print __METHOD__." result=".$result."\n";
72 72
 		$this->assertEquals('a_file', $result);
73 73
 
74
-		$result = dol_basename('adir/νεο');    // With cyrillic data. Here basename fails to return correct value
74
+		$result = dol_basename('adir/νεο'); // With cyrillic data. Here basename fails to return correct value
75 75
 		print __METHOD__." result=".$result."\n";
76 76
 		$this->assertEquals('νεο', $result);
77 77
 
78
-		$result = dol_basename('adir/νεο/');    // With cyrillic data. Here basename fails to return correct value
78
+		$result = dol_basename('adir/νεο/'); // With cyrillic data. Here basename fails to return correct value
79 79
 		print __METHOD__." result=".$result."\n";
80 80
 		$this->assertEquals('νεο', $result);
81 81
 	}
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	 */
89 89
 	public function testDolCountNbOfLine()
90 90
 	{
91
-		global $conf,$user,$langs,$db;
91
+		global $conf, $user, $langs, $db;
92 92
 		$conf = $this->savconf;
93 93
 		$user = $this->savuser;
94 94
 		$langs = $this->savlangs;
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 	 */
110 110
 	public function testDolIsFileDir()
111 111
 	{
112
-		global $conf,$user,$langs,$db;
112
+		global $conf, $user, $langs, $db;
113 113
 		$conf = $this->savconf;
114 114
 		$user = $this->savuser;
115 115
 		$langs = $this->savlangs;
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	*/
136 136
 	public function testDolOther()
137 137
 	{
138
-		global $conf,$user,$langs,$db;
138
+		global $conf, $user, $langs, $db;
139 139
 		$conf = $this->savconf;
140 140
 		$user = $this->savuser;
141 141
 		$langs = $this->savlangs;
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 	 */
167 167
 	public function testDolMimeType()
168 168
 	{
169
-		global $conf,$user,$langs,$db;
169
+		global $conf, $user, $langs, $db;
170 170
 		$conf = $this->savconf;
171 171
 		$user = $this->savuser;
172 172
 		$langs = $this->savlangs;
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 	 */
213 213
 	public function testDolDeleteDir()
214 214
 	{
215
-		global $conf,$user,$langs,$db;
215
+		global $conf, $user, $langs, $db;
216 216
 		$conf = $this->savconf;
217 217
 		$user = $this->savuser;
218 218
 		$langs = $this->savlangs;
@@ -222,13 +222,13 @@  discard block
 block discarded – undo
222 222
 		$dirout2 = $conf->admin->dir_temp.'/test2';
223 223
 
224 224
 		$count = 0;
225
-		$result = dol_delete_dir_recursive($dirout, $count);	// If it has no permission to delete, it will fails as if dir does not exists, so we can't test it
225
+		$result = dol_delete_dir_recursive($dirout, $count); // If it has no permission to delete, it will fails as if dir does not exists, so we can't test it
226 226
 		print __METHOD__." result=".$result."\n";
227 227
 		$this->assertGreaterThanOrEqual(0, $result);
228 228
 
229 229
 		$count = 0;
230 230
 		$countdeleted = 0;
231
-		$result = dol_delete_dir_recursive($dirout, $count, 1, 0, $countdeleted);	// If it has no permission to delete, it will fails as if dir does not exists, so we can't test it
231
+		$result = dol_delete_dir_recursive($dirout, $count, 1, 0, $countdeleted); // If it has no permission to delete, it will fails as if dir does not exists, so we can't test it
232 232
 		print __METHOD__." result=".$result."\n";
233 233
 		$this->assertGreaterThanOrEqual(0, $result);
234 234
 		$this->assertGreaterThanOrEqual(0, $countdeleted);
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 		dol_mkdir($dirout2);
237 237
 		$count = 0;
238 238
 		$countdeleted = 0;
239
-		$result = dol_delete_dir_recursive($dirout2, $count, 1, 0, $countdeleted);	// If it has no permission to delete, it will fails as if dir does not exists, so we can't test it
239
+		$result = dol_delete_dir_recursive($dirout2, $count, 1, 0, $countdeleted); // If it has no permission to delete, it will fails as if dir does not exists, so we can't test it
240 240
 		print __METHOD__." result=".$result."\n";
241 241
 		$this->assertGreaterThanOrEqual(1, $result);
242 242
 		$this->assertGreaterThanOrEqual(1, $countdeleted);
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 	 */
251 251
 	public function testDolCopyMoveDelete()
252 252
 	{
253
-		global $conf,$user,$langs,$db;
253
+		global $conf, $user, $langs, $db;
254 254
 		$conf = $this->savconf;
255 255
 		$user = $this->savuser;
256 256
 		$langs = $this->savlangs;
@@ -260,21 +260,21 @@  discard block
 block discarded – undo
260 260
 
261 261
 		$result = dol_copy($file, '/adir/that/does/not/exists/file.csv');
262 262
 		print __METHOD__." result=".$result."\n";
263
-		$this->assertLessThan(0, $result, "$result".'copy dir that does not exists');    // We should have error
263
+		$this->assertLessThan(0, $result, "$result".'copy dir that does not exists'); // We should have error
264 264
 
265 265
 		$result = dol_copy($file, $conf->admin->dir_temp.'/file.csv', 0, 1);
266 266
 		print __METHOD__." result=".$result."\n";
267
-		$this->assertGreaterThanOrEqual(1, $result, 'copy file ('.$file.') into a dir that exists ('.$conf->admin->dir_temp.'/file.csv)');    // Should be 1
267
+		$this->assertGreaterThanOrEqual(1, $result, 'copy file ('.$file.') into a dir that exists ('.$conf->admin->dir_temp.'/file.csv)'); // Should be 1
268 268
 
269 269
 		// Again to test with overwriting=0
270 270
 		$result = dol_copy($file, $conf->admin->dir_temp.'/file.csv', 0, 0);
271 271
 		print __METHOD__." result=".$result."\n";
272
-		$this->assertEquals(0, $result, 'copy destination already exists, no overwrite');    // Should be 0
272
+		$this->assertEquals(0, $result, 'copy destination already exists, no overwrite'); // Should be 0
273 273
 
274 274
 		// Again to test with overwriting=1
275 275
 		$result = dol_copy($file, $conf->admin->dir_temp.'/file.csv', 0, 1);
276 276
 		print __METHOD__." result=".$result."\n";
277
-		$this->assertGreaterThanOrEqual(1, $result, 'copy destination already exists, overwrite');    // Should be 1
277
+		$this->assertGreaterThanOrEqual(1, $result, 'copy destination already exists, overwrite'); // Should be 1
278 278
 
279 279
 		// To test a move that should work
280 280
 		$result = dol_move($conf->admin->dir_temp.'/file.csv', $conf->admin->dir_temp.'/file2.csv', 0, 1);
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
 		// Test copy with special char / delete with blob
305 305
 		$result = dol_copy($file, $conf->admin->dir_temp.'/file with [x] and é.csv', 0, 1);
306 306
 		print __METHOD__." result=".$result."\n";
307
-		$this->assertGreaterThanOrEqual(1, $result, 'copy file with special chars, overwrite');    // Should be 1
307
+		$this->assertGreaterThanOrEqual(1, $result, 'copy file with special chars, overwrite'); // Should be 1
308 308
 
309 309
 		// Try to delete using a glob criteria
310 310
 		$result = dol_delete_file($conf->admin->dir_temp.'/file with [x]*é.csv');
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 	 */
320 320
 	public function testDolCompressUnCompress()
321 321
 	{
322
-		global $conf,$user,$langs,$db;
322
+		global $conf, $user, $langs, $db;
323 323
 		$conf = $this->savconf;
324 324
 		$user = $this->savuser;
325 325
 		$langs = $this->savlangs;
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
 	 */
408 408
 	public function testDolCheckSecureAccessDocument()
409 409
 	{
410
-		global $conf,$user,$langs,$db;
410
+		global $conf, $user, $langs, $db;
411 411
 		$conf = $this->savconf;
412 412
 		$user = $this->savuser;
413 413
 		$langs = $this->savlangs;
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
 		// Check access to SPECIMEN
428 428
 		$user->rights->facture->lire = 0;
429 429
 		$user->rights->facture->creer = 0;
430
-		$filename = 'SPECIMEN.pdf';             // Filename relative to module part
430
+		$filename = 'SPECIMEN.pdf'; // Filename relative to module part
431 431
 		$result = dol_check_secure_access_document('facture', $filename, 0, '', '', 'read');
432 432
 		$this->assertEquals(1, $result['accessallowed'], "Check access allowed to '$filename'".json_encode($result));
433 433
 
@@ -435,32 +435,32 @@  discard block
 block discarded – undo
435 435
 		// Check read permission
436 436
 		$user->rights->facture->lire = 1;
437 437
 		$user->rights->facture->creer = 1;
438
-		$filename = 'FA010101/FA010101.pdf';    // Filename relative to module part
438
+		$filename = 'FA010101/FA010101.pdf'; // Filename relative to module part
439 439
 		$result = dol_check_secure_access_document('facture', $filename, 0, '', '', 'read');
440 440
 		$this->assertEquals(1, $result['accessallowed'], "Check access allowed to '$filename'".json_encode($result));
441 441
 
442 442
 		$user->rights->facture->lire = 0;
443 443
 		$user->rights->facture->creer = 0;
444
-		$filename = 'FA010101/FA010101.pdf';    // Filename relative to module part
444
+		$filename = 'FA010101/FA010101.pdf'; // Filename relative to module part
445 445
 		$result = dol_check_secure_access_document('facture', $filename, 0, '', '', 'read');
446 446
 		$this->assertEquals(0, $result['accessallowed'], "Check access denied to '$filename':".json_encode($result));
447 447
 
448 448
 		// Check write permission
449 449
 		$user->rights->facture->lire = 0;
450 450
 		$user->rights->facture->creer = 0;
451
-		$filename = 'FA010101/FA010101.pdf';    // Filename relative to module part
451
+		$filename = 'FA010101/FA010101.pdf'; // Filename relative to module part
452 452
 		$result = dol_check_secure_access_document('facture', $filename, 0, '', '', 'write');
453 453
 		$this->assertEquals(0, $result['accessallowed']);
454 454
 
455 455
 		$user->rights->facture->lire = 1;
456 456
 		$user->rights->facture->creer = 1;
457
-		$filename = 'FA010101/FA010101.pdf';    // Filename relative to module part
457
+		$filename = 'FA010101/FA010101.pdf'; // Filename relative to module part
458 458
 		$result = dol_check_secure_access_document('facture', $filename, 0, '', '', 'write');
459 459
 		$this->assertEquals(1, $result['accessallowed']);
460 460
 
461 461
 		$user->rights->facture->lire = 1;
462 462
 		$user->rights->facture->creer = 0;
463
-		$filename = 'FA010101/FA010101.pdf';    // Filename relative to module part
463
+		$filename = 'FA010101/FA010101.pdf'; // Filename relative to module part
464 464
 		$result = dol_check_secure_access_document('facture', $filename, 0, '', '', 'write');
465 465
 		$this->assertEquals(0, $result['accessallowed']);
466 466
 
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
 	 */
478 478
 	public function testDolDirMove()
479 479
 	{
480
-		global $conf,$user,$langs,$db;
480
+		global $conf, $user, $langs, $db;
481 481
 		$conf = $this->savconf;
482 482
 		$user = $this->savuser;
483 483
 		$langs = $this->savlangs;
Please login to merge, or discard this patch.
test/phpunit/ProductTest.php 1 patch
Spacing   +37 added lines, -37 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
 
60 60
 		if (!isModEnabled('product')) {
61 61
 			print __METHOD__." Module Product must be enabled.\n";
@@ -75,15 +75,15 @@  discard block
 block discarded – undo
75 75
 	 */
76 76
 	public function testProductCreate()
77 77
 	{
78
-		global $conf,$user,$langs,$db;
79
-		$conf=$this->savconf;
80
-		$user=$this->savuser;
81
-		$langs=$this->savlangs;
82
-		$db=$this->savdb;
78
+		global $conf, $user, $langs, $db;
79
+		$conf = $this->savconf;
80
+		$user = $this->savuser;
81
+		$langs = $this->savlangs;
82
+		$db = $this->savdb;
83 83
 
84
-		$localobject=new Product($db);
84
+		$localobject = new Product($db);
85 85
 		$localobject->initAsSpecimen();
86
-		$result=$localobject->create($user);
86
+		$result = $localobject->create($user);
87 87
 
88 88
 		print __METHOD__." result=".$result."\n";
89 89
 		$this->assertLessThanOrEqual($result, 0, "Creation of product");
@@ -102,14 +102,14 @@  discard block
 block discarded – undo
102 102
 	 */
103 103
 	public function testProductFetch($id)
104 104
 	{
105
-		global $conf,$user,$langs,$db;
106
-		$conf=$this->savconf;
107
-		$user=$this->savuser;
108
-		$langs=$this->savlangs;
109
-		$db=$this->savdb;
110
-
111
-		$localobject=new Product($db);
112
-		$result=$localobject->fetch($id);
105
+		global $conf, $user, $langs, $db;
106
+		$conf = $this->savconf;
107
+		$user = $this->savuser;
108
+		$langs = $this->savlangs;
109
+		$db = $this->savdb;
110
+
111
+		$localobject = new Product($db);
112
+		$result = $localobject->fetch($id);
113 113
 		print __METHOD__." id=".$id." result=".$result."\n";
114 114
 		$this->assertLessThan($result, 0);
115 115
 
@@ -127,15 +127,15 @@  discard block
 block discarded – undo
127 127
 	 */
128 128
 	public function testProductUpdate($localobject)
129 129
 	{
130
-		global $conf,$user,$langs,$db;
131
-		$conf=$this->savconf;
132
-		$user=$this->savuser;
133
-		$langs=$this->savlangs;
134
-		$db=$this->savdb;
130
+		global $conf, $user, $langs, $db;
131
+		$conf = $this->savconf;
132
+		$user = $this->savuser;
133
+		$langs = $this->savlangs;
134
+		$db = $this->savdb;
135 135
 
136 136
 		$localobject->note_public = 'New public note after update';
137 137
 		$localobject->note_private = 'New private note after update';
138
-		$result=$localobject->update($localobject->id, $user);
138
+		$result = $localobject->update($localobject->id, $user);
139 139
 		print __METHOD__." id=".$localobject->id." result=".$result."\n";
140 140
 		$this->assertLessThan($result, 0, 'Error '.$localobject->error);
141 141
 
@@ -153,11 +153,11 @@  discard block
 block discarded – undo
153 153
 	 */
154 154
 	public function testProductOther($localobject)
155 155
 	{
156
-		global $conf,$user,$langs,$db;
157
-		$conf=$this->savconf;
158
-		$user=$this->savuser;
159
-		$langs=$this->savlangs;
160
-		$db=$this->savdb;
156
+		global $conf, $user, $langs, $db;
157
+		$conf = $this->savconf;
158
+		$user = $this->savuser;
159
+		$langs = $this->savlangs;
160
+		$db = $this->savdb;
161 161
 
162 162
 		$this->assertEquals(0, 0);
163 163
 
@@ -175,16 +175,16 @@  discard block
 block discarded – undo
175 175
 	 */
176 176
 	public function testProductDelete($id)
177 177
 	{
178
-		global $conf,$user,$langs,$db;
179
-		$conf=$this->savconf;
180
-		$user=$this->savuser;
181
-		$langs=$this->savlangs;
182
-		$db=$this->savdb;
178
+		global $conf, $user, $langs, $db;
179
+		$conf = $this->savconf;
180
+		$user = $this->savuser;
181
+		$langs = $this->savlangs;
182
+		$db = $this->savdb;
183 183
 
184
-		$localobject=new Product($db);
185
-		$result=$localobject->fetch($id);
184
+		$localobject = new Product($db);
185
+		$result = $localobject->fetch($id);
186 186
 
187
-		$result=$localobject->delete($user);
187
+		$result = $localobject->delete($user);
188 188
 		print __METHOD__." id=".$id." result=".$result."\n";
189 189
 		$this->assertLessThan($result, 0);
190 190
 
Please login to merge, or discard this patch.
test/phpunit/ProfidLibTest.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -23,42 +23,42 @@  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,$mysoc;
26
+global $conf, $user, $langs, $db, $mysoc;
27 27
 //define('TEST_DB_FORCE_TYPE','mysql');	// This is to force using mysql driver
28 28
 //require_once 'PHPUnit/Autoload.php';
29 29
 require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
30 30
 require_once dirname(__FILE__).'/../../htdocs/core/lib/profid.lib.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
 
@@ -80,11 +80,11 @@  discard block
 block discarded – undo
80 80
 	public function testIsValidLuhn()
81 81
 	{
82 82
 		// Tests OK
83
-		$this->assertTrue(isValidLuhn(972487086));		// int
84
-		$this->assertTrue(isValidLuhn("972487086"));	// string
83
+		$this->assertTrue(isValidLuhn(972487086)); // int
84
+		$this->assertTrue(isValidLuhn("972487086")); // string
85 85
 		// Tests KO
86
-		$this->assertFalse(isValidLuhn(123456789));		// int
87
-		$this->assertFalse(isValidLuhn("123456789"));	// string
86
+		$this->assertFalse(isValidLuhn(123456789)); // int
87
+		$this->assertFalse(isValidLuhn("123456789")); // string
88 88
 	}
89 89
 
90 90
 
@@ -97,11 +97,11 @@  discard block
 block discarded – undo
97 97
 	{
98 98
 		// Tests OK
99 99
 		$this->assertTrue(isValidSiren("732829320"));
100
-		$this->assertTrue(isValidSiren(" 732 829 320 "));	// formatted with spaces
100
+		$this->assertTrue(isValidSiren(" 732 829 320 ")); // formatted with spaces
101 101
 		// Tests NOK
102
-		$this->assertFalse(isValidSiren("123456ABC"));		// not numeric
103
-		$this->assertFalse(isValidSiren("43336767"));		// Luhn test OK but length != 9
104
-		$this->assertFalse(isValidSiren("123456789"));		// 9 digits but Luhn test KO
102
+		$this->assertFalse(isValidSiren("123456ABC")); // not numeric
103
+		$this->assertFalse(isValidSiren("43336767")); // Luhn test OK but length != 9
104
+		$this->assertFalse(isValidSiren("123456789")); // 9 digits but Luhn test KO
105 105
 	}
106 106
 
107 107
 
@@ -115,12 +115,12 @@  discard block
 block discarded – undo
115 115
 	{
116 116
 		// Tests OK
117 117
 		$this->assertTrue(isValidSiret("73282932000074"));
118
-		$this->assertTrue(isValidSiret(" 732 829 320 00074 "));		// formatted with spaces
119
-		$this->assertTrue(isValidSiret("35600000049837"));			// Specific cases of "La Poste" companies
118
+		$this->assertTrue(isValidSiret(" 732 829 320 00074 ")); // formatted with spaces
119
+		$this->assertTrue(isValidSiret("35600000049837")); // Specific cases of "La Poste" companies
120 120
 		// Tests NOK
121
-		$this->assertFalse(isValidSiret("123456ABC12345"));			// not numeric
122
-		$this->assertFalse(isValidSiret("3624679471379"));			// Luhn test OK but length != 14
123
-		$this->assertFalse(isValidSiret("12345678912345"));			// 14 digits but Luhn test KO
121
+		$this->assertFalse(isValidSiret("123456ABC12345")); // not numeric
122
+		$this->assertFalse(isValidSiret("3624679471379")); // Luhn test OK but length != 14
123
+		$this->assertFalse(isValidSiret("12345678912345")); // 14 digits but Luhn test KO
124 124
 	}
125 125
 
126 126
 
@@ -134,10 +134,10 @@  discard block
 block discarded – undo
134 134
 	{
135 135
 		// Tests OK
136 136
 		$this->assertTrue(isValidTinForPT("123456789"));
137
-		$this->assertTrue(isValidTinForPT(" 123 456 789 "));		// formatted with spaces
137
+		$this->assertTrue(isValidTinForPT(" 123 456 789 ")); // formatted with spaces
138 138
 		// Tests NOK
139
-		$this->assertFalse(isValidTinForPT("123456ABC"));			// not numeric
140
-		$this->assertFalse(isValidTinForPT("12345678"));			// length != 9
139
+		$this->assertFalse(isValidTinForPT("123456ABC")); // not numeric
140
+		$this->assertFalse(isValidTinForPT("12345678")); // length != 9
141 141
 	}
142 142
 
143 143
 
@@ -151,10 +151,10 @@  discard block
 block discarded – undo
151 151
 	{
152 152
 		// Tests OK
153 153
 		$this->assertTrue(isValidTinForDZ("123456789123456"));
154
-		$this->assertTrue(isValidTinForDZ(" 12345 67891 23456 "));		// formatted with spaces
154
+		$this->assertTrue(isValidTinForDZ(" 12345 67891 23456 ")); // formatted with spaces
155 155
 		// Tests NOK
156
-		$this->assertFalse(isValidTinForDZ("123456789123ABC"));			// not numeric
157
-		$this->assertFalse(isValidTinForDZ("123456789123"));			// length != 15
156
+		$this->assertFalse(isValidTinForDZ("123456789123ABC")); // not numeric
157
+		$this->assertFalse(isValidTinForDZ("123456789123")); // length != 15
158 158
 	}
159 159
 
160 160
 
@@ -170,10 +170,10 @@  discard block
 block discarded – undo
170 170
 		$this->assertTrue(isValidTinForBE("0123.123.123"));
171 171
 		$this->assertTrue(isValidTinForBE("1234.123.123"));
172 172
 		// Tests NOK
173
-		$this->assertFalse(isValidTinForBE("2345.123.123"));		// First digit shall be 0 or 1
174
-		$this->assertFalse(isValidTinForBE("1234 123 123"));		// formatted with spaces instead of dots
175
-		$this->assertFalse(isValidTinForBE("1234123123"));			// without dots formatting
176
-		$this->assertFalse(isValidTinForBE("ABCD.123.123"));		// not digits only
173
+		$this->assertFalse(isValidTinForBE("2345.123.123")); // First digit shall be 0 or 1
174
+		$this->assertFalse(isValidTinForBE("1234 123 123")); // formatted with spaces instead of dots
175
+		$this->assertFalse(isValidTinForBE("1234123123")); // without dots formatting
176
+		$this->assertFalse(isValidTinForBE("ABCD.123.123")); // not digits only
177 177
 	}
178 178
 
179 179
 	// TODO
Please login to merge, or discard this patch.
test/phpunit/BOMTest.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  * \brief   PHPUnit test for BillOfMaterials class.
24 24
  */
25 25
 
26
-global $conf,$user,$langs,$db;
26
+global $conf, $user, $langs, $db;
27 27
 //define('TEST_DB_FORCE_TYPE','mysql');	// This is to force using mysql driver
28 28
 //require_once 'PHPUnit/Autoload.php';
29 29
 require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	$user->fetch(1);
36 36
 	$user->getrights();
37 37
 }
38
-$conf->global->MAIN_DISABLE_ALL_MAILS=1;
38
+$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
39 39
 
40 40
 $langs->load("main");
41 41
 
@@ -56,15 +56,15 @@  discard block
 block discarded – undo
56 56
 	 */
57 57
 	public function testBOMCreate()
58 58
 	{
59
-		global $conf,$user,$langs,$db;
60
-		$conf=$this->savconf;
61
-		$user=$this->savuser;
62
-		$langs=$this->savlangs;
63
-		$db=$this->savdb;
59
+		global $conf, $user, $langs, $db;
60
+		$conf = $this->savconf;
61
+		$user = $this->savuser;
62
+		$langs = $this->savlangs;
63
+		$db = $this->savdb;
64 64
 
65
-		$localobject=new BOM($db);
65
+		$localobject = new BOM($db);
66 66
 		$localobject->initAsSpecimen();
67
-		$result=$localobject->create($user);
67
+		$result = $localobject->create($user);
68 68
 
69 69
 		print __METHOD__." result=".$result."\n";
70 70
 		$this->assertLessThan($result, 0);
@@ -83,15 +83,15 @@  discard block
 block discarded – undo
83 83
 	 */
84 84
 	public function testBOMDelete($id)
85 85
 	{
86
-		global $conf,$user,$langs,$db;
87
-		$conf=$this->savconf;
88
-		$user=$this->savuser;
89
-		$langs=$this->savlangs;
90
-		$db=$this->savdb;
86
+		global $conf, $user, $langs, $db;
87
+		$conf = $this->savconf;
88
+		$user = $this->savuser;
89
+		$langs = $this->savlangs;
90
+		$db = $this->savdb;
91 91
 
92
-		$localobject=new BOM($db);
93
-		$result=$localobject->fetch($id);
94
-		$result=$localobject->delete($user);
92
+		$localobject = new BOM($db);
93
+		$result = $localobject->fetch($id);
94
+		$result = $localobject->delete($user);
95 95
 
96 96
 		print __METHOD__." id=".$id." result=".$result."\n";
97 97
 		$this->assertLessThan($result, 0);
Please login to merge, or discard this patch.
test/phpunit/WebservicesThirdpartyTest.php 1 patch
Spacing   +51 added lines, -51 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
 /**
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 {
54 54
 	protected $soapclient;
55 55
 
56
-	private $ns='http://www.dolibarr.org/ns/';
56
+	private $ns = 'http://www.dolibarr.org/ns/';
57 57
 
58 58
 
59 59
 	/**
@@ -68,11 +68,11 @@  discard block
 block discarded – undo
68 68
 		parent::__construct($name);
69 69
 
70 70
 		//$this->sharedFixture
71
-		global $conf,$user,$langs,$db;
72
-		$this->savconf=$conf;
73
-		$this->savuser=$user;
74
-		$this->savlangs=$langs;
75
-		$this->savdb=$db;
71
+		global $conf, $user, $langs, $db;
72
+		$this->savconf = $conf;
73
+		$this->savuser = $user;
74
+		$this->savlangs = $langs;
75
+		$this->savdb = $db;
76 76
 
77 77
 		$WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_thirdparty.php';
78 78
 
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 		print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n";
81 81
 		$this->soapclient = new nusoap_client($WS_DOL_URL);
82 82
 		if ($this->soapclient) {
83
-			$this->soapclient->soap_defencoding='UTF-8';
83
+			$this->soapclient->soap_defencoding = 'UTF-8';
84 84
 			$this->soapclient->decodeUTF8(false);
85 85
 		}
86 86
 
@@ -97,17 +97,17 @@  discard block
 block discarded – undo
97 97
 	 */
98 98
 	public function testWSThirdpartycreateThirdParty()
99 99
 	{
100
-		global $conf,$user,$langs,$db;
101
-		$conf=$this->savconf;
102
-		$user=$this->savuser;
103
-		$langs=$this->savlangs;
104
-		$db=$this->savdb;
100
+		global $conf, $user, $langs, $db;
101
+		$conf = $this->savconf;
102
+		$user = $this->savuser;
103
+		$langs = $this->savlangs;
104
+		$db = $this->savdb;
105 105
 
106
-		$WS_METHOD  = 'createThirdParty';
106
+		$WS_METHOD = 'createThirdParty';
107 107
 
108 108
 
109 109
 		// Call the WebService method and store its result in $result.
110
-		$authentication=array(
110
+		$authentication = array(
111 111
 				'dolibarrkey'=>getDolGlobalString('WEBSERVICES_KEY'),
112 112
 				'sourceapplication'=>'DEMO',
113 113
 				'login'=>'admin',
@@ -153,16 +153,16 @@  discard block
 block discarded – undo
153 153
 		);
154 154
 
155 155
 		// Test URL
156
-		$result='';
156
+		$result = '';
157 157
 		$parameters = array('authentication'=>$authentication, 'thirdparty'=>$body);
158 158
 		print __METHOD__." call method ".$WS_METHOD."\n";
159 159
 		try {
160 160
 			$result = $this->soapclient->call($WS_METHOD, $parameters, $this->ns, '');
161 161
 		} catch (SoapFault $exception) {
162 162
 			echo $exception;
163
-			$result=0;
163
+			$result = 0;
164 164
 		}
165
-		if (! $result || !empty($result['faultstring'])) {
165
+		if (!$result || !empty($result['faultstring'])) {
166 166
 			//var_dump($soapclient);
167 167
 			print $this->soapclient->error_str;
168 168
 			print "\n<br>\n";
@@ -190,33 +190,33 @@  discard block
 block discarded – undo
190 190
 	 */
191 191
 	public function testWSThirdpartygetThirdPartyById($result)
192 192
 	{
193
-		global $conf,$user,$langs,$db;
194
-		$conf=$this->savconf;
195
-		$user=$this->savuser;
196
-		$langs=$this->savlangs;
197
-		$db=$this->savdb;
193
+		global $conf, $user, $langs, $db;
194
+		$conf = $this->savconf;
195
+		$user = $this->savuser;
196
+		$langs = $this->savlangs;
197
+		$db = $this->savdb;
198 198
 		$id = $result['id'];
199 199
 
200
-		$WS_METHOD  = 'getThirdParty';
200
+		$WS_METHOD = 'getThirdParty';
201 201
 
202 202
 		// Call the WebService method and store its result in $result.
203
-		$authentication=array(
203
+		$authentication = array(
204 204
 		'dolibarrkey'=>getDolGlobalString('WEBSERVICES_KEY'),
205 205
 		'sourceapplication'=>'DEMO',
206 206
 		'login'=>'admin',
207 207
 		'password'=>'admin',
208 208
 		'entity'=>'');
209 209
 
210
-		$result='';
210
+		$result = '';
211 211
 		$parameters = array('authentication'=>$authentication, 'id'=>$id);
212 212
 		print __METHOD__." call method ".$WS_METHOD."\n";
213 213
 		try {
214 214
 			$result = $this->soapclient->call($WS_METHOD, $parameters, $this->ns, '');
215 215
 		} catch (SoapFault $exception) {
216 216
 			echo $exception;
217
-			$result=0;
217
+			$result = 0;
218 218
 		}
219
-		if (! $result || !empty($result['faultstring'])) {
219
+		if (!$result || !empty($result['faultstring'])) {
220 220
 			//var_dump($soapclient);
221 221
 			print $this->soapclient->error_str;
222 222
 			print "\n<br>\n";
@@ -251,17 +251,17 @@  discard block
 block discarded – undo
251 251
 	 */
252 252
 	public function testWSThirdpartygetThirdPartyByRefExt($result)
253 253
 	{
254
-		global $conf,$user,$langs,$db;
255
-		$conf=$this->savconf;
256
-		$user=$this->savuser;
257
-		$langs=$this->savlangs;
258
-		$db=$this->savdb;
254
+		global $conf, $user, $langs, $db;
255
+		$conf = $this->savconf;
256
+		$user = $this->savuser;
257
+		$langs = $this->savlangs;
258
+		$db = $this->savdb;
259 259
 		$id = $result['id'];
260 260
 
261
-		$WS_METHOD  = 'getThirdParty';
261
+		$WS_METHOD = 'getThirdParty';
262 262
 
263 263
 		// Call the WebService method and store its result in $result.
264
-		$authentication=array(
264
+		$authentication = array(
265 265
 				'dolibarrkey'=>getDolGlobalString('WEBSERVICES_KEY'),
266 266
 				'sourceapplication'=>'DEMO',
267 267
 				'login'=>'admin',
@@ -269,17 +269,17 @@  discard block
 block discarded – undo
269 269
 				'entity'=>'');
270 270
 
271 271
 		// Test URL
272
-		$result='';
272
+		$result = '';
273 273
 		$parameters = array('authentication'=>$authentication, 'id'=>'', 'ref'=>'', 'ref_ext'=>'12');
274 274
 		print __METHOD__." call method ".$WS_METHOD."\n";
275 275
 		try {
276 276
 			$result = $this->soapclient->call($WS_METHOD, $parameters, $this->ns, '');
277 277
 		} catch (SoapFault $exception) {
278 278
 			echo $exception;
279
-			$result=0;
279
+			$result = 0;
280 280
 		}
281 281
 		print $this->soapclient->response;
282
-		if (! $result || !empty($result['faultstring'])) {
282
+		if (!$result || !empty($result['faultstring'])) {
283 283
 			//var_dump($soapclient);
284 284
 			print $this->soapclient->error_str;
285 285
 			print "\n<br>\n";
@@ -312,33 +312,33 @@  discard block
 block discarded – undo
312 312
 	 */
313 313
 	public function testWSThirdpartydeleteThirdPartyById($result)
314 314
 	{
315
-		global $conf,$user,$langs,$db;
316
-		$conf=$this->savconf;
317
-		$user=$this->savuser;
318
-		$langs=$this->savlangs;
319
-		$db=$this->savdb;
315
+		global $conf, $user, $langs, $db;
316
+		$conf = $this->savconf;
317
+		$user = $this->savuser;
318
+		$langs = $this->savlangs;
319
+		$db = $this->savdb;
320 320
 		$id = $result['id'];
321 321
 
322
-		$WS_METHOD  = 'deleteThirdParty';
322
+		$WS_METHOD = 'deleteThirdParty';
323 323
 
324 324
 		// Call the WebService method and store its result in $result.
325
-		$authentication=array(
325
+		$authentication = array(
326 326
 				'dolibarrkey'=>getDolGlobalString('WEBSERVICES_KEY'),
327 327
 				'sourceapplication'=>'DEMO',
328 328
 				'login'=>'admin',
329 329
 				'password'=>'admin',
330 330
 				'entity'=>'');
331 331
 
332
-		$result='';
332
+		$result = '';
333 333
 		$parameters = array('authentication'=>$authentication, 'id'=>$id, 'ref'=>'', 'ref_ext'=>'');
334 334
 		print __METHOD__." call method ".$WS_METHOD."\n";
335 335
 		try {
336 336
 			$result = $this->soapclient->call($WS_METHOD, $parameters, $this->ns, '');
337 337
 		} catch (SoapFault $exception) {
338 338
 			echo $exception;
339
-			$result=0;
339
+			$result = 0;
340 340
 		}
341
-		if (! $result || !empty($result['faultstring'])) {
341
+		if (!$result || !empty($result['faultstring'])) {
342 342
 			print 'Error: '.$this->soapclient->error_str;
343 343
 			print "\n<br>\n";
344 344
 			print $this->soapclient->request;
Please login to merge, or discard this patch.
test/phpunit/ContratTest.php 1 patch
Spacing   +30 added lines, -30 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,21 +55,21 @@  discard block
 block discarded – undo
55 55
 	 */
56 56
 	public function testContratCreate()
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 = "ContratTest Unittest";
66 66
 		$socid = $soc->create($user);
67 67
 		$this->assertLessThan($socid, 0, $soc->errorsToString());
68 68
 
69
-		$localobject=new Contrat($db);
69
+		$localobject = new Contrat($db);
70 70
 		$localobject->initAsSpecimen();
71 71
 		$localobject->socid = $socid;
72
-		$result=$localobject->create($user);
72
+		$result = $localobject->create($user);
73 73
 
74 74
 		print __METHOD__." result=".$result."\n";
75 75
 		$this->assertLessThan($result, 0, $localobject->errorsToString());
@@ -88,14 +88,14 @@  discard block
 block discarded – undo
88 88
 	 */
89 89
 	public function testContratFetch($id)
90 90
 	{
91
-		global $conf,$user,$langs,$db;
92
-		$conf=$this->savconf;
93
-		$user=$this->savuser;
94
-		$langs=$this->savlangs;
95
-		$db=$this->savdb;
91
+		global $conf, $user, $langs, $db;
92
+		$conf = $this->savconf;
93
+		$user = $this->savuser;
94
+		$langs = $this->savlangs;
95
+		$db = $this->savdb;
96 96
 
97
-		$localobject=new Contrat($db);
98
-		$result=$localobject->fetch($id);
97
+		$localobject = new Contrat($db);
98
+		$result = $localobject->fetch($id);
99 99
 
100 100
 		print __METHOD__." id=".$id." result=".$result."\n";
101 101
 		$this->assertLessThan($result, 0);
@@ -114,11 +114,11 @@  discard block
 block discarded – undo
114 114
 	 */
115 115
 	public function testContratOther($localobject)
116 116
 	{
117
-		global $conf,$user,$langs,$db;
118
-		$conf=$this->savconf;
119
-		$user=$this->savuser;
120
-		$langs=$this->savlangs;
121
-		$db=$this->savdb;
117
+		global $conf, $user, $langs, $db;
118
+		$conf = $this->savconf;
119
+		$user = $this->savuser;
120
+		$langs = $this->savlangs;
121
+		$db = $this->savdb;
122 122
 
123 123
 		/*$result=$localobject->setstatus(0);
124 124
 		print __METHOD__." id=".$localobject->id." result=".$result."\n";
@@ -143,15 +143,15 @@  discard block
 block discarded – undo
143 143
 	 */
144 144
 	public function testContratDelete($id)
145 145
 	{
146
-		global $conf,$user,$langs,$db;
147
-		$conf=$this->savconf;
148
-		$user=$this->savuser;
149
-		$langs=$this->savlangs;
150
-		$db=$this->savdb;
151
-
152
-		$localobject=new Contrat($db);
153
-		$result=$localobject->fetch($id);
154
-		$result=$localobject->delete($user);
146
+		global $conf, $user, $langs, $db;
147
+		$conf = $this->savconf;
148
+		$user = $this->savuser;
149
+		$langs = $this->savlangs;
150
+		$db = $this->savdb;
151
+
152
+		$localobject = new Contrat($db);
153
+		$result = $localobject->fetch($id);
154
+		$result = $localobject->delete($user);
155 155
 
156 156
 		print __METHOD__." id=".$id." result=".$result."\n";
157 157
 		$this->assertLessThan($result, 0);
Please login to merge, or discard this patch.
test/phpunit/UserTest.php 1 patch
Spacing   +73 added lines, -73 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,14 +55,14 @@  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
 
60 60
 		if (getDolGlobalString('MAIN_MODULE_LDAP')) {
61 61
 			print "\n".__METHOD__." module LDAP must be disabled.\n";
62 62
 			die(1);
63 63
 		}
64 64
 
65
-		$db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
65
+		$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
66 66
 
67 67
 		print __METHOD__."\n";
68 68
 	}
@@ -74,17 +74,17 @@  discard block
 block discarded – undo
74 74
 	 */
75 75
 	public function testUserCreate()
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 83
 		print __METHOD__." USER_PASSWORD_GENERATED=".getDolGlobalString('USER_PASSWORD_GENERATED')."\n";
84 84
 
85
-		$localobject=new User($db);
85
+		$localobject = new User($db);
86 86
 		$localobject->initAsSpecimen();
87
-		$result=$localobject->create($user);
87
+		$result = $localobject->create($user);
88 88
 
89 89
 		$this->assertLessThan($result, 0, 'Creation of user has failed: '.$localobject->error);
90 90
 		print __METHOD__." result=".$result."\n";
@@ -101,14 +101,14 @@  discard block
 block discarded – undo
101 101
 	 */
102 102
 	public function testUserFetch($id)
103 103
 	{
104
-		global $conf,$user,$langs,$db;
105
-		$conf=$this->savconf;
106
-		$user=$this->savuser;
107
-		$langs=$this->savlangs;
108
-		$db=$this->savdb;
104
+		global $conf, $user, $langs, $db;
105
+		$conf = $this->savconf;
106
+		$user = $this->savuser;
107
+		$langs = $this->savlangs;
108
+		$db = $this->savdb;
109 109
 
110
-		$localobject=new User($db);
111
-		$result=$localobject->fetch($id);
110
+		$localobject = new User($db);
111
+		$result = $localobject->fetch($id);
112 112
 
113 113
 		$this->assertLessThan($result, 0);
114 114
 		print __METHOD__." id=".$id." result=".$result."\n";
@@ -125,23 +125,23 @@  discard block
 block discarded – undo
125 125
 	 */
126 126
 	public function testUserUpdate($localobject)
127 127
 	{
128
-		global $conf,$user,$langs,$db;
129
-		$conf=$this->savconf;
130
-		$user=$this->savuser;
131
-		$langs=$this->savlangs;
132
-		$db=$this->savdb;
128
+		global $conf, $user, $langs, $db;
129
+		$conf = $this->savconf;
130
+		$user = $this->savuser;
131
+		$langs = $this->savlangs;
132
+		$db = $this->savdb;
133 133
 
134 134
 		$this->changeProperties($localobject);
135
-		$result=$localobject->update($user);
135
+		$result = $localobject->update($user);
136 136
 
137 137
 		print __METHOD__." id=".$localobject->id." result=".$result."\n";
138 138
 		$this->assertLessThan($result, 0);
139 139
 
140 140
 		// Test everything are still same than specimen
141
-		$newlocalobject=new User($db);
141
+		$newlocalobject = new User($db);
142 142
 		$newlocalobject->initAsSpecimen();
143 143
 		$this->changeProperties($newlocalobject);
144
-		$this->assertEquals($this->objCompare($localobject, $newlocalobject, true, array('id','socid','societe_id','specimen','note','ref','pass','pass_indatabase','pass_indatabase_crypted','pass_temp','datec','datem','datelastlogin','datepreviouslogin','flagdelsessionsbefore','iplastlogin','ippreviouslogin','trackid')), array());    // Actual, Expected
144
+		$this->assertEquals($this->objCompare($localobject, $newlocalobject, true, array('id', 'socid', 'societe_id', 'specimen', 'note', 'ref', 'pass', 'pass_indatabase', 'pass_indatabase_crypted', 'pass_temp', 'datec', 'datem', 'datelastlogin', 'datepreviouslogin', 'flagdelsessionsbefore', 'iplastlogin', 'ippreviouslogin', 'trackid')), array()); // Actual, Expected
145 145
 
146 146
 		return $localobject;
147 147
 	}
@@ -156,13 +156,13 @@  discard block
 block discarded – undo
156 156
 	 */
157 157
 	public function testUserDisable($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->setstatus(0);
165
+		$result = $localobject->setstatus(0);
166 166
 		print __METHOD__." id=".$localobject->id." result=".$result."\n";
167 167
 
168 168
 		$this->assertLessThan($result, 0);
@@ -180,11 +180,11 @@  discard block
 block discarded – undo
180 180
 	 */
181 181
 	public function testUserOther($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";
@@ -206,17 +206,17 @@  discard block
 block discarded – undo
206 206
 	 */
207 207
 	public function testUserHasRight($localobject)
208 208
 	{
209
-		global $conf,$user,$langs,$db;
210
-		$conf=$this->savconf;
211
-		$user=$this->savuser;
212
-		$langs=$this->savlangs;
213
-		$db=$this->savdb;
209
+		global $conf, $user, $langs, $db;
210
+		$conf = $this->savconf;
211
+		$user = $this->savuser;
212
+		$langs = $this->savlangs;
213
+		$db = $this->savdb;
214 214
 		/*$result=$localobject->setstatus(0);
215 215
 		print __METHOD__." id=".$localobject->id." result=".$result."\n";
216 216
 		$this->assertLessThan($result, 0);
217 217
 		*/
218 218
 
219
-		print __METHOD__." id=". $localobject->id ."\n";
219
+		print __METHOD__." id=".$localobject->id."\n";
220 220
 		//$this->assertNotEquals($user->date_creation, '');
221 221
 		$localobject->addrights(0, 'supplier_proposal');
222 222
 		$this->assertEquals($localobject->hasRight('member', ''), 0);
@@ -238,11 +238,11 @@  discard block
 block discarded – undo
238 238
 	 */
239 239
 	public function testUserSetPassword($localobject)
240 240
 	{
241
-		global $conf,$user,$langs,$db;
242
-		$conf=$this->savconf;
243
-		$user=$this->savuser;
244
-		$langs=$this->savlangs;
245
-		$db=$this->savdb;
241
+		global $conf, $user, $langs, $db;
242
+		$conf = $this->savconf;
243
+		$user = $this->savuser;
244
+		$langs = $this->savlangs;
245
+		$db = $this->savdb;
246 246
 
247 247
 		// Test the 'none' password generator
248 248
 
@@ -351,15 +351,15 @@  discard block
 block discarded – undo
351 351
 	 */
352 352
 	public function testUserDelete($id)
353 353
 	{
354
-		global $conf,$user,$langs,$db;
355
-		$conf=$this->savconf;
356
-		$user=$this->savuser;
357
-		$langs=$this->savlangs;
358
-		$db=$this->savdb;
354
+		global $conf, $user, $langs, $db;
355
+		$conf = $this->savconf;
356
+		$user = $this->savuser;
357
+		$langs = $this->savlangs;
358
+		$db = $this->savdb;
359 359
 
360
-		$localobject=new User($db);
361
-		$result=$localobject->fetch($id);
362
-		$result=$localobject->delete($user);
360
+		$localobject = new User($db);
361
+		$result = $localobject->fetch($id);
362
+		$result = $localobject->delete($user);
363 363
 
364 364
 		print __METHOD__." id=".$id." result=".$result."\n";
365 365
 		$this->assertLessThan($result, 0);
@@ -376,15 +376,15 @@  discard block
 block discarded – undo
376 376
 	 */
377 377
 	public function testUserAddPermission($id)
378 378
 	{
379
-		global $conf,$user,$langs,$db;
380
-		$conf=$this->savconf;
381
-		$user=$this->savuser;
382
-		$langs=$this->savlangs;
383
-		$db=$this->savdb;
379
+		global $conf, $user, $langs, $db;
380
+		$conf = $this->savconf;
381
+		$user = $this->savuser;
382
+		$langs = $this->savlangs;
383
+		$db = $this->savdb;
384 384
 
385
-		$localobject=new User($db);
386
-		$result=$localobject->fetch(1);			// Other tests use the user id 1
387
-		$result=$localobject->addrights(0, 'supplier_proposal');
385
+		$localobject = new User($db);
386
+		$result = $localobject->fetch(1); // Other tests use the user id 1
387
+		$result = $localobject->addrights(0, 'supplier_proposal');
388 388
 
389 389
 		print __METHOD__." id=".$id." result=".$result."\n";
390 390
 		$this->assertLessThan($result, 0);
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
 	 */
402 402
 	public function changeProperties(&$localobject)
403 403
 	{
404
-		$localobject->note_private='New note after update';
404
+		$localobject->note_private = 'New note after update';
405 405
 	}
406 406
 
407 407
 	/**
@@ -415,23 +415,23 @@  discard block
 block discarded – undo
415 415
 	 */
416 416
 	public function objCompare($oA, $oB, $ignoretype = true, $fieldstoignorearray = array('id'))
417 417
 	{
418
-		$retAr=array();
418
+		$retAr = array();
419 419
 
420 420
 		if (get_class($oA) !== get_class($oB)) {
421
-			$retAr[]="Supplied objects are not of same class.";
421
+			$retAr[] = "Supplied objects are not of same class.";
422 422
 		} else {
423
-			$oVarsA=get_object_vars($oA);
424
-			$oVarsB=get_object_vars($oB);
425
-			$aKeys=array_keys($oVarsA);
423
+			$oVarsA = get_object_vars($oA);
424
+			$oVarsB = get_object_vars($oB);
425
+			$aKeys = array_keys($oVarsA);
426 426
 			foreach ($aKeys as $sKey) {
427 427
 				if (in_array($sKey, $fieldstoignorearray)) {
428 428
 					continue;
429 429
 				}
430
-				if (! $ignoretype && ($oVarsA[$sKey] !== $oVarsB[$sKey])) {
431
-					$retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey]) ? get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ? get_class($oVarsB[$sKey]) : $oVarsB[$sKey]);
430
+				if (!$ignoretype && ($oVarsA[$sKey] !== $oVarsB[$sKey])) {
431
+					$retAr[] = $sKey.' : '.(is_object($oVarsA[$sKey]) ? get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ? get_class($oVarsB[$sKey]) : $oVarsB[$sKey]);
432 432
 				}
433 433
 				if ($ignoretype && ($oVarsA[$sKey] != $oVarsB[$sKey])) {
434
-					$retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey]) ? get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ? get_class($oVarsB[$sKey]) : $oVarsB[$sKey]);
434
+					$retAr[] = $sKey.' : '.(is_object($oVarsA[$sKey]) ? get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ? get_class($oVarsB[$sKey]) : $oVarsB[$sKey]);
435 435
 				}
436 436
 			}
437 437
 		}
Please login to merge, or discard this patch.