Test Failed
Push — master ( ed0f4f...3aebc2 )
by Alxarafe
43:14
created
dolibarr/test/phpunit/FactureTestRounding.php 1 patch
Indentation   +157 added lines, -157 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 FactureTestRounding 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()
79 62
     {
80
-    	global $conf,$user,$langs,$db;
81
-		$db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
63
+        parent::__construct();
82 64
 
83
-    	print __METHOD__."\n";
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
+    {
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
+
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
-	 */
100
-	protected function setUp()
95
+    /**
96
+     * Init phpunit tests
97
+     *
98
+     * @return	void
99
+     */
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
 
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
         $langs=$this->savlangs;
135 135
         $db=$this->savdb;
136 136
 
137
-		$conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=0;
137
+        $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=0;
138 138
 
139 139
         $localobject=new Facture($this->savdb);
140 140
         $localobject->initAsSpecimen();
@@ -211,35 +211,35 @@  discard block
 block discarded – undo
211 211
      */
212 212
     public function testFactureAddLine1()
213 213
     {
214
-    	global $conf,$user,$langs,$db;
215
-    	$conf=$this->savconf;
216
-    	$user=$this->savuser;
217
-    	$langs=$this->savlangs;
218
-    	$db=$this->savdb;
219
-
220
-    	// With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 0
221
-    	$conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=0;
222
-
223
-    	$localobject1a=new Facture($this->savdb);
224
-    	$localobject1a->initAsSpecimen('nolines');
225
-    	$facid=$localobject1a->create($user);
226
-    	$localobject1a->addline('Line 1', 6.36, 15, 21);	// This include update_price
227
-    	print __METHOD__." id=".$facid." total_ttc=".$localobject1a->total_ttc."\n";
228
-    	$this->assertEquals(95.40, $localobject1a->total_ht);
229
-    	$this->assertEquals(20.03, $localobject1a->total_tva);
230
-    	$this->assertEquals(115.43, $localobject1a->total_ttc);
231
-
232
-    	// With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 1
233
-    	$conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=1;
234
-
235
-    	$localobject1b=new Facture($this->savdb);
236
-    	$localobject1b->initAsSpecimen('nolines');
237
-    	$facid=$localobject1b->create($user);
238
-    	$localobject1b->addline('Line 1', 6.36, 15, 21);	// This include update_price
239
-    	print __METHOD__." id=".$facid." total_ttc=".$localobject1b->total_ttc."\n";
240
-    	$this->assertEquals(95.40, $localobject1b->total_ht, 'testFactureAddLine1 total_ht');
241
-    	$this->assertEquals(20.03, $localobject1b->total_tva, 'testFactureAddLine1 total_tva');
242
-    	$this->assertEquals(115.43, $localobject1b->total_ttc, 'testFactureAddLine1 total_ttc');
214
+        global $conf,$user,$langs,$db;
215
+        $conf=$this->savconf;
216
+        $user=$this->savuser;
217
+        $langs=$this->savlangs;
218
+        $db=$this->savdb;
219
+
220
+        // With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 0
221
+        $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=0;
222
+
223
+        $localobject1a=new Facture($this->savdb);
224
+        $localobject1a->initAsSpecimen('nolines');
225
+        $facid=$localobject1a->create($user);
226
+        $localobject1a->addline('Line 1', 6.36, 15, 21);	// This include update_price
227
+        print __METHOD__." id=".$facid." total_ttc=".$localobject1a->total_ttc."\n";
228
+        $this->assertEquals(95.40, $localobject1a->total_ht);
229
+        $this->assertEquals(20.03, $localobject1a->total_tva);
230
+        $this->assertEquals(115.43, $localobject1a->total_ttc);
231
+
232
+        // With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 1
233
+        $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=1;
234
+
235
+        $localobject1b=new Facture($this->savdb);
236
+        $localobject1b->initAsSpecimen('nolines');
237
+        $facid=$localobject1b->create($user);
238
+        $localobject1b->addline('Line 1', 6.36, 15, 21);	// This include update_price
239
+        print __METHOD__." id=".$facid." total_ttc=".$localobject1b->total_ttc."\n";
240
+        $this->assertEquals(95.40, $localobject1b->total_ht, 'testFactureAddLine1 total_ht');
241
+        $this->assertEquals(20.03, $localobject1b->total_tva, 'testFactureAddLine1 total_tva');
242
+        $this->assertEquals(115.43, $localobject1b->total_ttc, 'testFactureAddLine1 total_ttc');
243 243
     }
244 244
 
245 245
     /**
@@ -252,39 +252,39 @@  discard block
 block discarded – undo
252 252
      */
253 253
     public function testFactureAddLine2()
254 254
     {
255
-    	global $conf,$user,$langs,$db;
256
-    	$conf=$this->savconf;
257
-    	$user=$this->savuser;
258
-    	$langs=$this->savlangs;
259
-    	$db=$this->savdb;
260
-
261
-    	// With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 0
262
-    	$conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=0;
263
-
264
-    	$localobject2=new Facture($this->savdb);
265
-    	$localobject2->initAsSpecimen('nolines');
266
-    	$facid=$localobject2->create($user);
267
-    	$localobject2->addline('Line 1', 6.36, 5, 21);
268
-    	$localobject2->addline('Line 2', 6.36, 5, 21);
269
-    	$localobject2->addline('Line 3', 6.36, 5, 21);
270
-    	print __METHOD__." id=".$facid." total_ttc=".$localobject2->total_ttc."\n";
271
-    	$this->assertEquals(95.40, $localobject2->total_ht);
272
-    	$this->assertEquals(20.04, $localobject2->total_tva);
273
-    	$this->assertEquals(115.44, $localobject2->total_ttc);
274
-
275
-    	// With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 1
276
-    	$conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=1;
277
-
278
-    	$localobject2=new Facture($this->savdb);
279
-    	$localobject2->initAsSpecimen('nolines');
280
-    	$facid=$localobject2->create($user);
281
-    	$localobject2->addline('Line 1', 6.36, 5, 21);
282
-    	$localobject2->addline('Line 2', 6.36, 5, 21);
283
-    	$localobject2->addline('Line 3', 6.36, 5, 21);
284
-    	print __METHOD__." id=".$facid." total_ttc=".$localobject2->total_ttc."\n";
285
-    	$this->assertEquals(95.40, $localobject2->total_ht);
286
-    	$this->assertEquals(20.03, $localobject2->total_tva);
287
-    	$this->assertEquals(115.43, $localobject2->total_ttc);
255
+        global $conf,$user,$langs,$db;
256
+        $conf=$this->savconf;
257
+        $user=$this->savuser;
258
+        $langs=$this->savlangs;
259
+        $db=$this->savdb;
260
+
261
+        // With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 0
262
+        $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=0;
263
+
264
+        $localobject2=new Facture($this->savdb);
265
+        $localobject2->initAsSpecimen('nolines');
266
+        $facid=$localobject2->create($user);
267
+        $localobject2->addline('Line 1', 6.36, 5, 21);
268
+        $localobject2->addline('Line 2', 6.36, 5, 21);
269
+        $localobject2->addline('Line 3', 6.36, 5, 21);
270
+        print __METHOD__." id=".$facid." total_ttc=".$localobject2->total_ttc."\n";
271
+        $this->assertEquals(95.40, $localobject2->total_ht);
272
+        $this->assertEquals(20.04, $localobject2->total_tva);
273
+        $this->assertEquals(115.44, $localobject2->total_ttc);
274
+
275
+        // With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 1
276
+        $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=1;
277
+
278
+        $localobject2=new Facture($this->savdb);
279
+        $localobject2->initAsSpecimen('nolines');
280
+        $facid=$localobject2->create($user);
281
+        $localobject2->addline('Line 1', 6.36, 5, 21);
282
+        $localobject2->addline('Line 2', 6.36, 5, 21);
283
+        $localobject2->addline('Line 3', 6.36, 5, 21);
284
+        print __METHOD__." id=".$facid." total_ttc=".$localobject2->total_ttc."\n";
285
+        $this->assertEquals(95.40, $localobject2->total_ht);
286
+        $this->assertEquals(20.03, $localobject2->total_tva);
287
+        $this->assertEquals(115.43, $localobject2->total_ttc);
288 288
     }
289 289
 
290 290
     /**
@@ -297,42 +297,42 @@  discard block
 block discarded – undo
297 297
      */
298 298
     public function testFactureAddLine3()
299 299
     {
300
-    	global $conf,$user,$langs,$db;
301
-    	$conf=$this->savconf;
302
-    	$user=$this->savuser;
303
-    	$langs=$this->savlangs;
304
-    	$db=$this->savdb;
305
-
306
-    	// With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 0
307
-    	$conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=0;
308
-
309
-    	$localobject3=new Facture($this->savdb);
310
-    	$localobject3->initAsSpecimen('nolines');
311
-    	$facid=$localobject3->create($user);
312
-    	$localobject3->addline('Line 1', 6.36, 3, 21);
313
-    	$localobject3->addline('Line 2', 6.36, 3, 21);
314
-    	$localobject3->addline('Line 3', 6.36, 3, 21);
315
-    	$localobject3->addline('Line 4', 6.36, 3, 21);
316
-    	$localobject3->addline('Line 5', 6.36, 3, 21);
317
-    	print __METHOD__." id=".$facid." total_ttc=".$localobject3->total_ttc."\n";
318
-    	$this->assertEquals(95.40, $localobject3->total_ht);
319
-    	$this->assertEquals(20.05, $localobject3->total_tva);
320
-    	$this->assertEquals(115.45, $localobject3->total_ttc);
321
-
322
-    	// With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 1
323
-    	$conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=1;
324
-
325
-    	$localobject3=new Facture($this->savdb);
326
-    	$localobject3->initAsSpecimen('nolines');
327
-    	$facid=$localobject3->create($user);
328
-    	$localobject3->addline('Line 1', 6.36, 3, 21);
329
-    	$localobject3->addline('Line 2', 6.36, 3, 21);
330
-    	$localobject3->addline('Line 3', 6.36, 3, 21);
331
-    	$localobject3->addline('Line 4', 6.36, 3, 21);
332
-    	$localobject3->addline('Line 5', 6.36, 3, 21);
333
-    	print __METHOD__." id=".$facid." total_ttc=".$localobject3->total_ttc."\n";
334
-    	$this->assertEquals(95.40, $localobject3->total_ht);
335
-    	$this->assertEquals(20.03, $localobject3->total_tva);
336
-    	$this->assertEquals(115.43, $localobject3->total_ttc);
300
+        global $conf,$user,$langs,$db;
301
+        $conf=$this->savconf;
302
+        $user=$this->savuser;
303
+        $langs=$this->savlangs;
304
+        $db=$this->savdb;
305
+
306
+        // With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 0
307
+        $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=0;
308
+
309
+        $localobject3=new Facture($this->savdb);
310
+        $localobject3->initAsSpecimen('nolines');
311
+        $facid=$localobject3->create($user);
312
+        $localobject3->addline('Line 1', 6.36, 3, 21);
313
+        $localobject3->addline('Line 2', 6.36, 3, 21);
314
+        $localobject3->addline('Line 3', 6.36, 3, 21);
315
+        $localobject3->addline('Line 4', 6.36, 3, 21);
316
+        $localobject3->addline('Line 5', 6.36, 3, 21);
317
+        print __METHOD__." id=".$facid." total_ttc=".$localobject3->total_ttc."\n";
318
+        $this->assertEquals(95.40, $localobject3->total_ht);
319
+        $this->assertEquals(20.05, $localobject3->total_tva);
320
+        $this->assertEquals(115.45, $localobject3->total_ttc);
321
+
322
+        // With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 1
323
+        $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=1;
324
+
325
+        $localobject3=new Facture($this->savdb);
326
+        $localobject3->initAsSpecimen('nolines');
327
+        $facid=$localobject3->create($user);
328
+        $localobject3->addline('Line 1', 6.36, 3, 21);
329
+        $localobject3->addline('Line 2', 6.36, 3, 21);
330
+        $localobject3->addline('Line 3', 6.36, 3, 21);
331
+        $localobject3->addline('Line 4', 6.36, 3, 21);
332
+        $localobject3->addline('Line 5', 6.36, 3, 21);
333
+        print __METHOD__." id=".$facid." total_ttc=".$localobject3->total_ttc."\n";
334
+        $this->assertEquals(95.40, $localobject3->total_ht);
335
+        $this->assertEquals(20.03, $localobject3->total_tva);
336
+        $this->assertEquals(115.43, $localobject3->total_ttc);
337 337
     }
338 338
 }
Please login to merge, or discard this patch.
dolibarr/test/phpunit/ImportTest.php 1 patch
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -49,74 +49,74 @@  discard block
 block discarded – undo
49 49
  */
50 50
 class ImportTest 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 ImportTest
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 ImportTest
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;
83
-		//$db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
82
+        global $conf,$user,$langs,$db;
83
+        //$db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
84 84
 
85
-    	print __METHOD__."\n";
85
+        print __METHOD__."\n";
86 86
     }
87 87
 
88 88
     // tear down after class
89 89
     public static function tearDownAfterClass()
90 90
     {
91
-    	global $conf,$user,$langs,$db;
92
-		//$db->rollback();
91
+        global $conf,$user,$langs,$db;
92
+        //$db->rollback();
93 93
 
94
-		print __METHOD__."\n";
94
+        print __METHOD__."\n";
95 95
     }
96 96
 
97
-	/**
98
-	 * Init phpunit tests
99
-	 *
100
-	 * @return	void
101
-	 */
97
+    /**
98
+     * Init phpunit tests
99
+     *
100
+     * @return	void
101
+     */
102 102
     protected function setUp()
103 103
     {
104
-    	global $conf,$user,$langs,$db;
105
-		$conf=$this->savconf;
106
-		$user=$this->savuser;
107
-		$langs=$this->savlangs;
108
-		$db=$this->savdb;
104
+        global $conf,$user,$langs,$db;
105
+        $conf=$this->savconf;
106
+        $user=$this->savuser;
107
+        $langs=$this->savlangs;
108
+        $db=$this->savdb;
109 109
 
110
-		print __METHOD__."\n";
110
+        print __METHOD__."\n";
111 111
     }
112
-	/**
113
-	 * End phpunit tests
114
-	 *
115
-	 * @return	void
116
-	 */
112
+    /**
113
+     * End phpunit tests
114
+     *
115
+     * @return	void
116
+     */
117 117
     protected function tearDown()
118 118
     {
119
-    	print __METHOD__."\n";
119
+        print __METHOD__."\n";
120 120
     }
121 121
 
122 122
 
@@ -134,6 +134,6 @@  discard block
 block discarded – undo
134 134
         // according to option
135 135
 
136 136
 
137
-		return true;
137
+        return true;
138 138
     }
139 139
 }
Please login to merge, or discard this patch.
dolibarr/test/phpunit/JsonLibTest.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -62,9 +62,9 @@  discard block
 block discarded – undo
62 62
      */
63 63
     function __construct()
64 64
     {
65
-    	parent::__construct();
65
+        parent::__construct();
66 66
 
67
-    	//$this->sharedFixture
67
+        //$this->sharedFixture
68 68
         global $conf,$user,$langs,$db;
69 69
         $this->savconf=$conf;
70 70
         $this->savuser=$user;
@@ -94,11 +94,11 @@  discard block
 block discarded – undo
94 94
         print __METHOD__."\n";
95 95
     }
96 96
 
97
-	/**
98
-	 * Init phpunit tests
99
-	 *
100
-	 * @return	void
101
-	 */
97
+    /**
98
+     * Init phpunit tests
99
+     *
100
+     * @return	void
101
+     */
102 102
     protected function setUp()
103 103
     {
104 104
         global $conf,$user,$langs,$db;
@@ -109,11 +109,11 @@  discard block
 block discarded – undo
109 109
 
110 110
         print __METHOD__."\n";
111 111
     }
112
-	/**
113
-	 * End phpunit tests
114
-	 *
115
-	 * @return	void
116
-	 */
112
+    /**
113
+     * End phpunit tests
114
+     *
115
+     * @return	void
116
+     */
117 117
     protected function tearDown()
118 118
     {
119 119
         print __METHOD__."\n";
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 
136 136
         // Do a test with an array starting with 0
137 137
         $arraytotest=array(0=>array('key'=>1,'value'=>'PRODREF','label'=>'Product ref with é and special chars \\ \' "'));
138
-		$arrayencodedexpected='[{"key":1,"value":"PRODREF","label":"Product ref with \u00e9 and special chars \\\\ \' \""}]';
138
+        $arrayencodedexpected='[{"key":1,"value":"PRODREF","label":"Product ref with \u00e9 and special chars \\\\ \' \""}]';
139 139
 
140 140
         $encoded=json_encode($arraytotest);
141 141
         $this->assertEquals($arrayencodedexpected,$encoded);
@@ -147,9 +147,9 @@  discard block
 block discarded – undo
147 147
         $decoded=dol_json_decode($encoded,true);
148 148
         $this->assertEquals($arraytotest,$decoded,'test for dol_json_xxx');
149 149
 
150
-		// Same test but array start with 2 instead of 0
150
+        // Same test but array start with 2 instead of 0
151 151
         $arraytotest=array(2=>array('key'=>1,'value'=>'PRODREF','label'=>'Product ref with é and special chars \\ \' "'));
152
-		$arrayencodedexpected='{"2":{"key":1,"value":"PRODREF","label":"Product ref with \u00e9 and special chars \\\\ \' \""}}';
152
+        $arrayencodedexpected='{"2":{"key":1,"value":"PRODREF","label":"Product ref with \u00e9 and special chars \\\\ \' \""}}';
153 153
 
154 154
         $encoded=json_encode($arraytotest);
155 155
         $this->assertEquals($arrayencodedexpected,$encoded);
Please login to merge, or discard this patch.
dolibarr/test/phpunit/TicketTest.php 1 patch
Indentation   +364 added lines, -364 removed lines patch added patch discarded remove patch
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
 require_once dirname(__FILE__).'/../../htdocs/ticket/class/ticket.class.php';
32 32
 
33 33
 if (empty($user->id)) {
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,366 +47,366 @@  discard block
 block discarded – undo
47 47
  */
48 48
 class TicketTest 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 ContratTest
60
-	 */
61
-	public 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
-	{
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
-
83
-		print __METHOD__."\n";
84
-	}
85
-
86
-	// tear down after class
87
-	public static function tearDownAfterClass()
88
-	{
89
-		global $conf,$user,$langs,$db;
90
-		$db->rollback();
91
-
92
-		print __METHOD__."\n";
93
-	}
94
-
95
-	/**
96
-	 * Init phpunit tests
97
-	 *
98
-	 * @return	void
99
-	 */
100
-	protected function setUp()
101
-	{
102
-		global $conf,$user,$langs,$db;
103
-		$conf=$this->savconf;
104
-		$user=$this->savuser;
105
-		$langs=$this->savlangs;
106
-		$db=$this->savdb;
107
-
108
-		print __METHOD__."\n";
109
-	}
110
-	/**
111
-	 * End phpunit tests
112
-	 *
113
-	 * @return	void
114
-	 */
115
-	protected function tearDown()
116
-	{
117
-		print __METHOD__."\n";
118
-	}
119
-
120
-	/**
121
-	 * testTicketCreate
122
-	 *
123
-	 * @return	int
124
-	 */
125
-	public function testTicketCreate()
126
-	{
127
-		global $conf,$user,$langs,$db;
128
-		$conf=$this->savconf;
129
-		$user=$this->savuser;
130
-		$langs=$this->savlangs;
131
-		$db=$this->savdb;
132
-
133
-		// Try to create one with bad values
134
-		$localobject=new Ticket($this->savdb);
135
-		$localobject->initAsSpecimen();
136
-		$localobject->ref = '';
137
-		$result=$localobject->create($user);
138
-
139
-		print __METHOD__." result=".$result."\n";
140
-		$this->assertEquals(-3, $result, $localobject->error.join(',', $localobject->errors));
141
-
142
-		// Try to create one with correct values
143
-		$localobject=new Ticket($this->savdb);
144
-		$localobject->initAsSpecimen();
145
-		$result=$localobject->create($user);
146
-
147
-		print __METHOD__." result=".$result."\n";
148
-		$this->assertGreaterThan(0, $result, $localobject->error.join(',', $localobject->errors));
149
-
150
-		return $result;
151
-	}
152
-
153
-	/**
154
-	 * testTicketFetch
155
-	 *
156
-	 * @param	int		$id		Id of ticket
157
-	 * @return	int
158
-	 *
159
-	 * @depends	testTicketCreate
160
-	 * The depends says test is run only if previous is ok
161
-	 */
162
-	public function testTicketFetch($id)
163
-	{
164
-		global $conf,$user,$langs,$db;
165
-		$conf=$this->savconf;
166
-		$user=$this->savuser;
167
-		$langs=$this->savlangs;
168
-		$db=$this->savdb;
169
-
170
-		$localobject=new Ticket($this->savdb);
171
-		$result=$localobject->fetch($id);
172
-
173
-		print __METHOD__." id=".$id." result=".$result."\n";
174
-		$this->assertGreaterThan(0, $result);
175
-
176
-		return $localobject;
177
-	}
178
-
179
-	/**
180
-	 * testTicketmarkAsRead
181
-	 *
182
-	 * @param	Ticket		$localobject		Ticket
183
-	 * @return	int
184
-	 *
185
-	 * @depends	testTicketFetch
186
-	 * The depends says test is run only if previous is ok
187
-	 */
188
-	public function testTicketmarkAsRead($localobject)
189
-	{
190
-		global $conf,$user,$langs,$db;
191
-		$conf=$this->savconf;
192
-		$user=$this->savuser;
193
-		$langs=$this->savlangs;
194
-		$db=$this->savdb;
195
-
196
-		$result=$localobject->markAsRead($user);
197
-		print __METHOD__." id=".$localobject->id." result=".$result."\n";
198
-
199
-		$this->assertGreaterThan(0, $result);
200
-		return $localobject;
201
-	}
202
-
203
-	/**
204
-	 * testTicketsetProject
205
-	 *
206
-	 * @param	Ticket		$localobject		Ticket
207
-	 * @return	int
208
-	 *
209
-	 * @depends	testTicketFetch
210
-	 * The depends says test is run only if previous is ok
211
-	 */
212
-	public function testTicketsetProject($localobject)
213
-	{
214
-		global $conf,$user,$langs,$db;
215
-		$conf=$this->savconf;
216
-		$user=$this->savuser;
217
-		$langs=$this->savlangs;
218
-		$db=$this->savdb;
219
-
220
-		$project_id = 1;
221
-
222
-		$result=$localobject->setProject($project_id);
223
-		print __METHOD__." id=".$localobject->id." result=".$result."\n";
224
-
225
-		$this->assertGreaterThan(0, $result);
226
-		return $localobject;
227
-	}
228
-
229
-	/**
230
-	 * testTicketsetContract
231
-	 *
232
-	 * @param	Ticket		$localobject		Ticket
233
-	 * @return	int
234
-	 *
235
-	 * @depends	testTicketFetch
236
-	 * The depends says test is run only if previous is ok
237
-	 */
238
-	public function testTicketsetContract($localobject)
239
-	{
240
-		global $conf,$user,$langs,$db;
241
-		$conf=$this->savconf;
242
-		$user=$this->savuser;
243
-		$langs=$this->savlangs;
244
-		$db=$this->savdb;
245
-
246
-		$contract_id = 1;
247
-
248
-		$result=$localobject->setContract($contract_id);
249
-		print __METHOD__." id=".$localobject->id." result=".$result."\n";
250
-
251
-		$this->assertGreaterThan(0, $result);
252
-		return $localobject;
253
-	}
254
-
255
-	/**
256
-	 * testTicketsetProgression
257
-	 *
258
-	 * @param	Ticket		$localobject		Ticket
259
-	 * @return	int
260
-	 *
261
-	 * @depends	testTicketFetch
262
-	 * The depends says test is run only if previous is ok
263
-	 */
264
-	public function testTicketsetProgression($localobject)
265
-	{
266
-		global $conf,$user,$langs,$db;
267
-		$conf=$this->savconf;
268
-		$user=$this->savuser;
269
-		$langs=$this->savlangs;
270
-		$db=$this->savdb;
271
-
272
-		$percent = 80;
273
-
274
-		$result=$localobject->setProgression($percent);
275
-		print __METHOD__." id=".$localobject->id." result=".$result."\n";
276
-
277
-		$this->assertGreaterThan(0, $result);
278
-		return $localobject;
279
-	}
280
-
281
-	/**
282
-	 * testTicketassignUser
283
-	 *
284
-	 * @param	Ticket		$localobject		Ticket
285
-	 * @return	int
286
-	 *
287
-	 * @depends	testTicketFetch
288
-	 * The depends says test is run only if previous is ok
289
-	 */
290
-	public function testTicketassignUser($localobject)
291
-	{
292
-		global $conf,$user,$langs,$db;
293
-		$conf=$this->savconf;
294
-		$user=$this->savuser;
295
-		$langs=$this->savlangs;
296
-		$db=$this->savdb;
297
-
298
-		$user_id_to_assign = 1;
299
-
300
-		$result=$localobject->assignUser($user, $user_id_to_assign);
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 ContratTest
60
+     */
61
+    public 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
+    {
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
+
83
+        print __METHOD__."\n";
84
+    }
85
+
86
+    // tear down after class
87
+    public static function tearDownAfterClass()
88
+    {
89
+        global $conf,$user,$langs,$db;
90
+        $db->rollback();
91
+
92
+        print __METHOD__."\n";
93
+    }
94
+
95
+    /**
96
+     * Init phpunit tests
97
+     *
98
+     * @return	void
99
+     */
100
+    protected function setUp()
101
+    {
102
+        global $conf,$user,$langs,$db;
103
+        $conf=$this->savconf;
104
+        $user=$this->savuser;
105
+        $langs=$this->savlangs;
106
+        $db=$this->savdb;
107
+
108
+        print __METHOD__."\n";
109
+    }
110
+    /**
111
+     * End phpunit tests
112
+     *
113
+     * @return	void
114
+     */
115
+    protected function tearDown()
116
+    {
117
+        print __METHOD__."\n";
118
+    }
119
+
120
+    /**
121
+     * testTicketCreate
122
+     *
123
+     * @return	int
124
+     */
125
+    public function testTicketCreate()
126
+    {
127
+        global $conf,$user,$langs,$db;
128
+        $conf=$this->savconf;
129
+        $user=$this->savuser;
130
+        $langs=$this->savlangs;
131
+        $db=$this->savdb;
132
+
133
+        // Try to create one with bad values
134
+        $localobject=new Ticket($this->savdb);
135
+        $localobject->initAsSpecimen();
136
+        $localobject->ref = '';
137
+        $result=$localobject->create($user);
138
+
139
+        print __METHOD__." result=".$result."\n";
140
+        $this->assertEquals(-3, $result, $localobject->error.join(',', $localobject->errors));
141
+
142
+        // Try to create one with correct values
143
+        $localobject=new Ticket($this->savdb);
144
+        $localobject->initAsSpecimen();
145
+        $result=$localobject->create($user);
146
+
147
+        print __METHOD__." result=".$result."\n";
148
+        $this->assertGreaterThan(0, $result, $localobject->error.join(',', $localobject->errors));
149
+
150
+        return $result;
151
+    }
152
+
153
+    /**
154
+     * testTicketFetch
155
+     *
156
+     * @param	int		$id		Id of ticket
157
+     * @return	int
158
+     *
159
+     * @depends	testTicketCreate
160
+     * The depends says test is run only if previous is ok
161
+     */
162
+    public function testTicketFetch($id)
163
+    {
164
+        global $conf,$user,$langs,$db;
165
+        $conf=$this->savconf;
166
+        $user=$this->savuser;
167
+        $langs=$this->savlangs;
168
+        $db=$this->savdb;
169
+
170
+        $localobject=new Ticket($this->savdb);
171
+        $result=$localobject->fetch($id);
172
+
173
+        print __METHOD__." id=".$id." result=".$result."\n";
174
+        $this->assertGreaterThan(0, $result);
175
+
176
+        return $localobject;
177
+    }
178
+
179
+    /**
180
+     * testTicketmarkAsRead
181
+     *
182
+     * @param	Ticket		$localobject		Ticket
183
+     * @return	int
184
+     *
185
+     * @depends	testTicketFetch
186
+     * The depends says test is run only if previous is ok
187
+     */
188
+    public function testTicketmarkAsRead($localobject)
189
+    {
190
+        global $conf,$user,$langs,$db;
191
+        $conf=$this->savconf;
192
+        $user=$this->savuser;
193
+        $langs=$this->savlangs;
194
+        $db=$this->savdb;
195
+
196
+        $result=$localobject->markAsRead($user);
197
+        print __METHOD__." id=".$localobject->id." result=".$result."\n";
198
+
199
+        $this->assertGreaterThan(0, $result);
200
+        return $localobject;
201
+    }
202
+
203
+    /**
204
+     * testTicketsetProject
205
+     *
206
+     * @param	Ticket		$localobject		Ticket
207
+     * @return	int
208
+     *
209
+     * @depends	testTicketFetch
210
+     * The depends says test is run only if previous is ok
211
+     */
212
+    public function testTicketsetProject($localobject)
213
+    {
214
+        global $conf,$user,$langs,$db;
215
+        $conf=$this->savconf;
216
+        $user=$this->savuser;
217
+        $langs=$this->savlangs;
218
+        $db=$this->savdb;
219
+
220
+        $project_id = 1;
221
+
222
+        $result=$localobject->setProject($project_id);
223
+        print __METHOD__." id=".$localobject->id." result=".$result."\n";
224
+
225
+        $this->assertGreaterThan(0, $result);
226
+        return $localobject;
227
+    }
228
+
229
+    /**
230
+     * testTicketsetContract
231
+     *
232
+     * @param	Ticket		$localobject		Ticket
233
+     * @return	int
234
+     *
235
+     * @depends	testTicketFetch
236
+     * The depends says test is run only if previous is ok
237
+     */
238
+    public function testTicketsetContract($localobject)
239
+    {
240
+        global $conf,$user,$langs,$db;
241
+        $conf=$this->savconf;
242
+        $user=$this->savuser;
243
+        $langs=$this->savlangs;
244
+        $db=$this->savdb;
245
+
246
+        $contract_id = 1;
247
+
248
+        $result=$localobject->setContract($contract_id);
249
+        print __METHOD__." id=".$localobject->id." result=".$result."\n";
250
+
251
+        $this->assertGreaterThan(0, $result);
252
+        return $localobject;
253
+    }
254
+
255
+    /**
256
+     * testTicketsetProgression
257
+     *
258
+     * @param	Ticket		$localobject		Ticket
259
+     * @return	int
260
+     *
261
+     * @depends	testTicketFetch
262
+     * The depends says test is run only if previous is ok
263
+     */
264
+    public function testTicketsetProgression($localobject)
265
+    {
266
+        global $conf,$user,$langs,$db;
267
+        $conf=$this->savconf;
268
+        $user=$this->savuser;
269
+        $langs=$this->savlangs;
270
+        $db=$this->savdb;
271
+
272
+        $percent = 80;
273
+
274
+        $result=$localobject->setProgression($percent);
275
+        print __METHOD__." id=".$localobject->id." result=".$result."\n";
276
+
277
+        $this->assertGreaterThan(0, $result);
278
+        return $localobject;
279
+    }
280
+
281
+    /**
282
+     * testTicketassignUser
283
+     *
284
+     * @param	Ticket		$localobject		Ticket
285
+     * @return	int
286
+     *
287
+     * @depends	testTicketFetch
288
+     * The depends says test is run only if previous is ok
289
+     */
290
+    public function testTicketassignUser($localobject)
291
+    {
292
+        global $conf,$user,$langs,$db;
293
+        $conf=$this->savconf;
294
+        $user=$this->savuser;
295
+        $langs=$this->savlangs;
296
+        $db=$this->savdb;
297
+
298
+        $user_id_to_assign = 1;
299
+
300
+        $result=$localobject->assignUser($user, $user_id_to_assign);
301 301
         ;
302
-		print __METHOD__." id=".$localobject->id." result=".$result."\n";
303
-
304
-		$this->assertGreaterThan(0, $result);
305
-		return $localobject;
306
-	}
307
-
308
-	/**
309
-	 * testTicketassignUserOther
310
-	 *
311
-	 * @param	Ticket		$localobject		Ticket
312
-	 * @return	int
313
-	 *
314
-	 * @depends	testTicketFetch
315
-	 * The depends says test is run only if previous is ok
316
-	 */
317
-	public function testTicketassignUserOther($localobject)
318
-	{
319
-		global $conf,$user,$langs,$db;
320
-		$conf=$this->savconf;
321
-		$user=$this->savuser;
322
-		$langs=$this->savlangs;
323
-		$db=$this->savdb;
324
-
325
-		$user_id_to_assign = 2;
326
-
327
-		$result=$localobject->assignUser($user, $user_id_to_assign);
328
-		;
329
-		print __METHOD__." id=".$localobject->id." result=".$result."\n";
330
-
331
-		$this->assertGreaterThan(0, $result);
332
-		return $localobject;
333
-	}
334
-
335
-	/**
336
-	 * testTicketcreateTicketLog
337
-	 *
338
-	 * @param	Ticket		$localobject		Ticket
339
-	 * @return	int
340
-	 *
341
-	 * @depends	testTicketFetch
342
-	 * The depends says test is run only if previous is ok
343
-	 */
344
-	public function testTicketcreateTicketLog($localobject)
345
-	{
346
-		global $conf,$user,$langs,$db;
347
-		$conf=$this->savconf;
348
-		$user=$this->savuser;
349
-		$langs=$this->savlangs;
350
-		$db=$this->savdb;
351
-
352
-
353
-		$message = 'Test ticket log';
354
-		$noemail = 1;
355
-		$result=$localobject->createTicketLog($user, $message, $noemail);
356
-		print __METHOD__." id=".$localobject->id." result=".$result."\n";
357
-
358
-		$this->assertGreaterThan(0, $result);
359
-		return $localobject;
360
-	}
361
-
362
-	/**
363
-	 * testTicketclose
364
-	 *
365
-	 * @param	Ticket		$localobject		Ticket
366
-	 * @return	int
367
-	 *
368
-	 * @depends	testTicketFetch
369
-	 * The depends says test is run only if previous is ok
370
-	 */
371
-	public function testTicketclose($localobject)
372
-	{
373
-		global $conf,$user,$langs,$db;
374
-		$conf=$this->savconf;
375
-		$user=$this->savuser;
376
-		$langs=$this->savlangs;
377
-		$db=$this->savdb;
378
-
379
-		$result=$localobject->close();
380
-		print __METHOD__." id=".$localobject->id." result=".$result."\n";
381
-
382
-		$this->assertGreaterThan(0, $result);
383
-		return $localobject->id;
384
-	}
385
-
386
-
387
-	/**
388
-	 * testTicketDelete
389
-	 *
390
-	 * @param	int		$id		Id of ticket
391
-	 * @return	int
392
-	 *
393
-	 * @depends	testTicketclose
394
-	 * The depends says test is run only if previous is ok
395
-	 */
396
-	public function testTicketDelete($id)
397
-	{
398
-		global $conf,$user,$langs,$db;
399
-		$conf=$this->savconf;
400
-		$user=$this->savuser;
401
-		$langs=$this->savlangs;
402
-		$db=$this->savdb;
403
-
404
-		$localobject=new Ticket($this->savdb);
405
-		$result=$localobject->fetch($id);
406
-		$result=$localobject->delete($user);
407
-
408
-		print __METHOD__." id=".$id." result=".$result."\n";
409
-		$this->assertGreaterThan(0, $result);
410
-		return $result;
411
-	}
302
+        print __METHOD__." id=".$localobject->id." result=".$result."\n";
303
+
304
+        $this->assertGreaterThan(0, $result);
305
+        return $localobject;
306
+    }
307
+
308
+    /**
309
+     * testTicketassignUserOther
310
+     *
311
+     * @param	Ticket		$localobject		Ticket
312
+     * @return	int
313
+     *
314
+     * @depends	testTicketFetch
315
+     * The depends says test is run only if previous is ok
316
+     */
317
+    public function testTicketassignUserOther($localobject)
318
+    {
319
+        global $conf,$user,$langs,$db;
320
+        $conf=$this->savconf;
321
+        $user=$this->savuser;
322
+        $langs=$this->savlangs;
323
+        $db=$this->savdb;
324
+
325
+        $user_id_to_assign = 2;
326
+
327
+        $result=$localobject->assignUser($user, $user_id_to_assign);
328
+        ;
329
+        print __METHOD__." id=".$localobject->id." result=".$result."\n";
330
+
331
+        $this->assertGreaterThan(0, $result);
332
+        return $localobject;
333
+    }
334
+
335
+    /**
336
+     * testTicketcreateTicketLog
337
+     *
338
+     * @param	Ticket		$localobject		Ticket
339
+     * @return	int
340
+     *
341
+     * @depends	testTicketFetch
342
+     * The depends says test is run only if previous is ok
343
+     */
344
+    public function testTicketcreateTicketLog($localobject)
345
+    {
346
+        global $conf,$user,$langs,$db;
347
+        $conf=$this->savconf;
348
+        $user=$this->savuser;
349
+        $langs=$this->savlangs;
350
+        $db=$this->savdb;
351
+
352
+
353
+        $message = 'Test ticket log';
354
+        $noemail = 1;
355
+        $result=$localobject->createTicketLog($user, $message, $noemail);
356
+        print __METHOD__." id=".$localobject->id." result=".$result."\n";
357
+
358
+        $this->assertGreaterThan(0, $result);
359
+        return $localobject;
360
+    }
361
+
362
+    /**
363
+     * testTicketclose
364
+     *
365
+     * @param	Ticket		$localobject		Ticket
366
+     * @return	int
367
+     *
368
+     * @depends	testTicketFetch
369
+     * The depends says test is run only if previous is ok
370
+     */
371
+    public function testTicketclose($localobject)
372
+    {
373
+        global $conf,$user,$langs,$db;
374
+        $conf=$this->savconf;
375
+        $user=$this->savuser;
376
+        $langs=$this->savlangs;
377
+        $db=$this->savdb;
378
+
379
+        $result=$localobject->close();
380
+        print __METHOD__." id=".$localobject->id." result=".$result."\n";
381
+
382
+        $this->assertGreaterThan(0, $result);
383
+        return $localobject->id;
384
+    }
385
+
386
+
387
+    /**
388
+     * testTicketDelete
389
+     *
390
+     * @param	int		$id		Id of ticket
391
+     * @return	int
392
+     *
393
+     * @depends	testTicketclose
394
+     * The depends says test is run only if previous is ok
395
+     */
396
+    public function testTicketDelete($id)
397
+    {
398
+        global $conf,$user,$langs,$db;
399
+        $conf=$this->savconf;
400
+        $user=$this->savuser;
401
+        $langs=$this->savlangs;
402
+        $db=$this->savdb;
403
+
404
+        $localobject=new Ticket($this->savdb);
405
+        $result=$localobject->fetch($id);
406
+        $result=$localobject->delete($user);
407
+
408
+        print __METHOD__." id=".$id." result=".$result."\n";
409
+        $this->assertGreaterThan(0, $result);
410
+        return $result;
411
+    }
412 412
 }
Please login to merge, or discard this patch.
dolibarr/test/phpunit/CompanyBankAccountTest.php 1 patch
Indentation   +93 added lines, -93 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 CompanyBankAccountTest 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 CompanyBankAccountTest
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 CompanyBankAccountTest
60
+     */
61
+    function __construct()
79 62
     {
80
-    	global $conf,$user,$langs,$db;
81
-		$db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
63
+        parent::__construct();
82 64
 
83
-    	print __METHOD__."\n";
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
+    {
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
+
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;
107
-
108
-		print __METHOD__."\n";
109
-		//print $db->getVersion()."\n";
102
+        global $conf,$user,$langs,$db;
103
+        $conf=$this->savconf;
104
+        $user=$this->savuser;
105
+        $langs=$this->savlangs;
106
+        $db=$this->savdb;
107
+
108
+        print __METHOD__."\n";
109
+        //print $db->getVersion()."\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
     /**
@@ -125,19 +125,19 @@  discard block
 block discarded – undo
125 125
      */
126 126
     public function testCompanyBankAccountCreate()
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 CompanyBankAccount($this->savdb);
135
-    	$localobject->initAsSpecimen();
136
-    	$result=$localobject->create($user);
137
-
138
-    	print __METHOD__." result=".$result." id=".$localobject->id."\n";
139
-    	$this->assertLessThan($result, 0);
140
-    	return $localobject->id;
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 CompanyBankAccount($this->savdb);
135
+        $localobject->initAsSpecimen();
136
+        $result=$localobject->create($user);
137
+
138
+        print __METHOD__." result=".$result." id=".$localobject->id."\n";
139
+        $this->assertLessThan($result, 0);
140
+        return $localobject->id;
141 141
     }
142 142
 
143 143
     /**
@@ -151,17 +151,17 @@  discard block
 block discarded – undo
151 151
      */
152 152
     public function testCompanyBankAccountFetch($id)
153 153
     {
154
-    	global $conf,$user,$langs,$db;
155
-		$conf=$this->savconf;
156
-		$user=$this->savuser;
157
-		$langs=$this->savlangs;
158
-		$db=$this->savdb;
159
-
160
-		$localobject=new CompanyBankAccount($this->savdb);
161
-    	$result=$localobject->fetch($id);
162
-    	print __METHOD__." id=".$id." result=".$result."\n";
163
-    	$this->assertLessThan($result, 0);
164
-    	return $localobject;
154
+        global $conf,$user,$langs,$db;
155
+        $conf=$this->savconf;
156
+        $user=$this->savuser;
157
+        $langs=$this->savlangs;
158
+        $db=$this->savdb;
159
+
160
+        $localobject=new CompanyBankAccount($this->savdb);
161
+        $result=$localobject->fetch($id);
162
+        print __METHOD__." id=".$id." result=".$result."\n";
163
+        $this->assertLessThan($result, 0);
164
+        return $localobject;
165 165
     }
166 166
 
167 167
     /**
@@ -197,18 +197,18 @@  discard block
 block discarded – undo
197 197
      */
198 198
     public function testCompanyBankAccountUpdate($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;
205
-
206
-		$localobject->owner='New owner';
207
-    	$result=$localobject->update($user);
208
-
209
-	   	print __METHOD__." id=".$localobject->id." result=".$result."\n";
210
-    	$this->assertLessThan($result, 0);
211
-    	return $localobject;
200
+        global $conf,$user,$langs,$db;
201
+        $conf=$this->savconf;
202
+        $user=$this->savuser;
203
+        $langs=$this->savlangs;
204
+        $db=$this->savdb;
205
+
206
+        $localobject->owner='New owner';
207
+        $result=$localobject->update($user);
208
+
209
+            print __METHOD__." id=".$localobject->id." result=".$result."\n";
210
+        $this->assertLessThan($result, 0);
211
+        return $localobject;
212 212
     }
213 213
 
214 214
     /**
Please login to merge, or discard this patch.
dolibarr/test/phpunit/MarginsLibTest.php 1 patch
Indentation   +79 added lines, -79 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,74 +47,74 @@  discard block
 block discarded – undo
47 47
  */
48 48
 class MarginsLibTest 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 DateLibTest
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 DateLibTest
60
+     */
61
+    function __construct()
79 62
     {
80
-    	global $conf,$user,$langs,$db;
81
-		$db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
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
+    {
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
-	/**
111
-	 * End phpunit tests
112
-	 *
113
-	 * @return	void
114
-	 */
110
+    /**
111
+     * End phpunit tests
112
+     *
113
+     * @return	void
114
+     */
115 115
     protected function tearDown()
116 116
     {
117
-    	print __METHOD__."\n";
117
+        print __METHOD__."\n";
118 118
     }
119 119
 
120 120
     /**
@@ -124,29 +124,29 @@  discard block
 block discarded – undo
124 124
      */
125 125
     public function testGetMarginInfos()
126 126
     {
127
-    	global $conf,$user,$langs,$db;
128
-		$conf=$this->savconf;
129
-		$user=$this->savuser;
130
-		$langs=$this->savlangs;
131
-		$db=$this->savdb;
132
-
133
-		$result=getMarginInfos(10, 0, 19.6, 0, 0, 0, 8);
134
-		//var_dump($result);
135
-		print __METHOD__." result[0]=".$result[0]."\n";
136
-		$this->assertEquals(8,$result[0]);
137
-		print __METHOD__." result[1]=".$result[1]."\n";
138
-		$this->assertEquals(25,$result[1]);
139
-		print __METHOD__." result[2]=".$result[2]."\n";
140
-		$this->assertEquals(20,$result[2]);
141
-
142
-		$result=getMarginInfos(10, 10, 19.6, 0, 0, 0, 8);
143
-		print __METHOD__." result[0]=".$result[0]."\n";
144
-		$this->assertEquals(8,$result[0]);
145
-		print __METHOD__." result[1]=".$result[1]."\n";
146
-		$this->assertEquals(12.5,$result[1]);
147
-		print __METHOD__." result[2]=".$result[2]."\n";
148
-		$this->assertEquals(1/9*100,$result[2]);
149
-
150
-		return 0;
127
+        global $conf,$user,$langs,$db;
128
+        $conf=$this->savconf;
129
+        $user=$this->savuser;
130
+        $langs=$this->savlangs;
131
+        $db=$this->savdb;
132
+
133
+        $result=getMarginInfos(10, 0, 19.6, 0, 0, 0, 8);
134
+        //var_dump($result);
135
+        print __METHOD__." result[0]=".$result[0]."\n";
136
+        $this->assertEquals(8,$result[0]);
137
+        print __METHOD__." result[1]=".$result[1]."\n";
138
+        $this->assertEquals(25,$result[1]);
139
+        print __METHOD__." result[2]=".$result[2]."\n";
140
+        $this->assertEquals(20,$result[2]);
141
+
142
+        $result=getMarginInfos(10, 10, 19.6, 0, 0, 0, 8);
143
+        print __METHOD__." result[0]=".$result[0]."\n";
144
+        $this->assertEquals(8,$result[0]);
145
+        print __METHOD__." result[1]=".$result[1]."\n";
146
+        $this->assertEquals(12.5,$result[1]);
147
+        print __METHOD__." result[2]=".$result[2]."\n";
148
+        $this->assertEquals(1/9*100,$result[2]);
149
+
150
+        return 0;
151 151
     }
152 152
 }
Please login to merge, or discard this patch.
dolibarr/test/phpunit/ExpenseReportTest.php 1 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/HolidayTest.php 1 patch
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.
dolibarr/test/phpunit/FilesLibTest.php 1 patch
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.