Test Failed
Push — master ( ed0f4f...3aebc2 )
by Alxarafe
43:14
created
dolibarr/test/phpunit/HolidayTest.php 2 patches
Indentation   +187 added lines, -187 removed lines patch added patch discarded remove patch
@@ -32,9 +32,9 @@  discard block
 block discarded – undo
32 32
 
33 33
 if (empty($user->id))
34 34
 {
35
-	print "Load permissions for admin user nb 1\n";
36
-	$user->fetch(1);
37
-	$user->getrights();
35
+    print "Load permissions for admin user nb 1\n";
36
+    $user->fetch(1);
37
+    $user->getrights();
38 38
 }
39 39
 
40 40
 $conf->global->MAIN_DISABLE_ALL_MAILS=1;
@@ -49,75 +49,75 @@  discard block
 block discarded – undo
49 49
  */
50 50
 class HolidayTest extends PHPUnit_Framework_TestCase
51 51
 {
52
-	protected $savconf;
53
-	protected $savuser;
54
-	protected $savlangs;
55
-	protected $savdb;
56
-
57
-	/**
58
-	 * Constructor
59
-	 * We save global variables into local variables
60
-	 *
61
-	 * @return HolidayTest
62
-	 */
63
-	function __construct()
64
-	{
65
-		parent::__construct();
66
-
67
-		//$this->sharedFixture
68
-		global $conf,$user,$langs,$db;
69
-		$this->savconf=$conf;
70
-		$this->savuser=$user;
71
-		$this->savlangs=$langs;
72
-		$this->savdb=$db;
73
-
74
-		print __METHOD__." db->type=".$db->type." user->id=".$user->id;
75
-		//print " - db ".$db->db;
76
-		print "\n";
77
-	}
78
-
79
-	// Static methods
80
-  	public static function setUpBeforeClass()
52
+    protected $savconf;
53
+    protected $savuser;
54
+    protected $savlangs;
55
+    protected $savdb;
56
+
57
+    /**
58
+     * Constructor
59
+     * We save global variables into local variables
60
+     *
61
+     * @return HolidayTest
62
+     */
63
+    function __construct()
64
+    {
65
+        parent::__construct();
66
+
67
+        //$this->sharedFixture
68
+        global $conf,$user,$langs,$db;
69
+        $this->savconf=$conf;
70
+        $this->savuser=$user;
71
+        $this->savlangs=$langs;
72
+        $this->savdb=$db;
73
+
74
+        print __METHOD__." db->type=".$db->type." user->id=".$user->id;
75
+        //print " - db ".$db->db;
76
+        print "\n";
77
+    }
78
+
79
+    // Static methods
80
+        public static function setUpBeforeClass()
81 81
     {
82
-    	global $conf,$user,$langs,$db;
82
+        global $conf,$user,$langs,$db;
83 83
 
84 84
         $db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
85 85
 
86
-    	print __METHOD__."\n";
86
+        print __METHOD__."\n";
87 87
     }
88 88
 
89 89
     // tear down after class
90 90
     public static function tearDownAfterClass()
91 91
     {
92
-    	global $conf,$user,$langs,$db;
93
-		$db->rollback();
92
+        global $conf,$user,$langs,$db;
93
+        $db->rollback();
94 94
 
95
-		print __METHOD__."\n";
95
+        print __METHOD__."\n";
96 96
     }
97 97
 
98
-	/**
99
-	 * Init phpunit tests
100
-	 *
101
-	 * @return	void
102
-	 */
98
+    /**
99
+     * Init phpunit tests
100
+     *
101
+     * @return	void
102
+     */
103 103
     protected function setUp()
104 104
     {
105
-    	global $conf,$user,$langs,$db;
106
-		$conf=$this->savconf;
107
-		$user=$this->savuser;
108
-		$langs=$this->savlangs;
109
-		$db=$this->savdb;
105
+        global $conf,$user,$langs,$db;
106
+        $conf=$this->savconf;
107
+        $user=$this->savuser;
108
+        $langs=$this->savlangs;
109
+        $db=$this->savdb;
110 110
 
111
-		print __METHOD__."\n";
111
+        print __METHOD__."\n";
112 112
     }
113
-	/**
114
-	 * End phpunit tests
115
-	 *
116
-	 * @return	void
117
-	 */
113
+    /**
114
+     * End phpunit tests
115
+     *
116
+     * @return	void
117
+     */
118 118
     protected function tearDown()
119 119
     {
120
-    	print __METHOD__."\n";
120
+        print __METHOD__."\n";
121 121
     }
122 122
 
123 123
     /**
@@ -127,20 +127,20 @@  discard block
 block discarded – undo
127 127
      */
128 128
     public function testHolidayCreate()
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 Holiday($this->savdb);
137
-    	$localobject->initAsSpecimen();
138
-    	$result=$localobject->create($user);
136
+        $localobject=new Holiday($this->savdb);
137
+        $localobject->initAsSpecimen();
138
+        $result=$localobject->create($user);
139 139
 
140 140
         print __METHOD__." result=".$result."\n";
141
-    	$this->assertLessThan($result, 0);
141
+        $this->assertLessThan($result, 0);
142 142
 
143
-    	return $result;
143
+        return $result;
144 144
     }
145 145
 
146 146
     /**
@@ -153,19 +153,19 @@  discard block
 block discarded – undo
153 153
      */
154 154
     public function testHolidayFetch($id)
155 155
     {
156
-    	global $conf,$user,$langs,$db;
157
-		$conf=$this->savconf;
158
-		$user=$this->savuser;
159
-		$langs=$this->savlangs;
160
-		$db=$this->savdb;
156
+        global $conf,$user,$langs,$db;
157
+        $conf=$this->savconf;
158
+        $user=$this->savuser;
159
+        $langs=$this->savlangs;
160
+        $db=$this->savdb;
161 161
 
162
-		$localobject=new Holiday($this->savdb);
163
-    	$result=$localobject->fetch($id);
162
+        $localobject=new Holiday($this->savdb);
163
+        $result=$localobject->fetch($id);
164 164
 
165 165
         print __METHOD__." id=".$id." result=".$result."\n";
166
-    	$this->assertLessThan($result, 0);
166
+        $this->assertLessThan($result, 0);
167 167
 
168
-    	return $localobject;
168
+        return $localobject;
169 169
     }
170 170
 
171 171
     /**
@@ -179,55 +179,55 @@  discard block
 block discarded – undo
179 179
      */
180 180
     public function testHolidayUpdate($localobject)
181 181
     {
182
-    	global $conf,$user,$langs,$db;
183
-		$conf=$this->savconf;
184
-		$user=$this->savuser;
185
-		$langs=$this->savlangs;
186
-		$db=$this->savdb;
187
-
188
-		$localobject->oldcopy = clone $localobject;
189
-
190
-		$localobject->note_private='New private note after update';
191
-		$localobject->note_public='New public note after update';
192
-		$localobject->lastname='New name';
193
-		$localobject->firstname='New firstname';
194
-		$localobject->address='New address';
195
-		$localobject->zip='New zip';
196
-		$localobject->town='New town';
197
-    	$localobject->country_id=2;
198
-    	//$localobject->status=0;
199
-		$localobject->phone_pro='New tel pro';
200
-		$localobject->phone_perso='New tel perso';
201
-		$localobject->phone_mobile='New tel mobile';
202
-		$localobject->fax='New fax';
203
-		$localobject->email='[email protected]';
204
-		$localobject->jabberid='New im id';
205
-		$localobject->default_lang='es_ES';
206
-
207
-		$result=$localobject->update($localobject->id,$user);
208
-    	print __METHOD__." id=".$localobject->id." result=".$result."\n";
209
-    	$this->assertLessThan($result, 0, 'Holiday::update error');
210
-
211
-    	$result=$localobject->update_note($localobject->note_private,'_private');
212
-    	print __METHOD__." id=".$localobject->id." result=".$result."\n";
213
-		$this->assertLessThan($result, 0, 'Holiday::update_note (private) error');
214
-
215
-		$result=$localobject->update_note($localobject->note_public, '_public');
216
-		print __METHOD__." id=".$localobject->id." result=".$result."\n";
217
-		$this->assertLessThan($result, 0, 'Holiday::update_note (public) error');
218
-
219
-
220
-		$newobject=new Holiday($this->savdb);
221
-    	$result=$newobject->fetch($localobject->id);
182
+        global $conf,$user,$langs,$db;
183
+        $conf=$this->savconf;
184
+        $user=$this->savuser;
185
+        $langs=$this->savlangs;
186
+        $db=$this->savdb;
187
+
188
+        $localobject->oldcopy = clone $localobject;
189
+
190
+        $localobject->note_private='New private note after update';
191
+        $localobject->note_public='New public note after update';
192
+        $localobject->lastname='New name';
193
+        $localobject->firstname='New firstname';
194
+        $localobject->address='New address';
195
+        $localobject->zip='New zip';
196
+        $localobject->town='New town';
197
+        $localobject->country_id=2;
198
+        //$localobject->status=0;
199
+        $localobject->phone_pro='New tel pro';
200
+        $localobject->phone_perso='New tel perso';
201
+        $localobject->phone_mobile='New tel mobile';
202
+        $localobject->fax='New fax';
203
+        $localobject->email='[email protected]';
204
+        $localobject->jabberid='New im id';
205
+        $localobject->default_lang='es_ES';
206
+
207
+        $result=$localobject->update($localobject->id,$user);
222 208
         print __METHOD__." id=".$localobject->id." result=".$result."\n";
223
-    	$this->assertLessThan($result, 0, 'Holiday::fetch error');
209
+        $this->assertLessThan($result, 0, 'Holiday::update error');
224 210
 
225
-    	print __METHOD__." old=".$localobject->note." new=".$newobject->note."\n";
226
-    	$this->assertEquals($localobject->note, $newobject->note,'Holiday::update_note error compare note');
227
-    	//print __METHOD__." old=".$localobject->note_public." new=".$newobject->note_public."\n";
228
-    	//$this->assertEquals($localobject->note_public, $newobject->note_public);
211
+        $result=$localobject->update_note($localobject->note_private,'_private');
212
+        print __METHOD__." id=".$localobject->id." result=".$result."\n";
213
+        $this->assertLessThan($result, 0, 'Holiday::update_note (private) error');
214
+
215
+        $result=$localobject->update_note($localobject->note_public, '_public');
216
+        print __METHOD__." id=".$localobject->id." result=".$result."\n";
217
+        $this->assertLessThan($result, 0, 'Holiday::update_note (public) error');
229 218
 
230
-    	return $localobject;
219
+
220
+        $newobject=new Holiday($this->savdb);
221
+        $result=$newobject->fetch($localobject->id);
222
+        print __METHOD__." id=".$localobject->id." result=".$result."\n";
223
+        $this->assertLessThan($result, 0, 'Holiday::fetch error');
224
+
225
+        print __METHOD__." old=".$localobject->note." new=".$newobject->note."\n";
226
+        $this->assertEquals($localobject->note, $newobject->note,'Holiday::update_note error compare note');
227
+        //print __METHOD__." old=".$localobject->note_public." new=".$newobject->note_public."\n";
228
+        //$this->assertEquals($localobject->note_public, $newobject->note_public);
229
+
230
+        return $localobject;
231 231
     }
232 232
 
233 233
     /**
@@ -241,15 +241,15 @@  discard block
 block discarded – undo
241 241
      */
242 242
     public function testHolidayOther($localobject)
243 243
     {
244
-    	global $conf,$user,$langs,$db;
245
-		$conf=$this->savconf;
246
-		$user=$this->savuser;
247
-		$langs=$this->savlangs;
248
-		$db=$this->savdb;
244
+        global $conf,$user,$langs,$db;
245
+        $conf=$this->savconf;
246
+        $user=$this->savuser;
247
+        $langs=$this->savlangs;
248
+        $db=$this->savdb;
249 249
 
250
-		//$localobject->fetch($localobject->id);
250
+        //$localobject->fetch($localobject->id);
251 251
 
252
-		/*
252
+        /*
253 253
         $result=$localobject->getNomUrl(1);
254 254
         print __METHOD__." id=".$localobject->id." result=".$result."\n";
255 255
         $this->assertNotEquals($result, '');
@@ -277,20 +277,20 @@  discard block
 block discarded – undo
277 277
      */
278 278
     public function testHolidayDelete($id)
279 279
     {
280
-    	global $conf,$user,$langs,$db;
281
-		$conf=$this->savconf;
282
-		$user=$this->savuser;
283
-		$langs=$this->savlangs;
284
-		$db=$this->savdb;
280
+        global $conf,$user,$langs,$db;
281
+        $conf=$this->savconf;
282
+        $user=$this->savuser;
283
+        $langs=$this->savlangs;
284
+        $db=$this->savdb;
285 285
 
286
-		$localobject=new Holiday($this->savdb);
287
-    	$result=$localobject->fetch($id);
286
+        $localobject=new Holiday($this->savdb);
287
+        $result=$localobject->fetch($id);
288 288
 
289
-    	$result=$localobject->delete(0);
290
-		print __METHOD__." id=".$id." result=".$result."\n";
291
-    	$this->assertLessThan($result, 0);
289
+        $result=$localobject->delete(0);
290
+        print __METHOD__." id=".$id." result=".$result."\n";
291
+        $this->assertLessThan($result, 0);
292 292
 
293
-    	return $result;
293
+        return $result;
294 294
     }
295 295
 
296 296
     /**
@@ -300,55 +300,55 @@  discard block
 block discarded – undo
300 300
      */
301 301
     public function testVerifDateHolidayCP()
302 302
     {
303
-    	global $conf,$user,$langs,$db;
304
-    	$conf=$this->savconf;
305
-    	$user=$this->savuser;
306
-    	$langs=$this->savlangs;
307
-    	$db=$this->savdb;
308
-
309
-    	// Create a leave request the 1st morning only
310
-    	$localobjecta=new Holiday($this->savdb);
311
-    	$localobjecta->initAsSpecimen();
312
-    	$localobjecta->date_debut = dol_mktime(0, 0, 0, 1, 1, 2020);
313
-    	$localobjecta->date_fin = dol_mktime(0, 0, 0, 1, 1, 2020);
314
-    	$localobjecta->halfday = 1;
315
-    	$result=$localobjecta->create($user);
316
-
317
-    	// Create a leave request the 2 afternoon only
318
-    	$localobjectb=new Holiday($this->savdb);
319
-    	$localobjectb->initAsSpecimen();
320
-    	$localobjectb->date_debut = dol_mktime(0, 0, 0, 1, 2, 2020);
321
-    	$localobjectb->date_fin = dol_mktime(0, 0, 0, 1, 2, 2020);
322
-    	$localobjectb->halfday = -1;
323
-    	$result=$localobjectb->create($user);
324
-
325
-    	$date_debut = dol_mktime(0, 0, 0, 1, 1, 2020);
326
-    	$date_fin = dol_mktime(0, 0, 0, 1, 2, 2020);
327
-
328
-    	$localobjectc=new Holiday($this->savdb);
329
-
330
-    	$result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_debut, 0);
331
-    	$this->assertFalse($result, 'result should be false, there is overlapping, full day is not available.');
332
-    	$result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_fin, 0);
333
-    	$this->assertFalse($result, 'result should be false, there is overlapping, full day is not available.');
334
-    	$result=$localobjectc->verifDateHolidayCP($user->id, $date_fin, $date_fin, 0);
335
-    	$this->assertFalse($result, 'result should be false, there is overlapping, full day is not available.');
336
-
337
-    	$result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_debut, 1);
338
-    	$this->assertFalse($result, 'result should be false, there is overlapping, morning of first day is not available.');
339
-    	$result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_fin, 1);
340
-    	$this->assertFalse($result, 'result should be false, there is overlapping, morning of first day is not available.');
341
-    	$result=$localobjectc->verifDateHolidayCP($user->id, $date_fin, $date_fin, 1);
342
-    	$this->assertTrue($result, 'result should be true, there is no overlapping');
343
-
344
-    	$result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_debut, -1);
345
-    	$this->assertTrue($result, 'result should be true, there is no overlapping');
346
-    	$result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_fin, -1);
347
-    	$this->assertFalse($result, 'result should be false, there is overlapping, afternoon of second day is not available');
348
-    	$result=$localobjectc->verifDateHolidayCP($user->id, $date_fin, $date_fin, -1);
349
-    	$this->assertFalse($result, 'result should be false, there is overlapping, afternoon of second day is not available');
350
-
351
-    	$result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_fin, 2);	// start afternoon and end morning
352
-    	$this->assertTrue($result, 'result should be true, there is no overlapping');
303
+        global $conf,$user,$langs,$db;
304
+        $conf=$this->savconf;
305
+        $user=$this->savuser;
306
+        $langs=$this->savlangs;
307
+        $db=$this->savdb;
308
+
309
+        // Create a leave request the 1st morning only
310
+        $localobjecta=new Holiday($this->savdb);
311
+        $localobjecta->initAsSpecimen();
312
+        $localobjecta->date_debut = dol_mktime(0, 0, 0, 1, 1, 2020);
313
+        $localobjecta->date_fin = dol_mktime(0, 0, 0, 1, 1, 2020);
314
+        $localobjecta->halfday = 1;
315
+        $result=$localobjecta->create($user);
316
+
317
+        // Create a leave request the 2 afternoon only
318
+        $localobjectb=new Holiday($this->savdb);
319
+        $localobjectb->initAsSpecimen();
320
+        $localobjectb->date_debut = dol_mktime(0, 0, 0, 1, 2, 2020);
321
+        $localobjectb->date_fin = dol_mktime(0, 0, 0, 1, 2, 2020);
322
+        $localobjectb->halfday = -1;
323
+        $result=$localobjectb->create($user);
324
+
325
+        $date_debut = dol_mktime(0, 0, 0, 1, 1, 2020);
326
+        $date_fin = dol_mktime(0, 0, 0, 1, 2, 2020);
327
+
328
+        $localobjectc=new Holiday($this->savdb);
329
+
330
+        $result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_debut, 0);
331
+        $this->assertFalse($result, 'result should be false, there is overlapping, full day is not available.');
332
+        $result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_fin, 0);
333
+        $this->assertFalse($result, 'result should be false, there is overlapping, full day is not available.');
334
+        $result=$localobjectc->verifDateHolidayCP($user->id, $date_fin, $date_fin, 0);
335
+        $this->assertFalse($result, 'result should be false, there is overlapping, full day is not available.');
336
+
337
+        $result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_debut, 1);
338
+        $this->assertFalse($result, 'result should be false, there is overlapping, morning of first day is not available.');
339
+        $result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_fin, 1);
340
+        $this->assertFalse($result, 'result should be false, there is overlapping, morning of first day is not available.');
341
+        $result=$localobjectc->verifDateHolidayCP($user->id, $date_fin, $date_fin, 1);
342
+        $this->assertTrue($result, 'result should be true, there is no overlapping');
343
+
344
+        $result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_debut, -1);
345
+        $this->assertTrue($result, 'result should be true, there is no overlapping');
346
+        $result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_fin, -1);
347
+        $this->assertFalse($result, 'result should be false, there is overlapping, afternoon of second day is not available');
348
+        $result=$localobjectc->verifDateHolidayCP($user->id, $date_fin, $date_fin, -1);
349
+        $this->assertFalse($result, 'result should be false, there is overlapping, afternoon of second day is not available');
350
+
351
+        $result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_fin, 2);	// start afternoon and end morning
352
+        $this->assertTrue($result, 'result should be true, there is no overlapping');
353 353
     }
354 354
 }
Please login to merge, or discard this patch.
Spacing   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  *		\remarks	To run this script as CLI:  phpunit filename.php
24 24
  */
25 25
 
26
-global $conf,$user,$langs,$db;
26
+global $conf, $user, $langs, $db;
27 27
 //define('TEST_DB_FORCE_TYPE','mysql');	// This is to force using mysql driver
28 28
 //require_once 'PHPUnit/Autoload.php';
29 29
 require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	$user->getrights();
38 38
 }
39 39
 
40
-$conf->global->MAIN_DISABLE_ALL_MAILS=1;
40
+$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
41 41
 
42 42
 
43 43
 /**
@@ -65,11 +65,11 @@  discard block
 block discarded – undo
65 65
 		parent::__construct();
66 66
 
67 67
 		//$this->sharedFixture
68
-		global $conf,$user,$langs,$db;
69
-		$this->savconf=$conf;
70
-		$this->savuser=$user;
71
-		$this->savlangs=$langs;
72
-		$this->savdb=$db;
68
+		global $conf, $user, $langs, $db;
69
+		$this->savconf = $conf;
70
+		$this->savuser = $user;
71
+		$this->savlangs = $langs;
72
+		$this->savdb = $db;
73 73
 
74 74
 		print __METHOD__." db->type=".$db->type." user->id=".$user->id;
75 75
 		//print " - db ".$db->db;
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
79 79
 	// Static methods
80 80
   	public static function setUpBeforeClass()
81 81
     {
82
-    	global $conf,$user,$langs,$db;
82
+    	global $conf, $user, $langs, $db;
83 83
 
84
-        $db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
84
+        $db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
85 85
 
86 86
     	print __METHOD__."\n";
87 87
     }
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
     // tear down after class
90 90
     public static function tearDownAfterClass()
91 91
     {
92
-    	global $conf,$user,$langs,$db;
92
+    	global $conf, $user, $langs, $db;
93 93
 		$db->rollback();
94 94
 
95 95
 		print __METHOD__."\n";
@@ -102,11 +102,11 @@  discard block
 block discarded – undo
102 102
 	 */
103 103
     protected function setUp()
104 104
     {
105
-    	global $conf,$user,$langs,$db;
106
-		$conf=$this->savconf;
107
-		$user=$this->savuser;
108
-		$langs=$this->savlangs;
109
-		$db=$this->savdb;
105
+    	global $conf, $user, $langs, $db;
106
+		$conf = $this->savconf;
107
+		$user = $this->savuser;
108
+		$langs = $this->savlangs;
109
+		$db = $this->savdb;
110 110
 
111 111
 		print __METHOD__."\n";
112 112
     }
@@ -127,15 +127,15 @@  discard block
 block discarded – undo
127 127
      */
128 128
     public function testHolidayCreate()
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 Holiday($this->savdb);
136
+		$localobject = new Holiday($this->savdb);
137 137
     	$localobject->initAsSpecimen();
138
-    	$result=$localobject->create($user);
138
+    	$result = $localobject->create($user);
139 139
 
140 140
         print __METHOD__." result=".$result."\n";
141 141
     	$this->assertLessThan($result, 0);
@@ -153,14 +153,14 @@  discard block
 block discarded – undo
153 153
      */
154 154
     public function testHolidayFetch($id)
155 155
     {
156
-    	global $conf,$user,$langs,$db;
157
-		$conf=$this->savconf;
158
-		$user=$this->savuser;
159
-		$langs=$this->savlangs;
160
-		$db=$this->savdb;
156
+    	global $conf, $user, $langs, $db;
157
+		$conf = $this->savconf;
158
+		$user = $this->savuser;
159
+		$langs = $this->savlangs;
160
+		$db = $this->savdb;
161 161
 
162
-		$localobject=new Holiday($this->savdb);
163
-    	$result=$localobject->fetch($id);
162
+		$localobject = new Holiday($this->savdb);
163
+    	$result = $localobject->fetch($id);
164 164
 
165 165
         print __METHOD__." id=".$id." result=".$result."\n";
166 166
     	$this->assertLessThan($result, 0);
@@ -179,51 +179,51 @@  discard block
 block discarded – undo
179 179
      */
180 180
     public function testHolidayUpdate($localobject)
181 181
     {
182
-    	global $conf,$user,$langs,$db;
183
-		$conf=$this->savconf;
184
-		$user=$this->savuser;
185
-		$langs=$this->savlangs;
186
-		$db=$this->savdb;
182
+    	global $conf, $user, $langs, $db;
183
+		$conf = $this->savconf;
184
+		$user = $this->savuser;
185
+		$langs = $this->savlangs;
186
+		$db = $this->savdb;
187 187
 
188 188
 		$localobject->oldcopy = clone $localobject;
189 189
 
190
-		$localobject->note_private='New private note after update';
191
-		$localobject->note_public='New public note after update';
192
-		$localobject->lastname='New name';
193
-		$localobject->firstname='New firstname';
194
-		$localobject->address='New address';
195
-		$localobject->zip='New zip';
196
-		$localobject->town='New town';
197
-    	$localobject->country_id=2;
190
+		$localobject->note_private = 'New private note after update';
191
+		$localobject->note_public = 'New public note after update';
192
+		$localobject->lastname = 'New name';
193
+		$localobject->firstname = 'New firstname';
194
+		$localobject->address = 'New address';
195
+		$localobject->zip = 'New zip';
196
+		$localobject->town = 'New town';
197
+    	$localobject->country_id = 2;
198 198
     	//$localobject->status=0;
199
-		$localobject->phone_pro='New tel pro';
200
-		$localobject->phone_perso='New tel perso';
201
-		$localobject->phone_mobile='New tel mobile';
202
-		$localobject->fax='New fax';
203
-		$localobject->email='[email protected]';
204
-		$localobject->jabberid='New im id';
205
-		$localobject->default_lang='es_ES';
206
-
207
-		$result=$localobject->update($localobject->id,$user);
199
+		$localobject->phone_pro = 'New tel pro';
200
+		$localobject->phone_perso = 'New tel perso';
201
+		$localobject->phone_mobile = 'New tel mobile';
202
+		$localobject->fax = 'New fax';
203
+		$localobject->email = '[email protected]';
204
+		$localobject->jabberid = 'New im id';
205
+		$localobject->default_lang = 'es_ES';
206
+
207
+		$result = $localobject->update($localobject->id, $user);
208 208
     	print __METHOD__." id=".$localobject->id." result=".$result."\n";
209 209
     	$this->assertLessThan($result, 0, 'Holiday::update error');
210 210
 
211
-    	$result=$localobject->update_note($localobject->note_private,'_private');
211
+    	$result = $localobject->update_note($localobject->note_private, '_private');
212 212
     	print __METHOD__." id=".$localobject->id." result=".$result."\n";
213 213
 		$this->assertLessThan($result, 0, 'Holiday::update_note (private) error');
214 214
 
215
-		$result=$localobject->update_note($localobject->note_public, '_public');
215
+		$result = $localobject->update_note($localobject->note_public, '_public');
216 216
 		print __METHOD__." id=".$localobject->id." result=".$result."\n";
217 217
 		$this->assertLessThan($result, 0, 'Holiday::update_note (public) error');
218 218
 
219 219
 
220
-		$newobject=new Holiday($this->savdb);
221
-    	$result=$newobject->fetch($localobject->id);
220
+		$newobject = new Holiday($this->savdb);
221
+    	$result = $newobject->fetch($localobject->id);
222 222
         print __METHOD__." id=".$localobject->id." result=".$result."\n";
223 223
     	$this->assertLessThan($result, 0, 'Holiday::fetch error');
224 224
 
225 225
     	print __METHOD__." old=".$localobject->note." new=".$newobject->note."\n";
226
-    	$this->assertEquals($localobject->note, $newobject->note,'Holiday::update_note error compare note');
226
+    	$this->assertEquals($localobject->note, $newobject->note, 'Holiday::update_note error compare note');
227 227
     	//print __METHOD__." old=".$localobject->note_public." new=".$newobject->note_public."\n";
228 228
     	//$this->assertEquals($localobject->note_public, $newobject->note_public);
229 229
 
@@ -241,11 +241,11 @@  discard block
 block discarded – undo
241 241
      */
242 242
     public function testHolidayOther($localobject)
243 243
     {
244
-    	global $conf,$user,$langs,$db;
245
-		$conf=$this->savconf;
246
-		$user=$this->savuser;
247
-		$langs=$this->savlangs;
248
-		$db=$this->savdb;
244
+    	global $conf, $user, $langs, $db;
245
+		$conf = $this->savconf;
246
+		$user = $this->savuser;
247
+		$langs = $this->savlangs;
248
+		$db = $this->savdb;
249 249
 
250 250
 		//$localobject->fetch($localobject->id);
251 251
 
@@ -277,16 +277,16 @@  discard block
 block discarded – undo
277 277
      */
278 278
     public function testHolidayDelete($id)
279 279
     {
280
-    	global $conf,$user,$langs,$db;
281
-		$conf=$this->savconf;
282
-		$user=$this->savuser;
283
-		$langs=$this->savlangs;
284
-		$db=$this->savdb;
280
+    	global $conf, $user, $langs, $db;
281
+		$conf = $this->savconf;
282
+		$user = $this->savuser;
283
+		$langs = $this->savlangs;
284
+		$db = $this->savdb;
285 285
 
286
-		$localobject=new Holiday($this->savdb);
287
-    	$result=$localobject->fetch($id);
286
+		$localobject = new Holiday($this->savdb);
287
+    	$result = $localobject->fetch($id);
288 288
 
289
-    	$result=$localobject->delete(0);
289
+    	$result = $localobject->delete(0);
290 290
 		print __METHOD__." id=".$id." result=".$result."\n";
291 291
     	$this->assertLessThan($result, 0);
292 292
 
@@ -300,55 +300,55 @@  discard block
 block discarded – undo
300 300
      */
301 301
     public function testVerifDateHolidayCP()
302 302
     {
303
-    	global $conf,$user,$langs,$db;
304
-    	$conf=$this->savconf;
305
-    	$user=$this->savuser;
306
-    	$langs=$this->savlangs;
307
-    	$db=$this->savdb;
303
+    	global $conf, $user, $langs, $db;
304
+    	$conf = $this->savconf;
305
+    	$user = $this->savuser;
306
+    	$langs = $this->savlangs;
307
+    	$db = $this->savdb;
308 308
 
309 309
     	// Create a leave request the 1st morning only
310
-    	$localobjecta=new Holiday($this->savdb);
310
+    	$localobjecta = new Holiday($this->savdb);
311 311
     	$localobjecta->initAsSpecimen();
312 312
     	$localobjecta->date_debut = dol_mktime(0, 0, 0, 1, 1, 2020);
313 313
     	$localobjecta->date_fin = dol_mktime(0, 0, 0, 1, 1, 2020);
314 314
     	$localobjecta->halfday = 1;
315
-    	$result=$localobjecta->create($user);
315
+    	$result = $localobjecta->create($user);
316 316
 
317 317
     	// Create a leave request the 2 afternoon only
318
-    	$localobjectb=new Holiday($this->savdb);
318
+    	$localobjectb = new Holiday($this->savdb);
319 319
     	$localobjectb->initAsSpecimen();
320 320
     	$localobjectb->date_debut = dol_mktime(0, 0, 0, 1, 2, 2020);
321 321
     	$localobjectb->date_fin = dol_mktime(0, 0, 0, 1, 2, 2020);
322 322
     	$localobjectb->halfday = -1;
323
-    	$result=$localobjectb->create($user);
323
+    	$result = $localobjectb->create($user);
324 324
 
325 325
     	$date_debut = dol_mktime(0, 0, 0, 1, 1, 2020);
326 326
     	$date_fin = dol_mktime(0, 0, 0, 1, 2, 2020);
327 327
 
328
-    	$localobjectc=new Holiday($this->savdb);
328
+    	$localobjectc = new Holiday($this->savdb);
329 329
 
330
-    	$result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_debut, 0);
330
+    	$result = $localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_debut, 0);
331 331
     	$this->assertFalse($result, 'result should be false, there is overlapping, full day is not available.');
332
-    	$result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_fin, 0);
332
+    	$result = $localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_fin, 0);
333 333
     	$this->assertFalse($result, 'result should be false, there is overlapping, full day is not available.');
334
-    	$result=$localobjectc->verifDateHolidayCP($user->id, $date_fin, $date_fin, 0);
334
+    	$result = $localobjectc->verifDateHolidayCP($user->id, $date_fin, $date_fin, 0);
335 335
     	$this->assertFalse($result, 'result should be false, there is overlapping, full day is not available.');
336 336
 
337
-    	$result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_debut, 1);
337
+    	$result = $localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_debut, 1);
338 338
     	$this->assertFalse($result, 'result should be false, there is overlapping, morning of first day is not available.');
339
-    	$result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_fin, 1);
339
+    	$result = $localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_fin, 1);
340 340
     	$this->assertFalse($result, 'result should be false, there is overlapping, morning of first day is not available.');
341
-    	$result=$localobjectc->verifDateHolidayCP($user->id, $date_fin, $date_fin, 1);
341
+    	$result = $localobjectc->verifDateHolidayCP($user->id, $date_fin, $date_fin, 1);
342 342
     	$this->assertTrue($result, 'result should be true, there is no overlapping');
343 343
 
344
-    	$result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_debut, -1);
344
+    	$result = $localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_debut, -1);
345 345
     	$this->assertTrue($result, 'result should be true, there is no overlapping');
346
-    	$result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_fin, -1);
346
+    	$result = $localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_fin, -1);
347 347
     	$this->assertFalse($result, 'result should be false, there is overlapping, afternoon of second day is not available');
348
-    	$result=$localobjectc->verifDateHolidayCP($user->id, $date_fin, $date_fin, -1);
348
+    	$result = $localobjectc->verifDateHolidayCP($user->id, $date_fin, $date_fin, -1);
349 349
     	$this->assertFalse($result, 'result should be false, there is overlapping, afternoon of second day is not available');
350 350
 
351
-    	$result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_fin, 2);	// start afternoon and end morning
351
+    	$result = $localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_fin, 2); // start afternoon and end morning
352 352
     	$this->assertTrue($result, 'result should be true, there is no overlapping');
353 353
     }
354 354
 }
Please login to merge, or discard this patch.
dolibarr/test/phpunit/FilesLibTest.php 2 patches
Indentation   +175 added lines, -175 removed lines patch added patch discarded remove patch
@@ -32,9 +32,9 @@  discard block
 block discarded – undo
32 32
 
33 33
 if (empty($user->id))
34 34
 {
35
-	print "Load permissions for admin user nb 1\n";
36
-	$user->fetch(1);
37
-	$user->getrights();
35
+    print "Load permissions for admin user nb 1\n";
36
+    $user->fetch(1);
37
+    $user->getrights();
38 38
 }
39 39
 $conf->global->MAIN_DISABLE_ALL_MAILS=1;
40 40
 
@@ -48,160 +48,160 @@  discard block
 block discarded – undo
48 48
  */
49 49
 class FilesLibTest extends PHPUnit_Framework_TestCase
50 50
 {
51
-	protected $savconf;
52
-	protected $savuser;
53
-	protected $savlangs;
54
-	protected $savdb;
55
-
56
-	/**
57
-	 * Constructor
58
-	 * We save global variables into local variables
59
-	 *
60
-	 * @return FilesLibTest
61
-	 */
62
-	function __construct()
63
-	{
64
-		parent::__construct();
65
-
66
-		//$this->sharedFixture
67
-		global $conf,$user,$langs,$db;
68
-		$this->savconf=$conf;
69
-		$this->savuser=$user;
70
-		$this->savlangs=$langs;
71
-		$this->savdb=$db;
72
-
73
-		print __METHOD__." db->type=".$db->type." user->id=".$user->id;
74
-		//print " - db ".$db->db;
75
-		print "\n";
76
-	}
77
-
78
-	// Static methods
79
-  	public static function setUpBeforeClass()
51
+    protected $savconf;
52
+    protected $savuser;
53
+    protected $savlangs;
54
+    protected $savdb;
55
+
56
+    /**
57
+     * Constructor
58
+     * We save global variables into local variables
59
+     *
60
+     * @return FilesLibTest
61
+     */
62
+    function __construct()
80 63
     {
81
-    	global $conf,$user,$langs,$db;
82
-		$db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
64
+        parent::__construct();
83 65
 
84
-    	print __METHOD__."\n";
66
+        //$this->sharedFixture
67
+        global $conf,$user,$langs,$db;
68
+        $this->savconf=$conf;
69
+        $this->savuser=$user;
70
+        $this->savlangs=$langs;
71
+        $this->savdb=$db;
72
+
73
+        print __METHOD__." db->type=".$db->type." user->id=".$user->id;
74
+        //print " - db ".$db->db;
75
+        print "\n";
76
+    }
77
+
78
+    // Static methods
79
+        public static function setUpBeforeClass()
80
+    {
81
+        global $conf,$user,$langs,$db;
82
+        $db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
83
+
84
+        print __METHOD__."\n";
85 85
     }
86 86
 
87 87
     // tear down after class
88 88
     public static function tearDownAfterClass()
89 89
     {
90
-    	global $conf,$user,$langs,$db;
91
-		$db->rollback();
90
+        global $conf,$user,$langs,$db;
91
+        $db->rollback();
92 92
 
93
-		print __METHOD__."\n";
93
+        print __METHOD__."\n";
94 94
     }
95 95
 
96
-	/**
97
-	 * Init phpunit tests
98
-	 *
99
-	 * @return	void
100
-	 */
96
+    /**
97
+     * Init phpunit tests
98
+     *
99
+     * @return	void
100
+     */
101 101
     protected function setUp()
102 102
     {
103
-    	global $conf,$user,$langs,$db;
104
-		$conf=$this->savconf;
105
-		$user=$this->savuser;
106
-		$langs=$this->savlangs;
107
-		$db=$this->savdb;
103
+        global $conf,$user,$langs,$db;
104
+        $conf=$this->savconf;
105
+        $user=$this->savuser;
106
+        $langs=$this->savlangs;
107
+        $db=$this->savdb;
108 108
 
109
-		print __METHOD__."\n";
109
+        print __METHOD__."\n";
110 110
     }
111
-	/**
112
-	 * End phpunit tests
113
-	 *
114
-	 * @return	void
115
-	 */
111
+    /**
112
+     * End phpunit tests
113
+     *
114
+     * @return	void
115
+     */
116 116
     protected function tearDown()
117 117
     {
118
-    	print __METHOD__."\n";
118
+        print __METHOD__."\n";
119 119
     }
120 120
 
121 121
 
122
-	/**
122
+    /**
123 123
      * testDolBasename
124 124
      *
125 125
      * @return	int
126 126
      */
127 127
     public function testDolBasename()
128 128
     {
129
-    	global $conf,$user,$langs,$db;
130
-		$conf=$this->savconf;
131
-		$user=$this->savuser;
132
-		$langs=$this->savlangs;
133
-		$db=$this->savdb;
129
+        global $conf,$user,$langs,$db;
130
+        $conf=$this->savconf;
131
+        $user=$this->savuser;
132
+        $langs=$this->savlangs;
133
+        $db=$this->savdb;
134 134
 
135 135
         $result=dol_basename('adir/afile');
136
-    	print __METHOD__." result=".$result."\n";
137
-		$this->assertEquals('afile',$result);
136
+        print __METHOD__." result=".$result."\n";
137
+        $this->assertEquals('afile',$result);
138 138
 
139
-		$result=dol_basename('adir/afile/');
140
-    	print __METHOD__." result=".$result."\n";
141
-		$this->assertEquals('afile',$result);
139
+        $result=dol_basename('adir/afile/');
140
+        print __METHOD__." result=".$result."\n";
141
+        $this->assertEquals('afile',$result);
142 142
 
143
-		$result=dol_basename('adir/νεο');    // With cyrillic data. Here basename fails to return correct value
144
-    	print __METHOD__." result=".$result."\n";
145
-		$this->assertEquals('νεο',$result);
143
+        $result=dol_basename('adir/νεο');    // With cyrillic data. Here basename fails to return correct value
144
+        print __METHOD__." result=".$result."\n";
145
+        $this->assertEquals('νεο',$result);
146 146
 
147
-		$result=dol_basename('adir/νεο/');    // With cyrillic data. Here basename fails to return correct value
148
-    	print __METHOD__." result=".$result."\n";
149
-		$this->assertEquals('νεο',$result);
147
+        $result=dol_basename('adir/νεο/');    // With cyrillic data. Here basename fails to return correct value
148
+        print __METHOD__." result=".$result."\n";
149
+        $this->assertEquals('νεο',$result);
150 150
     }
151 151
 
152 152
 
153
-   /**
154
-    * testDolCountNbOfLine
155
-    *
156
-    * @return	int
157
-    */
153
+    /**
154
+     * testDolCountNbOfLine
155
+     *
156
+     * @return	int
157
+     */
158 158
     public function testDolCountNbOfLine()
159 159
     {
160
-    	global $conf,$user,$langs,$db;
161
-		$conf=$this->savconf;
162
-		$user=$this->savuser;
163
-		$langs=$this->savlangs;
164
-		$db=$this->savdb;
165
-
166
-		$file=dirname(__FILE__).'/Example_import_company_1.csv';
167
-		$result=dol_count_nb_of_line($file);
168
-    	print __METHOD__." result=".$result."\n";
169
-		$this->assertEquals(3,$result);
170
-
171
-		return $result;
160
+        global $conf,$user,$langs,$db;
161
+        $conf=$this->savconf;
162
+        $user=$this->savuser;
163
+        $langs=$this->savlangs;
164
+        $db=$this->savdb;
165
+
166
+        $file=dirname(__FILE__).'/Example_import_company_1.csv';
167
+        $result=dol_count_nb_of_line($file);
168
+        print __METHOD__." result=".$result."\n";
169
+        $this->assertEquals(3,$result);
170
+
171
+        return $result;
172 172
     }
173 173
 
174
-   /**
175
-    * testDolIsFileDir
176
-    *
177
-    * @return	int
178
-    */
174
+    /**
175
+     * testDolIsFileDir
176
+     *
177
+     * @return	int
178
+     */
179 179
     public function testDolIsFileDir()
180 180
     {
181
-    	global $conf,$user,$langs,$db;
182
-		$conf=$this->savconf;
183
-		$user=$this->savuser;
184
-		$langs=$this->savlangs;
185
-		$db=$this->savdb;
181
+        global $conf,$user,$langs,$db;
182
+        $conf=$this->savconf;
183
+        $user=$this->savuser;
184
+        $langs=$this->savlangs;
185
+        $db=$this->savdb;
186 186
 
187
-		$file=dirname(__FILE__).'/Example_import_company_1.csv';
187
+        $file=dirname(__FILE__).'/Example_import_company_1.csv';
188 188
 
189
-		$result=dol_is_file($file);
190
-    	print __METHOD__." result=".$result."\n";
191
-		$this->assertTrue($result);
189
+        $result=dol_is_file($file);
190
+        print __METHOD__." result=".$result."\n";
191
+        $this->assertTrue($result);
192 192
 
193
-		$result=dol_is_dir($file);
194
-    	print __METHOD__." result=".$result."\n";
195
-		$this->assertFalse($result);
193
+        $result=dol_is_dir($file);
194
+        print __METHOD__." result=".$result."\n";
195
+        $this->assertFalse($result);
196 196
 
197
-		return $result;
197
+        return $result;
198 198
     }
199 199
 
200 200
     /**
201 201
      * testDolOther
202 202
      *
203 203
      * @return boolean
204
-    */
204
+     */
205 205
     public function testDolOther()
206 206
     {
207 207
         global $conf,$user,$langs,$db;
@@ -211,12 +211,12 @@  discard block
 block discarded – undo
211 211
         $db=$this->savdb;
212 212
 
213 213
         $url='http://www.dolibarr.org';
214
-  		$result=dol_is_url($url);
214
+            $result=dol_is_url($url);
215 215
         print __METHOD__." result=".$result."\n";
216 216
         $this->assertTrue($result);
217 217
 
218 218
         $url='https://www.dolibarr.org';
219
-  		$result=dol_is_url($url);
219
+            $result=dol_is_url($url);
220 220
         print __METHOD__." result=".$result."\n";
221 221
         $this->assertTrue($result);
222 222
 
@@ -235,42 +235,42 @@  discard block
 block discarded – undo
235 235
      */
236 236
     public function testDolMimeType()
237 237
     {
238
-    	global $conf,$user,$langs,$db;
239
-    	$conf=$this->savconf;
240
-    	$user=$this->savuser;
241
-    	$langs=$this->savlangs;
242
-    	$db=$this->savdb;
243
-
244
-    	// file.png
245
-    	$result=dol_mimetype('file.png','',0);
246
-    	$this->assertEquals('image/png',$result);
247
-    	$result=dol_mimetype('file.png','',1);
248
-    	$this->assertEquals('png',$result);
249
-    	$result=dol_mimetype('file.png','',2);
250
-    	$this->assertEquals('image.png',$result);
251
-    	$result=dol_mimetype('file.png','',3);
252
-    	$this->assertEquals('',$result);
253
-    	// file.odt
254
-    	$result=dol_mimetype('file.odt','',0);
255
-    	$this->assertEquals('application/vnd.oasis.opendocument.text',$result);
256
-    	$result=dol_mimetype('file.odt','',1);
257
-    	$this->assertEquals('vnd.oasis.opendocument.text',$result);
258
-    	$result=dol_mimetype('file.odt','',2);
259
-    	$this->assertEquals('ooffice.png',$result);
260
-    	$result=dol_mimetype('file.odt','',3);
261
-    	$this->assertEquals('',$result);
262
-    	// file.php
263
-    	$result=dol_mimetype('file.php','',0);
264
-    	$this->assertEquals('text/plain',$result);
265
-    	$result=dol_mimetype('file.php','',1);
266
-    	$this->assertEquals('plain',$result);
267
-    	$result=dol_mimetype('file.php','',2);
268
-    	$this->assertEquals('php.png',$result);
269
-    	$result=dol_mimetype('file.php','',3);
270
-    	$this->assertEquals('php',$result);
271
-    	// file.php.noexe
272
-    	$result=dol_mimetype('file.php.noexe','',0);
273
-    	$this->assertEquals('text/plain',$result);
238
+        global $conf,$user,$langs,$db;
239
+        $conf=$this->savconf;
240
+        $user=$this->savuser;
241
+        $langs=$this->savlangs;
242
+        $db=$this->savdb;
243
+
244
+        // file.png
245
+        $result=dol_mimetype('file.png','',0);
246
+        $this->assertEquals('image/png',$result);
247
+        $result=dol_mimetype('file.png','',1);
248
+        $this->assertEquals('png',$result);
249
+        $result=dol_mimetype('file.png','',2);
250
+        $this->assertEquals('image.png',$result);
251
+        $result=dol_mimetype('file.png','',3);
252
+        $this->assertEquals('',$result);
253
+        // file.odt
254
+        $result=dol_mimetype('file.odt','',0);
255
+        $this->assertEquals('application/vnd.oasis.opendocument.text',$result);
256
+        $result=dol_mimetype('file.odt','',1);
257
+        $this->assertEquals('vnd.oasis.opendocument.text',$result);
258
+        $result=dol_mimetype('file.odt','',2);
259
+        $this->assertEquals('ooffice.png',$result);
260
+        $result=dol_mimetype('file.odt','',3);
261
+        $this->assertEquals('',$result);
262
+        // file.php
263
+        $result=dol_mimetype('file.php','',0);
264
+        $this->assertEquals('text/plain',$result);
265
+        $result=dol_mimetype('file.php','',1);
266
+        $this->assertEquals('plain',$result);
267
+        $result=dol_mimetype('file.php','',2);
268
+        $this->assertEquals('php.png',$result);
269
+        $result=dol_mimetype('file.php','',3);
270
+        $this->assertEquals('php',$result);
271
+        // file.php.noexe
272
+        $result=dol_mimetype('file.php.noexe','',0);
273
+        $this->assertEquals('text/plain',$result);
274 274
     }
275 275
 
276 276
 
@@ -281,34 +281,34 @@  discard block
 block discarded – undo
281 281
      */
282 282
     public function testDolDeleteDir()
283 283
     {
284
-    	global $conf,$user,$langs,$db;
285
-    	$conf=$this->savconf;
286
-    	$user=$this->savuser;
287
-    	$langs=$this->savlangs;
288
-    	$db=$this->savdb;
289
-
290
-    	$dirout=$conf->admin->dir_temp.'/test';
291
-    	$dirout2=$conf->admin->dir_temp.'/test2';
292
-
293
-    	$count=0;
294
-    	$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
295
-    	print __METHOD__." result=".$result."\n";
296
-    	$this->assertGreaterThanOrEqual(0,$result);
297
-
298
-    	$count=0;
299
-    	$countdeleted=0;
300
-    	$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
301
-    	print __METHOD__." result=".$result."\n";
302
-    	$this->assertGreaterThanOrEqual(0,$result);
303
-    	$this->assertGreaterThanOrEqual(0,$countdeleted);
304
-
305
-    	dol_mkdir($dirout2);
306
-    	$count=0;
307
-    	$countdeleted=0;
308
-    	$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
309
-    	print __METHOD__." result=".$result."\n";
310
-    	$this->assertGreaterThanOrEqual(1,$result);
311
-    	$this->assertGreaterThanOrEqual(1,$countdeleted);
284
+        global $conf,$user,$langs,$db;
285
+        $conf=$this->savconf;
286
+        $user=$this->savuser;
287
+        $langs=$this->savlangs;
288
+        $db=$this->savdb;
289
+
290
+        $dirout=$conf->admin->dir_temp.'/test';
291
+        $dirout2=$conf->admin->dir_temp.'/test2';
292
+
293
+        $count=0;
294
+        $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
295
+        print __METHOD__." result=".$result."\n";
296
+        $this->assertGreaterThanOrEqual(0,$result);
297
+
298
+        $count=0;
299
+        $countdeleted=0;
300
+        $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
301
+        print __METHOD__." result=".$result."\n";
302
+        $this->assertGreaterThanOrEqual(0,$result);
303
+        $this->assertGreaterThanOrEqual(0,$countdeleted);
304
+
305
+        dol_mkdir($dirout2);
306
+        $count=0;
307
+        $countdeleted=0;
308
+        $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
309
+        print __METHOD__." result=".$result."\n";
310
+        $this->assertGreaterThanOrEqual(1,$result);
311
+        $this->assertGreaterThanOrEqual(1,$countdeleted);
312 312
     }
313 313
 
314 314
 
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
         $savpermcreer = $user->rights->facture->creer;
460 460
 
461 461
 
462
-		// Check access to SPECIMEN
462
+        // Check access to SPECIMEN
463 463
         $user->rights->facture->lire = 0;
464 464
         $user->rights->facture->creer = 0;
465 465
         $filename='SPECIMEN.pdf';             // Filename relative to module part
Please login to merge, or discard this patch.
Spacing   +178 added lines, -178 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  *		\remarks	To run this script as CLI:  phpunit filename.php
25 25
  */
26 26
 
27
-global $conf,$user,$langs,$db;
27
+global $conf, $user, $langs, $db;
28 28
 //define('TEST_DB_FORCE_TYPE','mysql');	// This is to force using mysql driver
29 29
 //require_once 'PHPUnit/Autoload.php';
30 30
 require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	$user->fetch(1);
37 37
 	$user->getrights();
38 38
 }
39
-$conf->global->MAIN_DISABLE_ALL_MAILS=1;
39
+$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
40 40
 
41 41
 
42 42
 /**
@@ -64,11 +64,11 @@  discard block
 block discarded – undo
64 64
 		parent::__construct();
65 65
 
66 66
 		//$this->sharedFixture
67
-		global $conf,$user,$langs,$db;
68
-		$this->savconf=$conf;
69
-		$this->savuser=$user;
70
-		$this->savlangs=$langs;
71
-		$this->savdb=$db;
67
+		global $conf, $user, $langs, $db;
68
+		$this->savconf = $conf;
69
+		$this->savuser = $user;
70
+		$this->savlangs = $langs;
71
+		$this->savdb = $db;
72 72
 
73 73
 		print __METHOD__." db->type=".$db->type." user->id=".$user->id;
74 74
 		//print " - db ".$db->db;
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
 	// Static methods
79 79
   	public static function setUpBeforeClass()
80 80
     {
81
-    	global $conf,$user,$langs,$db;
82
-		$db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
81
+    	global $conf, $user, $langs, $db;
82
+		$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
83 83
 
84 84
     	print __METHOD__."\n";
85 85
     }
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
     // tear down after class
88 88
     public static function tearDownAfterClass()
89 89
     {
90
-    	global $conf,$user,$langs,$db;
90
+    	global $conf, $user, $langs, $db;
91 91
 		$db->rollback();
92 92
 
93 93
 		print __METHOD__."\n";
@@ -100,11 +100,11 @@  discard block
 block discarded – undo
100 100
 	 */
101 101
     protected function setUp()
102 102
     {
103
-    	global $conf,$user,$langs,$db;
104
-		$conf=$this->savconf;
105
-		$user=$this->savuser;
106
-		$langs=$this->savlangs;
107
-		$db=$this->savdb;
103
+    	global $conf, $user, $langs, $db;
104
+		$conf = $this->savconf;
105
+		$user = $this->savuser;
106
+		$langs = $this->savlangs;
107
+		$db = $this->savdb;
108 108
 
109 109
 		print __METHOD__."\n";
110 110
     }
@@ -126,27 +126,27 @@  discard block
 block discarded – undo
126 126
      */
127 127
     public function testDolBasename()
128 128
     {
129
-    	global $conf,$user,$langs,$db;
130
-		$conf=$this->savconf;
131
-		$user=$this->savuser;
132
-		$langs=$this->savlangs;
133
-		$db=$this->savdb;
129
+    	global $conf, $user, $langs, $db;
130
+		$conf = $this->savconf;
131
+		$user = $this->savuser;
132
+		$langs = $this->savlangs;
133
+		$db = $this->savdb;
134 134
 
135
-        $result=dol_basename('adir/afile');
135
+        $result = dol_basename('adir/afile');
136 136
     	print __METHOD__." result=".$result."\n";
137
-		$this->assertEquals('afile',$result);
137
+		$this->assertEquals('afile', $result);
138 138
 
139
-		$result=dol_basename('adir/afile/');
139
+		$result = dol_basename('adir/afile/');
140 140
     	print __METHOD__." result=".$result."\n";
141
-		$this->assertEquals('afile',$result);
141
+		$this->assertEquals('afile', $result);
142 142
 
143
-		$result=dol_basename('adir/νεο');    // With cyrillic data. Here basename fails to return correct value
143
+		$result = dol_basename('adir/νεο'); // With cyrillic data. Here basename fails to return correct value
144 144
     	print __METHOD__." result=".$result."\n";
145
-		$this->assertEquals('νεο',$result);
145
+		$this->assertEquals('νεο', $result);
146 146
 
147
-		$result=dol_basename('adir/νεο/');    // With cyrillic data. Here basename fails to return correct value
147
+		$result = dol_basename('adir/νεο/'); // With cyrillic data. Here basename fails to return correct value
148 148
     	print __METHOD__." result=".$result."\n";
149
-		$this->assertEquals('νεο',$result);
149
+		$this->assertEquals('νεο', $result);
150 150
     }
151 151
 
152 152
 
@@ -157,16 +157,16 @@  discard block
 block discarded – undo
157 157
     */
158 158
     public function testDolCountNbOfLine()
159 159
     {
160
-    	global $conf,$user,$langs,$db;
161
-		$conf=$this->savconf;
162
-		$user=$this->savuser;
163
-		$langs=$this->savlangs;
164
-		$db=$this->savdb;
165
-
166
-		$file=dirname(__FILE__).'/Example_import_company_1.csv';
167
-		$result=dol_count_nb_of_line($file);
160
+    	global $conf, $user, $langs, $db;
161
+		$conf = $this->savconf;
162
+		$user = $this->savuser;
163
+		$langs = $this->savlangs;
164
+		$db = $this->savdb;
165
+
166
+		$file = dirname(__FILE__).'/Example_import_company_1.csv';
167
+		$result = dol_count_nb_of_line($file);
168 168
     	print __METHOD__." result=".$result."\n";
169
-		$this->assertEquals(3,$result);
169
+		$this->assertEquals(3, $result);
170 170
 
171 171
 		return $result;
172 172
     }
@@ -178,19 +178,19 @@  discard block
 block discarded – undo
178 178
     */
179 179
     public function testDolIsFileDir()
180 180
     {
181
-    	global $conf,$user,$langs,$db;
182
-		$conf=$this->savconf;
183
-		$user=$this->savuser;
184
-		$langs=$this->savlangs;
185
-		$db=$this->savdb;
181
+    	global $conf, $user, $langs, $db;
182
+		$conf = $this->savconf;
183
+		$user = $this->savuser;
184
+		$langs = $this->savlangs;
185
+		$db = $this->savdb;
186 186
 
187
-		$file=dirname(__FILE__).'/Example_import_company_1.csv';
187
+		$file = dirname(__FILE__).'/Example_import_company_1.csv';
188 188
 
189
-		$result=dol_is_file($file);
189
+		$result = dol_is_file($file);
190 190
     	print __METHOD__." result=".$result."\n";
191 191
 		$this->assertTrue($result);
192 192
 
193
-		$result=dol_is_dir($file);
193
+		$result = dol_is_dir($file);
194 194
     	print __METHOD__." result=".$result."\n";
195 195
 		$this->assertFalse($result);
196 196
 
@@ -204,24 +204,24 @@  discard block
 block discarded – undo
204 204
     */
205 205
     public function testDolOther()
206 206
     {
207
-        global $conf,$user,$langs,$db;
208
-        $conf=$this->savconf;
209
-        $user=$this->savuser;
210
-        $langs=$this->savlangs;
211
-        $db=$this->savdb;
212
-
213
-        $url='http://www.dolibarr.org';
214
-  		$result=dol_is_url($url);
207
+        global $conf, $user, $langs, $db;
208
+        $conf = $this->savconf;
209
+        $user = $this->savuser;
210
+        $langs = $this->savlangs;
211
+        $db = $this->savdb;
212
+
213
+        $url = 'http://www.dolibarr.org';
214
+  		$result = dol_is_url($url);
215 215
         print __METHOD__." result=".$result."\n";
216 216
         $this->assertTrue($result);
217 217
 
218
-        $url='https://www.dolibarr.org';
219
-  		$result=dol_is_url($url);
218
+        $url = 'https://www.dolibarr.org';
219
+  		$result = dol_is_url($url);
220 220
         print __METHOD__." result=".$result."\n";
221 221
         $this->assertTrue($result);
222 222
 
223
-        $url='file://www.dolibarr.org/download/file.zip';
224
-        $result=dol_is_url($url);
223
+        $url = 'file://www.dolibarr.org/download/file.zip';
224
+        $result = dol_is_url($url);
225 225
         print __METHOD__." result=".$result."\n";
226 226
         $this->assertTrue($result);
227 227
 
@@ -235,42 +235,42 @@  discard block
 block discarded – undo
235 235
      */
236 236
     public function testDolMimeType()
237 237
     {
238
-    	global $conf,$user,$langs,$db;
239
-    	$conf=$this->savconf;
240
-    	$user=$this->savuser;
241
-    	$langs=$this->savlangs;
242
-    	$db=$this->savdb;
238
+    	global $conf, $user, $langs, $db;
239
+    	$conf = $this->savconf;
240
+    	$user = $this->savuser;
241
+    	$langs = $this->savlangs;
242
+    	$db = $this->savdb;
243 243
 
244 244
     	// file.png
245
-    	$result=dol_mimetype('file.png','',0);
246
-    	$this->assertEquals('image/png',$result);
247
-    	$result=dol_mimetype('file.png','',1);
248
-    	$this->assertEquals('png',$result);
249
-    	$result=dol_mimetype('file.png','',2);
250
-    	$this->assertEquals('image.png',$result);
251
-    	$result=dol_mimetype('file.png','',3);
252
-    	$this->assertEquals('',$result);
245
+    	$result = dol_mimetype('file.png', '', 0);
246
+    	$this->assertEquals('image/png', $result);
247
+    	$result = dol_mimetype('file.png', '', 1);
248
+    	$this->assertEquals('png', $result);
249
+    	$result = dol_mimetype('file.png', '', 2);
250
+    	$this->assertEquals('image.png', $result);
251
+    	$result = dol_mimetype('file.png', '', 3);
252
+    	$this->assertEquals('', $result);
253 253
     	// file.odt
254
-    	$result=dol_mimetype('file.odt','',0);
255
-    	$this->assertEquals('application/vnd.oasis.opendocument.text',$result);
256
-    	$result=dol_mimetype('file.odt','',1);
257
-    	$this->assertEquals('vnd.oasis.opendocument.text',$result);
258
-    	$result=dol_mimetype('file.odt','',2);
259
-    	$this->assertEquals('ooffice.png',$result);
260
-    	$result=dol_mimetype('file.odt','',3);
261
-    	$this->assertEquals('',$result);
254
+    	$result = dol_mimetype('file.odt', '', 0);
255
+    	$this->assertEquals('application/vnd.oasis.opendocument.text', $result);
256
+    	$result = dol_mimetype('file.odt', '', 1);
257
+    	$this->assertEquals('vnd.oasis.opendocument.text', $result);
258
+    	$result = dol_mimetype('file.odt', '', 2);
259
+    	$this->assertEquals('ooffice.png', $result);
260
+    	$result = dol_mimetype('file.odt', '', 3);
261
+    	$this->assertEquals('', $result);
262 262
     	// file.php
263
-    	$result=dol_mimetype('file.php','',0);
264
-    	$this->assertEquals('text/plain',$result);
265
-    	$result=dol_mimetype('file.php','',1);
266
-    	$this->assertEquals('plain',$result);
267
-    	$result=dol_mimetype('file.php','',2);
268
-    	$this->assertEquals('php.png',$result);
269
-    	$result=dol_mimetype('file.php','',3);
270
-    	$this->assertEquals('php',$result);
263
+    	$result = dol_mimetype('file.php', '', 0);
264
+    	$this->assertEquals('text/plain', $result);
265
+    	$result = dol_mimetype('file.php', '', 1);
266
+    	$this->assertEquals('plain', $result);
267
+    	$result = dol_mimetype('file.php', '', 2);
268
+    	$this->assertEquals('php.png', $result);
269
+    	$result = dol_mimetype('file.php', '', 3);
270
+    	$this->assertEquals('php', $result);
271 271
     	// file.php.noexe
272
-    	$result=dol_mimetype('file.php.noexe','',0);
273
-    	$this->assertEquals('text/plain',$result);
272
+    	$result = dol_mimetype('file.php.noexe', '', 0);
273
+    	$this->assertEquals('text/plain', $result);
274 274
     }
275 275
 
276 276
 
@@ -281,34 +281,34 @@  discard block
 block discarded – undo
281 281
      */
282 282
     public function testDolDeleteDir()
283 283
     {
284
-    	global $conf,$user,$langs,$db;
285
-    	$conf=$this->savconf;
286
-    	$user=$this->savuser;
287
-    	$langs=$this->savlangs;
288
-    	$db=$this->savdb;
284
+    	global $conf, $user, $langs, $db;
285
+    	$conf = $this->savconf;
286
+    	$user = $this->savuser;
287
+    	$langs = $this->savlangs;
288
+    	$db = $this->savdb;
289 289
 
290
-    	$dirout=$conf->admin->dir_temp.'/test';
291
-    	$dirout2=$conf->admin->dir_temp.'/test2';
290
+    	$dirout = $conf->admin->dir_temp.'/test';
291
+    	$dirout2 = $conf->admin->dir_temp.'/test2';
292 292
 
293
-    	$count=0;
294
-    	$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
293
+    	$count = 0;
294
+    	$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
295 295
     	print __METHOD__." result=".$result."\n";
296
-    	$this->assertGreaterThanOrEqual(0,$result);
296
+    	$this->assertGreaterThanOrEqual(0, $result);
297 297
 
298
-    	$count=0;
299
-    	$countdeleted=0;
300
-    	$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
298
+    	$count = 0;
299
+    	$countdeleted = 0;
300
+    	$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
301 301
     	print __METHOD__." result=".$result."\n";
302
-    	$this->assertGreaterThanOrEqual(0,$result);
303
-    	$this->assertGreaterThanOrEqual(0,$countdeleted);
302
+    	$this->assertGreaterThanOrEqual(0, $result);
303
+    	$this->assertGreaterThanOrEqual(0, $countdeleted);
304 304
 
305 305
     	dol_mkdir($dirout2);
306
-    	$count=0;
307
-    	$countdeleted=0;
308
-    	$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
306
+    	$count = 0;
307
+    	$countdeleted = 0;
308
+    	$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
309 309
     	print __METHOD__." result=".$result."\n";
310
-    	$this->assertGreaterThanOrEqual(1,$result);
311
-    	$this->assertGreaterThanOrEqual(1,$countdeleted);
310
+    	$this->assertGreaterThanOrEqual(1, $result);
311
+    	$this->assertGreaterThanOrEqual(1, $countdeleted);
312 312
     }
313 313
 
314 314
 
@@ -322,66 +322,66 @@  discard block
 block discarded – undo
322 322
      */
323 323
     public function testDolCopyMoveDelete()
324 324
     {
325
-        global $conf,$user,$langs,$db;
326
-        $conf=$this->savconf;
327
-        $user=$this->savuser;
328
-        $langs=$this->savlangs;
329
-        $db=$this->savdb;
325
+        global $conf, $user, $langs, $db;
326
+        $conf = $this->savconf;
327
+        $user = $this->savuser;
328
+        $langs = $this->savlangs;
329
+        $db = $this->savdb;
330 330
 
331
-        $file=dirname(__FILE__).'/Example_import_company_1.csv';
331
+        $file = dirname(__FILE__).'/Example_import_company_1.csv';
332 332
 
333
-        $result=dol_copy($file, '/adir/that/does/not/exists/file.csv');
333
+        $result = dol_copy($file, '/adir/that/does/not/exists/file.csv');
334 334
         print __METHOD__." result=".$result."\n";
335
-        $this->assertLessThan(0,$result,'copy dir that does not exists');    // We should have error
335
+        $this->assertLessThan(0, $result, 'copy dir that does not exists'); // We should have error
336 336
 
337
-        $result=dol_copy($file, $conf->admin->dir_temp.'/file.csv',0,1);
337
+        $result = dol_copy($file, $conf->admin->dir_temp.'/file.csv', 0, 1);
338 338
         print __METHOD__." result=".$result."\n";
339
-        $this->assertGreaterThanOrEqual(1,$result, 'copy file ('.$file.') into a dir that exists ('.$conf->admin->dir_temp.'/file.csv'.')');    // Should be 1
339
+        $this->assertGreaterThanOrEqual(1, $result, 'copy file ('.$file.') into a dir that exists ('.$conf->admin->dir_temp.'/file.csv'.')'); // Should be 1
340 340
 
341 341
         // Again to test with overwriting=0
342
-        $result=dol_copy($file, $conf->admin->dir_temp.'/file.csv',0,0);
342
+        $result = dol_copy($file, $conf->admin->dir_temp.'/file.csv', 0, 0);
343 343
         print __METHOD__." result=".$result."\n";
344
-        $this->assertEquals(0,$result, 'copy destination already exists, no overwrite');    // Should be 0
344
+        $this->assertEquals(0, $result, 'copy destination already exists, no overwrite'); // Should be 0
345 345
 
346 346
         // Again to test with overwriting=1
347
-        $result=dol_copy($file, $conf->admin->dir_temp.'/file.csv',0,1);
347
+        $result = dol_copy($file, $conf->admin->dir_temp.'/file.csv', 0, 1);
348 348
         print __METHOD__." result=".$result."\n";
349
-        $this->assertGreaterThanOrEqual(1,$result,'copy destination already exists, overwrite');    // Should be 1
349
+        $this->assertGreaterThanOrEqual(1, $result, 'copy destination already exists, overwrite'); // Should be 1
350 350
 
351 351
         // To test a move that should work
352
-        $result=dol_move($conf->admin->dir_temp.'/file.csv',$conf->admin->dir_temp.'/file2.csv',0,1);
352
+        $result = dol_move($conf->admin->dir_temp.'/file.csv', $conf->admin->dir_temp.'/file2.csv', 0, 1);
353 353
         print __METHOD__." result=".$result."\n";
354
-        $this->assertTrue($result,'move with default mask');
354
+        $this->assertTrue($result, 'move with default mask');
355 355
 
356 356
         // To test a move that should work with forced mask
357
-        $result=dol_move($conf->admin->dir_temp.'/file2.csv',$conf->admin->dir_temp.'/file3.csv','0754',1); // file shoutld be rwxr-wr--
357
+        $result = dol_move($conf->admin->dir_temp.'/file2.csv', $conf->admin->dir_temp.'/file3.csv', '0754', 1); // file shoutld be rwxr-wr--
358 358
         print __METHOD__." result=".$result."\n";
359
-        $this->assertTrue($result,'move with forced mask');
359
+        $this->assertTrue($result, 'move with forced mask');
360 360
 
361 361
         // To test a delete that should success
362
-        $result=dol_delete_file($conf->admin->dir_temp.'/file3.csv');
362
+        $result = dol_delete_file($conf->admin->dir_temp.'/file3.csv');
363 363
         print __METHOD__." result=".$result."\n";
364
-        $this->assertTrue($result,'delete file');
364
+        $this->assertTrue($result, 'delete file');
365 365
 
366 366
         // Again to test there is error when deleting a non existing file with option disableglob
367
-        $result=dol_delete_file($conf->admin->dir_temp.'/file3.csv',1,1);
367
+        $result = dol_delete_file($conf->admin->dir_temp.'/file3.csv', 1, 1);
368 368
         print __METHOD__." result=".$result."\n";
369
-        $this->assertFalse($result,'delete file that does not exists with disableglo must return ko');
369
+        $this->assertFalse($result, 'delete file that does not exists with disableglo must return ko');
370 370
 
371 371
         // Again to test there is no error when deleting a non existing file without option disableglob
372
-        $result=dol_delete_file($conf->admin->dir_temp.'/file3csv',0,1);
372
+        $result = dol_delete_file($conf->admin->dir_temp.'/file3csv', 0, 1);
373 373
         print __METHOD__." result=".$result."\n";
374
-        $this->assertTrue($result,'delete file that does not exists without disabling glob must return ok');
374
+        $this->assertTrue($result, 'delete file that does not exists without disabling glob must return ok');
375 375
 
376 376
         // Test copy with special char / delete with blob
377
-        $result=dol_copy($file, $conf->admin->dir_temp.'/file with [x] and é.csv',0,1);
377
+        $result = dol_copy($file, $conf->admin->dir_temp.'/file with [x] and é.csv', 0, 1);
378 378
         print __METHOD__." result=".$result."\n";
379
-        $this->assertGreaterThanOrEqual(1,$result,'copy file with special chars, overwrite');    // Should be 1
379
+        $this->assertGreaterThanOrEqual(1, $result, 'copy file with special chars, overwrite'); // Should be 1
380 380
 
381 381
         // Try to delete using a glob criteria
382
-        $result=dol_delete_file($conf->admin->dir_temp.'/file with [x]*é.csv');
382
+        $result = dol_delete_file($conf->admin->dir_temp.'/file with [x]*é.csv');
383 383
         print __METHOD__." result=".$result."\n";
384
-        $this->assertTrue($result,'delete file using glob');
384
+        $this->assertTrue($result, 'delete file using glob');
385 385
     }
386 386
 
387 387
     /**
@@ -394,28 +394,28 @@  discard block
 block discarded – undo
394 394
      */
395 395
     public function testDolCompressUnCompress()
396 396
     {
397
-        global $conf,$user,$langs,$db;
398
-        $conf=$this->savconf;
399
-        $user=$this->savuser;
400
-        $langs=$this->savlangs;
401
-        $db=$this->savdb;
397
+        global $conf, $user, $langs, $db;
398
+        $conf = $this->savconf;
399
+        $user = $this->savuser;
400
+        $langs = $this->savlangs;
401
+        $db = $this->savdb;
402 402
 
403
-        $format='zip';
404
-        $filein=dirname(__FILE__).'/Example_import_company_1.csv';
405
-        $fileout=$conf->admin->dir_temp.'/test.'.$format;
406
-        $dirout=$conf->admin->dir_temp.'/test';
403
+        $format = 'zip';
404
+        $filein = dirname(__FILE__).'/Example_import_company_1.csv';
405
+        $fileout = $conf->admin->dir_temp.'/test.'.$format;
406
+        $dirout = $conf->admin->dir_temp.'/test';
407 407
 
408 408
         dol_delete_file($fileout);
409
-        $count=0;
410
-        dol_delete_dir_recursive($dirout,$count,1);
409
+        $count = 0;
410
+        dol_delete_dir_recursive($dirout, $count, 1);
411 411
 
412
-        $result=dol_compress_file($filein, $fileout, $format);
412
+        $result = dol_compress_file($filein, $fileout, $format);
413 413
         print __METHOD__." result=".$result."\n";
414
-        $this->assertGreaterThanOrEqual(1,$result);
414
+        $this->assertGreaterThanOrEqual(1, $result);
415 415
 
416
-        $result=dol_uncompress($fileout, $dirout);
417
-        print __METHOD__." result=".join(',',$result)."\n";
418
-        $this->assertEquals(0,count($result));
416
+        $result = dol_uncompress($fileout, $dirout);
417
+        print __METHOD__." result=".join(',', $result)."\n";
418
+        $this->assertEquals(0, count($result));
419 419
     }
420 420
 
421 421
     /**
@@ -428,12 +428,12 @@  discard block
 block discarded – undo
428 428
      */
429 429
     public function testDolDirList()
430 430
     {
431
-        global $conf,$user,$langs,$db;
431
+        global $conf, $user, $langs, $db;
432 432
 
433 433
         // Scan dir to guaruante we on't have library jquery twice (we accept exception of duplicte into ckeditor because all dir is removed for debian package, so there is no duplicate).
434
-        $founddirs=dol_dir_list(DOL_DOCUMENT_ROOT.'/includes/', 'files', 1, '^jquery\.js', array('ckeditor'));
434
+        $founddirs = dol_dir_list(DOL_DOCUMENT_ROOT.'/includes/', 'files', 1, '^jquery\.js', array('ckeditor'));
435 435
         print __METHOD__." count(founddirs)=".count($founddirs)."\n";
436
-        $this->assertEquals(1,count($founddirs));
436
+        $this->assertEquals(1, count($founddirs));
437 437
     }
438 438
 
439 439
 
@@ -444,11 +444,11 @@  discard block
 block discarded – undo
444 444
      */
445 445
     public function testDolCheckSecureAccessDocument()
446 446
     {
447
-        global $conf,$user,$langs,$db;
448
-        $conf=$this->savconf;
449
-        $user=$this->savuser;
450
-        $langs=$this->savlangs;
451
-        $db=$this->savdb;
447
+        global $conf, $user, $langs, $db;
448
+        $conf = $this->savconf;
449
+        $user = $this->savuser;
450
+        $langs = $this->savlangs;
451
+        $db = $this->savdb;
452 452
 
453 453
 
454 454
         //$dummyuser=new User($db);
@@ -462,42 +462,42 @@  discard block
 block discarded – undo
462 462
 		// Check access to SPECIMEN
463 463
         $user->rights->facture->lire = 0;
464 464
         $user->rights->facture->creer = 0;
465
-        $filename='SPECIMEN.pdf';             // Filename relative to module part
466
-        $result=dol_check_secure_access_document('facture', $filename, 0, '', '', 'read');
467
-        $this->assertEquals(1,$result['accessallowed']);
465
+        $filename = 'SPECIMEN.pdf'; // Filename relative to module part
466
+        $result = dol_check_secure_access_document('facture', $filename, 0, '', '', 'read');
467
+        $this->assertEquals(1, $result['accessallowed']);
468 468
 
469 469
 
470 470
         // Check read permission
471 471
         $user->rights->facture->lire = 1;
472 472
         $user->rights->facture->creer = 1;
473
-        $filename='FA010101/FA010101.pdf';    // Filename relative to module part
474
-        $result=dol_check_secure_access_document('facture', $filename, 0, '', '', 'read');
475
-        $this->assertEquals(1,$result['accessallowed']);
473
+        $filename = 'FA010101/FA010101.pdf'; // Filename relative to module part
474
+        $result = dol_check_secure_access_document('facture', $filename, 0, '', '', 'read');
475
+        $this->assertEquals(1, $result['accessallowed']);
476 476
 
477 477
         $user->rights->facture->lire = 0;
478 478
         $user->rights->facture->creer = 0;
479
-        $filename='FA010101/FA010101.pdf';    // Filename relative to module part
480
-        $result=dol_check_secure_access_document('facture', $filename, 0, '', '', 'read');
481
-        $this->assertEquals(0,$result['accessallowed']);
479
+        $filename = 'FA010101/FA010101.pdf'; // Filename relative to module part
480
+        $result = dol_check_secure_access_document('facture', $filename, 0, '', '', 'read');
481
+        $this->assertEquals(0, $result['accessallowed']);
482 482
 
483 483
         // Check write permission
484 484
         $user->rights->facture->lire = 0;
485 485
         $user->rights->facture->creer = 0;
486
-        $filename='FA010101/FA010101.pdf';    // Filename relative to module part
487
-        $result=dol_check_secure_access_document('facture', $filename, 0, '', '', 'write');
488
-        $this->assertEquals(0,$result['accessallowed']);
486
+        $filename = 'FA010101/FA010101.pdf'; // Filename relative to module part
487
+        $result = dol_check_secure_access_document('facture', $filename, 0, '', '', 'write');
488
+        $this->assertEquals(0, $result['accessallowed']);
489 489
 
490 490
         $user->rights->facture->lire = 1;
491 491
         $user->rights->facture->creer = 1;
492
-        $filename='FA010101/FA010101.pdf';    // Filename relative to module part
493
-        $result=dol_check_secure_access_document('facture', $filename, 0, '', '', 'write');
494
-        $this->assertEquals(1,$result['accessallowed']);
492
+        $filename = 'FA010101/FA010101.pdf'; // Filename relative to module part
493
+        $result = dol_check_secure_access_document('facture', $filename, 0, '', '', 'write');
494
+        $this->assertEquals(1, $result['accessallowed']);
495 495
 
496 496
         $user->rights->facture->lire = 1;
497 497
         $user->rights->facture->creer = 0;
498
-        $filename='FA010101/FA010101.pdf';    // Filename relative to module part
499
-        $result=dol_check_secure_access_document('facture', $filename, 0, '', '', 'write');
500
-        $this->assertEquals(0,$result['accessallowed']);
498
+        $filename = 'FA010101/FA010101.pdf'; // Filename relative to module part
499
+        $result = dol_check_secure_access_document('facture', $filename, 0, '', '', 'write');
500
+        $this->assertEquals(0, $result['accessallowed']);
501 501
 
502 502
 
503 503
         // We restore user properties
Please login to merge, or discard this patch.
dolibarr/test/phpunit/BonPrelevementTest.php 2 patches
Indentation   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
 
32 32
 if (empty($user->id))
33 33
 {
34
-	print "Load permissions for admin user nb 1\n";
35
-	$user->fetch(1);
36
-	$user->getrights();
34
+    print "Load permissions for admin user nb 1\n";
35
+    $user->fetch(1);
36
+    $user->getrights();
37 37
 }
38 38
 $conf->global->MAIN_DISABLE_ALL_MAILS=1;
39 39
 
@@ -49,32 +49,32 @@  discard block
 block discarded – undo
49 49
  */
50 50
 class BonPrelevementTest extends PHPUnit_Framework_TestCase
51 51
 {
52
-	protected $savconf;
53
-	protected $savuser;
54
-	protected $savlangs;
55
-	protected $savdb;
56
-
57
-	/**
58
-	 * Constructor
59
-	 * We save global variables into local variables
60
-	 *
61
-	 * @return BankAccountTest
62
-	 */
63
-	function __construct()
64
-	{
65
-		parent::__construct();
66
-
67
-		//$this->sharedFixture
68
-		global $conf,$user,$langs,$db;
69
-		$this->savconf=$conf;
70
-		$this->savuser=$user;
71
-		$this->savlangs=$langs;
72
-		$this->savdb=$db;
73
-
74
-		print __METHOD__." db->type=".$db->type." user->id=".$user->id;
75
-		//print " - db ".$db->db;
76
-		print "\n";
77
-	}
52
+    protected $savconf;
53
+    protected $savuser;
54
+    protected $savlangs;
55
+    protected $savdb;
56
+
57
+    /**
58
+     * Constructor
59
+     * We save global variables into local variables
60
+     *
61
+     * @return BankAccountTest
62
+     */
63
+    function __construct()
64
+    {
65
+        parent::__construct();
66
+
67
+        //$this->sharedFixture
68
+        global $conf,$user,$langs,$db;
69
+        $this->savconf=$conf;
70
+        $this->savuser=$user;
71
+        $this->savlangs=$langs;
72
+        $this->savdb=$db;
73
+
74
+        print __METHOD__." db->type=".$db->type." user->id=".$user->id;
75
+        //print " - db ".$db->db;
76
+        print "\n";
77
+    }
78 78
 
79 79
     /**
80 80
      * setUpBeforeClass
@@ -83,10 +83,10 @@  discard block
 block discarded – undo
83 83
      */
84 84
     public static function setUpBeforeClass()
85 85
     {
86
-    	global $conf,$user,$langs,$db;
87
-		$db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
86
+        global $conf,$user,$langs,$db;
87
+        $db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
88 88
 
89
-    	print __METHOD__."\n";
89
+        print __METHOD__."\n";
90 90
     }
91 91
 
92 92
     /**
@@ -96,35 +96,35 @@  discard block
 block discarded – undo
96 96
      */
97 97
     public static function tearDownAfterClass()
98 98
     {
99
-    	global $conf,$user,$langs,$db;
100
-		$db->rollback();
99
+        global $conf,$user,$langs,$db;
100
+        $db->rollback();
101 101
 
102
-		print __METHOD__."\n";
102
+        print __METHOD__."\n";
103 103
     }
104 104
 
105
-	/**
106
-	 * Init phpunit tests
107
-	 *
108
-	 * @return	void
109
-	 */
105
+    /**
106
+     * Init phpunit tests
107
+     *
108
+     * @return	void
109
+     */
110 110
     protected function setUp()
111 111
     {
112
-    	global $conf,$user,$langs,$db;
113
-		$conf=$this->savconf;
114
-		$user=$this->savuser;
115
-		$langs=$this->savlangs;
116
-		$db=$this->savdb;
112
+        global $conf,$user,$langs,$db;
113
+        $conf=$this->savconf;
114
+        $user=$this->savuser;
115
+        $langs=$this->savlangs;
116
+        $db=$this->savdb;
117 117
 
118
-		print __METHOD__."\n";
118
+        print __METHOD__."\n";
119 119
     }
120
-	/**
121
-	 * End phpunit tests
122
-	 *
123
-	 * @return	void
124
-	 */
120
+    /**
121
+     * End phpunit tests
122
+     *
123
+     * @return	void
124
+     */
125 125
     protected function tearDown()
126 126
     {
127
-    	print __METHOD__."\n";
127
+        print __METHOD__."\n";
128 128
     }
129 129
 
130 130
     /**
@@ -134,34 +134,34 @@  discard block
 block discarded – undo
134 134
      */
135 135
     public function testBonPrelevementCreate()
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
-		// TODO
144
-		// Create invoice
143
+        // TODO
144
+        // Create invoice
145 145
 
146 146
 
147
-		// Create payment with mode withdraw
147
+        // Create payment with mode withdraw
148 148
 
149 149
 
150
-		// Ask withdraw request
150
+        // Ask withdraw request
151 151
 
152 152
 
153
-		// Create withdraw record and generate SEPA file
154
-		$localobject=new BonPrelevement($this->savdb);
155
-    	//$localobject->date_solde=dol_now();
156
-    	$result=$localobject->Create(0,0,'simu');
153
+        // Create withdraw record and generate SEPA file
154
+        $localobject=new BonPrelevement($this->savdb);
155
+        //$localobject->date_solde=dol_now();
156
+        $result=$localobject->Create(0,0,'simu');
157 157
 
158
-    	print __METHOD__." result=".$result."\n";
159
-    	$this->assertEquals($result, 0);
158
+        print __METHOD__." result=".$result."\n";
159
+        $this->assertEquals($result, 0);
160 160
 
161
-    	// Test SEPA file
161
+        // Test SEPA file
162 162
 
163 163
 
164
-    	return $result;
164
+        return $result;
165 165
     }
166 166
 
167 167
     /**
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  *		\remarks	To run this script as CLI:  phpunit filename.php
24 24
  */
25 25
 
26
-global $conf,$user,$langs,$db;
26
+global $conf, $user, $langs, $db;
27 27
 //define('TEST_DB_FORCE_TYPE','mysql');	// This is to force using mysql driver
28 28
 //require_once 'PHPUnit/Autoload.php';
29 29
 require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	$user->fetch(1);
36 36
 	$user->getrights();
37 37
 }
38
-$conf->global->MAIN_DISABLE_ALL_MAILS=1;
38
+$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
39 39
 
40 40
 $langs->load("main");
41 41
 
@@ -65,11 +65,11 @@  discard block
 block discarded – undo
65 65
 		parent::__construct();
66 66
 
67 67
 		//$this->sharedFixture
68
-		global $conf,$user,$langs,$db;
69
-		$this->savconf=$conf;
70
-		$this->savuser=$user;
71
-		$this->savlangs=$langs;
72
-		$this->savdb=$db;
68
+		global $conf, $user, $langs, $db;
69
+		$this->savconf = $conf;
70
+		$this->savuser = $user;
71
+		$this->savlangs = $langs;
72
+		$this->savdb = $db;
73 73
 
74 74
 		print __METHOD__." db->type=".$db->type." user->id=".$user->id;
75 75
 		//print " - db ".$db->db;
@@ -83,8 +83,8 @@  discard block
 block discarded – undo
83 83
      */
84 84
     public static function setUpBeforeClass()
85 85
     {
86
-    	global $conf,$user,$langs,$db;
87
-		$db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
86
+    	global $conf, $user, $langs, $db;
87
+		$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
88 88
 
89 89
     	print __METHOD__."\n";
90 90
     }
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
      */
97 97
     public static function tearDownAfterClass()
98 98
     {
99
-    	global $conf,$user,$langs,$db;
99
+    	global $conf, $user, $langs, $db;
100 100
 		$db->rollback();
101 101
 
102 102
 		print __METHOD__."\n";
@@ -109,11 +109,11 @@  discard block
 block discarded – undo
109 109
 	 */
110 110
     protected function setUp()
111 111
     {
112
-    	global $conf,$user,$langs,$db;
113
-		$conf=$this->savconf;
114
-		$user=$this->savuser;
115
-		$langs=$this->savlangs;
116
-		$db=$this->savdb;
112
+    	global $conf, $user, $langs, $db;
113
+		$conf = $this->savconf;
114
+		$user = $this->savuser;
115
+		$langs = $this->savlangs;
116
+		$db = $this->savdb;
117 117
 
118 118
 		print __METHOD__."\n";
119 119
     }
@@ -134,11 +134,11 @@  discard block
 block discarded – undo
134 134
      */
135 135
     public function testBonPrelevementCreate()
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 143
 		// TODO
144 144
 		// Create invoice
@@ -151,9 +151,9 @@  discard block
 block discarded – undo
151 151
 
152 152
 
153 153
 		// Create withdraw record and generate SEPA file
154
-		$localobject=new BonPrelevement($this->savdb);
154
+		$localobject = new BonPrelevement($this->savdb);
155 155
     	//$localobject->date_solde=dol_now();
156
-    	$result=$localobject->Create(0,0,'simu');
156
+    	$result = $localobject->Create(0, 0, 'simu');
157 157
 
158 158
     	print __METHOD__." result=".$result."\n";
159 159
     	$this->assertEquals($result, 0);
Please login to merge, or discard this patch.
dolibarr/test/phpunit/UserGroupTest.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -59,9 +59,9 @@  discard block
 block discarded – undo
59 59
      */
60 60
     function __construct()
61 61
     {
62
-    	parent::__construct();
62
+        parent::__construct();
63 63
 
64
-    	//$this->sharedFixture
64
+        //$this->sharedFixture
65 65
         global $conf,$user,$langs,$db;
66 66
         $this->savconf=$conf;
67 67
         $this->savuser=$user;
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
      * Init phpunit tests
96 96
      *
97 97
      * @return  void
98
-    */
98
+     */
99 99
     protected function setUp()
100 100
     {
101 101
         global $conf,$user,$langs,$db;
Please login to merge, or discard this patch.
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  *      \remarks    To run this script as CLI:  phpunit filename.php
24 24
  */
25 25
 
26
-global $conf,$user,$langs,$db;
26
+global $conf, $user, $langs, $db;
27 27
 //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver
28 28
 //require_once 'PHPUnit/Autoload.php';
29 29
 require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
     $user->fetch(1);
35 35
     $user->getrights();
36 36
 }
37
-$conf->global->MAIN_DISABLE_ALL_MAILS=1;
37
+$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
38 38
 
39 39
 
40 40
 /**
@@ -62,11 +62,11 @@  discard block
 block discarded – undo
62 62
     	parent::__construct();
63 63
 
64 64
     	//$this->sharedFixture
65
-        global $conf,$user,$langs,$db;
66
-        $this->savconf=$conf;
67
-        $this->savuser=$user;
68
-        $this->savlangs=$langs;
69
-        $this->savdb=$db;
65
+        global $conf, $user, $langs, $db;
66
+        $this->savconf = $conf;
67
+        $this->savuser = $user;
68
+        $this->savlangs = $langs;
69
+        $this->savdb = $db;
70 70
 
71 71
         print __METHOD__." db->type=".$db->type." user->id=".$user->id;
72 72
         //print " - db ".$db->db;
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     // Static methods
77 77
     public static function setUpBeforeClass()
78 78
     {
79
-        global $conf,$user,$langs,$db;
79
+        global $conf, $user, $langs, $db;
80 80
         $db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
81 81
 
82 82
         print __METHOD__."\n";
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
     // tear down after class
86 86
     public static function tearDownAfterClass()
87 87
     {
88
-        global $conf,$user,$langs,$db;
88
+        global $conf, $user, $langs, $db;
89 89
         $db->rollback();
90 90
 
91 91
         print __METHOD__."\n";
@@ -98,11 +98,11 @@  discard block
 block discarded – undo
98 98
     */
99 99
     protected function setUp()
100 100
     {
101
-        global $conf,$user,$langs,$db;
102
-        $conf=$this->savconf;
103
-        $user=$this->savuser;
104
-        $langs=$this->savlangs;
105
-        $db=$this->savdb;
101
+        global $conf, $user, $langs, $db;
102
+        $conf = $this->savconf;
103
+        $user = $this->savuser;
104
+        $langs = $this->savlangs;
105
+        $db = $this->savdb;
106 106
 
107 107
         print __METHOD__."\n";
108 108
     }
@@ -124,15 +124,15 @@  discard block
 block discarded – undo
124 124
      */
125 125
     public function testUserGroupCreate()
126 126
     {
127
-        global $conf,$user,$langs,$db;
128
-        $conf=$this->savconf;
129
-        $user=$this->savuser;
130
-        $langs=$this->savlangs;
131
-        $db=$this->savdb;
127
+        global $conf, $user, $langs, $db;
128
+        $conf = $this->savconf;
129
+        $user = $this->savuser;
130
+        $langs = $this->savlangs;
131
+        $db = $this->savdb;
132 132
 
133
-        $localobject=new UserGroup($this->savdb);
133
+        $localobject = new UserGroup($this->savdb);
134 134
         $localobject->initAsSpecimen();
135
-        $result=$localobject->create($user);
135
+        $result = $localobject->create($user);
136 136
 
137 137
         $this->assertLessThan($result, 0);
138 138
         print __METHOD__." result=".$result."\n";
@@ -149,14 +149,14 @@  discard block
 block discarded – undo
149 149
      */
150 150
     public function testUserGroupFetch($id)
151 151
     {
152
-        global $conf,$user,$langs,$db;
153
-        $conf=$this->savconf;
154
-        $user=$this->savuser;
155
-        $langs=$this->savlangs;
156
-        $db=$this->savdb;
152
+        global $conf, $user, $langs, $db;
153
+        $conf = $this->savconf;
154
+        $user = $this->savuser;
155
+        $langs = $this->savlangs;
156
+        $db = $this->savdb;
157 157
 
158
-        $localobject=new UserGroup($this->savdb);
159
-        $result=$localobject->fetch($id);
158
+        $localobject = new UserGroup($this->savdb);
159
+        $result = $localobject->fetch($id);
160 160
 
161 161
         $this->assertLessThan($result, 0);
162 162
         print __METHOD__." id=".$id." result=".$result."\n";
@@ -173,14 +173,14 @@  discard block
 block discarded – undo
173 173
      */
174 174
     public function testUserGroupUpdate($localobject)
175 175
     {
176
-        global $conf,$user,$langs,$db;
177
-        $conf=$this->savconf;
178
-        $user=$this->savuser;
179
-        $langs=$this->savlangs;
180
-        $db=$this->savdb;
176
+        global $conf, $user, $langs, $db;
177
+        $conf = $this->savconf;
178
+        $user = $this->savuser;
179
+        $langs = $this->savlangs;
180
+        $db = $this->savdb;
181 181
 
182
-        $localobject->note='New note after update';
183
-        $result=$localobject->update($user);
182
+        $localobject->note = 'New note after update';
183
+        $result = $localobject->update($user);
184 184
 
185 185
         print __METHOD__." id=".$localobject->id." result=".$result."\n";
186 186
         $this->assertLessThan($result, 0);
@@ -197,13 +197,13 @@  discard block
 block discarded – undo
197 197
      */
198 198
     public function testUserGroupAddRight($localobject)
199 199
     {
200
-        global $conf,$user,$langs,$db;
201
-        $conf=$this->savconf;
202
-        $user=$this->savuser;
203
-        $langs=$this->savlangs;
204
-        $db=$this->savdb;
200
+        global $conf, $user, $langs, $db;
201
+        $conf = $this->savconf;
202
+        $user = $this->savuser;
203
+        $langs = $this->savlangs;
204
+        $db = $this->savdb;
205 205
 
206
-        $result=$localobject->addrights(1,'bookmarks');
206
+        $result = $localobject->addrights(1, 'bookmarks');
207 207
         print __METHOD__." id=".$localobject->id." result=".$result."\n";
208 208
 
209 209
         $this->assertLessThan($result, 0);
@@ -220,13 +220,13 @@  discard block
 block discarded – undo
220 220
      */
221 221
     public function testUserGroupDelRight($localobject)
222 222
     {
223
-        global $conf,$user,$langs,$db;
224
-        $conf=$this->savconf;
225
-        $user=$this->savuser;
226
-        $langs=$this->savlangs;
227
-        $db=$this->savdb;
223
+        global $conf, $user, $langs, $db;
224
+        $conf = $this->savconf;
225
+        $user = $this->savuser;
226
+        $langs = $this->savlangs;
227
+        $db = $this->savdb;
228 228
 
229
-        $result=$localobject->delrights(1,'bookmarks');
229
+        $result = $localobject->delrights(1, 'bookmarks');
230 230
         print __METHOD__." id=".$localobject->id." result=".$result."\n";
231 231
 
232 232
         $this->assertLessThan($result, 0);
@@ -243,11 +243,11 @@  discard block
 block discarded – undo
243 243
      */
244 244
     public function testUserGroupOther($localobject)
245 245
     {
246
-        global $conf,$user,$langs,$db;
247
-        $conf=$this->savconf;
248
-        $user=$this->savuser;
249
-        $langs=$this->savlangs;
250
-        $db=$this->savdb;
246
+        global $conf, $user, $langs, $db;
247
+        $conf = $this->savconf;
248
+        $user = $this->savuser;
249
+        $langs = $this->savlangs;
250
+        $db = $this->savdb;
251 251
 
252 252
         /*$result=$localobject->setstatus(0);
253 253
         print __METHOD__." id=".$localobject->id." result=".$result."\n";
@@ -271,15 +271,15 @@  discard block
 block discarded – undo
271 271
      */
272 272
     public function testUserGroupDelete($id)
273 273
     {
274
-        global $conf,$user,$langs,$db;
275
-        $conf=$this->savconf;
276
-        $user=$this->savuser;
277
-        $langs=$this->savlangs;
278
-        $db=$this->savdb;
279
-
280
-        $localobject=new UserGroup($this->savdb);
281
-        $result=$localobject->fetch($id);
282
-        $result=$localobject->delete($id);
274
+        global $conf, $user, $langs, $db;
275
+        $conf = $this->savconf;
276
+        $user = $this->savuser;
277
+        $langs = $this->savlangs;
278
+        $db = $this->savdb;
279
+
280
+        $localobject = new UserGroup($this->savdb);
281
+        $result = $localobject->fetch($id);
282
+        $result = $localobject->delete($id);
283 283
 
284 284
         print __METHOD__." id=".$id." result=".$result."\n";
285 285
         $this->assertLessThan($result, 0);
Please login to merge, or discard this patch.
dolibarr/test/phpunit/functional/InstallTest.php 2 patches
Indentation   +153 added lines, -153 removed lines patch added patch discarded remove patch
@@ -23,263 +23,263 @@
 block discarded – undo
23 23
  */
24 24
 class InstallTest extends PHPUnit_Extensions_Selenium2TestCase
25 25
 {
26
-	protected static $url = 'https://dev.dolibarr.org';
27
-	protected static $db_name = 'dolibarr_test';
28
-	protected static $db_host = 'localhost';
29
-	protected static $db_admin_user = 'root';
30
-	protected static $db_admin_pass = '';
31
-	protected static $db_user = 'dolibarr';
32
-	protected static $db_pass = 'dolibarr';
33
-	protected static $dol_admin_user = 'admin';
34
-	protected static $dol_admin_pass = 'admin';
35
-
36
-	public static $browsers = array(
37
-		array(
38
-			'browser' => 'chrome',
39
-			'browserName' => 'chrome',
40
-			'sessionStrategy' => 'shared',
41
-			'desiredCapabilities' => array()
42
-		)
43
-	);
26
+    protected static $url = 'https://dev.dolibarr.org';
27
+    protected static $db_name = 'dolibarr_test';
28
+    protected static $db_host = 'localhost';
29
+    protected static $db_admin_user = 'root';
30
+    protected static $db_admin_pass = '';
31
+    protected static $db_user = 'dolibarr';
32
+    protected static $db_pass = 'dolibarr';
33
+    protected static $dol_admin_user = 'admin';
34
+    protected static $dol_admin_pass = 'admin';
35
+
36
+    public static $browsers = array(
37
+        array(
38
+            'browser' => 'chrome',
39
+            'browserName' => 'chrome',
40
+            'sessionStrategy' => 'shared',
41
+            'desiredCapabilities' => array()
42
+        )
43
+    );
44 44
 
45 45
     /**
46 46
      * setUpBeforeClass
47 47
      *
48 48
      * @return	void
49 49
      */
50
-	public static function setUpBeforeClass()
51
-	{
52
-		// Make sure we backup and remove the configuration file to force new install.
53
-		@rename('htdocs/conf/conf.php', sys_get_temp_dir() . '/conf.php');
50
+    public static function setUpBeforeClass()
51
+    {
52
+        // Make sure we backup and remove the configuration file to force new install.
53
+        @rename('htdocs/conf/conf.php', sys_get_temp_dir() . '/conf.php');
54 54
 
55
-		// Start without a database
56
-		self::dropTestDatabase();
55
+        // Start without a database
56
+        self::dropTestDatabase();
57 57
 
58
-		// Run the tests in the same window
59
-		self::shareSession(true);
60
-	}
58
+        // Run the tests in the same window
59
+        self::shareSession(true);
60
+    }
61 61
 
62 62
     /**
63 63
      * dropTestDatabase
64 64
      *
65 65
      * @return	void
66 66
      */
67
-	protected static function dropTestDatabase()
68
-	{
69
-		$mysqli = new mysqli(self::$db_host, self::$db_admin_user, self::$db_admin_pass);
70
-		$mysqli->query("DROP DATABASE " . self::$db_name);
71
-	}
67
+    protected static function dropTestDatabase()
68
+    {
69
+        $mysqli = new mysqli(self::$db_host, self::$db_admin_user, self::$db_admin_pass);
70
+        $mysqli->query("DROP DATABASE " . self::$db_name);
71
+    }
72 72
 
73 73
     /**
74 74
      * tearDownAfterClass
75 75
      *
76 76
      * @return	void
77 77
      */
78
-	public static function tearDownAfterClass()
79
-	{
80
-		// Remove the generated configuration and restore the backed up file.
81
-		@unlink('htdocs/conf/conf.php');
82
-		@rename(sys_get_temp_dir() . '/conf.php', 'htdocs/conf/conf.php');
78
+    public static function tearDownAfterClass()
79
+    {
80
+        // Remove the generated configuration and restore the backed up file.
81
+        @unlink('htdocs/conf/conf.php');
82
+        @rename(sys_get_temp_dir() . '/conf.php', 'htdocs/conf/conf.php');
83 83
 
84
-		// Cleanup test database
85
-		self::dropTestDatabase();
86
-	}
84
+        // Cleanup test database
85
+        self::dropTestDatabase();
86
+    }
87 87
 
88 88
     /**
89 89
      * setUp
90 90
      *
91 91
      * @return  void
92 92
      */
93
-	public function setUp()
94
-	{
95
-		// Populating the database can take quite long.
96
-		$this->setSeleniumServerRequestsTimeout(120000);
97
-		$this->setBrowserUrl(self::$url);
98
-	}
93
+    public function setUp()
94
+    {
95
+        // Populating the database can take quite long.
96
+        $this->setSeleniumServerRequestsTimeout(120000);
97
+        $this->setBrowserUrl(self::$url);
98
+    }
99 99
 
100 100
     /**
101 101
      * testInstallRedirect
102 102
      *
103 103
      * @return  void
104 104
      */
105
-	public function testInstallRedirect()
106
-	{
107
-		$this->url('/');
108
-		$this->assertContains('/install/index.php', $this->url());
109
-	}
105
+    public function testInstallRedirect()
106
+    {
107
+        $this->url('/');
108
+        $this->assertContains('/install/index.php', $this->url());
109
+    }
110 110
 
111 111
     /**
112 112
      * testInstallPageTitle
113 113
      *
114 114
      * @return  void
115 115
      */
116
-	public function testInstallPageTitle()
117
-	{
118
-		$this->assertContains('Dolibarr', $this->title());
119
-	}
116
+    public function testInstallPageTitle()
117
+    {
118
+        $this->assertContains('Dolibarr', $this->title());
119
+    }
120 120
 
121 121
     /**
122 122
      * testInstallProcess
123 123
      *
124 124
      * @return  void
125 125
      */
126
-	public function testInstallProcess()
127
-	{
128
-		// FIXME: the button itself should have an ID
129
-		$this->byId('nextbutton')->byTag('input')->click();
130
-		$this->assertContains('/install/check.php', $this->url());
131
-	}
126
+    public function testInstallProcess()
127
+    {
128
+        // FIXME: the button itself should have an ID
129
+        $this->byId('nextbutton')->byTag('input')->click();
130
+        $this->assertContains('/install/check.php', $this->url());
131
+    }
132 132
 
133 133
     /**
134 134
      * testCheckPage
135 135
      *
136 136
      * @return  void
137 137
      */
138
-	public function testCheckPage()
139
-	{
140
-		$unavailable_choices = $this->byId('navail_choices');
141
-		$show_hide_choices = $this->byId('AShowChoices')->byTag('a');
142
-		$this->assertFalse($unavailable_choices->displayed());
143
-		// FIXME: the link itself should have an ID
144
-		$show_hide_choices->click();
145
-		$this->assertTrue($unavailable_choices->displayed());
146
-		$show_hide_choices->click();
147
-		$this->assertFalse($unavailable_choices->displayed());
148
-		$this->byClassName('button')->click();
149
-		$this->assertContains('/install/fileconf.php', $this->url());
150
-	}
138
+    public function testCheckPage()
139
+    {
140
+        $unavailable_choices = $this->byId('navail_choices');
141
+        $show_hide_choices = $this->byId('AShowChoices')->byTag('a');
142
+        $this->assertFalse($unavailable_choices->displayed());
143
+        // FIXME: the link itself should have an ID
144
+        $show_hide_choices->click();
145
+        $this->assertTrue($unavailable_choices->displayed());
146
+        $show_hide_choices->click();
147
+        $this->assertFalse($unavailable_choices->displayed());
148
+        $this->byClassName('button')->click();
149
+        $this->assertContains('/install/fileconf.php', $this->url());
150
+    }
151 151
 
152 152
     /**
153 153
      * testForm
154 154
      *
155 155
      * @return  void
156 156
      */
157
-	public function testForm()
158
-	{
159
-		$this->assertFalse($this->byClassName('hideroot')->displayed());
160
-		$this->assertTrue($this->byClassName('hidesqlite')->displayed());
157
+    public function testForm()
158
+    {
159
+        $this->assertFalse($this->byClassName('hideroot')->displayed());
160
+        $this->assertTrue($this->byClassName('hidesqlite')->displayed());
161 161
 
162
-		// FIXME: This element should have an ID
163
-		$this->assertFalse($this->byName('main_force_https')->selected());
164
-		$this->byName('main_force_https')->click();
162
+        // FIXME: This element should have an ID
163
+        $this->assertFalse($this->byName('main_force_https')->selected());
164
+        $this->byName('main_force_https')->click();
165 165
 
166
-		$this->assertEquals('dolibarr', $this->byId('db_name')->value());
167
-		$this->byId('db_name')->clear();
168
-		$this->byId('db_name')->value(self::$db_name);
166
+        $this->assertEquals('dolibarr', $this->byId('db_name')->value());
167
+        $this->byId('db_name')->clear();
168
+        $this->byId('db_name')->value(self::$db_name);
169 169
 
170
-		$this->assertEquals('mysqli', $this->byId('db_type')->value());
170
+        $this->assertEquals('mysqli', $this->byId('db_type')->value());
171 171
 
172
-		// FIXME: This element should have an ID
173
-		$this->assertEquals('localhost', $this->byName('db_host')->value());
172
+        // FIXME: This element should have an ID
173
+        $this->assertEquals('localhost', $this->byName('db_host')->value());
174 174
 
175
-		$this->assertEquals(3306, $this->byId('db_port')->value());
175
+        $this->assertEquals(3306, $this->byId('db_port')->value());
176 176
 
177
-		$this->assertEquals('llx_', $this->byId('db_prefix')->value());
177
+        $this->assertEquals('llx_', $this->byId('db_prefix')->value());
178 178
 
179
-		$this->byId('db_create_database')->click();
180
-		$this->assertTrue($this->byClassName('hideroot')->displayed());
181
-		$this->byId('db_create_database')->click();
182
-		$this->assertFalse($this->byClassName('hideroot')->displayed());
179
+        $this->byId('db_create_database')->click();
180
+        $this->assertTrue($this->byClassName('hideroot')->displayed());
181
+        $this->byId('db_create_database')->click();
182
+        $this->assertFalse($this->byClassName('hideroot')->displayed());
183 183
 
184
-		$this->byId('db_user')->value(self::$db_user);
184
+        $this->byId('db_user')->value(self::$db_user);
185 185
 
186
-		$this->byId('db_pass')->value(self::$db_pass);
186
+        $this->byId('db_pass')->value(self::$db_pass);
187 187
 
188
-		$this->byId('db_create_user')->click();
189
-		$this->assertTrue($this->byClassName('hideroot')->displayed());
190
-		$this->byId('db_create_user')->click();
191
-		$this->assertFalse($this->byClassName('hideroot')->displayed());
188
+        $this->byId('db_create_user')->click();
189
+        $this->assertTrue($this->byClassName('hideroot')->displayed());
190
+        $this->byId('db_create_user')->click();
191
+        $this->assertFalse($this->byClassName('hideroot')->displayed());
192 192
 
193
-		$this->byId('db_create_database')->click();
194
-		$this->byId('db_create_user')->click();
195
-		$this->assertTrue($this->byClassName('hideroot')->displayed());
193
+        $this->byId('db_create_database')->click();
194
+        $this->byId('db_create_user')->click();
195
+        $this->assertTrue($this->byClassName('hideroot')->displayed());
196 196
 
197
-		$this->byId('db_user_root')->value('root');
198
-		$this->byId('db_pass_root')->value('');
199
-	}
197
+        $this->byId('db_user_root')->value('root');
198
+        $this->byId('db_pass_root')->value('');
199
+    }
200 200
 
201 201
     /**
202 202
      * testFormSubmit
203 203
      *
204 204
      * @return  void
205 205
      */
206
-	public function testFormSubmit()
207
-	{
208
-		$this->byName('forminstall')->submit();
209
-		$this->assertContains('/install/step1.php', $this->url());
210
-	}
206
+    public function testFormSubmit()
207
+    {
208
+        $this->byName('forminstall')->submit();
209
+        $this->assertContains('/install/step1.php', $this->url());
210
+    }
211 211
 
212 212
     /**
213 213
      * testStep1
214 214
      *
215 215
      * @return  void
216 216
      */
217
-	public function testStep1()
218
-	{
219
-		$this->assertFalse($this->byId('pleasewait')->displayed());
220
-		$start = new DateTimeImmutable();
221
-		// FIXME: the button itself should have an ID
222
-		$this->byId('nextbutton')->byTag('input')->click();
223
-		$time = $start->diff(new DateTimeImmutable());
224
-		echo "\nPopulating the database took " . $time->format("%s seconds.\n");
225
-		$this->assertContains('/install/step2.php', $this->url());
226
-	}
217
+    public function testStep1()
218
+    {
219
+        $this->assertFalse($this->byId('pleasewait')->displayed());
220
+        $start = new DateTimeImmutable();
221
+        // FIXME: the button itself should have an ID
222
+        $this->byId('nextbutton')->byTag('input')->click();
223
+        $time = $start->diff(new DateTimeImmutable());
224
+        echo "\nPopulating the database took " . $time->format("%s seconds.\n");
225
+        $this->assertContains('/install/step2.php', $this->url());
226
+    }
227 227
 
228 228
     /**
229 229
      * testStep2
230 230
      *
231 231
      * @return  void
232 232
      */
233
-	public function testStep2()
234
-	{
235
-		$this->byName('forminstall')->submit();
236
-		$this->assertContains('/install/step4.php', $this->url());
237
-	}
233
+    public function testStep2()
234
+    {
235
+        $this->byName('forminstall')->submit();
236
+        $this->assertContains('/install/step4.php', $this->url());
237
+    }
238 238
 
239
-	// There is no step 3
239
+    // There is no step 3
240 240
 
241 241
     /**
242 242
      * testStep4
243 243
      *
244 244
      * @return  void
245 245
      */
246
-	public function testStep4()
247
-	{
248
-		// FIXME: should have an ID
249
-		$this->byName('login')->value(self::$dol_admin_user);
250
-		// FIXME: should have an ID
251
-		$this->byName('pass')->value('admin');
252
-		// FIXME: should have an ID
253
-		$this->byName('pass_verif')->value(self::$dol_admin_pass);
254
-		// FIXME: the button itself should have an ID
255
-		$this->byId('nextbutton')->byTag('input')->click();
256
-		$this->assertContains('/install/step5.php', $this->url());
257
-	}
246
+    public function testStep4()
247
+    {
248
+        // FIXME: should have an ID
249
+        $this->byName('login')->value(self::$dol_admin_user);
250
+        // FIXME: should have an ID
251
+        $this->byName('pass')->value('admin');
252
+        // FIXME: should have an ID
253
+        $this->byName('pass_verif')->value(self::$dol_admin_pass);
254
+        // FIXME: the button itself should have an ID
255
+        $this->byId('nextbutton')->byTag('input')->click();
256
+        $this->assertContains('/install/step5.php', $this->url());
257
+    }
258 258
 
259 259
     /**
260 260
      * testStep5
261 261
      *
262 262
      * @return  void
263 263
      */
264
-	public function testStep5()
265
-	{
266
-		// FIXME: this button should have an ID
267
-		$this->byTag('a')->click();
268
-		$this->assertContains('/admin/index.php', $this->url());
269
-	}
264
+    public function testStep5()
265
+    {
266
+        // FIXME: this button should have an ID
267
+        $this->byTag('a')->click();
268
+        $this->assertContains('/admin/index.php', $this->url());
269
+    }
270 270
 
271 271
     /**
272 272
      * testFirstLogin
273 273
      *
274 274
      * @return  void
275 275
      */
276
-	public function testFirstLogin()
277
-	{
278
-		$this->assertEquals('login', $this->byTag('form')->attribute('id'));
279
-		$this->assertEquals(self::$dol_admin_user, $this->byId('username')->value());
280
-		$this->byId('password')->value(self::$dol_admin_pass);
281
-		// FIXME: login button should have an ID
282
-		$this->byId('login')->submit();
283
-		$this->assertEquals('mainbody', $this->byTag('body')->attribute('id'));
284
-	}
276
+    public function testFirstLogin()
277
+    {
278
+        $this->assertEquals('login', $this->byTag('form')->attribute('id'));
279
+        $this->assertEquals(self::$dol_admin_user, $this->byId('username')->value());
280
+        $this->byId('password')->value(self::$dol_admin_pass);
281
+        // FIXME: login button should have an ID
282
+        $this->byId('login')->submit();
283
+        $this->assertEquals('mainbody', $this->byTag('body')->attribute('id'));
284
+    }
285 285
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	public static function setUpBeforeClass()
51 51
 	{
52 52
 		// Make sure we backup and remove the configuration file to force new install.
53
-		@rename('htdocs/conf/conf.php', sys_get_temp_dir() . '/conf.php');
53
+		@rename('htdocs/conf/conf.php', sys_get_temp_dir().'/conf.php');
54 54
 
55 55
 		// Start without a database
56 56
 		self::dropTestDatabase();
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	protected static function dropTestDatabase()
68 68
 	{
69 69
 		$mysqli = new mysqli(self::$db_host, self::$db_admin_user, self::$db_admin_pass);
70
-		$mysqli->query("DROP DATABASE " . self::$db_name);
70
+		$mysqli->query("DROP DATABASE ".self::$db_name);
71 71
 	}
72 72
 
73 73
     /**
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	{
80 80
 		// Remove the generated configuration and restore the backed up file.
81 81
 		@unlink('htdocs/conf/conf.php');
82
-		@rename(sys_get_temp_dir() . '/conf.php', 'htdocs/conf/conf.php');
82
+		@rename(sys_get_temp_dir().'/conf.php', 'htdocs/conf/conf.php');
83 83
 
84 84
 		// Cleanup test database
85 85
 		self::dropTestDatabase();
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 		// FIXME: the button itself should have an ID
222 222
 		$this->byId('nextbutton')->byTag('input')->click();
223 223
 		$time = $start->diff(new DateTimeImmutable());
224
-		echo "\nPopulating the database took " . $time->format("%s seconds.\n");
224
+		echo "\nPopulating the database took ".$time->format("%s seconds.\n");
225 225
 		$this->assertContains('/install/step2.php', $this->url());
226 226
 	}
227 227
 
Please login to merge, or discard this patch.
dolibarr/test/phpunit/functional/TakePosFunctionalTest.php 2 patches
Indentation   +248 added lines, -248 removed lines patch added patch discarded remove patch
@@ -41,32 +41,32 @@  discard block
 block discarded – undo
41 41
  */
42 42
 class TakePosFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase
43 43
 {
44
-	// TODO: move to a global configuration file?
45
-	/** @var string Base URL of the webserver under test */
46
-	protected static $base_url = 'http://dev.zenfusion.fr';
47
-	/**
48
-	 * @var string Dolibarr admin username
49
-	 * @see authenticate
50
-	 */
51
-	protected static $dol_admin_user = 'admin';
52
-	/**
53
-	 * @var string Dolibarr admin password
54
-	 * @see authenticate
55
-	 */
56
-	protected static $dol_admin_pass = 'admin';
57
-	/** @var int Dolibarr module ID */
58
-	private static $module_id = 500000; // TODO: autodetect?
44
+    // TODO: move to a global configuration file?
45
+    /** @var string Base URL of the webserver under test */
46
+    protected static $base_url = 'http://dev.zenfusion.fr';
47
+    /**
48
+     * @var string Dolibarr admin username
49
+     * @see authenticate
50
+     */
51
+    protected static $dol_admin_user = 'admin';
52
+    /**
53
+     * @var string Dolibarr admin password
54
+     * @see authenticate
55
+     */
56
+    protected static $dol_admin_pass = 'admin';
57
+    /** @var int Dolibarr module ID */
58
+    private static $module_id = 500000; // TODO: autodetect?
59 59
 
60
-	/** @var array Browsers to test with */
61
-	public static $browsers = array(
62
-		array(
63
-			'browser' => 'Google Chrome on Linux',
64
-			'browserName' => 'chrome',
65
-			'sessionStrategy' => 'shared',
66
-			'desiredCapabilities' => array()
67
-		),
68
-		// Geckodriver does not keep the session at the moment?!
69
-		// XPath selectors also don't seem to work
60
+    /** @var array Browsers to test with */
61
+    public static $browsers = array(
62
+        array(
63
+            'browser' => 'Google Chrome on Linux',
64
+            'browserName' => 'chrome',
65
+            'sessionStrategy' => 'shared',
66
+            'desiredCapabilities' => array()
67
+        ),
68
+        // Geckodriver does not keep the session at the moment?!
69
+        // XPath selectors also don't seem to work
70 70
 //        array(
71 71
 //            'browser' => 'Mozilla Firefox on Linux',
72 72
 //            'browserName' => 'firefox',
@@ -75,243 +75,243 @@  discard block
 block discarded – undo
75 75
 //                'marionette' => true
76 76
 //            )
77 77
 //        )
78
-	);
78
+    );
79 79
 
80
-	/**
81
-	 * Helper function to select links by href
82
-	 *
83
-	 * @param  string  $value      Href
84
-	 * @return mixed               Helper string
85
-	 */
86
-	protected function byHref($value)
87
-	{
88
-		$anchor = null;
89
-		$anchors = $this->elements($this->using('tag name')->value('a'));
90
-		foreach ($anchors as $anchor) {
91
-			if (strstr($anchor->attribute('href'), $value)) {
92
-				break;
93
-			}
94
-		}
95
-		return $anchor;
96
-	}
80
+    /**
81
+     * Helper function to select links by href
82
+     *
83
+     * @param  string  $value      Href
84
+     * @return mixed               Helper string
85
+     */
86
+    protected function byHref($value)
87
+    {
88
+        $anchor = null;
89
+        $anchors = $this->elements($this->using('tag name')->value('a'));
90
+        foreach ($anchors as $anchor) {
91
+            if (strstr($anchor->attribute('href'), $value)) {
92
+                break;
93
+            }
94
+        }
95
+        return $anchor;
96
+    }
97 97
 
98
-	/**
99
-	 * Global test setup
100
-	 *
101
-	 * @return	void
102
-	 */
103
-	public static function setUpBeforeClass()
104
-	{
105
-	}
98
+    /**
99
+     * Global test setup
100
+     *
101
+     * @return	void
102
+     */
103
+    public static function setUpBeforeClass()
104
+    {
105
+    }
106 106
 
107
-	/**
108
-	 * Unit test setup
109
-	 *
110
-	 * @return	void
111
-	 */
112
-	public function setUp()
113
-	{
114
-		$this->setSeleniumServerRequestsTimeout(3600);
115
-		$this->setBrowserUrl(self::$base_url);
116
-	}
107
+    /**
108
+     * Unit test setup
109
+     *
110
+     * @return	void
111
+     */
112
+    public function setUp()
113
+    {
114
+        $this->setSeleniumServerRequestsTimeout(3600);
115
+        $this->setBrowserUrl(self::$base_url);
116
+    }
117 117
 
118
-	/**
119
-	 * Verify pre conditions
120
-	 *
121
-	 * @return	void
122
-	 */
123
-	protected function assertPreConditions()
124
-	{
125
-	}
118
+    /**
119
+     * Verify pre conditions
120
+     *
121
+     * @return	void
122
+     */
123
+    protected function assertPreConditions()
124
+    {
125
+    }
126 126
 
127
-	/**
128
-	 * Handle Dolibarr authentication
129
-	 *
130
-	 * @return	void
131
-	 */
132
-	private function authenticate()
133
-	{
134
-		try {
135
-			if ($this->byId('login')) {
136
-				$login = $this->byId('username');
137
-				$login->clear();
138
-				$login->value('admin');
139
-				$password = $this->byId('password');
140
-				$password->clear();
141
-				$password->value('admin');
142
-				$this->byId('login')->submit();
143
-			}
144
-		} catch (PHPUnit_Extensions_Selenium2TestCase_WebDriverException $e) {
145
-			// Login does not exist. Assume we are already authenticated
146
-		}
147
-	}
127
+    /**
128
+     * Handle Dolibarr authentication
129
+     *
130
+     * @return	void
131
+     */
132
+    private function authenticate()
133
+    {
134
+        try {
135
+            if ($this->byId('login')) {
136
+                $login = $this->byId('username');
137
+                $login->clear();
138
+                $login->value('admin');
139
+                $password = $this->byId('password');
140
+                $password->clear();
141
+                $password->value('admin');
142
+                $this->byId('login')->submit();
143
+            }
144
+        } catch (PHPUnit_Extensions_Selenium2TestCase_WebDriverException $e) {
145
+            // Login does not exist. Assume we are already authenticated
146
+        }
147
+    }
148 148
 
149
-	/**
150
-	 * Test enabling developer mode
151
-	 *
152
-	 * @return	void
153
-	 */
154
-	public function testEnableDeveloperMode()
155
-	{
156
-		$this->url('/admin/const.php');
157
-		$this->authenticate();
158
-		$main_features_level_path='//input[@value="MAIN_FEATURES_LEVEL"]/following::input[@type="text"]';
159
-		$main_features_level = $this->byXPath($main_features_level_path);
160
-		$main_features_level->clear();
161
-		$main_features_level->value('2');
162
-		$this->byName('update')->click();
163
-		// Page reloaded, we need a new XPath
164
-		$main_features_level = $this->byXPath($main_features_level_path);
165
-		$this->assertEquals('2', $main_features_level->value(), "MAIN_FEATURES_LEVEL value is 2");
166
-	}
149
+    /**
150
+     * Test enabling developer mode
151
+     *
152
+     * @return	void
153
+     */
154
+    public function testEnableDeveloperMode()
155
+    {
156
+        $this->url('/admin/const.php');
157
+        $this->authenticate();
158
+        $main_features_level_path='//input[@value="MAIN_FEATURES_LEVEL"]/following::input[@type="text"]';
159
+        $main_features_level = $this->byXPath($main_features_level_path);
160
+        $main_features_level->clear();
161
+        $main_features_level->value('2');
162
+        $this->byName('update')->click();
163
+        // Page reloaded, we need a new XPath
164
+        $main_features_level = $this->byXPath($main_features_level_path);
165
+        $this->assertEquals('2', $main_features_level->value(), "MAIN_FEATURES_LEVEL value is 2");
166
+    }
167 167
 
168
-	/**
169
-	 * Test enabling the module
170
-	 *
171
-	 * @return	void
172
-	 *
173
-	 * @depends testEnableDeveloperMode
174
-	 */
175
-	public function testModuleEnabled()
176
-	{
177
-		$this->url('/admin/modules.php');
178
-		$this->authenticate();
179
-		$module_status_image_path='//a[contains(@href, "' . self::$module_id . '")]/img';
180
-		$module_status_image = $this->byXPath($module_status_image_path);
181
-		if (strstr($module_status_image->attribute('src'), 'switch_off.png')) {
182
-			// Enable the module
183
-			$this->byHref('modTakePos')->click();
184
-		} else {
185
-			// Disable the module
186
-			$this->byHref('modTakePos')->click();
187
-			// Reenable the module
188
-			$this->byHref('modTakePos')->click();
189
-		}
190
-		// Page reloaded, we need a new Xpath
191
-		$module_status_image = $this->byXPath($module_status_image_path);
192
-		$this->assertContains('switch_on.png', $module_status_image->attribute('src'), "Module enabled");
193
-	}
168
+    /**
169
+     * Test enabling the module
170
+     *
171
+     * @return	void
172
+     *
173
+     * @depends testEnableDeveloperMode
174
+     */
175
+    public function testModuleEnabled()
176
+    {
177
+        $this->url('/admin/modules.php');
178
+        $this->authenticate();
179
+        $module_status_image_path='//a[contains(@href, "' . self::$module_id . '")]/img';
180
+        $module_status_image = $this->byXPath($module_status_image_path);
181
+        if (strstr($module_status_image->attribute('src'), 'switch_off.png')) {
182
+            // Enable the module
183
+            $this->byHref('modTakePos')->click();
184
+        } else {
185
+            // Disable the module
186
+            $this->byHref('modTakePos')->click();
187
+            // Reenable the module
188
+            $this->byHref('modTakePos')->click();
189
+        }
190
+        // Page reloaded, we need a new Xpath
191
+        $module_status_image = $this->byXPath($module_status_image_path);
192
+        $this->assertContains('switch_on.png', $module_status_image->attribute('src'), "Module enabled");
193
+    }
194 194
 
195
-	/**
196
-	 * Test access to the configuration page
197
-	 *
198
-	 * @return	void
199
-	 *
200
-	 * @depends testModuleEnabled
201
-	 */
202
-	public function testConfigurationPage()
203
-	{
204
-		$this->url('/custom/takepos/admin/setup.php');
205
-		$this->authenticate();
206
-		$this->assertContains('takepos/admin/setup.php', $this->url(), 'Configuration page');
207
-	}
195
+    /**
196
+     * Test access to the configuration page
197
+     *
198
+     * @return	void
199
+     *
200
+     * @depends testModuleEnabled
201
+     */
202
+    public function testConfigurationPage()
203
+    {
204
+        $this->url('/custom/takepos/admin/setup.php');
205
+        $this->authenticate();
206
+        $this->assertContains('takepos/admin/setup.php', $this->url(), 'Configuration page');
207
+    }
208 208
 
209
-	/**
210
-	 * Test access to the about page
211
-	 *
212
-	 * @return	void
213
-	 *
214
-	 * @depends testConfigurationPage
215
-	 */
216
-	public function testAboutPage()
217
-	{
218
-		$this->url('/custom/takepos/admin/about.php');
219
-		$this->authenticate();
220
-		$this->assertContains('takepos/admin/about.php', $this->url(), 'About page');
221
-	}
209
+    /**
210
+     * Test access to the about page
211
+     *
212
+     * @return	void
213
+     *
214
+     * @depends testConfigurationPage
215
+     */
216
+    public function testAboutPage()
217
+    {
218
+        $this->url('/custom/takepos/admin/about.php');
219
+        $this->authenticate();
220
+        $this->assertContains('takepos/admin/about.php', $this->url(), 'About page');
221
+    }
222 222
 
223
-	/**
224
-	 * Test about page is rendering Markdown
225
-	 *
226
-	 * @return	void
227
-	 *
228
-	 * @depends testAboutPage
229
-	 */
230
-	public function testAboutPageRendersMarkdownReadme()
231
-	{
232
-		$this->url('/custom/takepos/admin/about.php');
233
-		$this->authenticate();
234
-		$this->assertEquals(
235
-			'Dolibarr Module Template (aka My Module)',
236
-			$this->byTag('h1')->text(),
237
-			"Readme title"
238
-		);
239
-	}
223
+    /**
224
+     * Test about page is rendering Markdown
225
+     *
226
+     * @return	void
227
+     *
228
+     * @depends testAboutPage
229
+     */
230
+    public function testAboutPageRendersMarkdownReadme()
231
+    {
232
+        $this->url('/custom/takepos/admin/about.php');
233
+        $this->authenticate();
234
+        $this->assertEquals(
235
+            'Dolibarr Module Template (aka My Module)',
236
+            $this->byTag('h1')->text(),
237
+            "Readme title"
238
+        );
239
+    }
240 240
 
241
-	/**
242
-	 * Test box is properly declared
243
-	 *
244
-	 * @return	void
245
-	 *
246
-	 * @depends testModuleEnabled
247
-	 */
248
-	public function testBoxDeclared()
249
-	{
250
-		$this->url('/admin/boxes.php');
251
-		$this->authenticate();
252
-		$this->assertContains('takeposwidget1', $this->source(), "Box enabled");
253
-	}
241
+    /**
242
+     * Test box is properly declared
243
+     *
244
+     * @return	void
245
+     *
246
+     * @depends testModuleEnabled
247
+     */
248
+    public function testBoxDeclared()
249
+    {
250
+        $this->url('/admin/boxes.php');
251
+        $this->authenticate();
252
+        $this->assertContains('takeposwidget1', $this->source(), "Box enabled");
253
+    }
254 254
 
255
-	/**
256
-	 * Test trigger is properly enabled
257
-	 *
258
-	 * @return	void
259
-	 *
260
-	 * @depends testModuleEnabled
261
-	 */
262
-	public function testTriggerDeclared()
263
-	{
264
-		$this->url('/admin/triggers.php');
265
-		$this->authenticate();
266
-		$this->assertContains(
267
-			'interface_99_modTakePos_TakePosTriggers.class.php',
268
-			$this->byTag('body')->text(),
269
-			"Trigger declared"
270
-		);
271
-	}
255
+    /**
256
+     * Test trigger is properly enabled
257
+     *
258
+     * @return	void
259
+     *
260
+     * @depends testModuleEnabled
261
+     */
262
+    public function testTriggerDeclared()
263
+    {
264
+        $this->url('/admin/triggers.php');
265
+        $this->authenticate();
266
+        $this->assertContains(
267
+            'interface_99_modTakePos_TakePosTriggers.class.php',
268
+            $this->byTag('body')->text(),
269
+            "Trigger declared"
270
+        );
271
+    }
272 272
 
273
-	/**
274
-	 * Test trigger is properly declared
275
-	 *
276
-	 * @return	void
277
-	 *
278
-	 * @depends testTriggerDeclared
279
-	 */
280
-	public function testTriggerEnabled()
281
-	{
282
-		$this->url('/admin/triggers.php');
283
-		$this->authenticate();
284
-		$this->assertContains(
285
-			'tick.png',
286
-			$this->byXPath('//td[text()="interface_99_modTakePos_MyTrigger.class.php"]/following::img')->attribute('src'),
287
-			"Trigger enabled"
288
-		);
289
-	}
273
+    /**
274
+     * Test trigger is properly declared
275
+     *
276
+     * @return	void
277
+     *
278
+     * @depends testTriggerDeclared
279
+     */
280
+    public function testTriggerEnabled()
281
+    {
282
+        $this->url('/admin/triggers.php');
283
+        $this->authenticate();
284
+        $this->assertContains(
285
+            'tick.png',
286
+            $this->byXPath('//td[text()="interface_99_modTakePos_MyTrigger.class.php"]/following::img')->attribute('src'),
287
+            "Trigger enabled"
288
+        );
289
+    }
290 290
 
291
-	/**
292
-	 * Verify post conditions
293
-	 *
294
-	 * @return	void
295
-	 */
296
-	protected function assertPostConditions()
297
-	{
298
-	}
291
+    /**
292
+     * Verify post conditions
293
+     *
294
+     * @return	void
295
+     */
296
+    protected function assertPostConditions()
297
+    {
298
+    }
299 299
 
300
-	/**
301
-	 * Unit test teardown
302
-	 *
303
-	 * @return	void
304
-	 */
305
-	public function tearDown()
306
-	{
307
-	}
300
+    /**
301
+     * Unit test teardown
302
+     *
303
+     * @return	void
304
+     */
305
+    public function tearDown()
306
+    {
307
+    }
308 308
 
309
-	/**
310
-	 * Global test teardown
311
-	 *
312
-	 * @return	void
313
-	 */
314
-	public static function tearDownAfterClass()
315
-	{
316
-	}
309
+    /**
310
+     * Global test teardown
311
+     *
312
+     * @return	void
313
+     */
314
+    public static function tearDownAfterClass()
315
+    {
316
+    }
317 317
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	{
156 156
 		$this->url('/admin/const.php');
157 157
 		$this->authenticate();
158
-		$main_features_level_path='//input[@value="MAIN_FEATURES_LEVEL"]/following::input[@type="text"]';
158
+		$main_features_level_path = '//input[@value="MAIN_FEATURES_LEVEL"]/following::input[@type="text"]';
159 159
 		$main_features_level = $this->byXPath($main_features_level_path);
160 160
 		$main_features_level->clear();
161 161
 		$main_features_level->value('2');
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 	{
177 177
 		$this->url('/admin/modules.php');
178 178
 		$this->authenticate();
179
-		$module_status_image_path='//a[contains(@href, "' . self::$module_id . '")]/img';
179
+		$module_status_image_path = '//a[contains(@href, "'.self::$module_id.'")]/img';
180 180
 		$module_status_image = $this->byXPath($module_status_image_path);
181 181
 		if (strstr($module_status_image->attribute('src'), 'switch_off.png')) {
182 182
 			// Enable the module
Please login to merge, or discard this patch.
dolibarr/test/phpunit/CMailFileTest.php 2 patches
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  *      \remarks    To run this script as CLI:  phpunit filename.php
24 24
  */
25 25
 
26
-global $conf,$user,$langs,$db;
26
+global $conf, $user, $langs, $db;
27 27
 //define('TEST_DB_FORCE_TYPE','mysql');	// This is to force using mysql driver
28 28
 //require_once 'PHPUnit/Autoload.php';
29 29
 require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
     $user->fetch(1);
35 35
     $user->getrights();
36 36
 }
37
-$conf->global->MAIN_DISABLE_ALL_MAILS=1;
37
+$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
38 38
 
39 39
 
40 40
 /**
@@ -62,11 +62,11 @@  discard block
 block discarded – undo
62 62
     	parent::__construct();
63 63
 
64 64
     	//$this->sharedFixture
65
-        global $conf,$user,$langs,$db;
66
-        $this->savconf=$conf;
67
-        $this->savuser=$user;
68
-        $this->savlangs=$langs;
69
-        $this->savdb=$db;
65
+        global $conf, $user, $langs, $db;
66
+        $this->savconf = $conf;
67
+        $this->savuser = $user;
68
+        $this->savlangs = $langs;
69
+        $this->savdb = $db;
70 70
 
71 71
         print __METHOD__." db->type=".$db->type." user->id=".$user->id;
72 72
         //print " - db ".$db->db;
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     // Static methods
77 77
     public static function setUpBeforeClass()
78 78
     {
79
-        global $conf,$user,$langs,$db;
79
+        global $conf, $user, $langs, $db;
80 80
         $db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
81 81
 
82 82
         print __METHOD__."\n";
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
     // tear down after class
86 86
     public static function tearDownAfterClass()
87 87
     {
88
-        global $conf,$user,$langs,$db;
88
+        global $conf, $user, $langs, $db;
89 89
         $db->rollback();
90 90
 
91 91
         print __METHOD__."\n";
@@ -98,13 +98,13 @@  discard block
 block discarded – undo
98 98
      */
99 99
     protected function setUp()
100 100
     {
101
-        global $conf,$user,$langs,$db;
102
-        $conf=$this->savconf;
103
-        $user=$this->savuser;
104
-        $langs=$this->savlangs;
105
-        $db=$this->savdb;
101
+        global $conf, $user, $langs, $db;
102
+        $conf = $this->savconf;
103
+        $user = $this->savuser;
104
+        $langs = $this->savlangs;
105
+        $db = $this->savdb;
106 106
 
107
-        $conf->global->MAIN_DISABLE_ALL_MAILS=1;    // If I comment/remove this lien, unit test still works alone but failed when ran from AllTest. Don't know why.
107
+        $conf->global->MAIN_DISABLE_ALL_MAILS = 1; // If I comment/remove this lien, unit test still works alone but failed when ran from AllTest. Don't know why.
108 108
 
109 109
         print __METHOD__."\n";
110 110
     }
@@ -125,17 +125,17 @@  discard block
 block discarded – undo
125 125
      */
126 126
     public function testCMailFileText()
127 127
     {
128
-        global $conf,$user,$langs,$db;
129
-        $conf=$this->savconf;
130
-        $user=$this->savuser;
131
-        $langs=$this->savlangs;
132
-        $db=$this->savdb;
128
+        global $conf, $user, $langs, $db;
129
+        $conf = $this->savconf;
130
+        $user = $this->savuser;
131
+        $langs = $this->savlangs;
132
+        $db = $this->savdb;
133 133
 
134
-        $localobject=new CMailFile('Test','[email protected]','[email protected]','Message txt',array(),array(),array(),'','',1,0);
134
+        $localobject = new CMailFile('Test', '[email protected]', '[email protected]', 'Message txt', array(), array(), array(), '', '', 1, 0);
135 135
 
136
-        $result=$localobject->sendfile();
136
+        $result = $localobject->sendfile();
137 137
         print __METHOD__." result=".$result."\n";
138
-        $this->assertFalse($result);   // False because mail send disabled
138
+        $this->assertFalse($result); // False because mail send disabled
139 139
 
140 140
         return $result;
141 141
     }
@@ -147,53 +147,53 @@  discard block
 block discarded – undo
147 147
      */
148 148
     public function testCMailFileStatic()
149 149
     {
150
-        global $conf,$user,$langs,$db;
151
-        $conf=$this->savconf;
152
-        $user=$this->savuser;
153
-        $langs=$this->savlangs;
154
-        $db=$this->savdb;
150
+        global $conf, $user, $langs, $db;
151
+        $conf = $this->savconf;
152
+        $user = $this->savuser;
153
+        $langs = $this->savlangs;
154
+        $db = $this->savdb;
155 155
 
156
-        $localobject=new CMailFile('','','','');
156
+        $localobject = new CMailFile('', '', '', '');
157 157
 
158
-        $src='John Doe <[email protected]>';
159
-        $result=$localobject->getValidAddress($src,0);
158
+        $src = 'John Doe <[email protected]>';
159
+        $result = $localobject->getValidAddress($src, 0);
160 160
         print __METHOD__." result=".$result."\n";
161
-        $this->assertEquals($result,'John Doe <[email protected]>');
161
+        $this->assertEquals($result, 'John Doe <[email protected]>');
162 162
 
163
-        $src='John Doe <[email protected]>';
164
-        $result=$localobject->getValidAddress($src,1);
163
+        $src = 'John Doe <[email protected]>';
164
+        $result = $localobject->getValidAddress($src, 1);
165 165
         print __METHOD__." result=".$result."\n";
166
-        $this->assertEquals($result,'<[email protected]>');
166
+        $this->assertEquals($result, '<[email protected]>');
167 167
 
168
-        $src='John Doe <[email protected]>';
169
-        $result=$localobject->getValidAddress($src,2);
168
+        $src = 'John Doe <[email protected]>';
169
+        $result = $localobject->getValidAddress($src, 2);
170 170
         print __METHOD__." result=".$result."\n";
171
-        $this->assertEquals($result,'[email protected]');
171
+        $this->assertEquals($result, '[email protected]');
172 172
 
173
-        $src='John Doe <[email protected]>';
174
-        $result=$localobject->getValidAddress($src,3,0);
173
+        $src = 'John Doe <[email protected]>';
174
+        $result = $localobject->getValidAddress($src, 3, 0);
175 175
         print __METHOD__." result=".$result."\n";
176
-        $this->assertEquals($result,'"John Doe" <[email protected]>');
176
+        $this->assertEquals($result, '"John Doe" <[email protected]>');
177 177
 
178
-        $src='John Doe <[email protected]>';
179
-        $result=$localobject->getValidAddress($src,3,1);
178
+        $src = 'John Doe <[email protected]>';
179
+        $result = $localobject->getValidAddress($src, 3, 1);
180 180
         print __METHOD__." result=".$result."\n";
181
-        $this->assertEquals($result,'"=?UTF-8?B?Sm9obiBEb2U=?=" <[email protected]>');
181
+        $this->assertEquals($result, '"=?UTF-8?B?Sm9obiBEb2U=?=" <[email protected]>');
182 182
 
183
-        $src='John Doe <[email protected]>';
184
-        $result=$localobject->getValidAddress($src,4);
183
+        $src = 'John Doe <[email protected]>';
184
+        $result = $localobject->getValidAddress($src, 4);
185 185
         print __METHOD__." result=".$result."\n";
186
-        $this->assertEquals($result,'John Doe');
186
+        $this->assertEquals($result, 'John Doe');
187 187
 
188
-        $src='John Doe <[email protected]>, John Doe2 <[email protected]>, John Doe3 <[email protected]>';
189
-        $result=$localobject->getValidAddress($src,4);
188
+        $src = 'John Doe <[email protected]>, John Doe2 <[email protected]>, John Doe3 <[email protected]>';
189
+        $result = $localobject->getValidAddress($src, 4);
190 190
         print __METHOD__." result=".$result."\n";
191
-        $this->assertEquals($result,'John Doe,John Doe2,John Doe3');
191
+        $this->assertEquals($result, 'John Doe,John Doe2,John Doe3');
192 192
 
193
-        $src='John Doe <[email protected]>, John Doe2 <[email protected]>, John Doe3 <[email protected]>';
194
-        $result=$localobject->getValidAddress($src,4,0,2);
193
+        $src = 'John Doe <[email protected]>, John Doe2 <[email protected]>, John Doe3 <[email protected]>';
194
+        $result = $localobject->getValidAddress($src, 4, 0, 2);
195 195
         print __METHOD__." result=".$result."\n";
196
-        $this->assertEquals($result,'John Doe,John Doe2...');
196
+        $this->assertEquals($result, 'John Doe,John Doe2...');
197 197
 
198 198
         return $result;
199 199
     }
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -60,9 +60,9 @@
 block discarded – undo
60 60
      */
61 61
     function __construct()
62 62
     {
63
-    	parent::__construct();
63
+        parent::__construct();
64 64
 
65
-    	//$this->sharedFixture
65
+        //$this->sharedFixture
66 66
         global $conf,$user,$langs,$db;
67 67
         $this->savconf=$conf;
68 68
         $this->savuser=$user;
Please login to merge, or discard this patch.
dolibarr/test/phpunit/CategorieTest.php 2 patches
Indentation   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -60,9 +60,9 @@  discard block
 block discarded – undo
60 60
      */
61 61
     function __construct()
62 62
     {
63
-    	parent::__construct();
63
+        parent::__construct();
64 64
 
65
-    	//$this->sharedFixture
65
+        //$this->sharedFixture
66 66
         global $conf,$user,$langs,$db;
67 67
         $this->savconf=$conf;
68 68
         $this->savuser=$user;
@@ -238,7 +238,6 @@  discard block
 block discarded – undo
238 238
      *
239 239
      * @param   Category        $localobject        Category
240 240
      * @return  int
241
-
242 241
      * @depends testCategorieFetch
243 242
      * The depends says test is run only if previous is ok
244 243
      */
Please login to merge, or discard this patch.
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  *      \remarks    To run this script as CLI:  phpunit filename.php
24 24
  */
25 25
 
26
-global $conf,$user,$langs,$db;
26
+global $conf, $user, $langs, $db;
27 27
 //define('TEST_DB_FORCE_TYPE','mysql');	// This is to force using mysql driver
28 28
 //require_once 'PHPUnit/Autoload.php';
29 29
 require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
     $user->fetch(1);
36 36
     $user->getrights();
37 37
 }
38
-$conf->global->MAIN_DISABLE_ALL_MAILS=1;
38
+$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
39 39
 
40 40
 
41 41
 /**
@@ -63,11 +63,11 @@  discard block
 block discarded – undo
63 63
     	parent::__construct();
64 64
 
65 65
     	//$this->sharedFixture
66
-        global $conf,$user,$langs,$db;
67
-        $this->savconf=$conf;
68
-        $this->savuser=$user;
69
-        $this->savlangs=$langs;
70
-        $this->savdb=$db;
66
+        global $conf, $user, $langs, $db;
67
+        $this->savconf = $conf;
68
+        $this->savuser = $user;
69
+        $this->savlangs = $langs;
70
+        $this->savdb = $db;
71 71
 
72 72
         print __METHOD__." db->type=".$db->type." user->id=".$user->id;
73 73
         //print " - db ".$db->db;
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
     // Static methods
78 78
     public static function setUpBeforeClass()
79 79
     {
80
-        global $conf,$user,$langs,$db;
80
+        global $conf, $user, $langs, $db;
81 81
         $db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
82 82
 
83 83
         print __METHOD__."\n";
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
     // tear down after class
87 87
     public static function tearDownAfterClass()
88 88
     {
89
-        global $conf,$user,$langs,$db;
89
+        global $conf, $user, $langs, $db;
90 90
         $db->rollback();
91 91
 
92 92
         print __METHOD__."\n";
@@ -99,11 +99,11 @@  discard block
 block discarded – undo
99 99
      */
100 100
     protected function setUp()
101 101
     {
102
-        global $conf,$user,$langs,$db;
103
-        $conf=$this->savconf;
104
-        $user=$this->savuser;
105
-        $langs=$this->savlangs;
106
-        $db=$this->savdb;
102
+        global $conf, $user, $langs, $db;
103
+        $conf = $this->savconf;
104
+        $user = $this->savuser;
105
+        $langs = $this->savlangs;
106
+        $db = $this->savdb;
107 107
 
108 108
         print __METHOD__."\n";
109 109
     }
@@ -124,37 +124,37 @@  discard block
 block discarded – undo
124 124
      */
125 125
     public function testCategorieCreate()
126 126
     {
127
-        global $conf,$user,$langs,$db;
128
-        $conf=$this->savconf;
129
-        $user=$this->savuser;
130
-        $langs=$this->savlangs;
131
-        $db=$this->savdb;
127
+        global $conf, $user, $langs, $db;
128
+        $conf = $this->savconf;
129
+        $user = $this->savuser;
130
+        $langs = $this->savlangs;
131
+        $db = $this->savdb;
132 132
 
133 133
 
134 134
         // We create a category
135
-        $localobject=new Categorie($this->savdb);
135
+        $localobject = new Categorie($this->savdb);
136 136
         $localobject->initAsSpecimen();
137 137
 
138 138
         // Check it does not exist (return 0)
139
-        $resultCheck=$localobject->already_exists();
139
+        $resultCheck = $localobject->already_exists();
140 140
         print __METHOD__." resultCheck=".$resultCheck."\n";
141 141
         $this->assertEquals(0, $resultCheck);
142 142
 
143 143
         // Create
144
-        $resultFirstCreate=$localobject->create($user);
144
+        $resultFirstCreate = $localobject->create($user);
145 145
         print __METHOD__." resultFirstCreate=".$resultFirstCreate."\n";
146 146
         $this->assertGreaterThan(0, $resultFirstCreate);
147 147
 
148 148
         // We try to create another one with same ref
149
-        $localobject2=new Categorie($this->savdb);
149
+        $localobject2 = new Categorie($this->savdb);
150 150
         $localobject2->initAsSpecimen();
151 151
 
152 152
         // Check it does exist (return 1)
153
-        $resultCheck=$localobject2->already_exists();
153
+        $resultCheck = $localobject2->already_exists();
154 154
         print __METHOD__." resultCheck=".$resultCheck."\n";
155 155
         $this->assertGreaterThan(0, $resultCheck);
156 156
 
157
-        $resultSecondCreate=$localobject2->create($user);
157
+        $resultSecondCreate = $localobject2->create($user);
158 158
         print __METHOD__." result=".$resultSecondCreate."\n";
159 159
         $this->assertEquals(-4, $resultSecondCreate);
160 160
 
@@ -172,38 +172,38 @@  discard block
 block discarded – undo
172 172
      */
173 173
     public function testCategorieProduct($id)
174 174
     {
175
-        global $conf,$user,$langs,$db;
176
-        $conf=$this->savconf;
177
-        $user=$this->savuser;
178
-        $langs=$this->savlangs;
179
-        $db=$this->savdb;
175
+        global $conf, $user, $langs, $db;
176
+        $conf = $this->savconf;
177
+        $user = $this->savuser;
178
+        $langs = $this->savlangs;
179
+        $db = $this->savdb;
180 180
 
181
-        $localobjecttmp=new Categorie($this->savdb);
181
+        $localobjecttmp = new Categorie($this->savdb);
182 182
         $localobjecttmp->initAsSpecimen();
183
-        $localobjecttmp->label='Specimen Category for product';
184
-        $localobjecttmp->type=0;    // product category
185
-        $catid=$localobjecttmp->create($user);
183
+        $localobjecttmp->label = 'Specimen Category for product';
184
+        $localobjecttmp->type = 0; // product category
185
+        $catid = $localobjecttmp->create($user);
186 186
 
187 187
         print __METHOD__." catid=".$catid."\n";
188 188
         $this->assertGreaterThan(0, $catid);
189 189
 
190 190
         // Try to create product linked to category
191
-        $localobject2=new Product($this->savdb);
191
+        $localobject2 = new Product($this->savdb);
192 192
         $localobject2->initAsSpecimen();
193
-        $localobject2->ref.='-CATEG';
194
-        $localobject2->tva_npr=1;
195
-        $result=$localobject2->create($user);
193
+        $localobject2->ref .= '-CATEG';
194
+        $localobject2->tva_npr = 1;
195
+        $result = $localobject2->create($user);
196 196
         $cat = new Categorie($this->savdb);
197 197
         $cat->id = $catid;
198
-        $result=$cat->add_type($localobject2,"product");
198
+        $result = $cat->add_type($localobject2, "product");
199 199
 
200 200
         print __METHOD__." result=".$result."\n";
201 201
         $this->assertGreaterThan(0, $result);
202 202
 
203 203
         // Get list of categories for product
204
-        $localcateg=new Categorie($this->savdb);
205
-        $listofcateg=$localcateg->containing($localobject2->id, Categorie::TYPE_PRODUCT, 'label');
206
-        $this->assertTrue(in_array('Specimen Category for product',$listofcateg), 'Categ not found linked to product when it should');
204
+        $localcateg = new Categorie($this->savdb);
205
+        $listofcateg = $localcateg->containing($localobject2->id, Categorie::TYPE_PRODUCT, 'label');
206
+        $this->assertTrue(in_array('Specimen Category for product', $listofcateg), 'Categ not found linked to product when it should');
207 207
 
208 208
         return $id;
209 209
     }
@@ -219,14 +219,14 @@  discard block
 block discarded – undo
219 219
      */
220 220
     public function testCategorieFetch($id)
221 221
     {
222
-        global $conf,$user,$langs,$db;
223
-        $conf=$this->savconf;
224
-        $user=$this->savuser;
225
-        $langs=$this->savlangs;
226
-        $db=$this->savdb;
222
+        global $conf, $user, $langs, $db;
223
+        $conf = $this->savconf;
224
+        $user = $this->savuser;
225
+        $langs = $this->savlangs;
226
+        $db = $this->savdb;
227 227
 
228
-        $localobject=new Categorie($this->savdb);
229
-        $result=$localobject->fetch($id);
228
+        $localobject = new Categorie($this->savdb);
229
+        $result = $localobject->fetch($id);
230 230
 
231 231
         print __METHOD__." id=".$id." result=".$result."\n";
232 232
         $this->assertGreaterThan(0, $result);
@@ -244,14 +244,14 @@  discard block
 block discarded – undo
244 244
      */
245 245
     public function testCategorieUpdate($localobject)
246 246
     {
247
-        global $conf,$user,$langs,$db;
248
-        $conf=$this->savconf;
249
-        $user=$this->savuser;
250
-        $langs=$this->savlangs;
251
-        $db=$this->savdb;
247
+        global $conf, $user, $langs, $db;
248
+        $conf = $this->savconf;
249
+        $user = $this->savuser;
250
+        $langs = $this->savlangs;
251
+        $db = $this->savdb;
252 252
 
253
-        $localobject->note='New note after update';
254
-        $result=$localobject->update($user);
253
+        $localobject->note = 'New note after update';
254
+        $result = $localobject->update($user);
255 255
 
256 256
         print __METHOD__." id=".$localobject->id." result=".$result."\n";
257 257
         $this->assertGreaterThan(0, $result);
@@ -269,20 +269,20 @@  discard block
 block discarded – undo
269 269
      */
270 270
     public function testCategorieOther($localobject)
271 271
     {
272
-        global $conf,$user,$langs,$db;
273
-        $conf=$this->savconf;
274
-        $user=$this->savuser;
275
-        $langs=$this->savlangs;
276
-        $db=$this->savdb;
272
+        global $conf, $user, $langs, $db;
273
+        $conf = $this->savconf;
274
+        $user = $this->savuser;
275
+        $langs = $this->savlangs;
276
+        $db = $this->savdb;
277 277
 
278 278
         /*$result=$localobject->setstatus(0);
279 279
         print __METHOD__." id=".$localobject->id." result=".$result."\n";
280 280
         $this->assertLessThan($result, 0);
281 281
         */
282
-        $localobject2=new Categorie($db);
282
+        $localobject2 = new Categorie($db);
283 283
         $localobject2->initAsSpecimen();
284 284
 
285
-        $retarray=$localobject->liste_photos('/');
285
+        $retarray = $localobject->liste_photos('/');
286 286
         print __METHOD__." retarray size=".count($retarray)."\n";
287 287
         $this->assertTrue(is_array($retarray));
288 288
 
@@ -300,15 +300,15 @@  discard block
 block discarded – undo
300 300
      */
301 301
     public function testCategorieDelete($id)
302 302
     {
303
-        global $conf,$user,$langs,$db;
304
-        $conf=$this->savconf;
305
-        $user=$this->savuser;
306
-        $langs=$this->savlangs;
307
-        $db=$this->savdb;
303
+        global $conf, $user, $langs, $db;
304
+        $conf = $this->savconf;
305
+        $user = $this->savuser;
306
+        $langs = $this->savlangs;
307
+        $db = $this->savdb;
308 308
 
309
-        $localobject=new Categorie($this->savdb);
310
-        $result=$localobject->fetch($id);
311
-        $result=$localobject->delete($user);
309
+        $localobject = new Categorie($this->savdb);
310
+        $result = $localobject->fetch($id);
311
+        $result = $localobject->delete($user);
312 312
 
313 313
         print __METHOD__." id=".$id." result=".$result."\n";
314 314
         $this->assertGreaterThan(0, $result);
@@ -324,14 +324,14 @@  discard block
 block discarded – undo
324 324
      */
325 325
     public function testCategorieStatic()
326 326
     {
327
-        global $conf,$user,$langs,$db;
328
-        $conf=$this->savconf;
329
-        $user=$this->savuser;
330
-        $langs=$this->savlangs;
331
-        $db=$this->savdb;
332
-
333
-        $localobject=new Categorie($this->savdb);
334
-        $retarray=$localobject->get_full_arbo(3);
327
+        global $conf, $user, $langs, $db;
328
+        $conf = $this->savconf;
329
+        $user = $this->savuser;
330
+        $langs = $this->savlangs;
331
+        $db = $this->savdb;
332
+
333
+        $localobject = new Categorie($this->savdb);
334
+        $retarray = $localobject->get_full_arbo(3);
335 335
 
336 336
         print __METHOD__." retarray size=".count($retarray)."\n";
337 337
         $this->assertTrue(is_array($retarray));
Please login to merge, or discard this patch.
dolibarr/test/phpunit/FormAdminTest.php 2 patches
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
 
32 32
 if (empty($user->id))
33 33
 {
34
-	print "Load permissions for admin user nb 1\n";
35
-	$user->fetch(1);
36
-	$user->getrights();
34
+    print "Load permissions for admin user nb 1\n";
35
+    $user->fetch(1);
36
+    $user->getrights();
37 37
 }
38 38
 $conf->global->MAIN_DISABLE_ALL_MAILS=1;
39 39
 
@@ -47,75 +47,75 @@  discard block
 block discarded – undo
47 47
  */
48 48
 class FormAdminTest extends PHPUnit_Framework_TestCase
49 49
 {
50
-	protected $savconf;
51
-	protected $savuser;
52
-	protected $savlangs;
53
-	protected $savdb;
54
-
55
-	/**
56
-	 * Constructor
57
-	 * We save global variables into local variables
58
-	 *
59
-	 * @return FactureTest
60
-	 */
61
-	function __construct()
62
-	{
63
-		parent::__construct();
64
-
65
-		//$this->sharedFixture
66
-		global $conf,$user,$langs,$db;
67
-		$this->savconf=$conf;
68
-		$this->savuser=$user;
69
-		$this->savlangs=$langs;
70
-		$this->savdb=$db;
71
-
72
-		print __METHOD__." db->type=".$db->type." user->id=".$user->id;
73
-		//print " - db ".$db->db;
74
-		print "\n";
75
-	}
76
-
77
-	// Static methods
78
-  	public static function setUpBeforeClass()
50
+    protected $savconf;
51
+    protected $savuser;
52
+    protected $savlangs;
53
+    protected $savdb;
54
+
55
+    /**
56
+     * Constructor
57
+     * We save global variables into local variables
58
+     *
59
+     * @return FactureTest
60
+     */
61
+    function __construct()
62
+    {
63
+        parent::__construct();
64
+
65
+        //$this->sharedFixture
66
+        global $conf,$user,$langs,$db;
67
+        $this->savconf=$conf;
68
+        $this->savuser=$user;
69
+        $this->savlangs=$langs;
70
+        $this->savdb=$db;
71
+
72
+        print __METHOD__." db->type=".$db->type." user->id=".$user->id;
73
+        //print " - db ".$db->db;
74
+        print "\n";
75
+    }
76
+
77
+    // Static methods
78
+        public static function setUpBeforeClass()
79 79
     {
80
-    	global $conf,$user,$langs,$db;
81
-		$db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
80
+        global $conf,$user,$langs,$db;
81
+        $db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
82 82
 
83
-    	print __METHOD__."\n";
83
+        print __METHOD__."\n";
84 84
     }
85 85
 
86 86
     // tear down after class
87 87
     public static function tearDownAfterClass()
88 88
     {
89
-    	global $conf,$user,$langs,$db;
90
-		$db->rollback();
89
+        global $conf,$user,$langs,$db;
90
+        $db->rollback();
91 91
 
92
-		print __METHOD__."\n";
92
+        print __METHOD__."\n";
93 93
     }
94 94
 
95
-	/**
96
-	 * Init phpunit tests
97
-	 *
98
-	 * @return	void
99
-	 */
95
+    /**
96
+     * Init phpunit tests
97
+     *
98
+     * @return	void
99
+     */
100 100
     protected function setUp()
101 101
     {
102
-    	global $conf,$user,$langs,$db;
103
-		$conf=$this->savconf;
104
-		$user=$this->savuser;
105
-		$langs=$this->savlangs;
106
-		$db=$this->savdb;
102
+        global $conf,$user,$langs,$db;
103
+        $conf=$this->savconf;
104
+        $user=$this->savuser;
105
+        $langs=$this->savlangs;
106
+        $db=$this->savdb;
107 107
 
108
-		print __METHOD__."\n";
108
+        print __METHOD__."\n";
109 109
     }
110 110
 
111
-	/**
112
-	 * End phpunit tests
113
-	 *
114
-	 * @return	void
115
-	 */
116
-	protected function tearDown()
111
+    /**
112
+     * End phpunit tests
113
+     *
114
+     * @return	void
115
+     */
116
+    protected function tearDown()
117 117
     {
118
-    	print __METHOD__."\n";
118
+        print __METHOD__."\n";
119 119
     }
120 120
 
121 121
     /**
@@ -125,17 +125,17 @@  discard block
 block discarded – undo
125 125
      */
126 126
     public function testSelectPaperFormat()
127 127
     {
128
-    	global $conf,$user,$langs,$db;
129
-		$conf=$this->savconf;
130
-		$user=$this->savuser;
131
-		$langs=$this->savlangs;
132
-		$db=$this->savdb;
133
-
134
-		$localobject=new FormAdmin($this->savdb);
135
-    	$result=$localobject->select_paper_format('','paperformat_id','A4');
136
-
137
-    	$this->assertEquals($result, '<select class="flat" id="paperformat_id" name="paperformat_id"><option value="EUA4">Format A4 - 210x297 mm</option></select>');
138
-    	print __METHOD__." result=".$result."\n";
139
-    	return $result;
128
+        global $conf,$user,$langs,$db;
129
+        $conf=$this->savconf;
130
+        $user=$this->savuser;
131
+        $langs=$this->savlangs;
132
+        $db=$this->savdb;
133
+
134
+        $localobject=new FormAdmin($this->savdb);
135
+        $result=$localobject->select_paper_format('','paperformat_id','A4');
136
+
137
+        $this->assertEquals($result, '<select class="flat" id="paperformat_id" name="paperformat_id"><option value="EUA4">Format A4 - 210x297 mm</option></select>');
138
+        print __METHOD__." result=".$result."\n";
139
+        return $result;
140 140
     }
141 141
 }
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  *		\remarks	To run this script as CLI:  phpunit filename.php
24 24
  */
25 25
 
26
-global $conf,$user,$langs,$db;
26
+global $conf, $user, $langs, $db;
27 27
 //define('TEST_DB_FORCE_TYPE','mysql');	// This is to force using mysql driver
28 28
 //require_once 'PHPUnit/Autoload.php';
29 29
 require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	$user->fetch(1);
36 36
 	$user->getrights();
37 37
 }
38
-$conf->global->MAIN_DISABLE_ALL_MAILS=1;
38
+$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
39 39
 
40 40
 
41 41
 /**
@@ -63,11 +63,11 @@  discard block
 block discarded – undo
63 63
 		parent::__construct();
64 64
 
65 65
 		//$this->sharedFixture
66
-		global $conf,$user,$langs,$db;
67
-		$this->savconf=$conf;
68
-		$this->savuser=$user;
69
-		$this->savlangs=$langs;
70
-		$this->savdb=$db;
66
+		global $conf, $user, $langs, $db;
67
+		$this->savconf = $conf;
68
+		$this->savuser = $user;
69
+		$this->savlangs = $langs;
70
+		$this->savdb = $db;
71 71
 
72 72
 		print __METHOD__." db->type=".$db->type." user->id=".$user->id;
73 73
 		//print " - db ".$db->db;
@@ -77,8 +77,8 @@  discard block
 block discarded – undo
77 77
 	// Static methods
78 78
   	public static function setUpBeforeClass()
79 79
     {
80
-    	global $conf,$user,$langs,$db;
81
-		$db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
80
+    	global $conf, $user, $langs, $db;
81
+		$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
82 82
 
83 83
     	print __METHOD__."\n";
84 84
     }
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
     // tear down after class
87 87
     public static function tearDownAfterClass()
88 88
     {
89
-    	global $conf,$user,$langs,$db;
89
+    	global $conf, $user, $langs, $db;
90 90
 		$db->rollback();
91 91
 
92 92
 		print __METHOD__."\n";
@@ -99,11 +99,11 @@  discard block
 block discarded – undo
99 99
 	 */
100 100
     protected function setUp()
101 101
     {
102
-    	global $conf,$user,$langs,$db;
103
-		$conf=$this->savconf;
104
-		$user=$this->savuser;
105
-		$langs=$this->savlangs;
106
-		$db=$this->savdb;
102
+    	global $conf, $user, $langs, $db;
103
+		$conf = $this->savconf;
104
+		$user = $this->savuser;
105
+		$langs = $this->savlangs;
106
+		$db = $this->savdb;
107 107
 
108 108
 		print __METHOD__."\n";
109 109
     }
@@ -125,14 +125,14 @@  discard block
 block discarded – undo
125 125
      */
126 126
     public function testSelectPaperFormat()
127 127
     {
128
-    	global $conf,$user,$langs,$db;
129
-		$conf=$this->savconf;
130
-		$user=$this->savuser;
131
-		$langs=$this->savlangs;
132
-		$db=$this->savdb;
133
-
134
-		$localobject=new FormAdmin($this->savdb);
135
-    	$result=$localobject->select_paper_format('','paperformat_id','A4');
128
+    	global $conf, $user, $langs, $db;
129
+		$conf = $this->savconf;
130
+		$user = $this->savuser;
131
+		$langs = $this->savlangs;
132
+		$db = $this->savdb;
133
+
134
+		$localobject = new FormAdmin($this->savdb);
135
+    	$result = $localobject->select_paper_format('', 'paperformat_id', 'A4');
136 136
 
137 137
     	$this->assertEquals($result, '<select class="flat" id="paperformat_id" name="paperformat_id"><option value="EUA4">Format A4 - 210x297 mm</option></select>');
138 138
     	print __METHOD__." result=".$result."\n";
Please login to merge, or discard this patch.