@@ -31,12 +31,12 @@ discard block |
||
31 | 31 | |
32 | 32 | if (empty($user->id)) |
33 | 33 | { |
34 | - print "Load permissions for user nb 1 (that should be admin)\n"; |
|
35 | - $user->fetch(1); |
|
34 | + print "Load permissions for user nb 1 (that should be admin)\n"; |
|
35 | + $user->fetch(1); |
|
36 | 36 | |
37 | - //$user->addrights(0, 'supplier_proposal'); |
|
37 | + //$user->addrights(0, 'supplier_proposal'); |
|
38 | 38 | |
39 | - $user->getrights(); |
|
39 | + $user->getrights(); |
|
40 | 40 | } |
41 | 41 | $conf->global->MAIN_DISABLE_ALL_MAILS=1; |
42 | 42 | |
@@ -50,82 +50,82 @@ discard block |
||
50 | 50 | */ |
51 | 51 | class SupplierProposalTest extends PHPUnit_Framework_TestCase |
52 | 52 | { |
53 | - protected $savconf; |
|
54 | - protected $savuser; |
|
55 | - protected $savlangs; |
|
56 | - protected $savdb; |
|
57 | - |
|
58 | - /** |
|
59 | - * Constructor |
|
60 | - * We save global variables into local variables |
|
61 | - * |
|
62 | - * @return PropalTest |
|
63 | - */ |
|
64 | - function __construct() |
|
65 | - { |
|
66 | - parent::__construct(); |
|
67 | - |
|
68 | - //$this->sharedFixture |
|
69 | - global $conf,$user,$langs,$db; |
|
70 | - $this->savconf=$conf; |
|
71 | - $this->savuser=$user; |
|
72 | - $this->savlangs=$langs; |
|
73 | - $this->savdb=$db; |
|
74 | - |
|
75 | - print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
|
76 | - //print " - db ".$db->db; |
|
77 | - print "\n"; |
|
78 | - } |
|
79 | - |
|
80 | - // Static methods |
|
81 | - public static function setUpBeforeClass() |
|
53 | + protected $savconf; |
|
54 | + protected $savuser; |
|
55 | + protected $savlangs; |
|
56 | + protected $savdb; |
|
57 | + |
|
58 | + /** |
|
59 | + * Constructor |
|
60 | + * We save global variables into local variables |
|
61 | + * |
|
62 | + * @return PropalTest |
|
63 | + */ |
|
64 | + function __construct() |
|
82 | 65 | { |
83 | - global $conf,$user,$langs,$db; |
|
84 | - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
66 | + parent::__construct(); |
|
85 | 67 | |
86 | - if (empty($conf->global->MAIN_MODULE_SUPPLIERPROPOSAL)) { print "\n".__METHOD__." module Supplier proposal must be enabled.\n"; die(); } |
|
68 | + //$this->sharedFixture |
|
69 | + global $conf,$user,$langs,$db; |
|
70 | + $this->savconf=$conf; |
|
71 | + $this->savuser=$user; |
|
72 | + $this->savlangs=$langs; |
|
73 | + $this->savdb=$db; |
|
74 | + |
|
75 | + print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
|
76 | + //print " - db ".$db->db; |
|
77 | + print "\n"; |
|
78 | + } |
|
79 | + |
|
80 | + // Static methods |
|
81 | + public static function setUpBeforeClass() |
|
82 | + { |
|
83 | + global $conf,$user,$langs,$db; |
|
84 | + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
87 | 85 | |
88 | - print __METHOD__."\n"; |
|
86 | + if (empty($conf->global->MAIN_MODULE_SUPPLIERPROPOSAL)) { print "\n".__METHOD__." module Supplier proposal must be enabled.\n"; die(); } |
|
87 | + |
|
88 | + print __METHOD__."\n"; |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | // tear down after class |
92 | 92 | public static function tearDownAfterClass() |
93 | 93 | { |
94 | - global $conf,$user,$langs,$db; |
|
95 | - $db->rollback(); |
|
94 | + global $conf,$user,$langs,$db; |
|
95 | + $db->rollback(); |
|
96 | 96 | |
97 | - print __METHOD__."\n"; |
|
97 | + print __METHOD__."\n"; |
|
98 | 98 | } |
99 | 99 | |
100 | - /** |
|
101 | - * Init phpunit tests |
|
102 | - * |
|
103 | - * @return void |
|
104 | - */ |
|
100 | + /** |
|
101 | + * Init phpunit tests |
|
102 | + * |
|
103 | + * @return void |
|
104 | + */ |
|
105 | 105 | protected function setUp() |
106 | 106 | { |
107 | - global $conf,$user,$langs,$db; |
|
108 | - $conf=$this->savconf; |
|
109 | - $user=$this->savuser; |
|
110 | - $langs=$this->savlangs; |
|
111 | - $db=$this->savdb; |
|
112 | - |
|
113 | - print __METHOD__."\n"; |
|
114 | - //print $db->getVersion()."\n"; |
|
115 | - |
|
116 | - // Set permission not set by default sql sample |
|
117 | - $user->addrights(0, 'supplier_proposal'); |
|
118 | - $user->getrights('supplier_proposal', 1); |
|
107 | + global $conf,$user,$langs,$db; |
|
108 | + $conf=$this->savconf; |
|
109 | + $user=$this->savuser; |
|
110 | + $langs=$this->savlangs; |
|
111 | + $db=$this->savdb; |
|
112 | + |
|
113 | + print __METHOD__."\n"; |
|
114 | + //print $db->getVersion()."\n"; |
|
115 | + |
|
116 | + // Set permission not set by default sql sample |
|
117 | + $user->addrights(0, 'supplier_proposal'); |
|
118 | + $user->getrights('supplier_proposal', 1); |
|
119 | 119 | } |
120 | 120 | |
121 | - /** |
|
122 | - * End phpunit tests |
|
123 | - * |
|
124 | - * @return void |
|
125 | - */ |
|
121 | + /** |
|
122 | + * End phpunit tests |
|
123 | + * |
|
124 | + * @return void |
|
125 | + */ |
|
126 | 126 | protected function tearDown() |
127 | 127 | { |
128 | - print __METHOD__."\n"; |
|
128 | + print __METHOD__."\n"; |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -135,19 +135,19 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public function testSupplierProposalCreate() |
137 | 137 | { |
138 | - global $conf,$user,$langs,$db; |
|
139 | - $conf=$this->savconf; |
|
140 | - $user=$this->savuser; |
|
141 | - $langs=$this->savlangs; |
|
142 | - $db=$this->savdb; |
|
143 | - |
|
144 | - $localobject=new SupplierProposal($this->savdb); |
|
145 | - $localobject->initAsSpecimen(); |
|
146 | - $result=$localobject->create($user); |
|
147 | - |
|
148 | - $this->assertLessThan($result, 0); |
|
149 | - print __METHOD__." result=".$result."\n"; |
|
150 | - return $result; |
|
138 | + global $conf,$user,$langs,$db; |
|
139 | + $conf=$this->savconf; |
|
140 | + $user=$this->savuser; |
|
141 | + $langs=$this->savlangs; |
|
142 | + $db=$this->savdb; |
|
143 | + |
|
144 | + $localobject=new SupplierProposal($this->savdb); |
|
145 | + $localobject->initAsSpecimen(); |
|
146 | + $result=$localobject->create($user); |
|
147 | + |
|
148 | + $this->assertLessThan($result, 0); |
|
149 | + print __METHOD__." result=".$result."\n"; |
|
150 | + return $result; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
@@ -161,18 +161,18 @@ discard block |
||
161 | 161 | */ |
162 | 162 | public function testSupplierProposalFetch($id) |
163 | 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 SupplierProposal($this->savdb); |
|
171 | - $result=$localobject->fetch($id); |
|
172 | - |
|
173 | - $this->assertLessThan($result, 0); |
|
174 | - print __METHOD__." id=".$id." result=".$result."\n"; |
|
175 | - return $localobject; |
|
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 SupplierProposal($this->savdb); |
|
171 | + $result=$localobject->fetch($id); |
|
172 | + |
|
173 | + $this->assertLessThan($result, 0); |
|
174 | + print __METHOD__." id=".$id." result=".$result."\n"; |
|
175 | + return $localobject; |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | /** |
@@ -186,18 +186,18 @@ discard block |
||
186 | 186 | */ |
187 | 187 | public function testSupplierProposalAddLine($localobject) |
188 | 188 | { |
189 | - global $conf,$user,$langs,$db; |
|
190 | - $conf=$this->savconf; |
|
191 | - $user=$this->savuser; |
|
192 | - $langs=$this->savlangs; |
|
193 | - $db=$this->savdb; |
|
194 | - |
|
195 | - $localobject->fetch_thirdparty(); |
|
196 | - $result=$localobject->addline('Added line', 10, 2, 19.6); |
|
197 | - |
|
198 | - $this->assertLessThan($result, 0); |
|
199 | - print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
200 | - return $localobject; |
|
189 | + global $conf,$user,$langs,$db; |
|
190 | + $conf=$this->savconf; |
|
191 | + $user=$this->savuser; |
|
192 | + $langs=$this->savlangs; |
|
193 | + $db=$this->savdb; |
|
194 | + |
|
195 | + $localobject->fetch_thirdparty(); |
|
196 | + $result=$localobject->addline('Added line', 10, 2, 19.6); |
|
197 | + |
|
198 | + $this->assertLessThan($result, 0); |
|
199 | + print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
200 | + return $localobject; |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | /** |
@@ -211,20 +211,20 @@ discard block |
||
211 | 211 | */ |
212 | 212 | public function testSupplierProposalValid($localobject) |
213 | 213 | { |
214 | - global $conf,$user,$langs,$db; |
|
215 | - $conf=$this->savconf; |
|
216 | - $user=$this->savuser; |
|
217 | - $langs=$this->savlangs; |
|
218 | - $db=$this->savdb; |
|
214 | + global $conf,$user,$langs,$db; |
|
215 | + $conf=$this->savconf; |
|
216 | + $user=$this->savuser; |
|
217 | + $langs=$this->savlangs; |
|
218 | + $db=$this->savdb; |
|
219 | 219 | |
220 | - $result=$localobject->valid($user); |
|
220 | + $result=$localobject->valid($user); |
|
221 | 221 | |
222 | - print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
223 | - $this->assertLessThan($result, 0); |
|
224 | - return $localobject; |
|
222 | + print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
223 | + $this->assertLessThan($result, 0); |
|
224 | + return $localobject; |
|
225 | 225 | } |
226 | 226 | |
227 | - /** |
|
227 | + /** |
|
228 | 228 | * testSupplierProposalOther |
229 | 229 | * |
230 | 230 | * @param Proposal $localobject Proposal |
@@ -264,18 +264,18 @@ discard block |
||
264 | 264 | */ |
265 | 265 | public function testSupplierProposalDelete($id) |
266 | 266 | { |
267 | - global $conf,$user,$langs,$db; |
|
268 | - $conf=$this->savconf; |
|
269 | - $user=$this->savuser; |
|
270 | - $langs=$this->savlangs; |
|
271 | - $db=$this->savdb; |
|
272 | - |
|
273 | - $localobject=new SupplierProposal($this->savdb); |
|
274 | - $result=$localobject->fetch($id); |
|
275 | - $result=$localobject->delete($user); |
|
276 | - |
|
277 | - print __METHOD__." id=".$id." result=".$result."\n"; |
|
278 | - $this->assertLessThan($result, 0); |
|
279 | - return $result; |
|
267 | + global $conf,$user,$langs,$db; |
|
268 | + $conf=$this->savconf; |
|
269 | + $user=$this->savuser; |
|
270 | + $langs=$this->savlangs; |
|
271 | + $db=$this->savdb; |
|
272 | + |
|
273 | + $localobject=new SupplierProposal($this->savdb); |
|
274 | + $result=$localobject->fetch($id); |
|
275 | + $result=$localobject->delete($user); |
|
276 | + |
|
277 | + print __METHOD__." id=".$id." result=".$result."\n"; |
|
278 | + $this->assertLessThan($result, 0); |
|
279 | + return $result; |
|
280 | 280 | } |
281 | 281 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * \remarks To run this script as CLI: phpunit filename.php |
24 | 24 | */ |
25 | 25 | |
26 | -global $conf,$user,$langs,$db; |
|
26 | +global $conf, $user, $langs, $db; |
|
27 | 27 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
28 | 28 | //require_once 'PHPUnit/Autoload.php'; |
29 | 29 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | |
39 | 39 | $user->getrights(); |
40 | 40 | } |
41 | -$conf->global->MAIN_DISABLE_ALL_MAILS=1; |
|
41 | +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
|
42 | 42 | |
43 | 43 | |
44 | 44 | /** |
@@ -66,11 +66,11 @@ discard block |
||
66 | 66 | parent::__construct(); |
67 | 67 | |
68 | 68 | //$this->sharedFixture |
69 | - global $conf,$user,$langs,$db; |
|
70 | - $this->savconf=$conf; |
|
71 | - $this->savuser=$user; |
|
72 | - $this->savlangs=$langs; |
|
73 | - $this->savdb=$db; |
|
69 | + global $conf, $user, $langs, $db; |
|
70 | + $this->savconf = $conf; |
|
71 | + $this->savuser = $user; |
|
72 | + $this->savlangs = $langs; |
|
73 | + $this->savdb = $db; |
|
74 | 74 | |
75 | 75 | print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
76 | 76 | //print " - db ".$db->db; |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | // Static methods |
81 | 81 | public static function setUpBeforeClass() |
82 | 82 | { |
83 | - global $conf,$user,$langs,$db; |
|
84 | - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
83 | + global $conf, $user, $langs, $db; |
|
84 | + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
85 | 85 | |
86 | 86 | if (empty($conf->global->MAIN_MODULE_SUPPLIERPROPOSAL)) { print "\n".__METHOD__." module Supplier proposal must be enabled.\n"; die(); } |
87 | 87 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | // tear down after class |
92 | 92 | public static function tearDownAfterClass() |
93 | 93 | { |
94 | - global $conf,$user,$langs,$db; |
|
94 | + global $conf, $user, $langs, $db; |
|
95 | 95 | $db->rollback(); |
96 | 96 | |
97 | 97 | print __METHOD__."\n"; |
@@ -104,11 +104,11 @@ discard block |
||
104 | 104 | */ |
105 | 105 | protected function setUp() |
106 | 106 | { |
107 | - global $conf,$user,$langs,$db; |
|
108 | - $conf=$this->savconf; |
|
109 | - $user=$this->savuser; |
|
110 | - $langs=$this->savlangs; |
|
111 | - $db=$this->savdb; |
|
107 | + global $conf, $user, $langs, $db; |
|
108 | + $conf = $this->savconf; |
|
109 | + $user = $this->savuser; |
|
110 | + $langs = $this->savlangs; |
|
111 | + $db = $this->savdb; |
|
112 | 112 | |
113 | 113 | print __METHOD__."\n"; |
114 | 114 | //print $db->getVersion()."\n"; |
@@ -135,15 +135,15 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public function testSupplierProposalCreate() |
137 | 137 | { |
138 | - global $conf,$user,$langs,$db; |
|
139 | - $conf=$this->savconf; |
|
140 | - $user=$this->savuser; |
|
141 | - $langs=$this->savlangs; |
|
142 | - $db=$this->savdb; |
|
138 | + global $conf, $user, $langs, $db; |
|
139 | + $conf = $this->savconf; |
|
140 | + $user = $this->savuser; |
|
141 | + $langs = $this->savlangs; |
|
142 | + $db = $this->savdb; |
|
143 | 143 | |
144 | - $localobject=new SupplierProposal($this->savdb); |
|
144 | + $localobject = new SupplierProposal($this->savdb); |
|
145 | 145 | $localobject->initAsSpecimen(); |
146 | - $result=$localobject->create($user); |
|
146 | + $result = $localobject->create($user); |
|
147 | 147 | |
148 | 148 | $this->assertLessThan($result, 0); |
149 | 149 | print __METHOD__." result=".$result."\n"; |
@@ -161,14 +161,14 @@ discard block |
||
161 | 161 | */ |
162 | 162 | public function testSupplierProposalFetch($id) |
163 | 163 | { |
164 | - global $conf,$user,$langs,$db; |
|
165 | - $conf=$this->savconf; |
|
166 | - $user=$this->savuser; |
|
167 | - $langs=$this->savlangs; |
|
168 | - $db=$this->savdb; |
|
164 | + global $conf, $user, $langs, $db; |
|
165 | + $conf = $this->savconf; |
|
166 | + $user = $this->savuser; |
|
167 | + $langs = $this->savlangs; |
|
168 | + $db = $this->savdb; |
|
169 | 169 | |
170 | - $localobject=new SupplierProposal($this->savdb); |
|
171 | - $result=$localobject->fetch($id); |
|
170 | + $localobject = new SupplierProposal($this->savdb); |
|
171 | + $result = $localobject->fetch($id); |
|
172 | 172 | |
173 | 173 | $this->assertLessThan($result, 0); |
174 | 174 | print __METHOD__." id=".$id." result=".$result."\n"; |
@@ -186,14 +186,14 @@ discard block |
||
186 | 186 | */ |
187 | 187 | public function testSupplierProposalAddLine($localobject) |
188 | 188 | { |
189 | - global $conf,$user,$langs,$db; |
|
190 | - $conf=$this->savconf; |
|
191 | - $user=$this->savuser; |
|
192 | - $langs=$this->savlangs; |
|
193 | - $db=$this->savdb; |
|
189 | + global $conf, $user, $langs, $db; |
|
190 | + $conf = $this->savconf; |
|
191 | + $user = $this->savuser; |
|
192 | + $langs = $this->savlangs; |
|
193 | + $db = $this->savdb; |
|
194 | 194 | |
195 | 195 | $localobject->fetch_thirdparty(); |
196 | - $result=$localobject->addline('Added line', 10, 2, 19.6); |
|
196 | + $result = $localobject->addline('Added line', 10, 2, 19.6); |
|
197 | 197 | |
198 | 198 | $this->assertLessThan($result, 0); |
199 | 199 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
@@ -211,13 +211,13 @@ discard block |
||
211 | 211 | */ |
212 | 212 | public function testSupplierProposalValid($localobject) |
213 | 213 | { |
214 | - global $conf,$user,$langs,$db; |
|
215 | - $conf=$this->savconf; |
|
216 | - $user=$this->savuser; |
|
217 | - $langs=$this->savlangs; |
|
218 | - $db=$this->savdb; |
|
214 | + global $conf, $user, $langs, $db; |
|
215 | + $conf = $this->savconf; |
|
216 | + $user = $this->savuser; |
|
217 | + $langs = $this->savlangs; |
|
218 | + $db = $this->savdb; |
|
219 | 219 | |
220 | - $result=$localobject->valid($user); |
|
220 | + $result = $localobject->valid($user); |
|
221 | 221 | |
222 | 222 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
223 | 223 | $this->assertLessThan($result, 0); |
@@ -235,11 +235,11 @@ discard block |
||
235 | 235 | */ |
236 | 236 | public function testSupplierProposalOther($localobject) |
237 | 237 | { |
238 | - global $conf,$user,$langs,$db; |
|
239 | - $conf=$this->savconf; |
|
240 | - $user=$this->savuser; |
|
241 | - $langs=$this->savlangs; |
|
242 | - $db=$this->savdb; |
|
238 | + global $conf, $user, $langs, $db; |
|
239 | + $conf = $this->savconf; |
|
240 | + $user = $this->savuser; |
|
241 | + $langs = $this->savlangs; |
|
242 | + $db = $this->savdb; |
|
243 | 243 | |
244 | 244 | /*$result=$localobject->setstatus(0); |
245 | 245 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
@@ -264,15 +264,15 @@ discard block |
||
264 | 264 | */ |
265 | 265 | public function testSupplierProposalDelete($id) |
266 | 266 | { |
267 | - global $conf,$user,$langs,$db; |
|
268 | - $conf=$this->savconf; |
|
269 | - $user=$this->savuser; |
|
270 | - $langs=$this->savlangs; |
|
271 | - $db=$this->savdb; |
|
272 | - |
|
273 | - $localobject=new SupplierProposal($this->savdb); |
|
274 | - $result=$localobject->fetch($id); |
|
275 | - $result=$localobject->delete($user); |
|
267 | + global $conf, $user, $langs, $db; |
|
268 | + $conf = $this->savconf; |
|
269 | + $user = $this->savuser; |
|
270 | + $langs = $this->savlangs; |
|
271 | + $db = $this->savdb; |
|
272 | + |
|
273 | + $localobject = new SupplierProposal($this->savdb); |
|
274 | + $result = $localobject->fetch($id); |
|
275 | + $result = $localobject->delete($user); |
|
276 | 276 | |
277 | 277 | print __METHOD__." id=".$id." result=".$result."\n"; |
278 | 278 | $this->assertLessThan($result, 0); |
@@ -40,8 +40,8 @@ discard block |
||
40 | 40 | } |
41 | 41 | if (empty($conf->adherent->enabled)) |
42 | 42 | { |
43 | - print "Error: Module member must be enabled to have significant results.\n"; |
|
44 | - exit(1); |
|
43 | + print "Error: Module member must be enabled to have significant results.\n"; |
|
44 | + exit(1); |
|
45 | 45 | } |
46 | 46 | if (! empty($conf->ldap->enabled)) |
47 | 47 | { |
@@ -215,18 +215,18 @@ discard block |
||
215 | 215 | // Test only with php7.2 or less |
216 | 216 | //if ((float) phpversion() < 7.3) |
217 | 217 | //{ |
218 | - require_once dirname(__FILE__).'/WebservicesProductsTest.php'; |
|
219 | - $suite->addTestSuite('WebservicesProductsTest'); |
|
220 | - require_once dirname(__FILE__).'/WebservicesInvoicesTest.php'; |
|
221 | - $suite->addTestSuite('WebservicesInvoicesTest'); |
|
222 | - require_once dirname(__FILE__).'/WebservicesOrdersTest.php'; |
|
223 | - $suite->addTestSuite('WebservicesOrdersTest'); |
|
224 | - require_once dirname(__FILE__).'/WebservicesOtherTest.php'; |
|
225 | - $suite->addTestSuite('WebservicesOtherTest'); |
|
226 | - require_once dirname(__FILE__).'/WebservicesThirdpartyTest.php'; |
|
227 | - $suite->addTestSuite('WebservicesThirdpartyTest'); |
|
228 | - require_once dirname(__FILE__).'/WebservicesUserTest.php'; |
|
229 | - $suite->addTestSuite('WebservicesUserTest'); |
|
218 | + require_once dirname(__FILE__).'/WebservicesProductsTest.php'; |
|
219 | + $suite->addTestSuite('WebservicesProductsTest'); |
|
220 | + require_once dirname(__FILE__).'/WebservicesInvoicesTest.php'; |
|
221 | + $suite->addTestSuite('WebservicesInvoicesTest'); |
|
222 | + require_once dirname(__FILE__).'/WebservicesOrdersTest.php'; |
|
223 | + $suite->addTestSuite('WebservicesOrdersTest'); |
|
224 | + require_once dirname(__FILE__).'/WebservicesOtherTest.php'; |
|
225 | + $suite->addTestSuite('WebservicesOtherTest'); |
|
226 | + require_once dirname(__FILE__).'/WebservicesThirdpartyTest.php'; |
|
227 | + $suite->addTestSuite('WebservicesThirdpartyTest'); |
|
228 | + require_once dirname(__FILE__).'/WebservicesUserTest.php'; |
|
229 | + $suite->addTestSuite('WebservicesUserTest'); |
|
230 | 230 | //} |
231 | 231 | |
232 | 232 | require_once dirname(__FILE__).'/ExportTest.php'; |
@@ -24,13 +24,13 @@ discard block |
||
24 | 24 | * \remarks To run this script as CLI: phpunit filename.php |
25 | 25 | */ |
26 | 26 | print "PHP Version: ".phpversion()."\n"; |
27 | -print "Memory: ". ini_get('memory_limit')."\n"; |
|
27 | +print "Memory: ".ini_get('memory_limit')."\n"; |
|
28 | 28 | |
29 | -global $conf,$user,$langs,$db; |
|
29 | +global $conf, $user, $langs, $db; |
|
30 | 30 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
31 | 31 | //require_once 'PHPUnit/Autoload.php'; |
32 | 32 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
33 | -print 'DOL_MAIN_URL_ROOT='.DOL_MAIN_URL_ROOT."\n"; // constant will be used by other tests |
|
33 | +print 'DOL_MAIN_URL_ROOT='.DOL_MAIN_URL_ROOT."\n"; // constant will be used by other tests |
|
34 | 34 | |
35 | 35 | |
36 | 36 | if ($langs->defaultlang != 'en_US') |
@@ -43,12 +43,12 @@ discard block |
||
43 | 43 | print "Error: Module member must be enabled to have significant results.\n"; |
44 | 44 | exit(1); |
45 | 45 | } |
46 | -if (! empty($conf->ldap->enabled)) |
|
46 | +if (!empty($conf->ldap->enabled)) |
|
47 | 47 | { |
48 | 48 | print "Error: LDAP module should not be enabled.\n"; |
49 | 49 | exit(1); |
50 | 50 | } |
51 | -if (! empty($conf->google->enabled)) |
|
51 | +if (!empty($conf->google->enabled)) |
|
52 | 52 | { |
53 | 53 | print "Warning: Google module should not be enabled.\n"; |
54 | 54 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | $user->fetch(1); |
59 | 59 | $user->getrights(); |
60 | 60 | } |
61 | -$conf->global->MAIN_DISABLE_ALL_MAILS=1; |
|
61 | +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
|
62 | 62 | |
63 | 63 | |
64 | 64 | |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | require_once dirname(__FILE__).'/FormAdminTest.php'; |
241 | 241 | $suite->addTestSuite('FormAdminTest'); |
242 | 242 | |
243 | - require_once dirname(__FILE__).'/ModulesTest.php'; // At end because it's the longer |
|
243 | + require_once dirname(__FILE__).'/ModulesTest.php'; // At end because it's the longer |
|
244 | 244 | $suite->addTestSuite('ModulesTest'); |
245 | 245 | |
246 | 246 |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | */ |
62 | 62 | function __construct() |
63 | 63 | { |
64 | - parent::__construct(); |
|
64 | + parent::__construct(); |
|
65 | 65 | |
66 | - //$this->sharedFixture |
|
66 | + //$this->sharedFixture |
|
67 | 67 | global $conf,$user,$langs,$db; |
68 | 68 | $this->savconf=$conf; |
69 | 69 | $this->savuser=$user; |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | return $localobject; |
169 | 169 | } |
170 | 170 | |
171 | - /** |
|
171 | + /** |
|
172 | 172 | * testBankAccountOther |
173 | 173 | * |
174 | 174 | * @param Object $localobject Object contract |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * \remarks To run this script as CLI: phpunit filename.php |
24 | 24 | */ |
25 | 25 | |
26 | -global $conf,$user,$langs,$db; |
|
26 | +global $conf, $user, $langs, $db; |
|
27 | 27 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
28 | 28 | //require_once 'PHPUnit/Autoload.php'; |
29 | 29 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | $user->fetch(1); |
35 | 35 | $user->getrights(); |
36 | 36 | } |
37 | -$conf->global->MAIN_DISABLE_ALL_MAILS=1; |
|
37 | +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
|
38 | 38 | |
39 | 39 | $langs->load("main"); |
40 | 40 | |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | parent::__construct(); |
65 | 65 | |
66 | 66 | //$this->sharedFixture |
67 | - global $conf,$user,$langs,$db; |
|
68 | - $this->savconf=$conf; |
|
69 | - $this->savuser=$user; |
|
70 | - $this->savlangs=$langs; |
|
71 | - $this->savdb=$db; |
|
67 | + global $conf, $user, $langs, $db; |
|
68 | + $this->savconf = $conf; |
|
69 | + $this->savuser = $user; |
|
70 | + $this->savlangs = $langs; |
|
71 | + $this->savdb = $db; |
|
72 | 72 | |
73 | 73 | print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
74 | 74 | //print " - db ".$db->db; |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | // Static methods |
79 | 79 | public static function setUpBeforeClass() |
80 | 80 | { |
81 | - global $conf,$user,$langs,$db; |
|
81 | + global $conf, $user, $langs, $db; |
|
82 | 82 | $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
83 | 83 | |
84 | 84 | print __METHOD__."\n"; |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | // tear down after class |
88 | 88 | public static function tearDownAfterClass() |
89 | 89 | { |
90 | - global $conf,$user,$langs,$db; |
|
90 | + global $conf, $user, $langs, $db; |
|
91 | 91 | $db->rollback(); |
92 | 92 | |
93 | 93 | print __METHOD__."\n"; |
@@ -100,11 +100,11 @@ discard block |
||
100 | 100 | */ |
101 | 101 | protected function setUp() |
102 | 102 | { |
103 | - global $conf,$user,$langs,$db; |
|
104 | - $conf=$this->savconf; |
|
105 | - $user=$this->savuser; |
|
106 | - $langs=$this->savlangs; |
|
107 | - $db=$this->savdb; |
|
103 | + global $conf, $user, $langs, $db; |
|
104 | + $conf = $this->savconf; |
|
105 | + $user = $this->savuser; |
|
106 | + $langs = $this->savlangs; |
|
107 | + $db = $this->savdb; |
|
108 | 108 | |
109 | 109 | print __METHOD__."\n"; |
110 | 110 | } |
@@ -125,16 +125,16 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function testBankAccountCreate() |
127 | 127 | { |
128 | - global $conf,$user,$langs,$db; |
|
129 | - $conf=$this->savconf; |
|
130 | - $user=$this->savuser; |
|
131 | - $langs=$this->savlangs; |
|
132 | - $db=$this->savdb; |
|
128 | + global $conf, $user, $langs, $db; |
|
129 | + $conf = $this->savconf; |
|
130 | + $user = $this->savuser; |
|
131 | + $langs = $this->savlangs; |
|
132 | + $db = $this->savdb; |
|
133 | 133 | |
134 | - $localobject=new Account($this->savdb); |
|
134 | + $localobject = new Account($this->savdb); |
|
135 | 135 | $localobject->initAsSpecimen(); |
136 | - $localobject->date_solde=dol_now(); |
|
137 | - $result=$localobject->create($user); |
|
136 | + $localobject->date_solde = dol_now(); |
|
137 | + $result = $localobject->create($user); |
|
138 | 138 | |
139 | 139 | print __METHOD__." result=".$result."\n"; |
140 | 140 | $this->assertLessThan($result, 0); |
@@ -153,14 +153,14 @@ discard block |
||
153 | 153 | */ |
154 | 154 | public function testBankAccountFetch($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 Account($this->savdb); |
|
163 | - $result=$localobject->fetch($id); |
|
162 | + $localobject = new Account($this->savdb); |
|
163 | + $result = $localobject->fetch($id); |
|
164 | 164 | |
165 | 165 | print __METHOD__." id=".$id." result=".$result."\n"; |
166 | 166 | $this->assertLessThan($result, 0); |
@@ -179,11 +179,11 @@ discard block |
||
179 | 179 | */ |
180 | 180 | public function testBankAccountOther($localobject) |
181 | 181 | { |
182 | - global $conf,$user,$langs,$db; |
|
183 | - $conf=$this->savconf; |
|
184 | - $user=$this->savuser; |
|
185 | - $langs=$this->savlangs; |
|
186 | - $db=$this->savdb; |
|
182 | + global $conf, $user, $langs, $db; |
|
183 | + $conf = $this->savconf; |
|
184 | + $user = $this->savuser; |
|
185 | + $langs = $this->savlangs; |
|
186 | + $db = $this->savdb; |
|
187 | 187 | |
188 | 188 | /*$result=$localobject->setstatus(0); |
189 | 189 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
@@ -208,15 +208,15 @@ discard block |
||
208 | 208 | */ |
209 | 209 | public function testBankAccountDelete($id) |
210 | 210 | { |
211 | - global $conf,$user,$langs,$db; |
|
212 | - $conf=$this->savconf; |
|
213 | - $user=$this->savuser; |
|
214 | - $langs=$this->savlangs; |
|
215 | - $db=$this->savdb; |
|
216 | - |
|
217 | - $localobject=new Account($this->savdb); |
|
218 | - $result=$localobject->fetch($id); |
|
219 | - $result=$localobject->delete($user); |
|
211 | + global $conf, $user, $langs, $db; |
|
212 | + $conf = $this->savconf; |
|
213 | + $user = $this->savuser; |
|
214 | + $langs = $this->savlangs; |
|
215 | + $db = $this->savdb; |
|
216 | + |
|
217 | + $localobject = new Account($this->savdb); |
|
218 | + $result = $localobject->fetch($id); |
|
219 | + $result = $localobject->delete($user); |
|
220 | 220 | |
221 | 221 | print __METHOD__." id=".$id." result=".$result."\n"; |
222 | 222 | $this->assertLessThan($result, 0); |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | */ |
64 | 64 | function __construct() |
65 | 65 | { |
66 | - parent::__construct(); |
|
66 | + parent::__construct(); |
|
67 | 67 | |
68 | - //$this->sharedFixture |
|
68 | + //$this->sharedFixture |
|
69 | 69 | global $conf,$user,$langs,$db; |
70 | 70 | $this->savconf=$conf; |
71 | 71 | $this->savuser=$user; |
@@ -97,11 +97,11 @@ discard block |
||
97 | 97 | print __METHOD__."\n"; |
98 | 98 | } |
99 | 99 | |
100 | - /** |
|
101 | - * Init phpunit tests |
|
102 | - * |
|
103 | - * @return void |
|
104 | - */ |
|
100 | + /** |
|
101 | + * Init phpunit tests |
|
102 | + * |
|
103 | + * @return void |
|
104 | + */ |
|
105 | 105 | protected function setUp() |
106 | 106 | { |
107 | 107 | global $conf,$user,$langs,$db; |
@@ -114,10 +114,10 @@ discard block |
||
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
117 | - * End phpunit tests |
|
118 | - * |
|
119 | - * @return void |
|
120 | - */ |
|
117 | + * End phpunit tests |
|
118 | + * |
|
119 | + * @return void |
|
120 | + */ |
|
121 | 121 | protected function tearDown() |
122 | 122 | { |
123 | 123 | print __METHOD__."\n"; |
@@ -131,22 +131,22 @@ discard block |
||
131 | 131 | */ |
132 | 132 | public function testIsValidMXRecord() |
133 | 133 | { |
134 | - // Nb of line is same than entry text |
|
135 | - |
|
136 | - $input="yahoo.com"; |
|
137 | - $result=isValidMXRecord($input); |
|
138 | - print __METHOD__." result=".$result."\n"; |
|
139 | - $this->assertEquals(1, $result); |
|
140 | - |
|
141 | - $input="yhaoo.com"; |
|
142 | - $result=isValidMXRecord($input); |
|
143 | - print __METHOD__." result=".$result."\n"; |
|
144 | - $this->assertEquals(0, $result); |
|
145 | - |
|
146 | - $input="dolibarr.fr"; |
|
147 | - $result=isValidMXRecord($input); |
|
148 | - print __METHOD__." result=".$result."\n"; |
|
149 | - $this->assertEquals(0, $result); |
|
134 | + // Nb of line is same than entry text |
|
135 | + |
|
136 | + $input="yahoo.com"; |
|
137 | + $result=isValidMXRecord($input); |
|
138 | + print __METHOD__." result=".$result."\n"; |
|
139 | + $this->assertEquals(1, $result); |
|
140 | + |
|
141 | + $input="yhaoo.com"; |
|
142 | + $result=isValidMXRecord($input); |
|
143 | + print __METHOD__." result=".$result."\n"; |
|
144 | + $this->assertEquals(0, $result); |
|
145 | + |
|
146 | + $input="dolibarr.fr"; |
|
147 | + $result=isValidMXRecord($input); |
|
148 | + print __METHOD__." result=".$result."\n"; |
|
149 | + $this->assertEquals(0, $result); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
@@ -156,172 +156,172 @@ discard block |
||
156 | 156 | */ |
157 | 157 | public function testDolGetFirstLineOfText() |
158 | 158 | { |
159 | - // Nb of line is same than entry text |
|
160 | - |
|
161 | - $input="aaaa"; |
|
162 | - $result=dolGetFirstLineOfText($input); |
|
163 | - print __METHOD__." result=".$result."\n"; |
|
164 | - $this->assertEquals("aaaa", $result); |
|
165 | - |
|
166 | - $input="aaaa\nbbbbbbbbbbbb\n"; |
|
167 | - $result=dolGetFirstLineOfText($input, 2); |
|
168 | - print __METHOD__." result=".$result."\n"; |
|
169 | - $this->assertEquals("aaaa\nbbbbbbbbbbbb", $result); |
|
170 | - |
|
171 | - $input="aaaa<br>bbbbbbbbbbbb<br>"; |
|
172 | - $result=dolGetFirstLineOfText($input, 2); |
|
173 | - print __METHOD__." result=".$result."\n"; |
|
174 | - $this->assertEquals("aaaa<br>\nbbbbbbbbbbbb", $result); |
|
175 | - |
|
176 | - // Nb of line is lower |
|
177 | - |
|
178 | - $input="aaaa\nbbbbbbbbbbbb\ncccccc\n"; |
|
179 | - $result=dolGetFirstLineOfText($input); |
|
180 | - print __METHOD__." result=".$result."\n"; |
|
181 | - $this->assertEquals("aaaa...", $result); |
|
182 | - |
|
183 | - $input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>"; |
|
184 | - $result=dolGetFirstLineOfText($input); |
|
185 | - print __METHOD__." result=".$result."\n"; |
|
186 | - $this->assertEquals("aaaa...", $result); |
|
187 | - |
|
188 | - $input="aaaa\nbbbbbbbbbbbb\ncccccc\n"; |
|
189 | - $result=dolGetFirstLineOfText($input, 2); |
|
190 | - print __METHOD__." result=".$result."\n"; |
|
191 | - $this->assertEquals("aaaa\nbbbbbbbbbbbb...", $result); |
|
192 | - |
|
193 | - $input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>"; |
|
194 | - $result=dolGetFirstLineOfText($input, 2); |
|
195 | - print __METHOD__." result=".$result."\n"; |
|
196 | - $this->assertEquals("aaaa<br>\nbbbbbbbbbbbb...", $result); |
|
197 | - |
|
198 | - // Nb of line is higher |
|
199 | - |
|
200 | - $input="aaaa<br>bbbbbbbbbbbb<br>cccccc"; |
|
201 | - $result=dolGetFirstLineOfText($input, 100); |
|
202 | - print __METHOD__." result=".$result."\n"; |
|
203 | - $this->assertEquals("aaaa<br>\nbbbbbbbbbbbb<br>\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 a'); |
|
204 | - |
|
205 | - $input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>"; |
|
206 | - $result=dolGetFirstLineOfText($input, 100); |
|
207 | - print __METHOD__." result=".$result."\n"; |
|
208 | - $this->assertEquals("aaaa<br>\nbbbbbbbbbbbb<br>\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 b'); |
|
209 | - |
|
210 | - $input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>\n"; |
|
211 | - $result=dolGetFirstLineOfText($input, 100); |
|
212 | - print __METHOD__." result=".$result."\n"; |
|
213 | - $this->assertEquals("aaaa<br>\nbbbbbbbbbbbb<br>\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 c'); |
|
159 | + // Nb of line is same than entry text |
|
160 | + |
|
161 | + $input="aaaa"; |
|
162 | + $result=dolGetFirstLineOfText($input); |
|
163 | + print __METHOD__." result=".$result."\n"; |
|
164 | + $this->assertEquals("aaaa", $result); |
|
165 | + |
|
166 | + $input="aaaa\nbbbbbbbbbbbb\n"; |
|
167 | + $result=dolGetFirstLineOfText($input, 2); |
|
168 | + print __METHOD__." result=".$result."\n"; |
|
169 | + $this->assertEquals("aaaa\nbbbbbbbbbbbb", $result); |
|
170 | + |
|
171 | + $input="aaaa<br>bbbbbbbbbbbb<br>"; |
|
172 | + $result=dolGetFirstLineOfText($input, 2); |
|
173 | + print __METHOD__." result=".$result."\n"; |
|
174 | + $this->assertEquals("aaaa<br>\nbbbbbbbbbbbb", $result); |
|
175 | + |
|
176 | + // Nb of line is lower |
|
177 | + |
|
178 | + $input="aaaa\nbbbbbbbbbbbb\ncccccc\n"; |
|
179 | + $result=dolGetFirstLineOfText($input); |
|
180 | + print __METHOD__." result=".$result."\n"; |
|
181 | + $this->assertEquals("aaaa...", $result); |
|
182 | + |
|
183 | + $input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>"; |
|
184 | + $result=dolGetFirstLineOfText($input); |
|
185 | + print __METHOD__." result=".$result."\n"; |
|
186 | + $this->assertEquals("aaaa...", $result); |
|
187 | + |
|
188 | + $input="aaaa\nbbbbbbbbbbbb\ncccccc\n"; |
|
189 | + $result=dolGetFirstLineOfText($input, 2); |
|
190 | + print __METHOD__." result=".$result."\n"; |
|
191 | + $this->assertEquals("aaaa\nbbbbbbbbbbbb...", $result); |
|
192 | + |
|
193 | + $input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>"; |
|
194 | + $result=dolGetFirstLineOfText($input, 2); |
|
195 | + print __METHOD__." result=".$result."\n"; |
|
196 | + $this->assertEquals("aaaa<br>\nbbbbbbbbbbbb...", $result); |
|
197 | + |
|
198 | + // Nb of line is higher |
|
199 | + |
|
200 | + $input="aaaa<br>bbbbbbbbbbbb<br>cccccc"; |
|
201 | + $result=dolGetFirstLineOfText($input, 100); |
|
202 | + print __METHOD__." result=".$result."\n"; |
|
203 | + $this->assertEquals("aaaa<br>\nbbbbbbbbbbbb<br>\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 a'); |
|
204 | + |
|
205 | + $input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>"; |
|
206 | + $result=dolGetFirstLineOfText($input, 100); |
|
207 | + print __METHOD__." result=".$result."\n"; |
|
208 | + $this->assertEquals("aaaa<br>\nbbbbbbbbbbbb<br>\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 b'); |
|
209 | + |
|
210 | + $input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>\n"; |
|
211 | + $result=dolGetFirstLineOfText($input, 100); |
|
212 | + print __METHOD__." result=".$result."\n"; |
|
213 | + $this->assertEquals("aaaa<br>\nbbbbbbbbbbbb<br>\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 c'); |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | |
217 | - /** |
|
218 | - * testDolBuildPath |
|
219 | - * |
|
220 | - * @return void |
|
221 | - */ |
|
222 | - public function testDolBuildPath() |
|
223 | - { |
|
224 | - /*$tmp=dol_buildpath('/google/oauth2callback.php', 0); |
|
217 | + /** |
|
218 | + * testDolBuildPath |
|
219 | + * |
|
220 | + * @return void |
|
221 | + */ |
|
222 | + public function testDolBuildPath() |
|
223 | + { |
|
224 | + /*$tmp=dol_buildpath('/google/oauth2callback.php', 0); |
|
225 | 225 | var_dump($tmp); |
226 | 226 | */ |
227 | 227 | |
228 | - /*$tmp=dol_buildpath('/google/oauth2callback.php', 1); |
|
228 | + /*$tmp=dol_buildpath('/google/oauth2callback.php', 1); |
|
229 | 229 | var_dump($tmp); |
230 | 230 | */ |
231 | 231 | |
232 | - $result=dol_buildpath('/google/oauth2callback.php', 2); |
|
233 | - print __METHOD__." result=".$result."\n"; |
|
234 | - $this->assertStringStartsWith('http', $result); |
|
232 | + $result=dol_buildpath('/google/oauth2callback.php', 2); |
|
233 | + print __METHOD__." result=".$result."\n"; |
|
234 | + $this->assertStringStartsWith('http', $result); |
|
235 | 235 | |
236 | - $result=dol_buildpath('/google/oauth2callback.php', 3); |
|
236 | + $result=dol_buildpath('/google/oauth2callback.php', 3); |
|
237 | 237 | print __METHOD__." result=".$result."\n"; |
238 | 238 | $this->assertStringStartsWith('http', $result); |
239 | - } |
|
239 | + } |
|
240 | 240 | |
241 | 241 | |
242 | 242 | /** |
243 | - * testGetBrowserInfo |
|
244 | - * |
|
245 | - * @return void |
|
246 | - */ |
|
243 | + * testGetBrowserInfo |
|
244 | + * |
|
245 | + * @return void |
|
246 | + */ |
|
247 | 247 | public function testGetBrowserInfo() |
248 | 248 | { |
249 | - // MSIE 5.0 |
|
249 | + // MSIE 5.0 |
|
250 | 250 | $user_agent ='Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt; KITV4 Wanadoo; KITV5 Wanadoo)'; |
251 | 251 | $tmp=getBrowserInfo($user_agent); |
252 | 252 | $this->assertEquals('ie',$tmp['browsername']); |
253 | 253 | $this->assertEquals('5.0',$tmp['browserversion']); |
254 | - $this->assertEmpty($tmp['phone']); |
|
255 | - $this->assertFalse($tmp['tablet']); |
|
256 | - $this->assertEquals('classic', $tmp['layout']); |
|
254 | + $this->assertEmpty($tmp['phone']); |
|
255 | + $this->assertFalse($tmp['tablet']); |
|
256 | + $this->assertEquals('classic', $tmp['layout']); |
|
257 | 257 | |
258 | - // Firefox 0.9.1 |
|
258 | + // Firefox 0.9.1 |
|
259 | 259 | $user_agent ='Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5a) Gecko/20030728 Mozilla Firefox/0.9.1'; |
260 | 260 | $tmp=getBrowserInfo($user_agent); |
261 | 261 | $this->assertEquals('firefox',$tmp['browsername']); |
262 | 262 | $this->assertEquals('0.9.1',$tmp['browserversion']); |
263 | - $this->assertEmpty($tmp['phone']); |
|
264 | - $this->assertFalse($tmp['tablet']); |
|
265 | - $this->assertEquals('classic', $tmp['layout']); |
|
263 | + $this->assertEmpty($tmp['phone']); |
|
264 | + $this->assertFalse($tmp['tablet']); |
|
265 | + $this->assertEquals('classic', $tmp['layout']); |
|
266 | 266 | |
267 | 267 | $user_agent ='Mozilla/3.0 (Windows 98; U) Opera 6.03 [en]'; |
268 | 268 | $tmp=getBrowserInfo($user_agent); |
269 | 269 | $this->assertEquals('opera',$tmp['browsername']); |
270 | 270 | $this->assertEquals('6.03',$tmp['browserversion']); |
271 | - $this->assertEmpty($tmp['phone']); |
|
272 | - $this->assertFalse($tmp['tablet']); |
|
273 | - $this->assertEquals('classic', $tmp['layout']); |
|
271 | + $this->assertEmpty($tmp['phone']); |
|
272 | + $this->assertFalse($tmp['tablet']); |
|
273 | + $this->assertEquals('classic', $tmp['layout']); |
|
274 | 274 | |
275 | 275 | $user_agent ='Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.21 (KHTML, like Gecko) Chrome/19.0.1042.0 Safari/535.21'; |
276 | 276 | $tmp=getBrowserInfo($user_agent); |
277 | 277 | $this->assertEquals('chrome',$tmp['browsername']); |
278 | 278 | $this->assertEquals('19.0.1042.0',$tmp['browserversion']); |
279 | - $this->assertEmpty($tmp['phone']); |
|
280 | - $this->assertFalse($tmp['tablet']); |
|
281 | - $this->assertEquals('classic', $tmp['layout']); |
|
279 | + $this->assertEmpty($tmp['phone']); |
|
280 | + $this->assertFalse($tmp['tablet']); |
|
281 | + $this->assertEquals('classic', $tmp['layout']); |
|
282 | 282 | |
283 | 283 | $user_agent ='chrome (Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11)'; |
284 | 284 | $tmp=getBrowserInfo($user_agent); |
285 | 285 | $this->assertEquals('chrome',$tmp['browsername']); |
286 | 286 | $this->assertEquals('17.0.963.56',$tmp['browserversion']); |
287 | - $this->assertEmpty($tmp['phone']); |
|
288 | - $this->assertFalse($tmp['tablet']); |
|
289 | - $this->assertEquals('classic', $tmp['layout']); |
|
287 | + $this->assertEmpty($tmp['phone']); |
|
288 | + $this->assertFalse($tmp['tablet']); |
|
289 | + $this->assertEquals('classic', $tmp['layout']); |
|
290 | 290 | |
291 | 291 | $user_agent ='Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; de-at) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1'; |
292 | 292 | $tmp=getBrowserInfo($user_agent); |
293 | 293 | $this->assertEquals('safari',$tmp['browsername']); |
294 | 294 | $this->assertEquals('533.21.1',$tmp['browserversion']); |
295 | - $this->assertEmpty($tmp['phone']); |
|
296 | - $this->assertFalse($tmp['tablet']); |
|
297 | - $this->assertEquals('classic', $tmp['layout']); |
|
298 | - |
|
299 | - //Internet Explorer 11 |
|
300 | - $user_agent = 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko'; |
|
301 | - $tmp=getBrowserInfo($user_agent); |
|
302 | - $this->assertEquals('ie',$tmp['browsername']); |
|
303 | - $this->assertEquals('11.0',$tmp['browserversion']); |
|
304 | - $this->assertEmpty($tmp['phone']); |
|
305 | - $this->assertFalse($tmp['tablet']); |
|
306 | - $this->assertEquals('classic', $tmp['layout']); |
|
307 | - |
|
308 | - //Internet Explorer 11 bis |
|
309 | - $user_agent = 'Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; NP06; rv:11.0) like Gecko'; |
|
310 | - $tmp=getBrowserInfo($user_agent); |
|
311 | - $this->assertEquals('ie',$tmp['browsername']); |
|
312 | - $this->assertEquals('11.0',$tmp['browserversion']); |
|
313 | - $this->assertEmpty($tmp['phone']); |
|
314 | - $this->assertFalse($tmp['tablet']); |
|
315 | - $this->assertEquals('classic', $tmp['layout']); |
|
316 | - |
|
317 | - //iPad |
|
318 | - $user_agent = 'Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25'; |
|
319 | - $tmp=getBrowserInfo($user_agent); |
|
320 | - $this->assertEquals('safari',$tmp['browsername']); |
|
321 | - $this->assertEquals('8536.25',$tmp['browserversion']); |
|
322 | - $this->assertEquals('ios',$tmp['browseros']); |
|
323 | - $this->assertEquals('tablet',$tmp['layout']); |
|
324 | - $this->assertEquals('iphone',$tmp['phone']); |
|
295 | + $this->assertEmpty($tmp['phone']); |
|
296 | + $this->assertFalse($tmp['tablet']); |
|
297 | + $this->assertEquals('classic', $tmp['layout']); |
|
298 | + |
|
299 | + //Internet Explorer 11 |
|
300 | + $user_agent = 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko'; |
|
301 | + $tmp=getBrowserInfo($user_agent); |
|
302 | + $this->assertEquals('ie',$tmp['browsername']); |
|
303 | + $this->assertEquals('11.0',$tmp['browserversion']); |
|
304 | + $this->assertEmpty($tmp['phone']); |
|
305 | + $this->assertFalse($tmp['tablet']); |
|
306 | + $this->assertEquals('classic', $tmp['layout']); |
|
307 | + |
|
308 | + //Internet Explorer 11 bis |
|
309 | + $user_agent = 'Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; NP06; rv:11.0) like Gecko'; |
|
310 | + $tmp=getBrowserInfo($user_agent); |
|
311 | + $this->assertEquals('ie',$tmp['browsername']); |
|
312 | + $this->assertEquals('11.0',$tmp['browserversion']); |
|
313 | + $this->assertEmpty($tmp['phone']); |
|
314 | + $this->assertFalse($tmp['tablet']); |
|
315 | + $this->assertEquals('classic', $tmp['layout']); |
|
316 | + |
|
317 | + //iPad |
|
318 | + $user_agent = 'Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25'; |
|
319 | + $tmp=getBrowserInfo($user_agent); |
|
320 | + $this->assertEquals('safari',$tmp['browsername']); |
|
321 | + $this->assertEquals('8536.25',$tmp['browserversion']); |
|
322 | + $this->assertEquals('ios',$tmp['browseros']); |
|
323 | + $this->assertEquals('tablet',$tmp['layout']); |
|
324 | + $this->assertEquals('iphone',$tmp['phone']); |
|
325 | 325 | } |
326 | 326 | |
327 | 327 | |
@@ -332,48 +332,48 @@ discard block |
||
332 | 332 | */ |
333 | 333 | public function testGetLanguageCodeFromCountryCode() |
334 | 334 | { |
335 | - global $mysoc; |
|
335 | + global $mysoc; |
|
336 | 336 | |
337 | - $language = getLanguageCodeFromCountryCode('US'); |
|
338 | - $this->assertEquals('en_US', $language, 'US'); |
|
337 | + $language = getLanguageCodeFromCountryCode('US'); |
|
338 | + $this->assertEquals('en_US', $language, 'US'); |
|
339 | 339 | |
340 | - $language = getLanguageCodeFromCountryCode('ES'); |
|
341 | - $this->assertEquals('es_ES', $language, 'ES'); |
|
340 | + $language = getLanguageCodeFromCountryCode('ES'); |
|
341 | + $this->assertEquals('es_ES', $language, 'ES'); |
|
342 | 342 | |
343 | - $language = getLanguageCodeFromCountryCode('CL'); |
|
344 | - $this->assertEquals('es_CL', $language, 'CL'); |
|
343 | + $language = getLanguageCodeFromCountryCode('CL'); |
|
344 | + $this->assertEquals('es_CL', $language, 'CL'); |
|
345 | 345 | |
346 | - $language = getLanguageCodeFromCountryCode('CA'); |
|
347 | - $this->assertEquals('en_CA', $language, 'CA'); |
|
346 | + $language = getLanguageCodeFromCountryCode('CA'); |
|
347 | + $this->assertEquals('en_CA', $language, 'CA'); |
|
348 | 348 | |
349 | - $language = getLanguageCodeFromCountryCode('MQ'); |
|
350 | - $this->assertEquals('fr_CA', $language); |
|
349 | + $language = getLanguageCodeFromCountryCode('MQ'); |
|
350 | + $this->assertEquals('fr_CA', $language); |
|
351 | 351 | |
352 | - $language = getLanguageCodeFromCountryCode('FR'); |
|
353 | - $this->assertEquals('fr_FR', $language); |
|
352 | + $language = getLanguageCodeFromCountryCode('FR'); |
|
353 | + $this->assertEquals('fr_FR', $language); |
|
354 | 354 | |
355 | - $language = getLanguageCodeFromCountryCode('BE'); |
|
356 | - $this->assertEquals('fr_BE', $language); |
|
355 | + $language = getLanguageCodeFromCountryCode('BE'); |
|
356 | + $this->assertEquals('fr_BE', $language); |
|
357 | 357 | |
358 | - $mysoc->country_code = 'FR'; |
|
359 | - $language = getLanguageCodeFromCountryCode('CH'); |
|
360 | - $this->assertEquals('fr_CH', $language); |
|
358 | + $mysoc->country_code = 'FR'; |
|
359 | + $language = getLanguageCodeFromCountryCode('CH'); |
|
360 | + $this->assertEquals('fr_CH', $language); |
|
361 | 361 | |
362 | - $mysoc->country_code = 'DE'; |
|
363 | - $language = getLanguageCodeFromCountryCode('CH'); |
|
364 | - $this->assertEquals('de_CH', $language); |
|
362 | + $mysoc->country_code = 'DE'; |
|
363 | + $language = getLanguageCodeFromCountryCode('CH'); |
|
364 | + $this->assertEquals('de_CH', $language); |
|
365 | 365 | |
366 | - $language = getLanguageCodeFromCountryCode('DE'); |
|
367 | - $this->assertEquals('de_DE', $language); |
|
366 | + $language = getLanguageCodeFromCountryCode('DE'); |
|
367 | + $this->assertEquals('de_DE', $language); |
|
368 | 368 | |
369 | - $language = getLanguageCodeFromCountryCode('SA'); |
|
370 | - $this->assertEquals('ar_SA', $language); |
|
369 | + $language = getLanguageCodeFromCountryCode('SA'); |
|
370 | + $this->assertEquals('ar_SA', $language); |
|
371 | 371 | |
372 | - $language = getLanguageCodeFromCountryCode('SE'); |
|
373 | - $this->assertEquals('sv_SE', $language); |
|
372 | + $language = getLanguageCodeFromCountryCode('SE'); |
|
373 | + $this->assertEquals('sv_SE', $language); |
|
374 | 374 | |
375 | - $language = getLanguageCodeFromCountryCode('DK'); |
|
376 | - $this->assertEquals('da_DK', $language); |
|
375 | + $language = getLanguageCodeFromCountryCode('DK'); |
|
376 | + $this->assertEquals('da_DK', $language); |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | /** |
@@ -570,9 +570,9 @@ discard block |
||
570 | 570 | */ |
571 | 571 | public function testDolHtmlEntitiesBr() |
572 | 572 | { |
573 | - // Text not already HTML |
|
573 | + // Text not already HTML |
|
574 | 574 | |
575 | - $input="A string\nwith a é, &, < and >."; |
|
575 | + $input="A string\nwith a é, &, < and >."; |
|
576 | 576 | $after=dol_htmlentitiesbr($input,0); // Add <br> before \n |
577 | 577 | $this->assertEquals("A string<br>\nwith a é, &, < and >.",$after); |
578 | 578 | |
@@ -645,9 +645,9 @@ discard block |
||
645 | 645 | */ |
646 | 646 | public function testDolUnaccent() |
647 | 647 | { |
648 | - // Text not already HTML |
|
648 | + // Text not already HTML |
|
649 | 649 | |
650 | - $input="A string\nwith a à ä é è ë ï ü ö ÿ, &, < and >."; |
|
650 | + $input="A string\nwith a à ä é è ë ï ü ö ÿ, &, < and >."; |
|
651 | 651 | $after=dol_string_unaccent($input); |
652 | 652 | $this->assertEquals("A string\nwith a a a e e e i u o y, &, < and >.",$after); |
653 | 653 | } |
@@ -738,14 +738,14 @@ discard block |
||
738 | 738 | */ |
739 | 739 | public function testDolMkTime() |
740 | 740 | { |
741 | - global $conf; |
|
741 | + global $conf; |
|
742 | 742 | |
743 | - $savtz=date_default_timezone_get(); |
|
743 | + $savtz=date_default_timezone_get(); |
|
744 | 744 | |
745 | - // Some test for UTC TZ |
|
746 | - date_default_timezone_set('UTC'); |
|
745 | + // Some test for UTC TZ |
|
746 | + date_default_timezone_set('UTC'); |
|
747 | 747 | |
748 | - // Check bad hours |
|
748 | + // Check bad hours |
|
749 | 749 | $result=dol_mktime(25,0,0,1,1,1970,1,1); // Error (25 hours) |
750 | 750 | print __METHOD__." result=".$result."\n"; |
751 | 751 | $this->assertEquals('',$result); |
@@ -808,10 +808,10 @@ discard block |
||
808 | 808 | |
809 | 809 | |
810 | 810 | /** |
811 | - * testDolEscapeHtmlTag |
|
812 | - * |
|
813 | - * @return void |
|
814 | - */ |
|
811 | + * testDolEscapeHtmlTag |
|
812 | + * |
|
813 | + * @return void |
|
814 | + */ |
|
815 | 815 | public function testDolEscapeHtmlTag() |
816 | 816 | { |
817 | 817 | $input='x&<b>#</b>,"'; // & and " are converted into html entities, <b> are removed |
@@ -831,30 +831,30 @@ discard block |
||
831 | 831 | */ |
832 | 832 | public function testDolFormatAddress() |
833 | 833 | { |
834 | - global $conf,$user,$langs,$db; |
|
835 | - $conf=$this->savconf; |
|
836 | - $user=$this->savuser; |
|
837 | - $langs=$this->savlangs; |
|
838 | - $db=$this->savdb; |
|
839 | - |
|
840 | - $object=new Societe($db); |
|
841 | - $object->initAsSpecimen(); |
|
842 | - |
|
843 | - $object->country_code='FR'; |
|
844 | - $address=dol_format_address($object); |
|
845 | - $this->assertEquals("21 jump street\n99999 MyTown",$address); |
|
846 | - |
|
847 | - $object->country_code='GB'; |
|
848 | - $address=dol_format_address($object); |
|
849 | - $this->assertEquals("21 jump street\nMyTown, MyState\n99999",$address); |
|
850 | - |
|
851 | - $object->country_code='US'; |
|
852 | - $address=dol_format_address($object); |
|
853 | - $this->assertEquals("21 jump street\nMyTown, MyState, 99999",$address); |
|
854 | - |
|
855 | - $object->country_code='AU'; |
|
856 | - $address=dol_format_address($object); |
|
857 | - $this->assertEquals("21 jump street\nMyTown, MyState, 99999",$address); |
|
834 | + global $conf,$user,$langs,$db; |
|
835 | + $conf=$this->savconf; |
|
836 | + $user=$this->savuser; |
|
837 | + $langs=$this->savlangs; |
|
838 | + $db=$this->savdb; |
|
839 | + |
|
840 | + $object=new Societe($db); |
|
841 | + $object->initAsSpecimen(); |
|
842 | + |
|
843 | + $object->country_code='FR'; |
|
844 | + $address=dol_format_address($object); |
|
845 | + $this->assertEquals("21 jump street\n99999 MyTown",$address); |
|
846 | + |
|
847 | + $object->country_code='GB'; |
|
848 | + $address=dol_format_address($object); |
|
849 | + $this->assertEquals("21 jump street\nMyTown, MyState\n99999",$address); |
|
850 | + |
|
851 | + $object->country_code='US'; |
|
852 | + $address=dol_format_address($object); |
|
853 | + $this->assertEquals("21 jump street\nMyTown, MyState, 99999",$address); |
|
854 | + |
|
855 | + $object->country_code='AU'; |
|
856 | + $address=dol_format_address($object); |
|
857 | + $this->assertEquals("21 jump street\nMyTown, MyState, 99999",$address); |
|
858 | 858 | } |
859 | 859 | |
860 | 860 | |
@@ -903,7 +903,7 @@ discard block |
||
903 | 903 | print __METHOD__." s=".$s."\n"; |
904 | 904 | $this->assertContains('theme',$s,'testImgPicto1'); |
905 | 905 | |
906 | - $s=img_picto('title','img.png','style="float: right"',0); |
|
906 | + $s=img_picto('title','img.png','style="float: right"',0); |
|
907 | 907 | print __METHOD__." s=".$s."\n"; |
908 | 908 | $this->assertContains('theme',$s,'testImgPicto2'); |
909 | 909 | $this->assertContains('style="float: right"',$s,'testImgPicto2'); |
@@ -978,13 +978,13 @@ discard block |
||
978 | 978 | $companyfr=new Societe($db); |
979 | 979 | $companyfr->country_code='FR'; |
980 | 980 | $companyfr->tva_assuj=1; |
981 | - $companyfr->tva_intra='FR9999'; |
|
981 | + $companyfr->tva_intra='FR9999'; |
|
982 | 982 | |
983 | 983 | // Buyers |
984 | 984 | $companymc=new Societe($db); |
985 | 985 | $companymc->country_code='MC'; |
986 | 986 | $companymc->tva_assuj=1; |
987 | - $companyfr->tva_intra='MC9999'; |
|
987 | + $companyfr->tva_intra='MC9999'; |
|
988 | 988 | |
989 | 989 | $companyit=new Societe($db); |
990 | 990 | $companyit->country_code='IT'; |
@@ -1068,84 +1068,84 @@ discard block |
||
1068 | 1068 | */ |
1069 | 1069 | public function testGetDefaultLocalTax() |
1070 | 1070 | { |
1071 | - global $conf,$user,$langs,$db; |
|
1072 | - $this->savconf=$conf; |
|
1073 | - $this->savuser=$user; |
|
1074 | - $this->savlangs=$langs; |
|
1075 | - $this->savdb=$db; |
|
1076 | - |
|
1077 | - $companyfrnovat=new Societe($db); |
|
1078 | - $companyfrnovat->country_code='FR'; |
|
1079 | - $companyfrnovat->tva_assuj=0; |
|
1080 | - $companyfrnovat->localtax1_assuj=0; |
|
1081 | - $companyfrnovat->localtax2_assuj=0; |
|
1082 | - |
|
1083 | - $companyes=new Societe($db); |
|
1084 | - $companyes->country_code='ES'; |
|
1085 | - $companyes->tva_assuj=1; |
|
1086 | - $companyes->localtax1_assuj=1; |
|
1087 | - $companyes->localtax2_assuj=1; |
|
1088 | - |
|
1089 | - $companymc=new Societe($db); |
|
1090 | - $companymc->country_code='MC'; |
|
1091 | - $companymc->tva_assuj=1; |
|
1092 | - $companymc->localtax1_assuj=0; |
|
1093 | - $companymc->localtax2_assuj=0; |
|
1094 | - |
|
1095 | - $companyit=new Societe($db); |
|
1096 | - $companyit->country_code='IT'; |
|
1097 | - $companyit->tva_assuj=1; |
|
1098 | - $companyit->tva_intra='IT99999'; |
|
1099 | - $companyit->localtax1_assuj=0; |
|
1100 | - $companyit->localtax2_assuj=0; |
|
1101 | - |
|
1102 | - $notcompanyit=new Societe($db); |
|
1103 | - $notcompanyit->country_code='IT'; |
|
1104 | - $notcompanyit->tva_assuj=1; |
|
1105 | - $notcompanyit->tva_intra=''; |
|
1106 | - $notcompanyit->typent_code='TE_PRIVATE'; |
|
1107 | - $notcompanyit->localtax1_assuj=0; |
|
1108 | - $notcompanyit->localtax2_assuj=0; |
|
1109 | - |
|
1110 | - $companyus=new Societe($db); |
|
1111 | - $companyus->country_code='US'; |
|
1112 | - $companyus->tva_assuj=1; |
|
1113 | - $companyus->tva_intra=''; |
|
1114 | - $companyus->localtax1_assuj=0; |
|
1115 | - $companyus->localtax2_assuj=0; |
|
1116 | - |
|
1117 | - // Test RULE FR-MC |
|
1118 | - $vat1=get_default_localtax($companyfrnovat,$companymc,1,0); |
|
1119 | - $vat2=get_default_localtax($companyfrnovat,$companymc,2,0); |
|
1120 | - $this->assertEquals(0,$vat1); |
|
1121 | - $this->assertEquals(0,$vat2); |
|
1122 | - |
|
1123 | - // Test RULE ES-ES |
|
1124 | - $vat1=get_default_localtax($companyes,$companyes,1,0); |
|
1125 | - $vat2=get_default_localtax($companyes,$companyes,2,0); |
|
1126 | - $this->assertEquals($vat1, 5.2); |
|
1127 | - $this->assertStringStartsWith((string) $vat2, '-19:-15:-9'); // Can be -19 (old version) or '-19:-15:-9' (new setup) |
|
1128 | - |
|
1129 | - // Test RULE ES-IT |
|
1130 | - $vat1=get_default_localtax($companyes,$companyit,1,0); |
|
1131 | - $vat2=get_default_localtax($companyes,$companyit,2,0); |
|
1132 | - $this->assertEquals(0,$vat1); |
|
1133 | - $this->assertEquals(0,$vat2); |
|
1134 | - |
|
1135 | - // Test RULE ES-IT |
|
1136 | - $vat1=get_default_localtax($companyes,$notcompanyit,1,0); |
|
1137 | - $vat2=get_default_localtax($companyes,$notcompanyit,2,0); |
|
1138 | - $this->assertEquals(0,$vat1); |
|
1139 | - $this->assertEquals(0,$vat2); |
|
1140 | - |
|
1141 | - // Test RULE FR-IT |
|
1142 | - // Not tested |
|
1143 | - |
|
1144 | - // Test RULE ES-US |
|
1145 | - $vat1=get_default_localtax($companyes,$companyus,1,0); |
|
1146 | - $vat2=get_default_localtax($companyes,$companyus,2,0); |
|
1147 | - $this->assertEquals(0,$vat1); |
|
1148 | - $this->assertEquals(0,$vat2); |
|
1071 | + global $conf,$user,$langs,$db; |
|
1072 | + $this->savconf=$conf; |
|
1073 | + $this->savuser=$user; |
|
1074 | + $this->savlangs=$langs; |
|
1075 | + $this->savdb=$db; |
|
1076 | + |
|
1077 | + $companyfrnovat=new Societe($db); |
|
1078 | + $companyfrnovat->country_code='FR'; |
|
1079 | + $companyfrnovat->tva_assuj=0; |
|
1080 | + $companyfrnovat->localtax1_assuj=0; |
|
1081 | + $companyfrnovat->localtax2_assuj=0; |
|
1082 | + |
|
1083 | + $companyes=new Societe($db); |
|
1084 | + $companyes->country_code='ES'; |
|
1085 | + $companyes->tva_assuj=1; |
|
1086 | + $companyes->localtax1_assuj=1; |
|
1087 | + $companyes->localtax2_assuj=1; |
|
1088 | + |
|
1089 | + $companymc=new Societe($db); |
|
1090 | + $companymc->country_code='MC'; |
|
1091 | + $companymc->tva_assuj=1; |
|
1092 | + $companymc->localtax1_assuj=0; |
|
1093 | + $companymc->localtax2_assuj=0; |
|
1094 | + |
|
1095 | + $companyit=new Societe($db); |
|
1096 | + $companyit->country_code='IT'; |
|
1097 | + $companyit->tva_assuj=1; |
|
1098 | + $companyit->tva_intra='IT99999'; |
|
1099 | + $companyit->localtax1_assuj=0; |
|
1100 | + $companyit->localtax2_assuj=0; |
|
1101 | + |
|
1102 | + $notcompanyit=new Societe($db); |
|
1103 | + $notcompanyit->country_code='IT'; |
|
1104 | + $notcompanyit->tva_assuj=1; |
|
1105 | + $notcompanyit->tva_intra=''; |
|
1106 | + $notcompanyit->typent_code='TE_PRIVATE'; |
|
1107 | + $notcompanyit->localtax1_assuj=0; |
|
1108 | + $notcompanyit->localtax2_assuj=0; |
|
1109 | + |
|
1110 | + $companyus=new Societe($db); |
|
1111 | + $companyus->country_code='US'; |
|
1112 | + $companyus->tva_assuj=1; |
|
1113 | + $companyus->tva_intra=''; |
|
1114 | + $companyus->localtax1_assuj=0; |
|
1115 | + $companyus->localtax2_assuj=0; |
|
1116 | + |
|
1117 | + // Test RULE FR-MC |
|
1118 | + $vat1=get_default_localtax($companyfrnovat,$companymc,1,0); |
|
1119 | + $vat2=get_default_localtax($companyfrnovat,$companymc,2,0); |
|
1120 | + $this->assertEquals(0,$vat1); |
|
1121 | + $this->assertEquals(0,$vat2); |
|
1122 | + |
|
1123 | + // Test RULE ES-ES |
|
1124 | + $vat1=get_default_localtax($companyes,$companyes,1,0); |
|
1125 | + $vat2=get_default_localtax($companyes,$companyes,2,0); |
|
1126 | + $this->assertEquals($vat1, 5.2); |
|
1127 | + $this->assertStringStartsWith((string) $vat2, '-19:-15:-9'); // Can be -19 (old version) or '-19:-15:-9' (new setup) |
|
1128 | + |
|
1129 | + // Test RULE ES-IT |
|
1130 | + $vat1=get_default_localtax($companyes,$companyit,1,0); |
|
1131 | + $vat2=get_default_localtax($companyes,$companyit,2,0); |
|
1132 | + $this->assertEquals(0,$vat1); |
|
1133 | + $this->assertEquals(0,$vat2); |
|
1134 | + |
|
1135 | + // Test RULE ES-IT |
|
1136 | + $vat1=get_default_localtax($companyes,$notcompanyit,1,0); |
|
1137 | + $vat2=get_default_localtax($companyes,$notcompanyit,2,0); |
|
1138 | + $this->assertEquals(0,$vat1); |
|
1139 | + $this->assertEquals(0,$vat2); |
|
1140 | + |
|
1141 | + // Test RULE FR-IT |
|
1142 | + // Not tested |
|
1143 | + |
|
1144 | + // Test RULE ES-US |
|
1145 | + $vat1=get_default_localtax($companyes,$companyus,1,0); |
|
1146 | + $vat2=get_default_localtax($companyes,$companyus,2,0); |
|
1147 | + $this->assertEquals(0,$vat1); |
|
1148 | + $this->assertEquals(0,$vat2); |
|
1149 | 1149 | } |
1150 | 1150 | |
1151 | 1151 | |
@@ -1156,108 +1156,108 @@ discard block |
||
1156 | 1156 | */ |
1157 | 1157 | public function testDolExplodeIntoArray() |
1158 | 1158 | { |
1159 | - $stringtoexplode='AA=B/B.CC=.EE=FF.HH=GG;.'; |
|
1160 | - $tmp=dolExplodeIntoArray($stringtoexplode,'.','='); |
|
1159 | + $stringtoexplode='AA=B/B.CC=.EE=FF.HH=GG;.'; |
|
1160 | + $tmp=dolExplodeIntoArray($stringtoexplode,'.','='); |
|
1161 | 1161 | |
1162 | 1162 | print __METHOD__." tmp=".json_encode($tmp)."\n"; |
1163 | 1163 | $this->assertEquals('{"AA":"B\/B","CC":"","EE":"FF","HH":"GG;"}',json_encode($tmp)); |
1164 | 1164 | } |
1165 | 1165 | |
1166 | - /** |
|
1167 | - * dol_nl2br |
|
1168 | - * |
|
1169 | - * @return void |
|
1170 | - */ |
|
1166 | + /** |
|
1167 | + * dol_nl2br |
|
1168 | + * |
|
1169 | + * @return void |
|
1170 | + */ |
|
1171 | 1171 | public function testDolNl2Br() |
1172 | 1172 | { |
1173 | 1173 | |
1174 | - //String to encode |
|
1175 | - $string = "a\na"; |
|
1174 | + //String to encode |
|
1175 | + $string = "a\na"; |
|
1176 | 1176 | |
1177 | - $this->assertEquals(dol_nl2br($string), "a<br>\na"); |
|
1177 | + $this->assertEquals(dol_nl2br($string), "a<br>\na"); |
|
1178 | 1178 | |
1179 | - //With $forxml parameter |
|
1180 | - $this->assertEquals(dol_nl2br($string, 0, 1), "a<br />\na"); |
|
1179 | + //With $forxml parameter |
|
1180 | + $this->assertEquals(dol_nl2br($string, 0, 1), "a<br />\na"); |
|
1181 | 1181 | |
1182 | - //Replacing \n by br |
|
1183 | - $this->assertEquals(dol_nl2br($string, 1), "a<br>a"); |
|
1182 | + //Replacing \n by br |
|
1183 | + $this->assertEquals(dol_nl2br($string, 1), "a<br>a"); |
|
1184 | 1184 | |
1185 | - //With $forxml parameter |
|
1186 | - $this->assertEquals(dol_nl2br($string, 1, 1), "a<br />a"); |
|
1187 | - } |
|
1185 | + //With $forxml parameter |
|
1186 | + $this->assertEquals(dol_nl2br($string, 1, 1), "a<br />a"); |
|
1187 | + } |
|
1188 | 1188 | |
1189 | - /** |
|
1190 | - * testDolPrice2Num |
|
1191 | - * |
|
1192 | - * @return boolean |
|
1193 | - */ |
|
1194 | - public function testDolPrice2Num() |
|
1195 | - { |
|
1196 | - $this->assertEquals(1000, price2num('1 000.0')); |
|
1197 | - $this->assertEquals(1000, price2num('1 000','MT')); |
|
1198 | - $this->assertEquals(1000, price2num('1 000','MU')); |
|
1189 | + /** |
|
1190 | + * testDolPrice2Num |
|
1191 | + * |
|
1192 | + * @return boolean |
|
1193 | + */ |
|
1194 | + public function testDolPrice2Num() |
|
1195 | + { |
|
1196 | + $this->assertEquals(1000, price2num('1 000.0')); |
|
1197 | + $this->assertEquals(1000, price2num('1 000','MT')); |
|
1198 | + $this->assertEquals(1000, price2num('1 000','MU')); |
|
1199 | 1199 | |
1200 | - $this->assertEquals(1000.123456, price2num('1 000.123456')); |
|
1200 | + $this->assertEquals(1000.123456, price2num('1 000.123456')); |
|
1201 | 1201 | |
1202 | - // Round down |
|
1203 | - $this->assertEquals(1000.12, price2num('1 000.123452','MT')); |
|
1204 | - $this->assertEquals(1000.12345, price2num('1 000.123452','MU'),"Test MU"); |
|
1202 | + // Round down |
|
1203 | + $this->assertEquals(1000.12, price2num('1 000.123452','MT')); |
|
1204 | + $this->assertEquals(1000.12345, price2num('1 000.123452','MU'),"Test MU"); |
|
1205 | 1205 | |
1206 | - // Round up |
|
1207 | - $this->assertEquals(1000.13, price2num('1 000.125456','MT')); |
|
1208 | - $this->assertEquals(1000.12546, price2num('1 000.125456','MU'),"Test MU"); |
|
1206 | + // Round up |
|
1207 | + $this->assertEquals(1000.13, price2num('1 000.125456','MT')); |
|
1208 | + $this->assertEquals(1000.12546, price2num('1 000.125456','MU'),"Test MU"); |
|
1209 | 1209 | |
1210 | - // Text can't be converted |
|
1211 | - $this->assertEquals('12.4$',price2num('12.4$')); |
|
1212 | - $this->assertEquals('12r.4$',price2num('12r.4$')); |
|
1210 | + // Text can't be converted |
|
1211 | + $this->assertEquals('12.4$',price2num('12.4$')); |
|
1212 | + $this->assertEquals('12r.4$',price2num('12r.4$')); |
|
1213 | 1213 | |
1214 | - return true; |
|
1215 | - } |
|
1214 | + return true; |
|
1215 | + } |
|
1216 | 1216 | |
1217 | - /** |
|
1218 | - * testDolGetDate |
|
1219 | - * |
|
1220 | - * @return boolean |
|
1221 | - */ |
|
1222 | - public function testDolGetDate() |
|
1223 | - { |
|
1224 | - global $conf; |
|
1217 | + /** |
|
1218 | + * testDolGetDate |
|
1219 | + * |
|
1220 | + * @return boolean |
|
1221 | + */ |
|
1222 | + public function testDolGetDate() |
|
1223 | + { |
|
1224 | + global $conf; |
|
1225 | 1225 | |
1226 | - $conf->global->MAIN_START_WEEK = 0; |
|
1226 | + $conf->global->MAIN_START_WEEK = 0; |
|
1227 | 1227 | |
1228 | - $tmp=dol_getdate(1); // 1/1/1970 and 1 second = thirday |
|
1229 | - $this->assertEquals(4, $tmp['wday']); |
|
1228 | + $tmp=dol_getdate(1); // 1/1/1970 and 1 second = thirday |
|
1229 | + $this->assertEquals(4, $tmp['wday']); |
|
1230 | 1230 | |
1231 | - $tmp=dol_getdate(24*60*60+1); // 2/1/1970 and 1 second = friday |
|
1232 | - $this->assertEquals(5, $tmp['wday']); |
|
1231 | + $tmp=dol_getdate(24*60*60+1); // 2/1/1970 and 1 second = friday |
|
1232 | + $this->assertEquals(5, $tmp['wday']); |
|
1233 | 1233 | |
1234 | - $conf->global->MAIN_START_WEEK = 1; |
|
1234 | + $conf->global->MAIN_START_WEEK = 1; |
|
1235 | 1235 | |
1236 | - $tmp=dol_getdate(1); // 1/1/1970 and 1 second = thirday |
|
1237 | - $this->assertEquals(4, $tmp['wday']); |
|
1236 | + $tmp=dol_getdate(1); // 1/1/1970 and 1 second = thirday |
|
1237 | + $this->assertEquals(4, $tmp['wday']); |
|
1238 | 1238 | |
1239 | - $tmp=dol_getdate(24*60*60+1); // 2/1/1970 and 1 second = friday |
|
1240 | - $this->assertEquals(5, $tmp['wday']); |
|
1239 | + $tmp=dol_getdate(24*60*60+1); // 2/1/1970 and 1 second = friday |
|
1240 | + $this->assertEquals(5, $tmp['wday']); |
|
1241 | 1241 | |
1242 | - return true; |
|
1243 | - } |
|
1242 | + return true; |
|
1243 | + } |
|
1244 | 1244 | |
1245 | 1245 | |
1246 | - /** |
|
1247 | - * testDolGetDate |
|
1248 | - * |
|
1249 | - * @return boolean |
|
1250 | - */ |
|
1251 | - public function testMakeSubstitutions() |
|
1252 | - { |
|
1253 | - global $conf, $langs; |
|
1254 | - $langs->load("main"); |
|
1246 | + /** |
|
1247 | + * testDolGetDate |
|
1248 | + * |
|
1249 | + * @return boolean |
|
1250 | + */ |
|
1251 | + public function testMakeSubstitutions() |
|
1252 | + { |
|
1253 | + global $conf, $langs; |
|
1254 | + $langs->load("main"); |
|
1255 | 1255 | |
1256 | - $substit=array("AAA"=>'Not used', "BBB"=>'Not used', "CCC"=>"C replaced"); |
|
1257 | - $chaine='This is a string with __[MAIN_THEME]__ and __(DIRECTION)__ and __CCC__'; |
|
1258 | - $newstring = make_substitutions($chaine, $substit); |
|
1259 | - $this->assertEquals($newstring, 'This is a string with eldy and ltr and __C replaced__'); |
|
1256 | + $substit=array("AAA"=>'Not used', "BBB"=>'Not used', "CCC"=>"C replaced"); |
|
1257 | + $chaine='This is a string with __[MAIN_THEME]__ and __(DIRECTION)__ and __CCC__'; |
|
1258 | + $newstring = make_substitutions($chaine, $substit); |
|
1259 | + $this->assertEquals($newstring, 'This is a string with eldy and ltr and __C replaced__'); |
|
1260 | 1260 | |
1261 | - return true; |
|
1262 | - } |
|
1261 | + return true; |
|
1262 | + } |
|
1263 | 1263 | } |
@@ -24,22 +24,22 @@ discard block |
||
24 | 24 | * \remarks To run this script as CLI: phpunit filename.php |
25 | 25 | */ |
26 | 26 | |
27 | -global $conf,$user,$langs,$db; |
|
27 | +global $conf, $user, $langs, $db; |
|
28 | 28 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
29 | 29 | //require_once 'PHPUnit/Autoload.php'; |
30 | 30 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
31 | 31 | require_once dirname(__FILE__).'/../../htdocs/core/lib/date.lib.php'; |
32 | 32 | |
33 | -if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); |
|
34 | -if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); |
|
35 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
36 | -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); |
|
37 | -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); |
|
38 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); |
|
39 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show |
|
40 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php |
|
41 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
42 | -if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) |
|
33 | +if (!defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); |
|
34 | +if (!defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); |
|
35 | +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); |
|
36 | +if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); |
|
37 | +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); |
|
38 | +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); |
|
39 | +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no menu to show |
|
40 | +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php |
|
41 | +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); |
|
42 | +if (!defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) |
|
43 | 43 | |
44 | 44 | /** |
45 | 45 | * Class for PHPUnit tests |
@@ -66,11 +66,11 @@ discard block |
||
66 | 66 | parent::__construct(); |
67 | 67 | |
68 | 68 | //$this->sharedFixture |
69 | - global $conf,$user,$langs,$db; |
|
70 | - $this->savconf=$conf; |
|
71 | - $this->savuser=$user; |
|
72 | - $this->savlangs=$langs; |
|
73 | - $this->savdb=$db; |
|
69 | + global $conf, $user, $langs, $db; |
|
70 | + $this->savconf = $conf; |
|
71 | + $this->savuser = $user; |
|
72 | + $this->savlangs = $langs; |
|
73 | + $this->savdb = $db; |
|
74 | 74 | |
75 | 75 | print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
76 | 76 | //print " - db ".$db->db; |
@@ -80,10 +80,10 @@ discard block |
||
80 | 80 | // Static methods |
81 | 81 | public static function setUpBeforeClass() |
82 | 82 | { |
83 | - global $conf,$user,$langs,$db; |
|
83 | + global $conf, $user, $langs, $db; |
|
84 | 84 | //$db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
85 | 85 | |
86 | - if (! function_exists('mb_substr')) { print "\n".__METHOD__." function mb_substr must be enabled.\n"; die(); } |
|
86 | + if (!function_exists('mb_substr')) { print "\n".__METHOD__." function mb_substr must be enabled.\n"; die(); } |
|
87 | 87 | |
88 | 88 | print __METHOD__."\n"; |
89 | 89 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | // tear down after class |
92 | 92 | public static function tearDownAfterClass() |
93 | 93 | { |
94 | - global $conf,$user,$langs,$db; |
|
94 | + global $conf, $user, $langs, $db; |
|
95 | 95 | //$db->rollback(); |
96 | 96 | |
97 | 97 | print __METHOD__."\n"; |
@@ -104,11 +104,11 @@ discard block |
||
104 | 104 | */ |
105 | 105 | protected function setUp() |
106 | 106 | { |
107 | - global $conf,$user,$langs,$db; |
|
108 | - $conf=$this->savconf; |
|
109 | - $user=$this->savuser; |
|
110 | - $langs=$this->savlangs; |
|
111 | - $db=$this->savdb; |
|
107 | + global $conf, $user, $langs, $db; |
|
108 | + $conf = $this->savconf; |
|
109 | + $user = $this->savuser; |
|
110 | + $langs = $this->savlangs; |
|
111 | + $db = $this->savdb; |
|
112 | 112 | |
113 | 113 | print __METHOD__."\n"; |
114 | 114 | } |
@@ -133,18 +133,18 @@ discard block |
||
133 | 133 | { |
134 | 134 | // Nb of line is same than entry text |
135 | 135 | |
136 | - $input="yahoo.com"; |
|
137 | - $result=isValidMXRecord($input); |
|
136 | + $input = "yahoo.com"; |
|
137 | + $result = isValidMXRecord($input); |
|
138 | 138 | print __METHOD__." result=".$result."\n"; |
139 | 139 | $this->assertEquals(1, $result); |
140 | 140 | |
141 | - $input="yhaoo.com"; |
|
142 | - $result=isValidMXRecord($input); |
|
141 | + $input = "yhaoo.com"; |
|
142 | + $result = isValidMXRecord($input); |
|
143 | 143 | print __METHOD__." result=".$result."\n"; |
144 | 144 | $this->assertEquals(0, $result); |
145 | 145 | |
146 | - $input="dolibarr.fr"; |
|
147 | - $result=isValidMXRecord($input); |
|
146 | + $input = "dolibarr.fr"; |
|
147 | + $result = isValidMXRecord($input); |
|
148 | 148 | print __METHOD__." result=".$result."\n"; |
149 | 149 | $this->assertEquals(0, $result); |
150 | 150 | } |
@@ -158,57 +158,57 @@ discard block |
||
158 | 158 | { |
159 | 159 | // Nb of line is same than entry text |
160 | 160 | |
161 | - $input="aaaa"; |
|
162 | - $result=dolGetFirstLineOfText($input); |
|
161 | + $input = "aaaa"; |
|
162 | + $result = dolGetFirstLineOfText($input); |
|
163 | 163 | print __METHOD__." result=".$result."\n"; |
164 | 164 | $this->assertEquals("aaaa", $result); |
165 | 165 | |
166 | - $input="aaaa\nbbbbbbbbbbbb\n"; |
|
167 | - $result=dolGetFirstLineOfText($input, 2); |
|
166 | + $input = "aaaa\nbbbbbbbbbbbb\n"; |
|
167 | + $result = dolGetFirstLineOfText($input, 2); |
|
168 | 168 | print __METHOD__." result=".$result."\n"; |
169 | 169 | $this->assertEquals("aaaa\nbbbbbbbbbbbb", $result); |
170 | 170 | |
171 | - $input="aaaa<br>bbbbbbbbbbbb<br>"; |
|
172 | - $result=dolGetFirstLineOfText($input, 2); |
|
171 | + $input = "aaaa<br>bbbbbbbbbbbb<br>"; |
|
172 | + $result = dolGetFirstLineOfText($input, 2); |
|
173 | 173 | print __METHOD__." result=".$result."\n"; |
174 | 174 | $this->assertEquals("aaaa<br>\nbbbbbbbbbbbb", $result); |
175 | 175 | |
176 | 176 | // Nb of line is lower |
177 | 177 | |
178 | - $input="aaaa\nbbbbbbbbbbbb\ncccccc\n"; |
|
179 | - $result=dolGetFirstLineOfText($input); |
|
178 | + $input = "aaaa\nbbbbbbbbbbbb\ncccccc\n"; |
|
179 | + $result = dolGetFirstLineOfText($input); |
|
180 | 180 | print __METHOD__." result=".$result."\n"; |
181 | 181 | $this->assertEquals("aaaa...", $result); |
182 | 182 | |
183 | - $input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>"; |
|
184 | - $result=dolGetFirstLineOfText($input); |
|
183 | + $input = "aaaa<br>bbbbbbbbbbbb<br>cccccc<br>"; |
|
184 | + $result = dolGetFirstLineOfText($input); |
|
185 | 185 | print __METHOD__." result=".$result."\n"; |
186 | 186 | $this->assertEquals("aaaa...", $result); |
187 | 187 | |
188 | - $input="aaaa\nbbbbbbbbbbbb\ncccccc\n"; |
|
189 | - $result=dolGetFirstLineOfText($input, 2); |
|
188 | + $input = "aaaa\nbbbbbbbbbbbb\ncccccc\n"; |
|
189 | + $result = dolGetFirstLineOfText($input, 2); |
|
190 | 190 | print __METHOD__." result=".$result."\n"; |
191 | 191 | $this->assertEquals("aaaa\nbbbbbbbbbbbb...", $result); |
192 | 192 | |
193 | - $input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>"; |
|
194 | - $result=dolGetFirstLineOfText($input, 2); |
|
193 | + $input = "aaaa<br>bbbbbbbbbbbb<br>cccccc<br>"; |
|
194 | + $result = dolGetFirstLineOfText($input, 2); |
|
195 | 195 | print __METHOD__." result=".$result."\n"; |
196 | 196 | $this->assertEquals("aaaa<br>\nbbbbbbbbbbbb...", $result); |
197 | 197 | |
198 | 198 | // Nb of line is higher |
199 | 199 | |
200 | - $input="aaaa<br>bbbbbbbbbbbb<br>cccccc"; |
|
201 | - $result=dolGetFirstLineOfText($input, 100); |
|
200 | + $input = "aaaa<br>bbbbbbbbbbbb<br>cccccc"; |
|
201 | + $result = dolGetFirstLineOfText($input, 100); |
|
202 | 202 | print __METHOD__." result=".$result."\n"; |
203 | 203 | $this->assertEquals("aaaa<br>\nbbbbbbbbbbbb<br>\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 a'); |
204 | 204 | |
205 | - $input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>"; |
|
206 | - $result=dolGetFirstLineOfText($input, 100); |
|
205 | + $input = "aaaa<br>bbbbbbbbbbbb<br>cccccc<br>"; |
|
206 | + $result = dolGetFirstLineOfText($input, 100); |
|
207 | 207 | print __METHOD__." result=".$result."\n"; |
208 | 208 | $this->assertEquals("aaaa<br>\nbbbbbbbbbbbb<br>\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 b'); |
209 | 209 | |
210 | - $input="aaaa<br>bbbbbbbbbbbb<br>cccccc<br>\n"; |
|
211 | - $result=dolGetFirstLineOfText($input, 100); |
|
210 | + $input = "aaaa<br>bbbbbbbbbbbb<br>cccccc<br>\n"; |
|
211 | + $result = dolGetFirstLineOfText($input, 100); |
|
212 | 212 | print __METHOD__." result=".$result."\n"; |
213 | 213 | $this->assertEquals("aaaa<br>\nbbbbbbbbbbbb<br>\ncccccc", $result, 'dolGetFirstLineOfText with nb 100 c'); |
214 | 214 | } |
@@ -229,11 +229,11 @@ discard block |
||
229 | 229 | var_dump($tmp); |
230 | 230 | */ |
231 | 231 | |
232 | - $result=dol_buildpath('/google/oauth2callback.php', 2); |
|
232 | + $result = dol_buildpath('/google/oauth2callback.php', 2); |
|
233 | 233 | print __METHOD__." result=".$result."\n"; |
234 | 234 | $this->assertStringStartsWith('http', $result); |
235 | 235 | |
236 | - $result=dol_buildpath('/google/oauth2callback.php', 3); |
|
236 | + $result = dol_buildpath('/google/oauth2callback.php', 3); |
|
237 | 237 | print __METHOD__." result=".$result."\n"; |
238 | 238 | $this->assertStringStartsWith('http', $result); |
239 | 239 | } |
@@ -247,81 +247,81 @@ discard block |
||
247 | 247 | public function testGetBrowserInfo() |
248 | 248 | { |
249 | 249 | // MSIE 5.0 |
250 | - $user_agent ='Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt; KITV4 Wanadoo; KITV5 Wanadoo)'; |
|
251 | - $tmp=getBrowserInfo($user_agent); |
|
252 | - $this->assertEquals('ie',$tmp['browsername']); |
|
253 | - $this->assertEquals('5.0',$tmp['browserversion']); |
|
250 | + $user_agent = 'Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt; KITV4 Wanadoo; KITV5 Wanadoo)'; |
|
251 | + $tmp = getBrowserInfo($user_agent); |
|
252 | + $this->assertEquals('ie', $tmp['browsername']); |
|
253 | + $this->assertEquals('5.0', $tmp['browserversion']); |
|
254 | 254 | $this->assertEmpty($tmp['phone']); |
255 | 255 | $this->assertFalse($tmp['tablet']); |
256 | 256 | $this->assertEquals('classic', $tmp['layout']); |
257 | 257 | |
258 | 258 | // Firefox 0.9.1 |
259 | - $user_agent ='Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5a) Gecko/20030728 Mozilla Firefox/0.9.1'; |
|
260 | - $tmp=getBrowserInfo($user_agent); |
|
261 | - $this->assertEquals('firefox',$tmp['browsername']); |
|
262 | - $this->assertEquals('0.9.1',$tmp['browserversion']); |
|
259 | + $user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5a) Gecko/20030728 Mozilla Firefox/0.9.1'; |
|
260 | + $tmp = getBrowserInfo($user_agent); |
|
261 | + $this->assertEquals('firefox', $tmp['browsername']); |
|
262 | + $this->assertEquals('0.9.1', $tmp['browserversion']); |
|
263 | 263 | $this->assertEmpty($tmp['phone']); |
264 | 264 | $this->assertFalse($tmp['tablet']); |
265 | 265 | $this->assertEquals('classic', $tmp['layout']); |
266 | 266 | |
267 | - $user_agent ='Mozilla/3.0 (Windows 98; U) Opera 6.03 [en]'; |
|
268 | - $tmp=getBrowserInfo($user_agent); |
|
269 | - $this->assertEquals('opera',$tmp['browsername']); |
|
270 | - $this->assertEquals('6.03',$tmp['browserversion']); |
|
267 | + $user_agent = 'Mozilla/3.0 (Windows 98; U) Opera 6.03 [en]'; |
|
268 | + $tmp = getBrowserInfo($user_agent); |
|
269 | + $this->assertEquals('opera', $tmp['browsername']); |
|
270 | + $this->assertEquals('6.03', $tmp['browserversion']); |
|
271 | 271 | $this->assertEmpty($tmp['phone']); |
272 | 272 | $this->assertFalse($tmp['tablet']); |
273 | 273 | $this->assertEquals('classic', $tmp['layout']); |
274 | 274 | |
275 | - $user_agent ='Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.21 (KHTML, like Gecko) Chrome/19.0.1042.0 Safari/535.21'; |
|
276 | - $tmp=getBrowserInfo($user_agent); |
|
277 | - $this->assertEquals('chrome',$tmp['browsername']); |
|
278 | - $this->assertEquals('19.0.1042.0',$tmp['browserversion']); |
|
275 | + $user_agent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.21 (KHTML, like Gecko) Chrome/19.0.1042.0 Safari/535.21'; |
|
276 | + $tmp = getBrowserInfo($user_agent); |
|
277 | + $this->assertEquals('chrome', $tmp['browsername']); |
|
278 | + $this->assertEquals('19.0.1042.0', $tmp['browserversion']); |
|
279 | 279 | $this->assertEmpty($tmp['phone']); |
280 | 280 | $this->assertFalse($tmp['tablet']); |
281 | 281 | $this->assertEquals('classic', $tmp['layout']); |
282 | 282 | |
283 | - $user_agent ='chrome (Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11)'; |
|
284 | - $tmp=getBrowserInfo($user_agent); |
|
285 | - $this->assertEquals('chrome',$tmp['browsername']); |
|
286 | - $this->assertEquals('17.0.963.56',$tmp['browserversion']); |
|
283 | + $user_agent = 'chrome (Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11)'; |
|
284 | + $tmp = getBrowserInfo($user_agent); |
|
285 | + $this->assertEquals('chrome', $tmp['browsername']); |
|
286 | + $this->assertEquals('17.0.963.56', $tmp['browserversion']); |
|
287 | 287 | $this->assertEmpty($tmp['phone']); |
288 | 288 | $this->assertFalse($tmp['tablet']); |
289 | 289 | $this->assertEquals('classic', $tmp['layout']); |
290 | 290 | |
291 | - $user_agent ='Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; de-at) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1'; |
|
292 | - $tmp=getBrowserInfo($user_agent); |
|
293 | - $this->assertEquals('safari',$tmp['browsername']); |
|
294 | - $this->assertEquals('533.21.1',$tmp['browserversion']); |
|
291 | + $user_agent = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; de-at) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1'; |
|
292 | + $tmp = getBrowserInfo($user_agent); |
|
293 | + $this->assertEquals('safari', $tmp['browsername']); |
|
294 | + $this->assertEquals('533.21.1', $tmp['browserversion']); |
|
295 | 295 | $this->assertEmpty($tmp['phone']); |
296 | 296 | $this->assertFalse($tmp['tablet']); |
297 | 297 | $this->assertEquals('classic', $tmp['layout']); |
298 | 298 | |
299 | 299 | //Internet Explorer 11 |
300 | 300 | $user_agent = 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko'; |
301 | - $tmp=getBrowserInfo($user_agent); |
|
302 | - $this->assertEquals('ie',$tmp['browsername']); |
|
303 | - $this->assertEquals('11.0',$tmp['browserversion']); |
|
301 | + $tmp = getBrowserInfo($user_agent); |
|
302 | + $this->assertEquals('ie', $tmp['browsername']); |
|
303 | + $this->assertEquals('11.0', $tmp['browserversion']); |
|
304 | 304 | $this->assertEmpty($tmp['phone']); |
305 | 305 | $this->assertFalse($tmp['tablet']); |
306 | 306 | $this->assertEquals('classic', $tmp['layout']); |
307 | 307 | |
308 | 308 | //Internet Explorer 11 bis |
309 | 309 | $user_agent = 'Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; NP06; rv:11.0) like Gecko'; |
310 | - $tmp=getBrowserInfo($user_agent); |
|
311 | - $this->assertEquals('ie',$tmp['browsername']); |
|
312 | - $this->assertEquals('11.0',$tmp['browserversion']); |
|
310 | + $tmp = getBrowserInfo($user_agent); |
|
311 | + $this->assertEquals('ie', $tmp['browsername']); |
|
312 | + $this->assertEquals('11.0', $tmp['browserversion']); |
|
313 | 313 | $this->assertEmpty($tmp['phone']); |
314 | 314 | $this->assertFalse($tmp['tablet']); |
315 | 315 | $this->assertEquals('classic', $tmp['layout']); |
316 | 316 | |
317 | 317 | //iPad |
318 | 318 | $user_agent = 'Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25'; |
319 | - $tmp=getBrowserInfo($user_agent); |
|
320 | - $this->assertEquals('safari',$tmp['browsername']); |
|
321 | - $this->assertEquals('8536.25',$tmp['browserversion']); |
|
322 | - $this->assertEquals('ios',$tmp['browseros']); |
|
323 | - $this->assertEquals('tablet',$tmp['layout']); |
|
324 | - $this->assertEquals('iphone',$tmp['phone']); |
|
319 | + $tmp = getBrowserInfo($user_agent); |
|
320 | + $this->assertEquals('safari', $tmp['browsername']); |
|
321 | + $this->assertEquals('8536.25', $tmp['browserversion']); |
|
322 | + $this->assertEquals('ios', $tmp['browseros']); |
|
323 | + $this->assertEquals('tablet', $tmp['layout']); |
|
324 | + $this->assertEquals('iphone', $tmp['phone']); |
|
325 | 325 | } |
326 | 326 | |
327 | 327 | |
@@ -384,64 +384,64 @@ discard block |
||
384 | 384 | public function testDolTextIsHtml() |
385 | 385 | { |
386 | 386 | // True |
387 | - $input='<html>xxx</html>'; |
|
388 | - $after=dol_textishtml($input); |
|
387 | + $input = '<html>xxx</html>'; |
|
388 | + $after = dol_textishtml($input); |
|
389 | 389 | $this->assertTrue($after, 'Test with html tag'); |
390 | - $input='<body>xxx</body>'; |
|
391 | - $after=dol_textishtml($input); |
|
390 | + $input = '<body>xxx</body>'; |
|
391 | + $after = dol_textishtml($input); |
|
392 | 392 | $this->assertTrue($after, 'Test with body tag'); |
393 | - $input='xxx <b>yyy</b> zzz'; |
|
394 | - $after=dol_textishtml($input); |
|
393 | + $input = 'xxx <b>yyy</b> zzz'; |
|
394 | + $after = dol_textishtml($input); |
|
395 | 395 | $this->assertTrue($after, 'Test with b tag'); |
396 | - $input='xxx <u>yyy</u> zzz'; |
|
397 | - $after=dol_textishtml($input); |
|
396 | + $input = 'xxx <u>yyy</u> zzz'; |
|
397 | + $after = dol_textishtml($input); |
|
398 | 398 | $this->assertTrue($after, 'Test with u tag'); |
399 | - $input='text with <div>some div</div>'; |
|
400 | - $after=dol_textishtml($input); |
|
399 | + $input = 'text with <div>some div</div>'; |
|
400 | + $after = dol_textishtml($input); |
|
401 | 401 | $this->assertTrue($after, 'Test with div tag'); |
402 | - $input='text with HTML entities'; |
|
403 | - $after=dol_textishtml($input); |
|
402 | + $input = 'text with HTML entities'; |
|
403 | + $after = dol_textishtml($input); |
|
404 | 404 | $this->assertTrue($after, 'Test with entities tag'); |
405 | - $input='xxx<br>'; |
|
406 | - $after=dol_textishtml($input); |
|
405 | + $input = 'xxx<br>'; |
|
406 | + $after = dol_textishtml($input); |
|
407 | 407 | $this->assertTrue($after, 'Test with entities br'); |
408 | - $input='xxx<br >'; |
|
409 | - $after=dol_textishtml($input); |
|
408 | + $input = 'xxx<br >'; |
|
409 | + $after = dol_textishtml($input); |
|
410 | 410 | $this->assertTrue($after, 'Test with entities br'); |
411 | - $input='xxx<br style="eee">'; |
|
412 | - $after=dol_textishtml($input); |
|
411 | + $input = 'xxx<br style="eee">'; |
|
412 | + $after = dol_textishtml($input); |
|
413 | 413 | $this->assertTrue($after, 'Test with entities br and attributes'); |
414 | - $input='xxx<br style="eee" >'; |
|
415 | - $after=dol_textishtml($input); |
|
414 | + $input = 'xxx<br style="eee" >'; |
|
415 | + $after = dol_textishtml($input); |
|
416 | 416 | $this->assertTrue($after, 'Test with entities br and attributes bis'); |
417 | - $input='<h2>abc</h2>'; |
|
418 | - $after=dol_textishtml($input); |
|
417 | + $input = '<h2>abc</h2>'; |
|
418 | + $after = dol_textishtml($input); |
|
419 | 419 | $this->assertTrue($after, 'Test with entities h2'); |
420 | - $input='<img id="abc" src="https://xxx.com/aaa/image.png" />'; |
|
421 | - $after=dol_textishtml($input); |
|
420 | + $input = '<img id="abc" src="https://xxx.com/aaa/image.png" />'; |
|
421 | + $after = dol_textishtml($input); |
|
422 | 422 | $this->assertTrue($after, 'Test with img tag'); |
423 | - $input='<a class="azerty" href="https://xxx.com/aaa/image.png" />'; |
|
424 | - $after=dol_textishtml($input); |
|
423 | + $input = '<a class="azerty" href="https://xxx.com/aaa/image.png" />'; |
|
424 | + $after = dol_textishtml($input); |
|
425 | 425 | $this->assertTrue($after, 'Test with a tag'); |
426 | - $input='This is a text with html spaces'; |
|
427 | - $after=dol_textishtml($input); |
|
426 | + $input = 'This is a text with html spaces'; |
|
427 | + $after = dol_textishtml($input); |
|
428 | 428 | $this->assertTrue($after, 'Test with a '); |
429 | - $input='This is a text with accent é'; |
|
430 | - $after=dol_textishtml($input); |
|
429 | + $input = 'This is a text with accent é'; |
|
430 | + $after = dol_textishtml($input); |
|
431 | 431 | $this->assertTrue($after, 'Test with a é'); |
432 | 432 | |
433 | 433 | // False |
434 | - $input='xxx < br>'; |
|
435 | - $after=dol_textishtml($input); |
|
434 | + $input = 'xxx < br>'; |
|
435 | + $after = dol_textishtml($input); |
|
436 | 436 | $this->assertFalse($after); |
437 | - $input='xxx <[email protected]>'; // <em> is html, <em... is not |
|
438 | - $after=dol_textishtml($input); |
|
437 | + $input = 'xxx <[email protected]>'; // <em> is html, <em... is not |
|
438 | + $after = dol_textishtml($input); |
|
439 | 439 | $this->assertFalse($after); |
440 | - $input='xxx <brstyle="ee">'; |
|
441 | - $after=dol_textishtml($input); |
|
440 | + $input = 'xxx <brstyle="ee">'; |
|
441 | + $after = dol_textishtml($input); |
|
442 | 442 | $this->assertFalse($after); |
443 | - $input='This is a text with html comments <!-- comment -->'; // we suppose this is not enough to be html content |
|
444 | - $after=dol_textishtml($input); |
|
443 | + $input = 'This is a text with html comments <!-- comment -->'; // we suppose this is not enough to be html content |
|
444 | + $after = dol_textishtml($input); |
|
445 | 445 | $this->assertFalse($after); |
446 | 446 | } |
447 | 447 | |
@@ -453,33 +453,33 @@ discard block |
||
453 | 453 | */ |
454 | 454 | public function testDolHtmlCleanLastBr() |
455 | 455 | { |
456 | - $input="A string\n"; |
|
457 | - $after=dol_htmlcleanlastbr($input); |
|
458 | - $this->assertEquals("A string",$after); |
|
456 | + $input = "A string\n"; |
|
457 | + $after = dol_htmlcleanlastbr($input); |
|
458 | + $this->assertEquals("A string", $after); |
|
459 | 459 | |
460 | - $input="A string first\nA string second\n"; |
|
461 | - $after=dol_htmlcleanlastbr($input); |
|
462 | - $this->assertEquals("A string first\nA string second",$after); |
|
460 | + $input = "A string first\nA string second\n"; |
|
461 | + $after = dol_htmlcleanlastbr($input); |
|
462 | + $this->assertEquals("A string first\nA string second", $after); |
|
463 | 463 | |
464 | - $input="A string\n\n\n"; |
|
465 | - $after=dol_htmlcleanlastbr($input); |
|
466 | - $this->assertEquals("A string",$after); |
|
464 | + $input = "A string\n\n\n"; |
|
465 | + $after = dol_htmlcleanlastbr($input); |
|
466 | + $this->assertEquals("A string", $after); |
|
467 | 467 | |
468 | - $input="A string<br>"; |
|
469 | - $after=dol_htmlcleanlastbr($input); |
|
470 | - $this->assertEquals("A string",$after); |
|
468 | + $input = "A string<br>"; |
|
469 | + $after = dol_htmlcleanlastbr($input); |
|
470 | + $this->assertEquals("A string", $after); |
|
471 | 471 | |
472 | - $input="A string first<br>\nA string second<br>"; |
|
473 | - $after=dol_htmlcleanlastbr($input); |
|
474 | - $this->assertEquals("A string first<br>\nA string second",$after); |
|
472 | + $input = "A string first<br>\nA string second<br>"; |
|
473 | + $after = dol_htmlcleanlastbr($input); |
|
474 | + $this->assertEquals("A string first<br>\nA string second", $after); |
|
475 | 475 | |
476 | - $input="A string\n<br type=\"_moz\" />\n"; |
|
477 | - $after=dol_htmlcleanlastbr($input); |
|
478 | - $this->assertEquals("A string",$after); |
|
476 | + $input = "A string\n<br type=\"_moz\" />\n"; |
|
477 | + $after = dol_htmlcleanlastbr($input); |
|
478 | + $this->assertEquals("A string", $after); |
|
479 | 479 | |
480 | - $input="A string\n<br><br />\n\n"; |
|
481 | - $after=dol_htmlcleanlastbr($input); |
|
482 | - $this->assertEquals("A string",$after); |
|
480 | + $input = "A string\n<br><br />\n\n"; |
|
481 | + $after = dol_htmlcleanlastbr($input); |
|
482 | + $this->assertEquals("A string", $after); |
|
483 | 483 | |
484 | 484 | return true; |
485 | 485 | } |
@@ -491,17 +491,17 @@ discard block |
||
491 | 491 | */ |
492 | 492 | public function testDolConcat() |
493 | 493 | { |
494 | - $text1="A string 1"; $text2="A string 2"; // text 1 and 2 are text, concat need only \n |
|
495 | - $after=dol_concatdesc($text1, $text2); |
|
496 | - $this->assertEquals("A string 1\nA string 2",$after); |
|
494 | + $text1 = "A string 1"; $text2 = "A string 2"; // text 1 and 2 are text, concat need only \n |
|
495 | + $after = dol_concatdesc($text1, $text2); |
|
496 | + $this->assertEquals("A string 1\nA string 2", $after); |
|
497 | 497 | |
498 | - $text1="A<br>string 1"; $text2="A string 2"; // text 1 is html, concat need <br>\n |
|
499 | - $after=dol_concatdesc($text1, $text2); |
|
500 | - $this->assertEquals("A<br>string 1<br>\nA string 2",$after); |
|
498 | + $text1 = "A<br>string 1"; $text2 = "A string 2"; // text 1 is html, concat need <br>\n |
|
499 | + $after = dol_concatdesc($text1, $text2); |
|
500 | + $this->assertEquals("A<br>string 1<br>\nA string 2", $after); |
|
501 | 501 | |
502 | - $text1="A string 1"; $text2="A <b>string</b> 2"; // text 2 is html, concat need <br>\n |
|
503 | - $after=dol_concatdesc($text1, $text2); |
|
504 | - $this->assertEquals("A string 1<br>\nA <b>string</b> 2",$after); |
|
502 | + $text1 = "A string 1"; $text2 = "A <b>string</b> 2"; // text 2 is html, concat need <br>\n |
|
503 | + $after = dol_concatdesc($text1, $text2); |
|
504 | + $this->assertEquals("A string 1<br>\nA <b>string</b> 2", $after); |
|
505 | 505 | |
506 | 506 | return true; |
507 | 507 | } |
@@ -514,49 +514,49 @@ discard block |
||
514 | 514 | */ |
515 | 515 | public function testDolStringNohtmltag() |
516 | 516 | { |
517 | - $text="A\nstring\n\nand more\n"; |
|
518 | - $after=dol_string_nohtmltag($text,0); |
|
519 | - $this->assertEquals("A\nstring\n\nand more",$after,"test1a"); |
|
517 | + $text = "A\nstring\n\nand more\n"; |
|
518 | + $after = dol_string_nohtmltag($text, 0); |
|
519 | + $this->assertEquals("A\nstring\n\nand more", $after, "test1a"); |
|
520 | 520 | |
521 | - $text="A <b>string<b><br>\n<br>\n\nwith html tag<br>\n"; |
|
522 | - $after=dol_string_nohtmltag($text, 0); |
|
523 | - $this->assertEquals("A string\n\n\n\n\nwith html tag",$after,"test2a 2 br and 3 \n give 5 \n"); |
|
521 | + $text = "A <b>string<b><br>\n<br>\n\nwith html tag<br>\n"; |
|
522 | + $after = dol_string_nohtmltag($text, 0); |
|
523 | + $this->assertEquals("A string\n\n\n\n\nwith html tag", $after, "test2a 2 br and 3 \n give 5 \n"); |
|
524 | 524 | |
525 | - $text="A <b>string<b><br>\n<br>\n\nwith html tag<br>\n"; |
|
526 | - $after=dol_string_nohtmltag($text, 1); |
|
527 | - $this->assertEquals("A string with html tag",$after,"test2b 2 br and 3 \n give 1 space"); |
|
525 | + $text = "A <b>string<b><br>\n<br>\n\nwith html tag<br>\n"; |
|
526 | + $after = dol_string_nohtmltag($text, 1); |
|
527 | + $this->assertEquals("A string with html tag", $after, "test2b 2 br and 3 \n give 1 space"); |
|
528 | 528 | |
529 | - $text="A <b>string<b><br>\n<br>\n\nwith html tag<br>\n"; |
|
530 | - $after=dol_string_nohtmltag($text, 2); |
|
531 | - $this->assertEquals("A string\n\nwith html tag",$after,"test2c 2 br and 3 \n give 2 \n"); |
|
529 | + $text = "A <b>string<b><br>\n<br>\n\nwith html tag<br>\n"; |
|
530 | + $after = dol_string_nohtmltag($text, 2); |
|
531 | + $this->assertEquals("A string\n\nwith html tag", $after, "test2c 2 br and 3 \n give 2 \n"); |
|
532 | 532 | |
533 | - $text="A string<br>Another string"; |
|
534 | - $after=dol_string_nohtmltag($text,0); |
|
535 | - $this->assertEquals("A string\nAnother string",$after,"test4"); |
|
533 | + $text = "A string<br>Another string"; |
|
534 | + $after = dol_string_nohtmltag($text, 0); |
|
535 | + $this->assertEquals("A string\nAnother string", $after, "test4"); |
|
536 | 536 | |
537 | - $text="A string<br>Another string"; |
|
538 | - $after=dol_string_nohtmltag($text,1); |
|
539 | - $this->assertEquals("A string Another string",$after,"test5"); |
|
537 | + $text = "A string<br>Another string"; |
|
538 | + $after = dol_string_nohtmltag($text, 1); |
|
539 | + $this->assertEquals("A string Another string", $after, "test5"); |
|
540 | 540 | |
541 | - $text='<a href="/myurl" title="<u>Afficher projet</u>">ABC</a>'; |
|
542 | - $after=dol_string_nohtmltag($text,1); |
|
543 | - $this->assertEquals("ABC",$after,"test6"); |
|
541 | + $text = '<a href="/myurl" title="<u>Afficher projet</u>">ABC</a>'; |
|
542 | + $after = dol_string_nohtmltag($text, 1); |
|
543 | + $this->assertEquals("ABC", $after, "test6"); |
|
544 | 544 | |
545 | - $text='<a href="/myurl" title="<u>Afficher projet</u>">DEF</a>'; |
|
546 | - $after=dol_string_nohtmltag($text,1); |
|
547 | - $this->assertEquals("DEF",$after,"test7"); |
|
545 | + $text = '<a href="/myurl" title="<u>Afficher projet</u>">DEF</a>'; |
|
546 | + $after = dol_string_nohtmltag($text, 1); |
|
547 | + $this->assertEquals("DEF", $after, "test7"); |
|
548 | 548 | |
549 | - $text='<a href="/myurl" title="<u>A title</u>">HIJ</a>'; |
|
550 | - $after=dol_string_nohtmltag($text,0); |
|
551 | - $this->assertEquals("HIJ",$after,"test8"); |
|
549 | + $text = '<a href="/myurl" title="<u>A title</u>">HIJ</a>'; |
|
550 | + $after = dol_string_nohtmltag($text, 0); |
|
551 | + $this->assertEquals("HIJ", $after, "test8"); |
|
552 | 552 | |
553 | - $text="A <b>string<b>\n\nwith html tag and '<' chars<br>\n"; |
|
554 | - $after=dol_string_nohtmltag($text, 0); |
|
555 | - $this->assertEquals("A string\n\nwith html tag and '<' chars",$after,"test9"); |
|
553 | + $text = "A <b>string<b>\n\nwith html tag and '<' chars<br>\n"; |
|
554 | + $after = dol_string_nohtmltag($text, 0); |
|
555 | + $this->assertEquals("A string\n\nwith html tag and '<' chars", $after, "test9"); |
|
556 | 556 | |
557 | - $text="A <b>string<b>\n\nwith tag with < chars<br>\n"; |
|
558 | - $after=dol_string_nohtmltag($text, 1); |
|
559 | - $this->assertEquals("A string with tag with < chars",$after,"test10"); |
|
557 | + $text = "A <b>string<b>\n\nwith tag with < chars<br>\n"; |
|
558 | + $after = dol_string_nohtmltag($text, 1); |
|
559 | + $this->assertEquals("A string with tag with < chars", $after, "test10"); |
|
560 | 560 | |
561 | 561 | return true; |
562 | 562 | } |
@@ -572,39 +572,39 @@ discard block |
||
572 | 572 | { |
573 | 573 | // Text not already HTML |
574 | 574 | |
575 | - $input="A string\nwith a é, &, < and >."; |
|
576 | - $after=dol_htmlentitiesbr($input,0); // Add <br> before \n |
|
577 | - $this->assertEquals("A string<br>\nwith a é, &, < and >.",$after); |
|
575 | + $input = "A string\nwith a é, &, < and >."; |
|
576 | + $after = dol_htmlentitiesbr($input, 0); // Add <br> before \n |
|
577 | + $this->assertEquals("A string<br>\nwith a é, &, < and >.", $after); |
|
578 | 578 | |
579 | - $input="A string\nwith a é, &, < and >."; |
|
580 | - $after=dol_htmlentitiesbr($input,1); // Replace \n with <br> |
|
581 | - $this->assertEquals("A string<br>with a é, &, < and >.",$after); |
|
579 | + $input = "A string\nwith a é, &, < and >."; |
|
580 | + $after = dol_htmlentitiesbr($input, 1); // Replace \n with <br> |
|
581 | + $this->assertEquals("A string<br>with a é, &, < and >.", $after); |
|
582 | 582 | |
583 | - $input="A string\nwith a é, &, < and >.\n\n"; // With some \n at end that should be cleaned |
|
584 | - $after=dol_htmlentitiesbr($input,0); // Add <br> before \n |
|
585 | - $this->assertEquals("A string<br>\nwith a é, &, < and >.",$after); |
|
583 | + $input = "A string\nwith a é, &, < and >.\n\n"; // With some \n at end that should be cleaned |
|
584 | + $after = dol_htmlentitiesbr($input, 0); // Add <br> before \n |
|
585 | + $this->assertEquals("A string<br>\nwith a é, &, < and >.", $after); |
|
586 | 586 | |
587 | - $input="A string\nwith a é, &, < and >.\n\n"; // With some \n at end that should be cleaned |
|
588 | - $after=dol_htmlentitiesbr($input,1); // Replace \n with <br> |
|
589 | - $this->assertEquals("A string<br>with a é, &, < and >.",$after); |
|
587 | + $input = "A string\nwith a é, &, < and >.\n\n"; // With some \n at end that should be cleaned |
|
588 | + $after = dol_htmlentitiesbr($input, 1); // Replace \n with <br> |
|
589 | + $this->assertEquals("A string<br>with a é, &, < and >.", $after); |
|
590 | 590 | |
591 | 591 | // Text already HTML, so &,<,> should not be converted |
592 | 592 | |
593 | - $input="A string<br>\nwith a é, &, < and >."; |
|
594 | - $after=dol_htmlentitiesbr($input); |
|
595 | - $this->assertEquals("A string<br>\nwith a é, &, < and >.",$after); |
|
593 | + $input = "A string<br>\nwith a é, &, < and >."; |
|
594 | + $after = dol_htmlentitiesbr($input); |
|
595 | + $this->assertEquals("A string<br>\nwith a é, &, < and >.", $after); |
|
596 | 596 | |
597 | - $input="<li>\nA string with a é, &, < and >.</li>\nAnother string"; |
|
598 | - $after=dol_htmlentitiesbr($input); |
|
599 | - $this->assertEquals("<li>\nA string with a é, &, < and >.</li>\nAnother string",$after); |
|
597 | + $input = "<li>\nA string with a é, &, < and >.</li>\nAnother string"; |
|
598 | + $after = dol_htmlentitiesbr($input); |
|
599 | + $this->assertEquals("<li>\nA string with a é, &, < and >.</li>\nAnother string", $after); |
|
600 | 600 | |
601 | - $input="A string<br>\nwith a é, &, < and >.<br>"; // With some <br> at end that should be cleaned |
|
602 | - $after=dol_htmlentitiesbr($input); |
|
603 | - $this->assertEquals("A string<br>\nwith a é, &, < and >.",$after); |
|
601 | + $input = "A string<br>\nwith a é, &, < and >.<br>"; // With some <br> at end that should be cleaned |
|
602 | + $after = dol_htmlentitiesbr($input); |
|
603 | + $this->assertEquals("A string<br>\nwith a é, &, < and >.", $after); |
|
604 | 604 | |
605 | - $input="<li>\nA string with a é, &, < and >.</li>\nAnother string<br>"; // With some <br> at end that should be cleaned |
|
606 | - $after=dol_htmlentitiesbr($input); |
|
607 | - $this->assertEquals("<li>\nA string with a é, &, < and >.</li>\nAnother string",$after); |
|
605 | + $input = "<li>\nA string with a é, &, < and >.</li>\nAnother string<br>"; // With some <br> at end that should be cleaned |
|
606 | + $after = dol_htmlentitiesbr($input); |
|
607 | + $this->assertEquals("<li>\nA string with a é, &, < and >.</li>\nAnother string", $after); |
|
608 | 608 | |
609 | 609 | // TODO Add test with param $removelasteolbr = 0 |
610 | 610 | |
@@ -620,19 +620,19 @@ discard block |
||
620 | 620 | public function testDolNbOfLinesBis() |
621 | 621 | { |
622 | 622 | // This is not a html string so nb of lines depends on \n |
623 | - $input="A string\nwith a é, &, < and > and bold tag.\nThird line"; |
|
624 | - $after=dol_nboflines_bis($input,0); |
|
625 | - $this->assertEquals($after,3); |
|
623 | + $input = "A string\nwith a é, &, < and > and bold tag.\nThird line"; |
|
624 | + $after = dol_nboflines_bis($input, 0); |
|
625 | + $this->assertEquals($after, 3); |
|
626 | 626 | |
627 | 627 | // This is a html string so nb of lines depends on <br> |
628 | - $input="A string\nwith a é, &, < and > and <b>bold</b> tag.\nThird line"; |
|
629 | - $after=dol_nboflines_bis($input,0); |
|
630 | - $this->assertEquals($after,1); |
|
628 | + $input = "A string\nwith a é, &, < and > and <b>bold</b> tag.\nThird line"; |
|
629 | + $after = dol_nboflines_bis($input, 0); |
|
630 | + $this->assertEquals($after, 1); |
|
631 | 631 | |
632 | 632 | // This is a html string so nb of lines depends on <br> |
633 | - $input="A string<br>with a é, &, < and > and <b>bold</b> tag.<br>Third line"; |
|
634 | - $after=dol_nboflines_bis($input,0); |
|
635 | - $this->assertEquals($after,3); |
|
633 | + $input = "A string<br>with a é, &, < and > and <b>bold</b> tag.<br>Third line"; |
|
634 | + $after = dol_nboflines_bis($input, 0); |
|
635 | + $this->assertEquals($after, 3); |
|
636 | 636 | |
637 | 637 | return true; |
638 | 638 | } |
@@ -647,9 +647,9 @@ discard block |
||
647 | 647 | { |
648 | 648 | // Text not already HTML |
649 | 649 | |
650 | - $input="A string\nwith a à ä é è ë ï ü ö ÿ, &, < and >."; |
|
651 | - $after=dol_string_unaccent($input); |
|
652 | - $this->assertEquals("A string\nwith a a a e e e i u o y, &, < and >.",$after); |
|
650 | + $input = "A string\nwith a à ä é è ë ï ü ö ÿ, &, < and >."; |
|
651 | + $after = dol_string_unaccent($input); |
|
652 | + $this->assertEquals("A string\nwith a a a e e e i u o y, &, < and >.", $after); |
|
653 | 653 | } |
654 | 654 | |
655 | 655 | |
@@ -661,17 +661,17 @@ discard block |
||
661 | 661 | public function testDolUtf8Check() |
662 | 662 | { |
663 | 663 | // True |
664 | - $result=utf8_check('azerty'); |
|
664 | + $result = utf8_check('azerty'); |
|
665 | 665 | $this->assertTrue($result); |
666 | 666 | |
667 | - $file=dirname(__FILE__).'/textutf8.txt'; |
|
668 | - $filecontent=file_get_contents($file); |
|
669 | - $result=utf8_check($filecontent); |
|
667 | + $file = dirname(__FILE__).'/textutf8.txt'; |
|
668 | + $filecontent = file_get_contents($file); |
|
669 | + $result = utf8_check($filecontent); |
|
670 | 670 | $this->assertTrue($result); |
671 | 671 | |
672 | - $file=dirname(__FILE__).'/textiso.txt'; |
|
673 | - $filecontent=file_get_contents($file); |
|
674 | - $result=utf8_check($filecontent); |
|
672 | + $file = dirname(__FILE__).'/textiso.txt'; |
|
673 | + $filecontent = file_get_contents($file); |
|
674 | + $result = utf8_check($filecontent); |
|
675 | 675 | $this->assertFalse($result); |
676 | 676 | } |
677 | 677 | |
@@ -683,50 +683,50 @@ discard block |
||
683 | 683 | public function testDolTrunc() |
684 | 684 | { |
685 | 685 | // Default trunc (will add ... if truncation truncation or keep last char if only one char) |
686 | - $input="éeéeéeàa"; |
|
687 | - $after=dol_trunc($input,3); |
|
688 | - $this->assertEquals("éeé...",$after,'Test A1'); |
|
689 | - $after=dol_trunc($input,2); |
|
690 | - $this->assertEquals("ée...",$after,'Test A2'); |
|
691 | - $after=dol_trunc($input,1); |
|
692 | - $this->assertEquals("é...",$after,'Test A3'); |
|
693 | - $input="éeéeé"; |
|
694 | - $after=dol_trunc($input,3); |
|
695 | - $this->assertEquals("éeéeé",$after,'Test B1'); |
|
696 | - $after=dol_trunc($input,2); |
|
697 | - $this->assertEquals("éeéeé",$after,'Test B2'); |
|
698 | - $after=dol_trunc($input,1); |
|
699 | - $this->assertEquals("é...",$after,'Test B3'); |
|
700 | - $input="éeée"; |
|
701 | - $after=dol_trunc($input,3); |
|
702 | - $this->assertEquals("éeée",$after,'Test C1'); |
|
703 | - $after=dol_trunc($input,2); |
|
704 | - $this->assertEquals("éeée",$after,'Test C2'); |
|
705 | - $after=dol_trunc($input,1); |
|
706 | - $this->assertEquals("éeée",$after,'Test C3'); |
|
707 | - $input="éeé"; |
|
708 | - $after=dol_trunc($input,3); |
|
709 | - $this->assertEquals("éeé",$after,'Test C'); |
|
710 | - $after=dol_trunc($input,2); |
|
711 | - $this->assertEquals("éeé",$after,'Test D'); |
|
712 | - $after=dol_trunc($input,1); |
|
713 | - $this->assertEquals("éeé",$after,'Test E'); |
|
686 | + $input = "éeéeéeàa"; |
|
687 | + $after = dol_trunc($input, 3); |
|
688 | + $this->assertEquals("éeé...", $after, 'Test A1'); |
|
689 | + $after = dol_trunc($input, 2); |
|
690 | + $this->assertEquals("ée...", $after, 'Test A2'); |
|
691 | + $after = dol_trunc($input, 1); |
|
692 | + $this->assertEquals("é...", $after, 'Test A3'); |
|
693 | + $input = "éeéeé"; |
|
694 | + $after = dol_trunc($input, 3); |
|
695 | + $this->assertEquals("éeéeé", $after, 'Test B1'); |
|
696 | + $after = dol_trunc($input, 2); |
|
697 | + $this->assertEquals("éeéeé", $after, 'Test B2'); |
|
698 | + $after = dol_trunc($input, 1); |
|
699 | + $this->assertEquals("é...", $after, 'Test B3'); |
|
700 | + $input = "éeée"; |
|
701 | + $after = dol_trunc($input, 3); |
|
702 | + $this->assertEquals("éeée", $after, 'Test C1'); |
|
703 | + $after = dol_trunc($input, 2); |
|
704 | + $this->assertEquals("éeée", $after, 'Test C2'); |
|
705 | + $after = dol_trunc($input, 1); |
|
706 | + $this->assertEquals("éeée", $after, 'Test C3'); |
|
707 | + $input = "éeé"; |
|
708 | + $after = dol_trunc($input, 3); |
|
709 | + $this->assertEquals("éeé", $after, 'Test C'); |
|
710 | + $after = dol_trunc($input, 2); |
|
711 | + $this->assertEquals("éeé", $after, 'Test D'); |
|
712 | + $after = dol_trunc($input, 1); |
|
713 | + $this->assertEquals("éeé", $after, 'Test E'); |
|
714 | 714 | // Trunc with no ... |
715 | - $input="éeéeéeàa"; |
|
716 | - $after=dol_trunc($input,3,'right','UTF-8',1); |
|
717 | - $this->assertEquals("éeé",$after,'Test F'); |
|
718 | - $after=dol_trunc($input,2,'right','UTF-8',1); |
|
719 | - $this->assertEquals("ée",$after,'Test G'); |
|
720 | - $input="éeé"; |
|
721 | - $after=dol_trunc($input,3,'right','UTF-8',1); |
|
722 | - $this->assertEquals("éeé",$after,'Test H'); |
|
723 | - $after=dol_trunc($input,2,'right','UTF-8',1); |
|
724 | - $this->assertEquals("ée",$after,'Test I'); |
|
725 | - $after=dol_trunc($input,1,'right','UTF-8',1); |
|
726 | - $this->assertEquals("é",$after,'Test J'); |
|
727 | - $input="éeéeéeàa"; |
|
728 | - $after=dol_trunc($input,4,'middle'); |
|
729 | - $this->assertEquals("ée...àa",$after,'Test K'); |
|
715 | + $input = "éeéeéeàa"; |
|
716 | + $after = dol_trunc($input, 3, 'right', 'UTF-8', 1); |
|
717 | + $this->assertEquals("éeé", $after, 'Test F'); |
|
718 | + $after = dol_trunc($input, 2, 'right', 'UTF-8', 1); |
|
719 | + $this->assertEquals("ée", $after, 'Test G'); |
|
720 | + $input = "éeé"; |
|
721 | + $after = dol_trunc($input, 3, 'right', 'UTF-8', 1); |
|
722 | + $this->assertEquals("éeé", $after, 'Test H'); |
|
723 | + $after = dol_trunc($input, 2, 'right', 'UTF-8', 1); |
|
724 | + $this->assertEquals("ée", $after, 'Test I'); |
|
725 | + $after = dol_trunc($input, 1, 'right', 'UTF-8', 1); |
|
726 | + $this->assertEquals("é", $after, 'Test J'); |
|
727 | + $input = "éeéeéeàa"; |
|
728 | + $after = dol_trunc($input, 4, 'middle'); |
|
729 | + $this->assertEquals("ée...àa", $after, 'Test K'); |
|
730 | 730 | |
731 | 731 | return true; |
732 | 732 | } |
@@ -740,49 +740,49 @@ discard block |
||
740 | 740 | { |
741 | 741 | global $conf; |
742 | 742 | |
743 | - $savtz=date_default_timezone_get(); |
|
743 | + $savtz = date_default_timezone_get(); |
|
744 | 744 | |
745 | 745 | // Some test for UTC TZ |
746 | 746 | date_default_timezone_set('UTC'); |
747 | 747 | |
748 | 748 | // Check bad hours |
749 | - $result=dol_mktime(25,0,0,1,1,1970,1,1); // Error (25 hours) |
|
749 | + $result = dol_mktime(25, 0, 0, 1, 1, 1970, 1, 1); // Error (25 hours) |
|
750 | 750 | print __METHOD__." result=".$result."\n"; |
751 | - $this->assertEquals('',$result); |
|
752 | - $result=dol_mktime(2,61,0,1,1,1970,1,1); // Error (61 minutes) |
|
751 | + $this->assertEquals('', $result); |
|
752 | + $result = dol_mktime(2, 61, 0, 1, 1, 1970, 1, 1); // Error (61 minutes) |
|
753 | 753 | print __METHOD__." result=".$result."\n"; |
754 | - $this->assertEquals('',$result); |
|
755 | - $result=dol_mktime(2,1,61,1,1,1970,1,1); // Error (61 seconds) |
|
754 | + $this->assertEquals('', $result); |
|
755 | + $result = dol_mktime(2, 1, 61, 1, 1, 1970, 1, 1); // Error (61 seconds) |
|
756 | 756 | print __METHOD__." result=".$result."\n"; |
757 | - $this->assertEquals('',$result); |
|
758 | - $result=dol_mktime(2,1,1,1,32,1970,1,1); // Error (day 32) |
|
757 | + $this->assertEquals('', $result); |
|
758 | + $result = dol_mktime(2, 1, 1, 1, 32, 1970, 1, 1); // Error (day 32) |
|
759 | 759 | print __METHOD__." result=".$result."\n"; |
760 | - $this->assertEquals('',$result); |
|
761 | - $result=dol_mktime(2,1,1,13,1,1970,1,1); // Error (month 13) |
|
760 | + $this->assertEquals('', $result); |
|
761 | + $result = dol_mktime(2, 1, 1, 13, 1, 1970, 1, 1); // Error (month 13) |
|
762 | 762 | print __METHOD__." result=".$result."\n"; |
763 | - $this->assertEquals('',$result); |
|
763 | + $this->assertEquals('', $result); |
|
764 | 764 | |
765 | - $result=dol_mktime(2,1,1,1,1,1970,1); // 1970-01-01 02:01:01 in GMT area -> 7261 |
|
765 | + $result = dol_mktime(2, 1, 1, 1, 1, 1970, 1); // 1970-01-01 02:01:01 in GMT area -> 7261 |
|
766 | 766 | print __METHOD__." result=".$result."\n"; |
767 | - $this->assertEquals(7261,$result); |
|
767 | + $this->assertEquals(7261, $result); |
|
768 | 768 | |
769 | - $result=dol_mktime(2,0,0,1,1,1970,0); // 1970-01-01 02:00:00 = 7200 in local area Europe/Paris = 3600 GMT |
|
769 | + $result = dol_mktime(2, 0, 0, 1, 1, 1970, 0); // 1970-01-01 02:00:00 = 7200 in local area Europe/Paris = 3600 GMT |
|
770 | 770 | print __METHOD__." result=".$result."\n"; |
771 | - $tz=getServerTimeZoneInt('winter'); // +1 in Europe/Paris at this time (this time is winter) |
|
772 | - $this->assertEquals(7200-($tz*3600),$result); // 7200 if we are at greenwich winter, 7200-($tz*3600) at local winter |
|
771 | + $tz = getServerTimeZoneInt('winter'); // +1 in Europe/Paris at this time (this time is winter) |
|
772 | + $this->assertEquals(7200 - ($tz * 3600), $result); // 7200 if we are at greenwich winter, 7200-($tz*3600) at local winter |
|
773 | 773 | |
774 | 774 | // Some test for local TZ Europe/Paris |
775 | 775 | date_default_timezone_set('Europe/Paris'); |
776 | 776 | |
777 | 777 | // Check that tz for paris in winter is used |
778 | - $result=dol_mktime(2,0,0,1,1,1970,'server'); // 1970-01-01 02:00:00 = 7200 in local area Europe/Paris = 3600 GMT |
|
778 | + $result = dol_mktime(2, 0, 0, 1, 1, 1970, 'server'); // 1970-01-01 02:00:00 = 7200 in local area Europe/Paris = 3600 GMT |
|
779 | 779 | print __METHOD__." result=".$result."\n"; |
780 | - $this->assertEquals(3600,$result); // 7200 if we are at greenwich winter, 3600 at Europe/Paris |
|
780 | + $this->assertEquals(3600, $result); // 7200 if we are at greenwich winter, 3600 at Europe/Paris |
|
781 | 781 | |
782 | 782 | // Check that daylight saving time is used |
783 | - $result=dol_mktime(2,0,0,6,1,2014,0); // 2014-06-01 02:00:00 = 1401588000-3600(location)-3600(daylight) in local area Europe/Paris = 1401588000 GMT |
|
783 | + $result = dol_mktime(2, 0, 0, 6, 1, 2014, 0); // 2014-06-01 02:00:00 = 1401588000-3600(location)-3600(daylight) in local area Europe/Paris = 1401588000 GMT |
|
784 | 784 | print __METHOD__." result=".$result."\n"; |
785 | - $this->assertEquals(1401588000-3600-3600,$result); // 1401588000 are at greenwich summer, 1401588000-3600(location)-3600(daylight) at Europe/Paris summer |
|
785 | + $this->assertEquals(1401588000 - 3600 - 3600, $result); // 1401588000 are at greenwich summer, 1401588000-3600(location)-3600(daylight) at Europe/Paris summer |
|
786 | 786 | |
787 | 787 | date_default_timezone_set($savtz); |
788 | 788 | } |
@@ -795,15 +795,15 @@ discard block |
||
795 | 795 | */ |
796 | 796 | public function testDolEscapeJs() |
797 | 797 | { |
798 | - $input="x&<b>#</b>,\"'"; // " will be converted into ' |
|
799 | - $result=dol_escape_js($input); |
|
800 | - $this->assertEquals("x&<b>#</b>,\'\'",$result,"Test mode=0"); |
|
798 | + $input = "x&<b>#</b>,\"'"; // " will be converted into ' |
|
799 | + $result = dol_escape_js($input); |
|
800 | + $this->assertEquals("x&<b>#</b>,\'\'", $result, "Test mode=0"); |
|
801 | 801 | |
802 | - $result=dol_escape_js($input,1); |
|
803 | - $this->assertEquals("x&<b>#</b>,\"\'",$result,"Test mode=1"); |
|
802 | + $result = dol_escape_js($input, 1); |
|
803 | + $this->assertEquals("x&<b>#</b>,\"\'", $result, "Test mode=1"); |
|
804 | 804 | |
805 | - $result=dol_escape_js($input,2); |
|
806 | - $this->assertEquals("x&<b>#</b>,\\\"'",$result,"Test mode=2"); |
|
805 | + $result = dol_escape_js($input, 2); |
|
806 | + $this->assertEquals("x&<b>#</b>,\\\"'", $result, "Test mode=2"); |
|
807 | 807 | } |
808 | 808 | |
809 | 809 | |
@@ -814,13 +814,13 @@ discard block |
||
814 | 814 | */ |
815 | 815 | public function testDolEscapeHtmlTag() |
816 | 816 | { |
817 | - $input='x&<b>#</b>,"'; // & and " are converted into html entities, <b> are removed |
|
818 | - $result=dol_escape_htmltag($input); |
|
819 | - $this->assertEquals('x&#,"',$result); |
|
817 | + $input = 'x&<b>#</b>,"'; // & and " are converted into html entities, <b> are removed |
|
818 | + $result = dol_escape_htmltag($input); |
|
819 | + $this->assertEquals('x&#,"', $result); |
|
820 | 820 | |
821 | - $input='x&<b>#</b>,"'; // & and " are converted into html entities, <b> are not removed |
|
822 | - $result=dol_escape_htmltag($input,1); |
|
823 | - $this->assertEquals('x&<b>#</b>,"',$result); |
|
821 | + $input = 'x&<b>#</b>,"'; // & and " are converted into html entities, <b> are not removed |
|
822 | + $result = dol_escape_htmltag($input, 1); |
|
823 | + $this->assertEquals('x&<b>#</b>,"', $result); |
|
824 | 824 | } |
825 | 825 | |
826 | 826 | |
@@ -831,30 +831,30 @@ discard block |
||
831 | 831 | */ |
832 | 832 | public function testDolFormatAddress() |
833 | 833 | { |
834 | - global $conf,$user,$langs,$db; |
|
835 | - $conf=$this->savconf; |
|
836 | - $user=$this->savuser; |
|
837 | - $langs=$this->savlangs; |
|
838 | - $db=$this->savdb; |
|
834 | + global $conf, $user, $langs, $db; |
|
835 | + $conf = $this->savconf; |
|
836 | + $user = $this->savuser; |
|
837 | + $langs = $this->savlangs; |
|
838 | + $db = $this->savdb; |
|
839 | 839 | |
840 | - $object=new Societe($db); |
|
840 | + $object = new Societe($db); |
|
841 | 841 | $object->initAsSpecimen(); |
842 | 842 | |
843 | - $object->country_code='FR'; |
|
844 | - $address=dol_format_address($object); |
|
845 | - $this->assertEquals("21 jump street\n99999 MyTown",$address); |
|
843 | + $object->country_code = 'FR'; |
|
844 | + $address = dol_format_address($object); |
|
845 | + $this->assertEquals("21 jump street\n99999 MyTown", $address); |
|
846 | 846 | |
847 | - $object->country_code='GB'; |
|
848 | - $address=dol_format_address($object); |
|
849 | - $this->assertEquals("21 jump street\nMyTown, MyState\n99999",$address); |
|
847 | + $object->country_code = 'GB'; |
|
848 | + $address = dol_format_address($object); |
|
849 | + $this->assertEquals("21 jump street\nMyTown, MyState\n99999", $address); |
|
850 | 850 | |
851 | - $object->country_code='US'; |
|
852 | - $address=dol_format_address($object); |
|
853 | - $this->assertEquals("21 jump street\nMyTown, MyState, 99999",$address); |
|
851 | + $object->country_code = 'US'; |
|
852 | + $address = dol_format_address($object); |
|
853 | + $this->assertEquals("21 jump street\nMyTown, MyState, 99999", $address); |
|
854 | 854 | |
855 | - $object->country_code='AU'; |
|
856 | - $address=dol_format_address($object); |
|
857 | - $this->assertEquals("21 jump street\nMyTown, MyState, 99999",$address); |
|
855 | + $object->country_code = 'AU'; |
|
856 | + $address = dol_format_address($object); |
|
857 | + $this->assertEquals("21 jump street\nMyTown, MyState, 99999", $address); |
|
858 | 858 | } |
859 | 859 | |
860 | 860 | |
@@ -865,29 +865,29 @@ discard block |
||
865 | 865 | */ |
866 | 866 | public function testDolPrintPhone() |
867 | 867 | { |
868 | - global $conf,$user,$langs,$db; |
|
869 | - $conf=$this->savconf; |
|
870 | - $user=$this->savuser; |
|
871 | - $langs=$this->savlangs; |
|
872 | - $db=$this->savdb; |
|
868 | + global $conf, $user, $langs, $db; |
|
869 | + $conf = $this->savconf; |
|
870 | + $user = $this->savuser; |
|
871 | + $langs = $this->savlangs; |
|
872 | + $db = $this->savdb; |
|
873 | 873 | |
874 | - $object=new Societe($db); |
|
874 | + $object = new Societe($db); |
|
875 | 875 | $object->initAsSpecimen(); |
876 | 876 | |
877 | - $object->country_code='FR'; |
|
878 | - $phone=dol_print_phone('1234567890', $object->country_code); |
|
877 | + $object->country_code = 'FR'; |
|
878 | + $phone = dol_print_phone('1234567890', $object->country_code); |
|
879 | 879 | $this->assertEquals('<span style="margin-right: 10px;">12 34 56 78 90</span>', $phone, 'Phone for FR 1'); |
880 | 880 | |
881 | - $object->country_code='FR'; |
|
882 | - $phone=dol_print_phone('1234567890', $object->country_code, 0, 0, 0, ''); |
|
881 | + $object->country_code = 'FR'; |
|
882 | + $phone = dol_print_phone('1234567890', $object->country_code, 0, 0, 0, ''); |
|
883 | 883 | $this->assertEquals('<span style="margin-right: 10px;">1234567890</span>', $phone, 'Phone for FR 2'); |
884 | 884 | |
885 | - $object->country_code='FR'; |
|
886 | - $phone=dol_print_phone('1234567890', $object->country_code, 0, 0, 0, ' '); |
|
885 | + $object->country_code = 'FR'; |
|
886 | + $phone = dol_print_phone('1234567890', $object->country_code, 0, 0, 0, ' '); |
|
887 | 887 | $this->assertEquals('<span style="margin-right: 10px;">12 34 56 78 90</span>', $phone, 'Phone for FR 3'); |
888 | 888 | |
889 | - $object->country_code='CA'; |
|
890 | - $phone=dol_print_phone('1234567890', $object->country_code, 0, 0, 0, ' '); |
|
889 | + $object->country_code = 'CA'; |
|
890 | + $phone = dol_print_phone('1234567890', $object->country_code, 0, 0, 0, ' '); |
|
891 | 891 | $this->assertEquals('<span style="margin-right: 10px;">(123) 456-7890</span>', $phone, 'Phone for CA 1'); |
892 | 892 | } |
893 | 893 | |
@@ -899,26 +899,26 @@ discard block |
||
899 | 899 | */ |
900 | 900 | public function testImgPicto() |
901 | 901 | { |
902 | - $s=img_picto('title','user'); |
|
902 | + $s = img_picto('title', 'user'); |
|
903 | 903 | print __METHOD__." s=".$s."\n"; |
904 | - $this->assertContains('theme',$s,'testImgPicto1'); |
|
904 | + $this->assertContains('theme', $s, 'testImgPicto1'); |
|
905 | 905 | |
906 | - $s=img_picto('title','img.png','style="float: right"',0); |
|
906 | + $s = img_picto('title', 'img.png', 'style="float: right"', 0); |
|
907 | 907 | print __METHOD__." s=".$s."\n"; |
908 | - $this->assertContains('theme',$s,'testImgPicto2'); |
|
909 | - $this->assertContains('style="float: right"',$s,'testImgPicto2'); |
|
908 | + $this->assertContains('theme', $s, 'testImgPicto2'); |
|
909 | + $this->assertContains('style="float: right"', $s, 'testImgPicto2'); |
|
910 | 910 | |
911 | - $s=img_picto('title', '/fullpath/img.png', '', 1); |
|
911 | + $s = img_picto('title', '/fullpath/img.png', '', 1); |
|
912 | 912 | print __METHOD__." s=".$s."\n"; |
913 | - $this->assertEquals('<img src="/fullpath/img.png" alt="" title="title" class="inline-block">',$s,'testImgPicto3'); |
|
913 | + $this->assertEquals('<img src="/fullpath/img.png" alt="" title="title" class="inline-block">', $s, 'testImgPicto3'); |
|
914 | 914 | |
915 | - $s=img_picto('title', '/fullpath/img.png', '', true); |
|
915 | + $s = img_picto('title', '/fullpath/img.png', '', true); |
|
916 | 916 | print __METHOD__." s=".$s."\n"; |
917 | - $this->assertEquals('<img src="/fullpath/img.png" alt="" title="title" class="inline-block">',$s,'testImgPicto4'); |
|
917 | + $this->assertEquals('<img src="/fullpath/img.png" alt="" title="title" class="inline-block">', $s, 'testImgPicto4'); |
|
918 | 918 | |
919 | - $s=img_picto('title', 'delete', '', 0, 1); |
|
919 | + $s = img_picto('title', 'delete', '', 0, 1); |
|
920 | 920 | print __METHOD__." s=".$s."\n"; |
921 | - $this->assertEquals(DOL_URL_ROOT.'/theme/eldy/img/delete.png',$s,'testImgPicto5'); |
|
921 | + $this->assertEquals(DOL_URL_ROOT.'/theme/eldy/img/delete.png', $s, 'testImgPicto5'); |
|
922 | 922 | } |
923 | 923 | |
924 | 924 | /** |
@@ -928,10 +928,10 @@ discard block |
||
928 | 928 | */ |
929 | 929 | public function testDolNow() |
930 | 930 | { |
931 | - $now=dol_now('gmt'); |
|
932 | - $nowtzserver=dol_now('tzserver'); |
|
933 | - print __METHOD__." getServerTimeZoneInt=".(getServerTimeZoneInt('now')*3600)."\n"; |
|
934 | - $this->assertEquals(getServerTimeZoneInt('now')*3600,($nowtzserver-$now)); |
|
931 | + $now = dol_now('gmt'); |
|
932 | + $nowtzserver = dol_now('tzserver'); |
|
933 | + print __METHOD__." getServerTimeZoneInt=".(getServerTimeZoneInt('now') * 3600)."\n"; |
|
934 | + $this->assertEquals(getServerTimeZoneInt('now') * 3600, ($nowtzserver - $now)); |
|
935 | 935 | } |
936 | 936 | |
937 | 937 | /** |
@@ -941,19 +941,19 @@ discard block |
||
941 | 941 | */ |
942 | 942 | public function testVerifCond() |
943 | 943 | { |
944 | - $verifcond=verifCond('1==1'); |
|
945 | - $this->assertTrue($verifcond,'Test a true comparison'); |
|
944 | + $verifcond = verifCond('1==1'); |
|
945 | + $this->assertTrue($verifcond, 'Test a true comparison'); |
|
946 | 946 | |
947 | - $verifcond=verifCond('1==2'); |
|
948 | - $this->assertFalse($verifcond,'Test a false comparison'); |
|
947 | + $verifcond = verifCond('1==2'); |
|
948 | + $this->assertFalse($verifcond, 'Test a false comparison'); |
|
949 | 949 | |
950 | - $verifcond=verifCond('$conf->facture->enabled'); |
|
951 | - $this->assertTrue($verifcond,'Test that conf property of a module report true when enabled'); |
|
950 | + $verifcond = verifCond('$conf->facture->enabled'); |
|
951 | + $this->assertTrue($verifcond, 'Test that conf property of a module report true when enabled'); |
|
952 | 952 | |
953 | - $verifcond=verifCond('$conf->moduledummy->enabled'); |
|
954 | - $this->assertFalse($verifcond,'Test that conf property of a module report false when disabled'); |
|
953 | + $verifcond = verifCond('$conf->moduledummy->enabled'); |
|
954 | + $this->assertFalse($verifcond, 'Test that conf property of a module report false when disabled'); |
|
955 | 955 | |
956 | - $verifcond=verifCond(''); |
|
956 | + $verifcond = verifCond(''); |
|
957 | 957 | $this->assertTrue($verifcond); |
958 | 958 | } |
959 | 959 | |
@@ -964,76 +964,76 @@ discard block |
||
964 | 964 | */ |
965 | 965 | public function testGetDefaultTva() |
966 | 966 | { |
967 | - global $conf,$user,$langs,$db; |
|
968 | - $this->savconf=$conf; |
|
969 | - $this->savuser=$user; |
|
970 | - $this->savlangs=$langs; |
|
971 | - $this->savdb=$db; |
|
967 | + global $conf, $user, $langs, $db; |
|
968 | + $this->savconf = $conf; |
|
969 | + $this->savuser = $user; |
|
970 | + $this->savlangs = $langs; |
|
971 | + $this->savdb = $db; |
|
972 | 972 | |
973 | 973 | // Sellers |
974 | - $companyfrnovat=new Societe($db); |
|
975 | - $companyfrnovat->country_code='FR'; |
|
976 | - $companyfrnovat->tva_assuj=0; |
|
974 | + $companyfrnovat = new Societe($db); |
|
975 | + $companyfrnovat->country_code = 'FR'; |
|
976 | + $companyfrnovat->tva_assuj = 0; |
|
977 | 977 | |
978 | - $companyfr=new Societe($db); |
|
979 | - $companyfr->country_code='FR'; |
|
980 | - $companyfr->tva_assuj=1; |
|
981 | - $companyfr->tva_intra='FR9999'; |
|
978 | + $companyfr = new Societe($db); |
|
979 | + $companyfr->country_code = 'FR'; |
|
980 | + $companyfr->tva_assuj = 1; |
|
981 | + $companyfr->tva_intra = 'FR9999'; |
|
982 | 982 | |
983 | 983 | // Buyers |
984 | - $companymc=new Societe($db); |
|
985 | - $companymc->country_code='MC'; |
|
986 | - $companymc->tva_assuj=1; |
|
987 | - $companyfr->tva_intra='MC9999'; |
|
984 | + $companymc = new Societe($db); |
|
985 | + $companymc->country_code = 'MC'; |
|
986 | + $companymc->tva_assuj = 1; |
|
987 | + $companyfr->tva_intra = 'MC9999'; |
|
988 | 988 | |
989 | - $companyit=new Societe($db); |
|
990 | - $companyit->country_code='IT'; |
|
991 | - $companyit->tva_assuj=1; |
|
992 | - $companyit->tva_intra='IT99999'; |
|
989 | + $companyit = new Societe($db); |
|
990 | + $companyit->country_code = 'IT'; |
|
991 | + $companyit->tva_assuj = 1; |
|
992 | + $companyit->tva_intra = 'IT99999'; |
|
993 | 993 | |
994 | - $companyde=new Societe($db); |
|
995 | - $companyde->country_code='DE'; |
|
996 | - $companyde->tva_assuj=1; |
|
997 | - $companyde->tva_intra='DE99999'; |
|
994 | + $companyde = new Societe($db); |
|
995 | + $companyde->country_code = 'DE'; |
|
996 | + $companyde->tva_assuj = 1; |
|
997 | + $companyde->tva_intra = 'DE99999'; |
|
998 | 998 | |
999 | - $notcompanyde=new Societe($db); |
|
1000 | - $notcompanyde->country_code='DE'; |
|
1001 | - $notcompanyde->tva_assuj=0; |
|
1002 | - $notcompanyde->tva_intra=''; |
|
1003 | - $notcompanyde->typent_code='TE_PRIVATE'; |
|
999 | + $notcompanyde = new Societe($db); |
|
1000 | + $notcompanyde->country_code = 'DE'; |
|
1001 | + $notcompanyde->tva_assuj = 0; |
|
1002 | + $notcompanyde->tva_intra = ''; |
|
1003 | + $notcompanyde->typent_code = 'TE_PRIVATE'; |
|
1004 | 1004 | |
1005 | - $companyus=new Societe($db); |
|
1006 | - $companyus->country_code='US'; |
|
1007 | - $companyus->tva_assuj=1; |
|
1008 | - $companyus->tva_intra=''; |
|
1005 | + $companyus = new Societe($db); |
|
1006 | + $companyus->country_code = 'US'; |
|
1007 | + $companyus->tva_assuj = 1; |
|
1008 | + $companyus->tva_intra = ''; |
|
1009 | 1009 | |
1010 | 1010 | |
1011 | 1011 | // Test RULE 0 (FR-DE) |
1012 | 1012 | // Not tested |
1013 | 1013 | |
1014 | 1014 | // Test RULE 1 |
1015 | - $vat=get_default_tva($companyfrnovat,$companymc,0); |
|
1016 | - $this->assertEquals(0,$vat,'RULE 1'); |
|
1015 | + $vat = get_default_tva($companyfrnovat, $companymc, 0); |
|
1016 | + $this->assertEquals(0, $vat, 'RULE 1'); |
|
1017 | 1017 | |
1018 | 1018 | // Test RULE 2 (FR-FR) |
1019 | - $vat=get_default_tva($companyfr,$companyfr,0); |
|
1020 | - $this->assertEquals(20,$vat,'RULE 2'); |
|
1019 | + $vat = get_default_tva($companyfr, $companyfr, 0); |
|
1020 | + $this->assertEquals(20, $vat, 'RULE 2'); |
|
1021 | 1021 | |
1022 | 1022 | // Test RULE 2 (FR-MC) |
1023 | - $vat=get_default_tva($companyfr,$companymc,0); |
|
1024 | - $this->assertEquals(20,$vat,'RULE 2'); |
|
1023 | + $vat = get_default_tva($companyfr, $companymc, 0); |
|
1024 | + $this->assertEquals(20, $vat, 'RULE 2'); |
|
1025 | 1025 | |
1026 | 1026 | // Test RULE 3 (FR-DE company) |
1027 | - $vat=get_default_tva($companyfr,$companyit,0); |
|
1028 | - $this->assertEquals(0,$vat,'RULE 3'); |
|
1027 | + $vat = get_default_tva($companyfr, $companyit, 0); |
|
1028 | + $this->assertEquals(0, $vat, 'RULE 3'); |
|
1029 | 1029 | |
1030 | 1030 | // Test RULE 4 (FR-DE not a company) |
1031 | - $vat=get_default_tva($companyfr,$notcompanyde,0); |
|
1032 | - $this->assertEquals(20,$vat,'RULE 4'); |
|
1031 | + $vat = get_default_tva($companyfr, $notcompanyde, 0); |
|
1032 | + $this->assertEquals(20, $vat, 'RULE 4'); |
|
1033 | 1033 | |
1034 | 1034 | // Test RULE 5 (FR-US) |
1035 | - $vat=get_default_tva($companyfr,$companyus,0); |
|
1036 | - $this->assertEquals(0,$vat,'RULE 5'); |
|
1035 | + $vat = get_default_tva($companyfr, $companyus, 0); |
|
1036 | + $this->assertEquals(0, $vat, 'RULE 5'); |
|
1037 | 1037 | |
1038 | 1038 | |
1039 | 1039 | // We do same tests but with option SERVICE_ARE_ECOMMERCE_200238EC on. |
@@ -1041,24 +1041,24 @@ discard block |
||
1041 | 1041 | |
1042 | 1042 | |
1043 | 1043 | // Test RULE 1 (FR-US) |
1044 | - $vat=get_default_tva($companyfr,$companyus,0); |
|
1045 | - $this->assertEquals(0,$vat,'RULE 1 ECOMMERCE_200238EC'); |
|
1044 | + $vat = get_default_tva($companyfr, $companyus, 0); |
|
1045 | + $this->assertEquals(0, $vat, 'RULE 1 ECOMMERCE_200238EC'); |
|
1046 | 1046 | |
1047 | 1047 | // Test RULE 2 (FR-FR) |
1048 | - $vat=get_default_tva($companyfr,$companyfr,0); |
|
1049 | - $this->assertEquals(20,$vat,'RULE 2 ECOMMERCE_200238EC'); |
|
1048 | + $vat = get_default_tva($companyfr, $companyfr, 0); |
|
1049 | + $this->assertEquals(20, $vat, 'RULE 2 ECOMMERCE_200238EC'); |
|
1050 | 1050 | |
1051 | 1051 | // Test RULE 3 (FR-DE company) |
1052 | - $vat=get_default_tva($companyfr,$companyde,0); |
|
1053 | - $this->assertEquals(0,$vat,'RULE 3 ECOMMERCE_200238EC'); |
|
1052 | + $vat = get_default_tva($companyfr, $companyde, 0); |
|
1053 | + $this->assertEquals(0, $vat, 'RULE 3 ECOMMERCE_200238EC'); |
|
1054 | 1054 | |
1055 | 1055 | // Test RULE 4 (FR-DE not a company) |
1056 | - $vat=get_default_tva($companyfr,$notcompanyde,0); |
|
1057 | - $this->assertEquals(19,$vat,'RULE 4 ECOMMERCE_200238EC'); |
|
1056 | + $vat = get_default_tva($companyfr, $notcompanyde, 0); |
|
1057 | + $this->assertEquals(19, $vat, 'RULE 4 ECOMMERCE_200238EC'); |
|
1058 | 1058 | |
1059 | 1059 | // Test RULE 5 (FR-US) |
1060 | - $vat=get_default_tva($companyfr,$companyus,0); |
|
1061 | - $this->assertEquals(0,$vat,'RULE 5 ECOMMERCE_200238EC'); |
|
1060 | + $vat = get_default_tva($companyfr, $companyus, 0); |
|
1061 | + $this->assertEquals(0, $vat, 'RULE 5 ECOMMERCE_200238EC'); |
|
1062 | 1062 | } |
1063 | 1063 | |
1064 | 1064 | /** |
@@ -1068,84 +1068,84 @@ discard block |
||
1068 | 1068 | */ |
1069 | 1069 | public function testGetDefaultLocalTax() |
1070 | 1070 | { |
1071 | - global $conf,$user,$langs,$db; |
|
1072 | - $this->savconf=$conf; |
|
1073 | - $this->savuser=$user; |
|
1074 | - $this->savlangs=$langs; |
|
1075 | - $this->savdb=$db; |
|
1076 | - |
|
1077 | - $companyfrnovat=new Societe($db); |
|
1078 | - $companyfrnovat->country_code='FR'; |
|
1079 | - $companyfrnovat->tva_assuj=0; |
|
1080 | - $companyfrnovat->localtax1_assuj=0; |
|
1081 | - $companyfrnovat->localtax2_assuj=0; |
|
1082 | - |
|
1083 | - $companyes=new Societe($db); |
|
1084 | - $companyes->country_code='ES'; |
|
1085 | - $companyes->tva_assuj=1; |
|
1086 | - $companyes->localtax1_assuj=1; |
|
1087 | - $companyes->localtax2_assuj=1; |
|
1088 | - |
|
1089 | - $companymc=new Societe($db); |
|
1090 | - $companymc->country_code='MC'; |
|
1091 | - $companymc->tva_assuj=1; |
|
1092 | - $companymc->localtax1_assuj=0; |
|
1093 | - $companymc->localtax2_assuj=0; |
|
1094 | - |
|
1095 | - $companyit=new Societe($db); |
|
1096 | - $companyit->country_code='IT'; |
|
1097 | - $companyit->tva_assuj=1; |
|
1098 | - $companyit->tva_intra='IT99999'; |
|
1099 | - $companyit->localtax1_assuj=0; |
|
1100 | - $companyit->localtax2_assuj=0; |
|
1101 | - |
|
1102 | - $notcompanyit=new Societe($db); |
|
1103 | - $notcompanyit->country_code='IT'; |
|
1104 | - $notcompanyit->tva_assuj=1; |
|
1105 | - $notcompanyit->tva_intra=''; |
|
1106 | - $notcompanyit->typent_code='TE_PRIVATE'; |
|
1107 | - $notcompanyit->localtax1_assuj=0; |
|
1108 | - $notcompanyit->localtax2_assuj=0; |
|
1109 | - |
|
1110 | - $companyus=new Societe($db); |
|
1111 | - $companyus->country_code='US'; |
|
1112 | - $companyus->tva_assuj=1; |
|
1113 | - $companyus->tva_intra=''; |
|
1114 | - $companyus->localtax1_assuj=0; |
|
1115 | - $companyus->localtax2_assuj=0; |
|
1071 | + global $conf, $user, $langs, $db; |
|
1072 | + $this->savconf = $conf; |
|
1073 | + $this->savuser = $user; |
|
1074 | + $this->savlangs = $langs; |
|
1075 | + $this->savdb = $db; |
|
1076 | + |
|
1077 | + $companyfrnovat = new Societe($db); |
|
1078 | + $companyfrnovat->country_code = 'FR'; |
|
1079 | + $companyfrnovat->tva_assuj = 0; |
|
1080 | + $companyfrnovat->localtax1_assuj = 0; |
|
1081 | + $companyfrnovat->localtax2_assuj = 0; |
|
1082 | + |
|
1083 | + $companyes = new Societe($db); |
|
1084 | + $companyes->country_code = 'ES'; |
|
1085 | + $companyes->tva_assuj = 1; |
|
1086 | + $companyes->localtax1_assuj = 1; |
|
1087 | + $companyes->localtax2_assuj = 1; |
|
1088 | + |
|
1089 | + $companymc = new Societe($db); |
|
1090 | + $companymc->country_code = 'MC'; |
|
1091 | + $companymc->tva_assuj = 1; |
|
1092 | + $companymc->localtax1_assuj = 0; |
|
1093 | + $companymc->localtax2_assuj = 0; |
|
1094 | + |
|
1095 | + $companyit = new Societe($db); |
|
1096 | + $companyit->country_code = 'IT'; |
|
1097 | + $companyit->tva_assuj = 1; |
|
1098 | + $companyit->tva_intra = 'IT99999'; |
|
1099 | + $companyit->localtax1_assuj = 0; |
|
1100 | + $companyit->localtax2_assuj = 0; |
|
1101 | + |
|
1102 | + $notcompanyit = new Societe($db); |
|
1103 | + $notcompanyit->country_code = 'IT'; |
|
1104 | + $notcompanyit->tva_assuj = 1; |
|
1105 | + $notcompanyit->tva_intra = ''; |
|
1106 | + $notcompanyit->typent_code = 'TE_PRIVATE'; |
|
1107 | + $notcompanyit->localtax1_assuj = 0; |
|
1108 | + $notcompanyit->localtax2_assuj = 0; |
|
1109 | + |
|
1110 | + $companyus = new Societe($db); |
|
1111 | + $companyus->country_code = 'US'; |
|
1112 | + $companyus->tva_assuj = 1; |
|
1113 | + $companyus->tva_intra = ''; |
|
1114 | + $companyus->localtax1_assuj = 0; |
|
1115 | + $companyus->localtax2_assuj = 0; |
|
1116 | 1116 | |
1117 | 1117 | // Test RULE FR-MC |
1118 | - $vat1=get_default_localtax($companyfrnovat,$companymc,1,0); |
|
1119 | - $vat2=get_default_localtax($companyfrnovat,$companymc,2,0); |
|
1120 | - $this->assertEquals(0,$vat1); |
|
1121 | - $this->assertEquals(0,$vat2); |
|
1118 | + $vat1 = get_default_localtax($companyfrnovat, $companymc, 1, 0); |
|
1119 | + $vat2 = get_default_localtax($companyfrnovat, $companymc, 2, 0); |
|
1120 | + $this->assertEquals(0, $vat1); |
|
1121 | + $this->assertEquals(0, $vat2); |
|
1122 | 1122 | |
1123 | 1123 | // Test RULE ES-ES |
1124 | - $vat1=get_default_localtax($companyes,$companyes,1,0); |
|
1125 | - $vat2=get_default_localtax($companyes,$companyes,2,0); |
|
1124 | + $vat1 = get_default_localtax($companyes, $companyes, 1, 0); |
|
1125 | + $vat2 = get_default_localtax($companyes, $companyes, 2, 0); |
|
1126 | 1126 | $this->assertEquals($vat1, 5.2); |
1127 | - $this->assertStringStartsWith((string) $vat2, '-19:-15:-9'); // Can be -19 (old version) or '-19:-15:-9' (new setup) |
|
1127 | + $this->assertStringStartsWith((string) $vat2, '-19:-15:-9'); // Can be -19 (old version) or '-19:-15:-9' (new setup) |
|
1128 | 1128 | |
1129 | 1129 | // Test RULE ES-IT |
1130 | - $vat1=get_default_localtax($companyes,$companyit,1,0); |
|
1131 | - $vat2=get_default_localtax($companyes,$companyit,2,0); |
|
1132 | - $this->assertEquals(0,$vat1); |
|
1133 | - $this->assertEquals(0,$vat2); |
|
1130 | + $vat1 = get_default_localtax($companyes, $companyit, 1, 0); |
|
1131 | + $vat2 = get_default_localtax($companyes, $companyit, 2, 0); |
|
1132 | + $this->assertEquals(0, $vat1); |
|
1133 | + $this->assertEquals(0, $vat2); |
|
1134 | 1134 | |
1135 | 1135 | // Test RULE ES-IT |
1136 | - $vat1=get_default_localtax($companyes,$notcompanyit,1,0); |
|
1137 | - $vat2=get_default_localtax($companyes,$notcompanyit,2,0); |
|
1138 | - $this->assertEquals(0,$vat1); |
|
1139 | - $this->assertEquals(0,$vat2); |
|
1136 | + $vat1 = get_default_localtax($companyes, $notcompanyit, 1, 0); |
|
1137 | + $vat2 = get_default_localtax($companyes, $notcompanyit, 2, 0); |
|
1138 | + $this->assertEquals(0, $vat1); |
|
1139 | + $this->assertEquals(0, $vat2); |
|
1140 | 1140 | |
1141 | 1141 | // Test RULE FR-IT |
1142 | 1142 | // Not tested |
1143 | 1143 | |
1144 | 1144 | // Test RULE ES-US |
1145 | - $vat1=get_default_localtax($companyes,$companyus,1,0); |
|
1146 | - $vat2=get_default_localtax($companyes,$companyus,2,0); |
|
1147 | - $this->assertEquals(0,$vat1); |
|
1148 | - $this->assertEquals(0,$vat2); |
|
1145 | + $vat1 = get_default_localtax($companyes, $companyus, 1, 0); |
|
1146 | + $vat2 = get_default_localtax($companyes, $companyus, 2, 0); |
|
1147 | + $this->assertEquals(0, $vat1); |
|
1148 | + $this->assertEquals(0, $vat2); |
|
1149 | 1149 | } |
1150 | 1150 | |
1151 | 1151 | |
@@ -1156,11 +1156,11 @@ discard block |
||
1156 | 1156 | */ |
1157 | 1157 | public function testDolExplodeIntoArray() |
1158 | 1158 | { |
1159 | - $stringtoexplode='AA=B/B.CC=.EE=FF.HH=GG;.'; |
|
1160 | - $tmp=dolExplodeIntoArray($stringtoexplode,'.','='); |
|
1159 | + $stringtoexplode = 'AA=B/B.CC=.EE=FF.HH=GG;.'; |
|
1160 | + $tmp = dolExplodeIntoArray($stringtoexplode, '.', '='); |
|
1161 | 1161 | |
1162 | 1162 | print __METHOD__." tmp=".json_encode($tmp)."\n"; |
1163 | - $this->assertEquals('{"AA":"B\/B","CC":"","EE":"FF","HH":"GG;"}',json_encode($tmp)); |
|
1163 | + $this->assertEquals('{"AA":"B\/B","CC":"","EE":"FF","HH":"GG;"}', json_encode($tmp)); |
|
1164 | 1164 | } |
1165 | 1165 | |
1166 | 1166 | /** |
@@ -1194,22 +1194,22 @@ discard block |
||
1194 | 1194 | public function testDolPrice2Num() |
1195 | 1195 | { |
1196 | 1196 | $this->assertEquals(1000, price2num('1 000.0')); |
1197 | - $this->assertEquals(1000, price2num('1 000','MT')); |
|
1198 | - $this->assertEquals(1000, price2num('1 000','MU')); |
|
1197 | + $this->assertEquals(1000, price2num('1 000', 'MT')); |
|
1198 | + $this->assertEquals(1000, price2num('1 000', 'MU')); |
|
1199 | 1199 | |
1200 | 1200 | $this->assertEquals(1000.123456, price2num('1 000.123456')); |
1201 | 1201 | |
1202 | 1202 | // Round down |
1203 | - $this->assertEquals(1000.12, price2num('1 000.123452','MT')); |
|
1204 | - $this->assertEquals(1000.12345, price2num('1 000.123452','MU'),"Test MU"); |
|
1203 | + $this->assertEquals(1000.12, price2num('1 000.123452', 'MT')); |
|
1204 | + $this->assertEquals(1000.12345, price2num('1 000.123452', 'MU'), "Test MU"); |
|
1205 | 1205 | |
1206 | 1206 | // Round up |
1207 | - $this->assertEquals(1000.13, price2num('1 000.125456','MT')); |
|
1208 | - $this->assertEquals(1000.12546, price2num('1 000.125456','MU'),"Test MU"); |
|
1207 | + $this->assertEquals(1000.13, price2num('1 000.125456', 'MT')); |
|
1208 | + $this->assertEquals(1000.12546, price2num('1 000.125456', 'MU'), "Test MU"); |
|
1209 | 1209 | |
1210 | 1210 | // Text can't be converted |
1211 | - $this->assertEquals('12.4$',price2num('12.4$')); |
|
1212 | - $this->assertEquals('12r.4$',price2num('12r.4$')); |
|
1211 | + $this->assertEquals('12.4$', price2num('12.4$')); |
|
1212 | + $this->assertEquals('12r.4$', price2num('12r.4$')); |
|
1213 | 1213 | |
1214 | 1214 | return true; |
1215 | 1215 | } |
@@ -1225,18 +1225,18 @@ discard block |
||
1225 | 1225 | |
1226 | 1226 | $conf->global->MAIN_START_WEEK = 0; |
1227 | 1227 | |
1228 | - $tmp=dol_getdate(1); // 1/1/1970 and 1 second = thirday |
|
1228 | + $tmp = dol_getdate(1); // 1/1/1970 and 1 second = thirday |
|
1229 | 1229 | $this->assertEquals(4, $tmp['wday']); |
1230 | 1230 | |
1231 | - $tmp=dol_getdate(24*60*60+1); // 2/1/1970 and 1 second = friday |
|
1231 | + $tmp = dol_getdate(24 * 60 * 60 + 1); // 2/1/1970 and 1 second = friday |
|
1232 | 1232 | $this->assertEquals(5, $tmp['wday']); |
1233 | 1233 | |
1234 | 1234 | $conf->global->MAIN_START_WEEK = 1; |
1235 | 1235 | |
1236 | - $tmp=dol_getdate(1); // 1/1/1970 and 1 second = thirday |
|
1236 | + $tmp = dol_getdate(1); // 1/1/1970 and 1 second = thirday |
|
1237 | 1237 | $this->assertEquals(4, $tmp['wday']); |
1238 | 1238 | |
1239 | - $tmp=dol_getdate(24*60*60+1); // 2/1/1970 and 1 second = friday |
|
1239 | + $tmp = dol_getdate(24 * 60 * 60 + 1); // 2/1/1970 and 1 second = friday |
|
1240 | 1240 | $this->assertEquals(5, $tmp['wday']); |
1241 | 1241 | |
1242 | 1242 | return true; |
@@ -1253,8 +1253,8 @@ discard block |
||
1253 | 1253 | global $conf, $langs; |
1254 | 1254 | $langs->load("main"); |
1255 | 1255 | |
1256 | - $substit=array("AAA"=>'Not used', "BBB"=>'Not used', "CCC"=>"C replaced"); |
|
1257 | - $chaine='This is a string with __[MAIN_THEME]__ and __(DIRECTION)__ and __CCC__'; |
|
1256 | + $substit = array("AAA"=>'Not used', "BBB"=>'Not used', "CCC"=>"C replaced"); |
|
1257 | + $chaine = 'This is a string with __[MAIN_THEME]__ and __(DIRECTION)__ and __CCC__'; |
|
1258 | 1258 | $newstring = make_substitutions($chaine, $substit); |
1259 | 1259 | $this->assertEquals($newstring, 'This is a string with eldy and ltr and __C replaced__'); |
1260 | 1260 |
@@ -30,16 +30,39 @@ |
||
30 | 30 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
31 | 31 | require_once dirname(__FILE__).'/../../htdocs/core/lib/date.lib.php'; |
32 | 32 | |
33 | -if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); |
|
34 | -if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); |
|
35 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
36 | -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); |
|
37 | -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); |
|
38 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); |
|
39 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show |
|
40 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php |
|
41 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
42 | -if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) |
|
33 | +if (! defined('NOREQUIREUSER')) { |
|
34 | + define('NOREQUIREUSER','1'); |
|
35 | +} |
|
36 | +if (! defined('NOREQUIREDB')) { |
|
37 | + define('NOREQUIREDB','1'); |
|
38 | +} |
|
39 | +if (! defined('NOREQUIRESOC')) { |
|
40 | + define('NOREQUIRESOC','1'); |
|
41 | +} |
|
42 | +if (! defined('NOREQUIRETRAN')) { |
|
43 | + define('NOREQUIRETRAN','1'); |
|
44 | +} |
|
45 | +if (! defined('NOCSRFCHECK')) { |
|
46 | + define('NOCSRFCHECK','1'); |
|
47 | +} |
|
48 | +if (! defined('NOTOKENRENEWAL')) { |
|
49 | + define('NOTOKENRENEWAL','1'); |
|
50 | +} |
|
51 | +if (! defined('NOREQUIREMENU')) { |
|
52 | + define('NOREQUIREMENU','1'); |
|
53 | +} |
|
54 | +// If there is no menu to show |
|
55 | +if (! defined('NOREQUIREHTML')) { |
|
56 | + define('NOREQUIREHTML','1'); |
|
57 | +} |
|
58 | +// If we don't need to load the html.form.class.php |
|
59 | +if (! defined('NOREQUIREAJAX')) { |
|
60 | + define('NOREQUIREAJAX','1'); |
|
61 | +} |
|
62 | +if (! defined("NOLOGIN")) { |
|
63 | + define("NOLOGIN",'1'); |
|
64 | +} |
|
65 | +// If this page is public (can be called outside logged session) |
|
43 | 66 | |
44 | 67 | /** |
45 | 68 | * Class for PHPUnit tests |
@@ -32,9 +32,9 @@ discard block |
||
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,123 +48,123 @@ discard block |
||
48 | 48 | */ |
49 | 49 | class GetUrlLibTest 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() |
|
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() |
|
80 | 80 | { |
81 | - global $conf,$user,$langs,$db; |
|
82 | - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
81 | + global $conf,$user,$langs,$db; |
|
82 | + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
83 | 83 | |
84 | - print __METHOD__."\n"; |
|
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 | * testGetRootURLFromURL |
124 | 124 | * |
125 | 125 | * @return int |
126 | 126 | */ |
127 | 127 | public function testGetRootURLFromURL() |
128 | 128 | { |
129 | - global $conf,$user,$langs,$db; |
|
130 | - $conf=$this->savconf; |
|
131 | - $user=$this->savuser; |
|
132 | - $langs=$this->savlangs; |
|
133 | - $db=$this->savdb; |
|
129 | + global $conf,$user,$langs,$db; |
|
130 | + $conf=$this->savconf; |
|
131 | + $user=$this->savuser; |
|
132 | + $langs=$this->savlangs; |
|
133 | + $db=$this->savdb; |
|
134 | 134 | |
135 | - $result=getRootURLFromURL('http://www.dolimed.com/screenshots/afile'); |
|
136 | - print __METHOD__." result=".$result."\n"; |
|
137 | - $this->assertEquals('http://www.dolimed.com',$result,'Test 1'); |
|
135 | + $result=getRootURLFromURL('http://www.dolimed.com/screenshots/afile'); |
|
136 | + print __METHOD__." result=".$result."\n"; |
|
137 | + $this->assertEquals('http://www.dolimed.com',$result,'Test 1'); |
|
138 | 138 | |
139 | - $result=getRootURLFromURL('https://www.dolimed.com/screenshots/afile'); |
|
140 | - print __METHOD__." result=".$result."\n"; |
|
141 | - $this->assertEquals('https://www.dolimed.com',$result,'Test 2'); |
|
139 | + $result=getRootURLFromURL('https://www.dolimed.com/screenshots/afile'); |
|
140 | + print __METHOD__." result=".$result."\n"; |
|
141 | + $this->assertEquals('https://www.dolimed.com',$result,'Test 2'); |
|
142 | 142 | |
143 | - $result=getRootURLFromURL('http://www.dolimed.com/screenshots'); |
|
144 | - print __METHOD__." result=".$result."\n"; |
|
145 | - $this->assertEquals('http://www.dolimed.com',$result); |
|
143 | + $result=getRootURLFromURL('http://www.dolimed.com/screenshots'); |
|
144 | + print __METHOD__." result=".$result."\n"; |
|
145 | + $this->assertEquals('http://www.dolimed.com',$result); |
|
146 | 146 | |
147 | - $result=getRootURLFromURL('https://www.dolimed.com/screenshots'); |
|
148 | - print __METHOD__." result=".$result."\n"; |
|
149 | - $this->assertEquals('https://www.dolimed.com',$result); |
|
147 | + $result=getRootURLFromURL('https://www.dolimed.com/screenshots'); |
|
148 | + print __METHOD__." result=".$result."\n"; |
|
149 | + $this->assertEquals('https://www.dolimed.com',$result); |
|
150 | 150 | |
151 | - $result=getRootURLFromURL('http://www.dolimed.com/'); |
|
152 | - print __METHOD__." result=".$result."\n"; |
|
153 | - $this->assertEquals('http://www.dolimed.com',$result); |
|
151 | + $result=getRootURLFromURL('http://www.dolimed.com/'); |
|
152 | + print __METHOD__." result=".$result."\n"; |
|
153 | + $this->assertEquals('http://www.dolimed.com',$result); |
|
154 | 154 | |
155 | - $result=getRootURLFromURL('https://www.dolimed.com/'); |
|
156 | - print __METHOD__." result=".$result."\n"; |
|
157 | - $this->assertEquals('https://www.dolimed.com',$result); |
|
155 | + $result=getRootURLFromURL('https://www.dolimed.com/'); |
|
156 | + print __METHOD__." result=".$result."\n"; |
|
157 | + $this->assertEquals('https://www.dolimed.com',$result); |
|
158 | 158 | |
159 | - $result=getRootURLFromURL('http://www.dolimed.com'); |
|
160 | - print __METHOD__." result=".$result."\n"; |
|
161 | - $this->assertEquals('http://www.dolimed.com',$result); |
|
159 | + $result=getRootURLFromURL('http://www.dolimed.com'); |
|
160 | + print __METHOD__." result=".$result."\n"; |
|
161 | + $this->assertEquals('http://www.dolimed.com',$result); |
|
162 | 162 | |
163 | - $result=getRootURLFromURL('https://www.dolimed.com'); |
|
164 | - print __METHOD__." result=".$result."\n"; |
|
165 | - $this->assertEquals('https://www.dolimed.com',$result); |
|
163 | + $result=getRootURLFromURL('https://www.dolimed.com'); |
|
164 | + print __METHOD__." result=".$result."\n"; |
|
165 | + $this->assertEquals('https://www.dolimed.com',$result); |
|
166 | 166 | |
167 | - return 1; |
|
167 | + return 1; |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | |
@@ -175,20 +175,20 @@ discard block |
||
175 | 175 | */ |
176 | 176 | public function testRemoveHtmlComment() |
177 | 177 | { |
178 | - global $conf,$user,$langs,$db; |
|
179 | - $conf=$this->savconf; |
|
180 | - $user=$this->savuser; |
|
181 | - $langs=$this->savlangs; |
|
182 | - $db=$this->savdb; |
|
178 | + global $conf,$user,$langs,$db; |
|
179 | + $conf=$this->savconf; |
|
180 | + $user=$this->savuser; |
|
181 | + $langs=$this->savlangs; |
|
182 | + $db=$this->savdb; |
|
183 | 183 | |
184 | - $result=removeHtmlComment('abc<!--[if lt IE 8]>aaaa<![endif]-->def'); |
|
185 | - print __METHOD__." result=".$result."\n"; |
|
186 | - $this->assertEquals('abcdef',$result,'Test 1'); |
|
184 | + $result=removeHtmlComment('abc<!--[if lt IE 8]>aaaa<![endif]-->def'); |
|
185 | + print __METHOD__." result=".$result."\n"; |
|
186 | + $this->assertEquals('abcdef',$result,'Test 1'); |
|
187 | 187 | |
188 | - $result=removeHtmlComment('abc<!--[if lt IE 8]>aa-->bb<!--aa<![endif]-->def'); |
|
189 | - print __METHOD__." result=".$result."\n"; |
|
190 | - $this->assertEquals('abcbbdef',$result,'Test 1'); |
|
188 | + $result=removeHtmlComment('abc<!--[if lt IE 8]>aa-->bb<!--aa<![endif]-->def'); |
|
189 | + print __METHOD__." result=".$result."\n"; |
|
190 | + $this->assertEquals('abcbbdef',$result,'Test 1'); |
|
191 | 191 | |
192 | - return 1; |
|
192 | + return 1; |
|
193 | 193 | } |
194 | 194 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * \remarks To run this script as CLI: phpunit filename.php |
25 | 25 | */ |
26 | 26 | |
27 | -global $conf,$user,$langs,$db; |
|
27 | +global $conf, $user, $langs, $db; |
|
28 | 28 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
29 | 29 | //require_once 'PHPUnit/Autoload.php'; |
30 | 30 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | $user->fetch(1); |
37 | 37 | $user->getrights(); |
38 | 38 | } |
39 | -$conf->global->MAIN_DISABLE_ALL_MAILS=1; |
|
39 | +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
|
40 | 40 | |
41 | 41 | |
42 | 42 | /** |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | parent::__construct(); |
65 | 65 | |
66 | 66 | //$this->sharedFixture |
67 | - global $conf,$user,$langs,$db; |
|
68 | - $this->savconf=$conf; |
|
69 | - $this->savuser=$user; |
|
70 | - $this->savlangs=$langs; |
|
71 | - $this->savdb=$db; |
|
67 | + global $conf, $user, $langs, $db; |
|
68 | + $this->savconf = $conf; |
|
69 | + $this->savuser = $user; |
|
70 | + $this->savlangs = $langs; |
|
71 | + $this->savdb = $db; |
|
72 | 72 | |
73 | 73 | print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
74 | 74 | //print " - db ".$db->db; |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | // Static methods |
79 | 79 | public static function setUpBeforeClass() |
80 | 80 | { |
81 | - global $conf,$user,$langs,$db; |
|
82 | - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
81 | + global $conf, $user, $langs, $db; |
|
82 | + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
83 | 83 | |
84 | 84 | print __METHOD__."\n"; |
85 | 85 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | // tear down after class |
88 | 88 | public static function tearDownAfterClass() |
89 | 89 | { |
90 | - global $conf,$user,$langs,$db; |
|
90 | + global $conf, $user, $langs, $db; |
|
91 | 91 | $db->rollback(); |
92 | 92 | |
93 | 93 | print __METHOD__."\n"; |
@@ -100,11 +100,11 @@ discard block |
||
100 | 100 | */ |
101 | 101 | protected function setUp() |
102 | 102 | { |
103 | - global $conf,$user,$langs,$db; |
|
104 | - $conf=$this->savconf; |
|
105 | - $user=$this->savuser; |
|
106 | - $langs=$this->savlangs; |
|
107 | - $db=$this->savdb; |
|
103 | + global $conf, $user, $langs, $db; |
|
104 | + $conf = $this->savconf; |
|
105 | + $user = $this->savuser; |
|
106 | + $langs = $this->savlangs; |
|
107 | + $db = $this->savdb; |
|
108 | 108 | |
109 | 109 | print __METHOD__."\n"; |
110 | 110 | } |
@@ -126,43 +126,43 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public function testGetRootURLFromURL() |
128 | 128 | { |
129 | - global $conf,$user,$langs,$db; |
|
130 | - $conf=$this->savconf; |
|
131 | - $user=$this->savuser; |
|
132 | - $langs=$this->savlangs; |
|
133 | - $db=$this->savdb; |
|
129 | + global $conf, $user, $langs, $db; |
|
130 | + $conf = $this->savconf; |
|
131 | + $user = $this->savuser; |
|
132 | + $langs = $this->savlangs; |
|
133 | + $db = $this->savdb; |
|
134 | 134 | |
135 | - $result=getRootURLFromURL('http://www.dolimed.com/screenshots/afile'); |
|
135 | + $result = getRootURLFromURL('http://www.dolimed.com/screenshots/afile'); |
|
136 | 136 | print __METHOD__." result=".$result."\n"; |
137 | - $this->assertEquals('http://www.dolimed.com',$result,'Test 1'); |
|
137 | + $this->assertEquals('http://www.dolimed.com', $result, 'Test 1'); |
|
138 | 138 | |
139 | - $result=getRootURLFromURL('https://www.dolimed.com/screenshots/afile'); |
|
139 | + $result = getRootURLFromURL('https://www.dolimed.com/screenshots/afile'); |
|
140 | 140 | print __METHOD__." result=".$result."\n"; |
141 | - $this->assertEquals('https://www.dolimed.com',$result,'Test 2'); |
|
141 | + $this->assertEquals('https://www.dolimed.com', $result, 'Test 2'); |
|
142 | 142 | |
143 | - $result=getRootURLFromURL('http://www.dolimed.com/screenshots'); |
|
143 | + $result = getRootURLFromURL('http://www.dolimed.com/screenshots'); |
|
144 | 144 | print __METHOD__." result=".$result."\n"; |
145 | - $this->assertEquals('http://www.dolimed.com',$result); |
|
145 | + $this->assertEquals('http://www.dolimed.com', $result); |
|
146 | 146 | |
147 | - $result=getRootURLFromURL('https://www.dolimed.com/screenshots'); |
|
147 | + $result = getRootURLFromURL('https://www.dolimed.com/screenshots'); |
|
148 | 148 | print __METHOD__." result=".$result."\n"; |
149 | - $this->assertEquals('https://www.dolimed.com',$result); |
|
149 | + $this->assertEquals('https://www.dolimed.com', $result); |
|
150 | 150 | |
151 | - $result=getRootURLFromURL('http://www.dolimed.com/'); |
|
151 | + $result = getRootURLFromURL('http://www.dolimed.com/'); |
|
152 | 152 | print __METHOD__." result=".$result."\n"; |
153 | - $this->assertEquals('http://www.dolimed.com',$result); |
|
153 | + $this->assertEquals('http://www.dolimed.com', $result); |
|
154 | 154 | |
155 | - $result=getRootURLFromURL('https://www.dolimed.com/'); |
|
155 | + $result = getRootURLFromURL('https://www.dolimed.com/'); |
|
156 | 156 | print __METHOD__." result=".$result."\n"; |
157 | - $this->assertEquals('https://www.dolimed.com',$result); |
|
157 | + $this->assertEquals('https://www.dolimed.com', $result); |
|
158 | 158 | |
159 | - $result=getRootURLFromURL('http://www.dolimed.com'); |
|
159 | + $result = getRootURLFromURL('http://www.dolimed.com'); |
|
160 | 160 | print __METHOD__." result=".$result."\n"; |
161 | - $this->assertEquals('http://www.dolimed.com',$result); |
|
161 | + $this->assertEquals('http://www.dolimed.com', $result); |
|
162 | 162 | |
163 | - $result=getRootURLFromURL('https://www.dolimed.com'); |
|
163 | + $result = getRootURLFromURL('https://www.dolimed.com'); |
|
164 | 164 | print __METHOD__." result=".$result."\n"; |
165 | - $this->assertEquals('https://www.dolimed.com',$result); |
|
165 | + $this->assertEquals('https://www.dolimed.com', $result); |
|
166 | 166 | |
167 | 167 | return 1; |
168 | 168 | } |
@@ -175,19 +175,19 @@ discard block |
||
175 | 175 | */ |
176 | 176 | public function testRemoveHtmlComment() |
177 | 177 | { |
178 | - global $conf,$user,$langs,$db; |
|
179 | - $conf=$this->savconf; |
|
180 | - $user=$this->savuser; |
|
181 | - $langs=$this->savlangs; |
|
182 | - $db=$this->savdb; |
|
178 | + global $conf, $user, $langs, $db; |
|
179 | + $conf = $this->savconf; |
|
180 | + $user = $this->savuser; |
|
181 | + $langs = $this->savlangs; |
|
182 | + $db = $this->savdb; |
|
183 | 183 | |
184 | - $result=removeHtmlComment('abc<!--[if lt IE 8]>aaaa<![endif]-->def'); |
|
184 | + $result = removeHtmlComment('abc<!--[if lt IE 8]>aaaa<![endif]-->def'); |
|
185 | 185 | print __METHOD__." result=".$result."\n"; |
186 | - $this->assertEquals('abcdef',$result,'Test 1'); |
|
186 | + $this->assertEquals('abcdef', $result, 'Test 1'); |
|
187 | 187 | |
188 | - $result=removeHtmlComment('abc<!--[if lt IE 8]>aa-->bb<!--aa<![endif]-->def'); |
|
188 | + $result = removeHtmlComment('abc<!--[if lt IE 8]>aa-->bb<!--aa<![endif]-->def'); |
|
189 | 189 | print __METHOD__." result=".$result."\n"; |
190 | - $this->assertEquals('abcbbdef',$result,'Test 1'); |
|
190 | + $this->assertEquals('abcbbdef', $result, 'Test 1'); |
|
191 | 191 | |
192 | 192 | return 1; |
193 | 193 | } |
@@ -23,12 +23,12 @@ discard block |
||
23 | 23 | * \remarks To run this script as CLI: phpunit filename.php |
24 | 24 | */ |
25 | 25 | |
26 | -global $conf,$user,$langs,$db; |
|
26 | +global $conf, $user, $langs, $db; |
|
27 | 27 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
28 | 28 | //require_once 'PHPUnit/Autoload.php'; |
29 | 29 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
30 | 30 | require_once dirname(__FILE__).'/../../htdocs/core/lib/date.lib.php'; |
31 | -require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP |
|
31 | +require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP |
|
32 | 32 | |
33 | 33 | |
34 | 34 | if (empty($user->id)) { |
@@ -36,9 +36,9 @@ discard block |
||
36 | 36 | $user->fetch(1); |
37 | 37 | $user->getrights(); |
38 | 38 | } |
39 | -$conf->global->MAIN_DISABLE_ALL_MAILS=1; |
|
39 | +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
|
40 | 40 | |
41 | -$conf->global->MAIN_UMASK='0666'; |
|
41 | +$conf->global->MAIN_UMASK = '0666'; |
|
42 | 42 | |
43 | 43 | |
44 | 44 | /** |
@@ -66,11 +66,11 @@ discard block |
||
66 | 66 | parent::__construct(); |
67 | 67 | |
68 | 68 | //$this->sharedFixture |
69 | - global $conf,$user,$langs,$db; |
|
70 | - $this->savconf=$conf; |
|
71 | - $this->savuser=$user; |
|
72 | - $this->savlangs=$langs; |
|
73 | - $this->savdb=$db; |
|
69 | + global $conf, $user, $langs, $db; |
|
70 | + $this->savconf = $conf; |
|
71 | + $this->savuser = $user; |
|
72 | + $this->savlangs = $langs; |
|
73 | + $this->savdb = $db; |
|
74 | 74 | |
75 | 75 | print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
76 | 76 | //print " - db ".$db->db; |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | // Static methods |
81 | 81 | public static function setUpBeforeClass() |
82 | 82 | { |
83 | - global $conf,$user,$langs,$db; |
|
83 | + global $conf, $user, $langs, $db; |
|
84 | 84 | $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
85 | 85 | |
86 | 86 | print __METHOD__."\n"; |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | // tear down after class |
90 | 90 | public static function tearDownAfterClass() |
91 | 91 | { |
92 | - global $conf,$user,$langs,$db; |
|
92 | + global $conf, $user, $langs, $db; |
|
93 | 93 | $db->rollback(); |
94 | 94 | |
95 | 95 | print __METHOD__."\n"; |
@@ -102,11 +102,11 @@ discard block |
||
102 | 102 | */ |
103 | 103 | protected function setUp() |
104 | 104 | { |
105 | - global $conf,$user,$langs,$db; |
|
106 | - $conf=$this->savconf; |
|
107 | - $user=$this->savuser; |
|
108 | - $langs=$this->savlangs; |
|
109 | - $db=$this->savdb; |
|
105 | + global $conf, $user, $langs, $db; |
|
106 | + $conf = $this->savconf; |
|
107 | + $user = $this->savuser; |
|
108 | + $langs = $this->savlangs; |
|
109 | + $db = $this->savdb; |
|
110 | 110 | |
111 | 111 | print __METHOD__."\n"; |
112 | 112 | } |
@@ -129,26 +129,26 @@ discard block |
||
129 | 129 | */ |
130 | 130 | public function testWSUserGetUser() |
131 | 131 | { |
132 | - global $conf,$user,$langs,$db; |
|
133 | - $conf=$this->savconf; |
|
134 | - $user=$this->savuser; |
|
135 | - $langs=$this->savlangs; |
|
136 | - $db=$this->savdb; |
|
132 | + global $conf, $user, $langs, $db; |
|
133 | + $conf = $this->savconf; |
|
134 | + $user = $this->savuser; |
|
135 | + $langs = $this->savlangs; |
|
136 | + $db = $this->savdb; |
|
137 | 137 | |
138 | 138 | $WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_user.php'; |
139 | 139 | $WS_METHOD = 'getUser'; |
140 | - $ns='http://www.dolibarr.org/ns/'; |
|
140 | + $ns = 'http://www.dolibarr.org/ns/'; |
|
141 | 141 | |
142 | 142 | // Set the WebService URL |
143 | 143 | print __METHOD__."Create nusoap_client for URL=".$WS_DOL_URL."\n"; |
144 | 144 | $soapclient = new nusoap_client($WS_DOL_URL); |
145 | 145 | if ($soapclient) { |
146 | - $soapclient->soap_defencoding='UTF-8'; |
|
146 | + $soapclient->soap_defencoding = 'UTF-8'; |
|
147 | 147 | $soapclient->decodeUTF8(false); |
148 | 148 | } |
149 | 149 | |
150 | 150 | // Call the WebService method and store its result in $result. |
151 | - $authentication=array( |
|
151 | + $authentication = array( |
|
152 | 152 | 'dolibarrkey'=>$conf->global->WEBSERVICES_KEY, |
153 | 153 | 'sourceapplication'=>'DEMO', |
154 | 154 | 'login'=>'admin', |
@@ -157,20 +157,20 @@ discard block |
||
157 | 157 | ); |
158 | 158 | |
159 | 159 | // Test URL |
160 | - $result=''; |
|
161 | - $parameters = array('authentication'=>$authentication,'id'=>0,'ref'=>'admin'); |
|
160 | + $result = ''; |
|
161 | + $parameters = array('authentication'=>$authentication, 'id'=>0, 'ref'=>'admin'); |
|
162 | 162 | print __METHOD__."Call method ".$WS_METHOD."\n"; |
163 | 163 | try { |
164 | - $result = $soapclient->call($WS_METHOD,$parameters,$ns,''); |
|
165 | - } catch(SoapFault $exception) { |
|
164 | + $result = $soapclient->call($WS_METHOD, $parameters, $ns, ''); |
|
165 | + } catch (SoapFault $exception) { |
|
166 | 166 | echo $exception; |
167 | - $result=0; |
|
167 | + $result = 0; |
|
168 | 168 | } |
169 | - if (! empty($result['faultstring'])) { |
|
169 | + if (!empty($result['faultstring'])) { |
|
170 | 170 | print $result['faultstring']."\n"; |
171 | - $result=0; |
|
171 | + $result = 0; |
|
172 | 172 | } |
173 | - if (! $result) { |
|
173 | + if (!$result) { |
|
174 | 174 | //var_dump($soapclient); |
175 | 175 | print $soapclient->error_str; |
176 | 176 | print "\n<br>\n"; |
@@ -184,16 +184,16 @@ discard block |
||
184 | 184 | $this->assertEquals('OK', $result['result']['result_code'], 'Test on ref admin'); |
185 | 185 | |
186 | 186 | // Test URL |
187 | - $result=''; |
|
188 | - $parameters = array('authentication'=>$authentication,'id'=>0,'ref'=>'refthatdoesnotexists'); |
|
187 | + $result = ''; |
|
188 | + $parameters = array('authentication'=>$authentication, 'id'=>0, 'ref'=>'refthatdoesnotexists'); |
|
189 | 189 | print __METHOD__."Call method ".$WS_METHOD."\n"; |
190 | 190 | try { |
191 | - $result = $soapclient->call($WS_METHOD,$parameters,$ns,''); |
|
192 | - } catch(SoapFault $exception) { |
|
191 | + $result = $soapclient->call($WS_METHOD, $parameters, $ns, ''); |
|
192 | + } catch (SoapFault $exception) { |
|
193 | 193 | echo $exception; |
194 | - $result=0; |
|
194 | + $result = 0; |
|
195 | 195 | } |
196 | - if (! $result || ! empty($result['faultstring'])) { |
|
196 | + if (!$result || !empty($result['faultstring'])) { |
|
197 | 197 | //var_dump($soapclient); |
198 | 198 | print $soapclient->error_str; |
199 | 199 | print "\n<br>\n"; |
@@ -59,9 +59,9 @@ discard block |
||
59 | 59 | */ |
60 | 60 | function __construct() |
61 | 61 | { |
62 | - parent::__construct(); |
|
62 | + parent::__construct(); |
|
63 | 63 | |
64 | - //$this->sharedFixture |
|
64 | + //$this->sharedFixture |
|
65 | 65 | global $conf,$user,$langs,$db; |
66 | 66 | $this->savconf=$conf; |
67 | 67 | $this->savuser=$user; |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * Init phpunit tests |
96 | 96 | * |
97 | 97 | * @return void |
98 | - */ |
|
98 | + */ |
|
99 | 99 | protected function setUp() |
100 | 100 | { |
101 | 101 | global $conf,$user,$langs,$db; |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | |
45 | 45 | if (empty($conf->service->enabled)) |
46 | 46 | { |
47 | - print "Error: Module service must be enabled.\n"; |
|
48 | - exit(1); |
|
47 | + print "Error: Module service must be enabled.\n"; |
|
48 | + exit(1); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | */ |
71 | 71 | function __construct() |
72 | 72 | { |
73 | - parent::__construct(); |
|
73 | + parent::__construct(); |
|
74 | 74 | |
75 | - //$this->sharedFixture |
|
75 | + //$this->sharedFixture |
|
76 | 76 | global $conf,$user,$langs,$db; |
77 | 77 | $this->savconf=$conf; |
78 | 78 | $this->savuser=$user; |
@@ -25,12 +25,12 @@ discard block |
||
25 | 25 | * \remarks To run this script as CLI: phpunit filename.php |
26 | 26 | */ |
27 | 27 | |
28 | -global $conf,$user,$langs,$db; |
|
28 | +global $conf, $user, $langs, $db; |
|
29 | 29 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
30 | 30 | //require_once 'PHPUnit/Autoload.php'; |
31 | 31 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
32 | 32 | require_once dirname(__FILE__).'/../../htdocs/core/lib/date.lib.php'; |
33 | -require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP |
|
33 | +require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP |
|
34 | 34 | |
35 | 35 | |
36 | 36 | if (empty($user->id)) { |
@@ -38,9 +38,9 @@ discard block |
||
38 | 38 | $user->fetch(1); |
39 | 39 | $user->getrights(); |
40 | 40 | } |
41 | -$conf->global->MAIN_DISABLE_ALL_MAILS=1; |
|
41 | +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
|
42 | 42 | |
43 | -$conf->global->MAIN_UMASK='0666'; |
|
43 | +$conf->global->MAIN_UMASK = '0666'; |
|
44 | 44 | |
45 | 45 | if (empty($conf->service->enabled)) |
46 | 46 | { |
@@ -73,11 +73,11 @@ discard block |
||
73 | 73 | parent::__construct(); |
74 | 74 | |
75 | 75 | //$this->sharedFixture |
76 | - global $conf,$user,$langs,$db; |
|
77 | - $this->savconf=$conf; |
|
78 | - $this->savuser=$user; |
|
79 | - $this->savlangs=$langs; |
|
80 | - $this->savdb=$db; |
|
76 | + global $conf, $user, $langs, $db; |
|
77 | + $this->savconf = $conf; |
|
78 | + $this->savuser = $user; |
|
79 | + $this->savlangs = $langs; |
|
80 | + $this->savdb = $db; |
|
81 | 81 | |
82 | 82 | print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
83 | 83 | //print " - db ".$db->db; |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | // Static methods |
88 | 88 | public static function setUpBeforeClass() |
89 | 89 | { |
90 | - global $conf,$user,$langs,$db; |
|
90 | + global $conf, $user, $langs, $db; |
|
91 | 91 | $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
92 | 92 | |
93 | 93 | print __METHOD__."\n"; |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | // tear down after class |
96 | 96 | public static function tearDownAfterClass() |
97 | 97 | { |
98 | - global $conf,$user,$langs,$db; |
|
98 | + global $conf, $user, $langs, $db; |
|
99 | 99 | $db->rollback(); |
100 | 100 | |
101 | 101 | print __METHOD__."\n"; |
@@ -108,11 +108,11 @@ discard block |
||
108 | 108 | */ |
109 | 109 | protected function setUp() |
110 | 110 | { |
111 | - global $conf,$user,$langs,$db; |
|
112 | - $conf=$this->savconf; |
|
113 | - $user=$this->savuser; |
|
114 | - $langs=$this->savlangs; |
|
115 | - $db=$this->savdb; |
|
111 | + global $conf, $user, $langs, $db; |
|
112 | + $conf = $this->savconf; |
|
113 | + $user = $this->savuser; |
|
114 | + $langs = $this->savlangs; |
|
115 | + $db = $this->savdb; |
|
116 | 116 | |
117 | 117 | print __METHOD__."\n"; |
118 | 118 | } |
@@ -135,28 +135,28 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public function testWSProductsCreateProductOrService() |
137 | 137 | { |
138 | - global $conf,$user,$langs,$db; |
|
139 | - $conf=$this->savconf; |
|
140 | - $user=$this->savuser; |
|
141 | - $langs=$this->savlangs; |
|
142 | - $db=$this->savdb; |
|
138 | + global $conf, $user, $langs, $db; |
|
139 | + $conf = $this->savconf; |
|
140 | + $user = $this->savuser; |
|
141 | + $langs = $this->savlangs; |
|
142 | + $db = $this->savdb; |
|
143 | 143 | |
144 | - $datestring=dol_print_date(dol_now(),'dayhourlog'); |
|
144 | + $datestring = dol_print_date(dol_now(), 'dayhourlog'); |
|
145 | 145 | |
146 | 146 | $WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_productorservice.php'; |
147 | 147 | $WS_METHOD = 'createProductOrService'; |
148 | - $ns='http://www.dolibarr.org/ns/'; |
|
148 | + $ns = 'http://www.dolibarr.org/ns/'; |
|
149 | 149 | |
150 | 150 | // Set the WebService URL |
151 | 151 | print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n"; |
152 | 152 | $soapclient = new nusoap_client($WS_DOL_URL); |
153 | 153 | if ($soapclient) { |
154 | - $soapclient->soap_defencoding='UTF-8'; |
|
154 | + $soapclient->soap_defencoding = 'UTF-8'; |
|
155 | 155 | $soapclient->decodeUTF8(false); |
156 | 156 | } |
157 | 157 | |
158 | 158 | // Call the WebService method and store its result in $result. |
159 | - $authentication=array( |
|
159 | + $authentication = array( |
|
160 | 160 | 'dolibarrkey'=>$conf->global->WEBSERVICES_KEY, |
161 | 161 | 'sourceapplication'=>'DEMO', |
162 | 162 | 'login'=>'admin', |
@@ -165,9 +165,9 @@ discard block |
||
165 | 165 | ); |
166 | 166 | |
167 | 167 | // Test URL |
168 | - $result=''; |
|
168 | + $result = ''; |
|
169 | 169 | $parameters = array( |
170 | - 'authentication'=>$authentication,'product'=>array( |
|
170 | + 'authentication'=>$authentication, 'product'=>array( |
|
171 | 171 | 'ref'=>'NewProductFromWS'.$datestring, |
172 | 172 | 'label'=>'New Product From WS '.$datestring, |
173 | 173 | 'type'=>1, |
@@ -178,12 +178,12 @@ discard block |
||
178 | 178 | ); |
179 | 179 | print __METHOD__." call method ".$WS_METHOD."\n"; |
180 | 180 | try { |
181 | - $result = $soapclient->call($WS_METHOD,$parameters,$ns,''); |
|
182 | - } catch(SoapFault $exception) { |
|
181 | + $result = $soapclient->call($WS_METHOD, $parameters, $ns, ''); |
|
182 | + } catch (SoapFault $exception) { |
|
183 | 183 | echo $exception; |
184 | - $result=0; |
|
184 | + $result = 0; |
|
185 | 185 | } |
186 | - if (! $result || ! empty($result['faultstring']) || $result['result']['result_code'] != 'OK') { |
|
186 | + if (!$result || !empty($result['faultstring']) || $result['result']['result_code'] != 'OK') { |
|
187 | 187 | //var_dump($soapclient); |
188 | 188 | print $soapclient->error_str; |
189 | 189 | print "\n<br>\n"; |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | } |
195 | 195 | |
196 | 196 | print __METHOD__." result=".$result."\n"; |
197 | - $this->assertEquals('OK',$result['result']['result_code']); |
|
197 | + $this->assertEquals('OK', $result['result']['result_code']); |
|
198 | 198 | |
199 | 199 | return $result['id']; |
200 | 200 | } |
@@ -209,26 +209,26 @@ discard block |
||
209 | 209 | */ |
210 | 210 | public function testWSProductsGetProductOrService($id) |
211 | 211 | { |
212 | - global $conf,$user,$langs,$db; |
|
213 | - $conf=$this->savconf; |
|
214 | - $user=$this->savuser; |
|
215 | - $langs=$this->savlangs; |
|
216 | - $db=$this->savdb; |
|
212 | + global $conf, $user, $langs, $db; |
|
213 | + $conf = $this->savconf; |
|
214 | + $user = $this->savuser; |
|
215 | + $langs = $this->savlangs; |
|
216 | + $db = $this->savdb; |
|
217 | 217 | |
218 | 218 | $WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_productorservice.php'; |
219 | 219 | $WS_METHOD = 'getProductOrService'; |
220 | - $ns='http://www.dolibarr.org/ns/'; |
|
220 | + $ns = 'http://www.dolibarr.org/ns/'; |
|
221 | 221 | |
222 | 222 | // Set the WebService URL |
223 | 223 | print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n"; |
224 | 224 | $soapclient = new nusoap_client($WS_DOL_URL); |
225 | 225 | if ($soapclient) { |
226 | - $soapclient->soap_defencoding='UTF-8'; |
|
226 | + $soapclient->soap_defencoding = 'UTF-8'; |
|
227 | 227 | $soapclient->decodeUTF8(false); |
228 | 228 | } |
229 | 229 | |
230 | 230 | // Call the WebService method and store its result in $result. |
231 | - $authentication=array( |
|
231 | + $authentication = array( |
|
232 | 232 | 'dolibarrkey'=>$conf->global->WEBSERVICES_KEY, |
233 | 233 | 'sourceapplication'=>'DEMO', |
234 | 234 | 'login'=>'admin', |
@@ -237,16 +237,16 @@ discard block |
||
237 | 237 | ); |
238 | 238 | |
239 | 239 | // Test URL |
240 | - $result=''; |
|
241 | - $parameters = array('authentication'=>$authentication,'id'=>$id,'ref'=>''); |
|
240 | + $result = ''; |
|
241 | + $parameters = array('authentication'=>$authentication, 'id'=>$id, 'ref'=>''); |
|
242 | 242 | print __METHOD__." call method ".$WS_METHOD."\n"; |
243 | 243 | try { |
244 | - $result = $soapclient->call($WS_METHOD,$parameters,$ns,''); |
|
245 | - } catch(SoapFault $exception) { |
|
244 | + $result = $soapclient->call($WS_METHOD, $parameters, $ns, ''); |
|
245 | + } catch (SoapFault $exception) { |
|
246 | 246 | echo $exception; |
247 | - $result=0; |
|
247 | + $result = 0; |
|
248 | 248 | } |
249 | - if (! $result || ! empty($result['faultstring'])) { |
|
249 | + if (!$result || !empty($result['faultstring'])) { |
|
250 | 250 | //var_dump($soapclient); |
251 | 251 | print $soapclient->error_str; |
252 | 252 | print "\n<br>\n"; |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | } |
258 | 258 | |
259 | 259 | print __METHOD__." result=".$result."\n"; |
260 | - $this->assertEquals('OK',$result['result']['result_code']); |
|
260 | + $this->assertEquals('OK', $result['result']['result_code']); |
|
261 | 261 | |
262 | 262 | return $id; |
263 | 263 | } |
@@ -272,26 +272,26 @@ discard block |
||
272 | 272 | */ |
273 | 273 | public function testWSProductsDeleteProductOrService($id) |
274 | 274 | { |
275 | - global $conf,$user,$langs,$db; |
|
276 | - $conf=$this->savconf; |
|
277 | - $user=$this->savuser; |
|
278 | - $langs=$this->savlangs; |
|
279 | - $db=$this->savdb; |
|
275 | + global $conf, $user, $langs, $db; |
|
276 | + $conf = $this->savconf; |
|
277 | + $user = $this->savuser; |
|
278 | + $langs = $this->savlangs; |
|
279 | + $db = $this->savdb; |
|
280 | 280 | |
281 | 281 | $WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_productorservice.php'; |
282 | 282 | $WS_METHOD = 'deleteProductOrService'; |
283 | - $ns='http://www.dolibarr.org/ns/'; |
|
283 | + $ns = 'http://www.dolibarr.org/ns/'; |
|
284 | 284 | |
285 | 285 | // Set the WebService URL |
286 | 286 | print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n"; |
287 | 287 | $soapclient = new nusoap_client($WS_DOL_URL); |
288 | 288 | if ($soapclient) { |
289 | - $soapclient->soap_defencoding='UTF-8'; |
|
289 | + $soapclient->soap_defencoding = 'UTF-8'; |
|
290 | 290 | $soapclient->decodeUTF8(false); |
291 | 291 | } |
292 | 292 | |
293 | 293 | // Call the WebService method and store its result in $result. |
294 | - $authentication=array( |
|
294 | + $authentication = array( |
|
295 | 295 | 'dolibarrkey'=>$conf->global->WEBSERVICES_KEY, |
296 | 296 | 'sourceapplication'=>'DEMO', |
297 | 297 | 'login'=>'admin', |
@@ -300,16 +300,16 @@ discard block |
||
300 | 300 | ); |
301 | 301 | |
302 | 302 | // Test URL |
303 | - $result=''; |
|
304 | - $parameters = array('authentication'=>$authentication,'listofid'=>$id); |
|
303 | + $result = ''; |
|
304 | + $parameters = array('authentication'=>$authentication, 'listofid'=>$id); |
|
305 | 305 | print __METHOD__." call method ".$WS_METHOD."\n"; |
306 | 306 | try { |
307 | - $result = $soapclient->call($WS_METHOD,$parameters,$ns,''); |
|
308 | - } catch(SoapFault $exception) { |
|
307 | + $result = $soapclient->call($WS_METHOD, $parameters, $ns, ''); |
|
308 | + } catch (SoapFault $exception) { |
|
309 | 309 | echo $exception; |
310 | - $result=0; |
|
310 | + $result = 0; |
|
311 | 311 | } |
312 | - if (! $result || ! empty($result['faultstring']) || $result['result']['result_code'] != 'OK') { |
|
312 | + if (!$result || !empty($result['faultstring']) || $result['result']['result_code'] != 'OK') { |
|
313 | 313 | //var_dump($soapclient); |
314 | 314 | print $soapclient->error_str; |
315 | 315 | print "\n<br>\n"; |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | } |
321 | 321 | |
322 | 322 | print __METHOD__." result=".$result."\n"; |
323 | - $this->assertEquals('OK',$result['result']['result_code']); |
|
323 | + $this->assertEquals('OK', $result['result']['result_code']); |
|
324 | 324 | |
325 | 325 | return 0; |
326 | 326 | } |
@@ -31,9 +31,9 @@ discard block |
||
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 |
||
47 | 47 | */ |
48 | 48 | class ChargeSocialesTest 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 ChargeSocialesTest |
|
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 ChargeSocialesTest |
|
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; |
|
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,19 +124,19 @@ discard block |
||
124 | 124 | */ |
125 | 125 | public function testChargeSocialesCreate() |
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 | - $localobject=new ChargeSociales($this->savdb); |
|
134 | - $localobject->initAsSpecimen(); |
|
135 | - $result=$localobject->create($user,$langs,$conf); |
|
136 | - print __METHOD__." result=".$result."\n"; |
|
137 | - |
|
138 | - $this->assertLessThan($result, 0); |
|
139 | - return $result; |
|
127 | + global $conf,$user,$langs,$db; |
|
128 | + $conf=$this->savconf; |
|
129 | + $user=$this->savuser; |
|
130 | + $langs=$this->savlangs; |
|
131 | + $db=$this->savdb; |
|
132 | + |
|
133 | + $localobject=new ChargeSociales($this->savdb); |
|
134 | + $localobject->initAsSpecimen(); |
|
135 | + $result=$localobject->create($user,$langs,$conf); |
|
136 | + print __METHOD__." result=".$result."\n"; |
|
137 | + |
|
138 | + $this->assertLessThan($result, 0); |
|
139 | + return $result; |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
@@ -150,18 +150,18 @@ discard block |
||
150 | 150 | */ |
151 | 151 | public function testChargeSocialesFetch($id) |
152 | 152 | { |
153 | - global $conf,$user,$langs,$db; |
|
154 | - $conf=$this->savconf; |
|
155 | - $user=$this->savuser; |
|
156 | - $langs=$this->savlangs; |
|
157 | - $db=$this->savdb; |
|
158 | - |
|
159 | - $localobject=new ChargeSociales($this->savdb); |
|
160 | - $result=$localobject->fetch($id); |
|
161 | - print __METHOD__." id=".$id." result=".$result."\n"; |
|
162 | - |
|
163 | - $this->assertLessThan($result, 0); |
|
164 | - return $localobject; |
|
153 | + global $conf,$user,$langs,$db; |
|
154 | + $conf=$this->savconf; |
|
155 | + $user=$this->savuser; |
|
156 | + $langs=$this->savlangs; |
|
157 | + $db=$this->savdb; |
|
158 | + |
|
159 | + $localobject=new ChargeSociales($this->savdb); |
|
160 | + $result=$localobject->fetch($id); |
|
161 | + print __METHOD__." id=".$id." result=".$result."\n"; |
|
162 | + |
|
163 | + $this->assertLessThan($result, 0); |
|
164 | + return $localobject; |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -175,17 +175,17 @@ discard block |
||
175 | 175 | */ |
176 | 176 | public function testChargeSocialesValid($localobject) |
177 | 177 | { |
178 | - global $conf,$user,$langs,$db; |
|
179 | - $conf=$this->savconf; |
|
180 | - $user=$this->savuser; |
|
181 | - $langs=$this->savlangs; |
|
182 | - $db=$this->savdb; |
|
178 | + global $conf,$user,$langs,$db; |
|
179 | + $conf=$this->savconf; |
|
180 | + $user=$this->savuser; |
|
181 | + $langs=$this->savlangs; |
|
182 | + $db=$this->savdb; |
|
183 | 183 | |
184 | - $result=$localobject->set_paid($user); |
|
185 | - print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
184 | + $result=$localobject->set_paid($user); |
|
185 | + print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
186 | 186 | |
187 | - $this->assertLessThan($result, 0); |
|
188 | - return $localobject; |
|
187 | + $this->assertLessThan($result, 0); |
|
188 | + return $localobject; |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
214 | 214 | $this->assertLessThanOrEqual($result, 0); |
215 | 215 | |
216 | - return $localobject->id; |
|
216 | + return $localobject->id; |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | /** |
@@ -227,18 +227,18 @@ discard block |
||
227 | 227 | */ |
228 | 228 | public function testChargeSocialesDelete($id) |
229 | 229 | { |
230 | - global $conf,$user,$langs,$db; |
|
231 | - $conf=$this->savconf; |
|
232 | - $user=$this->savuser; |
|
233 | - $langs=$this->savlangs; |
|
234 | - $db=$this->savdb; |
|
235 | - |
|
236 | - $localobject=new ChargeSociales($this->savdb); |
|
237 | - $result=$localobject->fetch($id); |
|
238 | - $result=$localobject->delete($id); |
|
239 | - |
|
240 | - print __METHOD__." id=".$id." result=".$result."\n"; |
|
241 | - $this->assertLessThan($result, 0); |
|
242 | - return $result; |
|
230 | + global $conf,$user,$langs,$db; |
|
231 | + $conf=$this->savconf; |
|
232 | + $user=$this->savuser; |
|
233 | + $langs=$this->savlangs; |
|
234 | + $db=$this->savdb; |
|
235 | + |
|
236 | + $localobject=new ChargeSociales($this->savdb); |
|
237 | + $result=$localobject->fetch($id); |
|
238 | + $result=$localobject->delete($id); |
|
239 | + |
|
240 | + print __METHOD__." id=".$id." result=".$result."\n"; |
|
241 | + $this->assertLessThan($result, 0); |
|
242 | + return $result; |
|
243 | 243 | } |
244 | 244 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * \remarks To run this script as CLI: phpunit filename.php |
24 | 24 | */ |
25 | 25 | |
26 | -global $conf,$user,$langs,$db; |
|
26 | +global $conf, $user, $langs, $db; |
|
27 | 27 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
28 | 28 | //require_once 'PHPUnit/Autoload.php'; |
29 | 29 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | $user->fetch(1); |
36 | 36 | $user->getrights(); |
37 | 37 | } |
38 | -$conf->global->MAIN_DISABLE_ALL_MAILS=1; |
|
38 | +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
|
39 | 39 | |
40 | 40 | |
41 | 41 | /** |
@@ -63,11 +63,11 @@ discard block |
||
63 | 63 | parent::__construct(); |
64 | 64 | |
65 | 65 | //$this->sharedFixture |
66 | - global $conf,$user,$langs,$db; |
|
67 | - $this->savconf=$conf; |
|
68 | - $this->savuser=$user; |
|
69 | - $this->savlangs=$langs; |
|
70 | - $this->savdb=$db; |
|
66 | + global $conf, $user, $langs, $db; |
|
67 | + $this->savconf = $conf; |
|
68 | + $this->savuser = $user; |
|
69 | + $this->savlangs = $langs; |
|
70 | + $this->savdb = $db; |
|
71 | 71 | |
72 | 72 | print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
73 | 73 | //print " - db ".$db->db; |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | // Static methods |
78 | 78 | public static function setUpBeforeClass() |
79 | 79 | { |
80 | - global $conf,$user,$langs,$db; |
|
81 | - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
80 | + global $conf, $user, $langs, $db; |
|
81 | + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
82 | 82 | |
83 | 83 | print __METHOD__."\n"; |
84 | 84 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | // tear down after class |
87 | 87 | public static function tearDownAfterClass() |
88 | 88 | { |
89 | - global $conf,$user,$langs,$db; |
|
89 | + global $conf, $user, $langs, $db; |
|
90 | 90 | $db->rollback(); |
91 | 91 | |
92 | 92 | print __METHOD__."\n"; |
@@ -99,11 +99,11 @@ discard block |
||
99 | 99 | */ |
100 | 100 | protected function setUp() |
101 | 101 | { |
102 | - global $conf,$user,$langs,$db; |
|
103 | - $conf=$this->savconf; |
|
104 | - $user=$this->savuser; |
|
105 | - $langs=$this->savlangs; |
|
106 | - $db=$this->savdb; |
|
102 | + global $conf, $user, $langs, $db; |
|
103 | + $conf = $this->savconf; |
|
104 | + $user = $this->savuser; |
|
105 | + $langs = $this->savlangs; |
|
106 | + $db = $this->savdb; |
|
107 | 107 | |
108 | 108 | print __METHOD__."\n"; |
109 | 109 | } |
@@ -124,15 +124,15 @@ discard block |
||
124 | 124 | */ |
125 | 125 | public function testChargeSocialesCreate() |
126 | 126 | { |
127 | - global $conf,$user,$langs,$db; |
|
128 | - $conf=$this->savconf; |
|
129 | - $user=$this->savuser; |
|
130 | - $langs=$this->savlangs; |
|
131 | - $db=$this->savdb; |
|
127 | + global $conf, $user, $langs, $db; |
|
128 | + $conf = $this->savconf; |
|
129 | + $user = $this->savuser; |
|
130 | + $langs = $this->savlangs; |
|
131 | + $db = $this->savdb; |
|
132 | 132 | |
133 | - $localobject=new ChargeSociales($this->savdb); |
|
133 | + $localobject = new ChargeSociales($this->savdb); |
|
134 | 134 | $localobject->initAsSpecimen(); |
135 | - $result=$localobject->create($user,$langs,$conf); |
|
135 | + $result = $localobject->create($user, $langs, $conf); |
|
136 | 136 | print __METHOD__." result=".$result."\n"; |
137 | 137 | |
138 | 138 | $this->assertLessThan($result, 0); |
@@ -150,14 +150,14 @@ discard block |
||
150 | 150 | */ |
151 | 151 | public function testChargeSocialesFetch($id) |
152 | 152 | { |
153 | - global $conf,$user,$langs,$db; |
|
154 | - $conf=$this->savconf; |
|
155 | - $user=$this->savuser; |
|
156 | - $langs=$this->savlangs; |
|
157 | - $db=$this->savdb; |
|
158 | - |
|
159 | - $localobject=new ChargeSociales($this->savdb); |
|
160 | - $result=$localobject->fetch($id); |
|
153 | + global $conf, $user, $langs, $db; |
|
154 | + $conf = $this->savconf; |
|
155 | + $user = $this->savuser; |
|
156 | + $langs = $this->savlangs; |
|
157 | + $db = $this->savdb; |
|
158 | + |
|
159 | + $localobject = new ChargeSociales($this->savdb); |
|
160 | + $result = $localobject->fetch($id); |
|
161 | 161 | print __METHOD__." id=".$id." result=".$result."\n"; |
162 | 162 | |
163 | 163 | $this->assertLessThan($result, 0); |
@@ -175,13 +175,13 @@ discard block |
||
175 | 175 | */ |
176 | 176 | public function testChargeSocialesValid($localobject) |
177 | 177 | { |
178 | - global $conf,$user,$langs,$db; |
|
179 | - $conf=$this->savconf; |
|
180 | - $user=$this->savuser; |
|
181 | - $langs=$this->savlangs; |
|
182 | - $db=$this->savdb; |
|
178 | + global $conf, $user, $langs, $db; |
|
179 | + $conf = $this->savconf; |
|
180 | + $user = $this->savuser; |
|
181 | + $langs = $this->savlangs; |
|
182 | + $db = $this->savdb; |
|
183 | 183 | |
184 | - $result=$localobject->set_paid($user); |
|
184 | + $result = $localobject->set_paid($user); |
|
185 | 185 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
186 | 186 | |
187 | 187 | $this->assertLessThan($result, 0); |
@@ -199,17 +199,17 @@ discard block |
||
199 | 199 | */ |
200 | 200 | public function testChargeSocialesOther($localobject) |
201 | 201 | { |
202 | - global $conf,$user,$langs,$db; |
|
203 | - $conf=$this->savconf; |
|
204 | - $user=$this->savuser; |
|
205 | - $langs=$this->savlangs; |
|
206 | - $db=$this->savdb; |
|
202 | + global $conf, $user, $langs, $db; |
|
203 | + $conf = $this->savconf; |
|
204 | + $user = $this->savuser; |
|
205 | + $langs = $this->savlangs; |
|
206 | + $db = $this->savdb; |
|
207 | 207 | |
208 | - $result=$localobject->getNomUrl(1); |
|
208 | + $result = $localobject->getNomUrl(1); |
|
209 | 209 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
210 | 210 | $this->assertNotEquals($result, ''); |
211 | 211 | |
212 | - $result=$localobject->getSommePaiement(); |
|
212 | + $result = $localobject->getSommePaiement(); |
|
213 | 213 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
214 | 214 | $this->assertLessThanOrEqual($result, 0); |
215 | 215 | |
@@ -227,15 +227,15 @@ discard block |
||
227 | 227 | */ |
228 | 228 | public function testChargeSocialesDelete($id) |
229 | 229 | { |
230 | - global $conf,$user,$langs,$db; |
|
231 | - $conf=$this->savconf; |
|
232 | - $user=$this->savuser; |
|
233 | - $langs=$this->savlangs; |
|
234 | - $db=$this->savdb; |
|
235 | - |
|
236 | - $localobject=new ChargeSociales($this->savdb); |
|
237 | - $result=$localobject->fetch($id); |
|
238 | - $result=$localobject->delete($id); |
|
230 | + global $conf, $user, $langs, $db; |
|
231 | + $conf = $this->savconf; |
|
232 | + $user = $this->savuser; |
|
233 | + $langs = $this->savlangs; |
|
234 | + $db = $this->savdb; |
|
235 | + |
|
236 | + $localobject = new ChargeSociales($this->savdb); |
|
237 | + $result = $localobject->fetch($id); |
|
238 | + $result = $localobject->delete($id); |
|
239 | 239 | |
240 | 240 | print __METHOD__." id=".$id." result=".$result."\n"; |
241 | 241 | $this->assertLessThan($result, 0); |
@@ -59,75 +59,75 @@ discard block |
||
59 | 59 | */ |
60 | 60 | class ScriptsTest extends PHPUnit_Framework_TestCase |
61 | 61 | { |
62 | - protected $savconf; |
|
63 | - protected $savuser; |
|
64 | - protected $savlangs; |
|
65 | - protected $savdb; |
|
66 | - |
|
67 | - /** |
|
68 | - * Constructor |
|
69 | - * We save global variables into local variables |
|
70 | - * |
|
71 | - * @return SecurityTest |
|
72 | - */ |
|
73 | - function __construct() |
|
74 | - { |
|
75 | - parent::__construct(); |
|
76 | - |
|
77 | - //$this->sharedFixture |
|
78 | - global $conf,$user,$langs,$db; |
|
79 | - $this->savconf=$conf; |
|
80 | - $this->savuser=$user; |
|
81 | - $this->savlangs=$langs; |
|
82 | - $this->savdb=$db; |
|
83 | - |
|
84 | - print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
|
85 | - //print " - db ".$db->db; |
|
86 | - print "\n"; |
|
87 | - } |
|
88 | - |
|
89 | - // Static methods |
|
90 | - public static function setUpBeforeClass() |
|
62 | + protected $savconf; |
|
63 | + protected $savuser; |
|
64 | + protected $savlangs; |
|
65 | + protected $savdb; |
|
66 | + |
|
67 | + /** |
|
68 | + * Constructor |
|
69 | + * We save global variables into local variables |
|
70 | + * |
|
71 | + * @return SecurityTest |
|
72 | + */ |
|
73 | + function __construct() |
|
74 | + { |
|
75 | + parent::__construct(); |
|
76 | + |
|
77 | + //$this->sharedFixture |
|
78 | + global $conf,$user,$langs,$db; |
|
79 | + $this->savconf=$conf; |
|
80 | + $this->savuser=$user; |
|
81 | + $this->savlangs=$langs; |
|
82 | + $this->savdb=$db; |
|
83 | + |
|
84 | + print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
|
85 | + //print " - db ".$db->db; |
|
86 | + print "\n"; |
|
87 | + } |
|
88 | + |
|
89 | + // Static methods |
|
90 | + public static function setUpBeforeClass() |
|
91 | 91 | { |
92 | - global $conf,$user,$langs,$db; |
|
93 | - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
92 | + global $conf,$user,$langs,$db; |
|
93 | + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
94 | 94 | |
95 | - print __METHOD__."\n"; |
|
95 | + print __METHOD__."\n"; |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | // tear down after class |
99 | 99 | public static function tearDownAfterClass() |
100 | 100 | { |
101 | - global $conf,$user,$langs,$db; |
|
102 | - $db->rollback(); |
|
101 | + global $conf,$user,$langs,$db; |
|
102 | + $db->rollback(); |
|
103 | 103 | |
104 | - print __METHOD__."\n"; |
|
104 | + print __METHOD__."\n"; |
|
105 | 105 | } |
106 | 106 | |
107 | - /** |
|
108 | - * Init phpunit tests |
|
109 | - * |
|
110 | - * @return void |
|
111 | - */ |
|
107 | + /** |
|
108 | + * Init phpunit tests |
|
109 | + * |
|
110 | + * @return void |
|
111 | + */ |
|
112 | 112 | protected function setUp() |
113 | 113 | { |
114 | - global $conf,$user,$langs,$db; |
|
115 | - $conf=$this->savconf; |
|
116 | - $user=$this->savuser; |
|
117 | - $langs=$this->savlangs; |
|
118 | - $db=$this->savdb; |
|
114 | + global $conf,$user,$langs,$db; |
|
115 | + $conf=$this->savconf; |
|
116 | + $user=$this->savuser; |
|
117 | + $langs=$this->savlangs; |
|
118 | + $db=$this->savdb; |
|
119 | 119 | |
120 | - print __METHOD__."\n"; |
|
120 | + print __METHOD__."\n"; |
|
121 | 121 | } |
122 | 122 | |
123 | - /** |
|
124 | - * End phpunit tests |
|
125 | - * |
|
126 | - * @return void |
|
127 | - */ |
|
123 | + /** |
|
124 | + * End phpunit tests |
|
125 | + * |
|
126 | + * @return void |
|
127 | + */ |
|
128 | 128 | protected function tearDown() |
129 | 129 | { |
130 | - print __METHOD__."\n"; |
|
130 | + print __METHOD__."\n"; |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
@@ -137,20 +137,20 @@ discard block |
||
137 | 137 | */ |
138 | 138 | public function testBank() |
139 | 139 | { |
140 | - global $conf,$user,$langs,$db; |
|
141 | - $conf=$this->savconf; |
|
142 | - $user=$this->savuser; |
|
143 | - $langs=$this->savlangs; |
|
144 | - $db=$this->savdb; |
|
140 | + global $conf,$user,$langs,$db; |
|
141 | + $conf=$this->savconf; |
|
142 | + $user=$this->savuser; |
|
143 | + $langs=$this->savlangs; |
|
144 | + $db=$this->savdb; |
|
145 | 145 | |
146 | - $script=dirname(__FILE__).'/../../scripts/bank/export-bank-receipts.php BANKDUMMY RECEIPTDUMMY excel2007 lang=fr_FR'; |
|
147 | - $result=exec($script, $output, $returnvar); |
|
146 | + $script=dirname(__FILE__).'/../../scripts/bank/export-bank-receipts.php BANKDUMMY RECEIPTDUMMY excel2007 lang=fr_FR'; |
|
147 | + $result=exec($script, $output, $returnvar); |
|
148 | 148 | |
149 | - print __METHOD__." result=".$result."\n"; |
|
150 | - print __METHOD__." output=".join("\n",$output)."\n"; |
|
151 | - print __METHOD__." returnvar=".$returnvar."\n"; |
|
152 | - $this->assertEquals($result,'Failed to find bank account with ref BANKDUMMY.'); |
|
153 | - $this->assertEquals($returnvar,255); |
|
149 | + print __METHOD__." result=".$result."\n"; |
|
150 | + print __METHOD__." output=".join("\n",$output)."\n"; |
|
151 | + print __METHOD__." returnvar=".$returnvar."\n"; |
|
152 | + $this->assertEquals($result,'Failed to find bank account with ref BANKDUMMY.'); |
|
153 | + $this->assertEquals($returnvar,255); |
|
154 | 154 | |
155 | 155 | return $result; |
156 | 156 | } |
@@ -163,13 +163,13 @@ discard block |
||
163 | 163 | */ |
164 | 164 | public function testCompany() |
165 | 165 | { |
166 | - global $conf,$user,$langs,$db; |
|
167 | - $conf=$this->savconf; |
|
168 | - $user=$this->savuser; |
|
169 | - $langs=$this->savlangs; |
|
170 | - $db=$this->savdb; |
|
166 | + global $conf,$user,$langs,$db; |
|
167 | + $conf=$this->savconf; |
|
168 | + $user=$this->savuser; |
|
169 | + $langs=$this->savlangs; |
|
170 | + $db=$this->savdb; |
|
171 | 171 | |
172 | - /* |
|
172 | + /* |
|
173 | 173 | $script=dirname(__FILE__).'/../../scripts/company/sync_contacts_dolibarr_2ldap now'; |
174 | 174 | $result=exec($script, $output, $returnvar); |
175 | 175 | |
@@ -190,34 +190,34 @@ discard block |
||
190 | 190 | */ |
191 | 191 | public function testContracts() |
192 | 192 | { |
193 | - global $conf,$user,$langs,$db; |
|
194 | - $conf=$this->savconf; |
|
195 | - $user=$this->savuser; |
|
196 | - $langs=$this->savlangs; |
|
197 | - $db=$this->savdb; |
|
198 | - |
|
199 | - $script=dirname(__FILE__).'/../../scripts/contracts/email_expire_services_to_customers.php test thirdparties'; |
|
200 | - $result=exec($script, $output, $returnvar); |
|
201 | - print __METHOD__." result=".$result."\n"; |
|
202 | - print __METHOD__." output=".join("\n",$output)."\n"; |
|
203 | - print __METHOD__." returnvar=".$returnvar."\n"; |
|
204 | - $this->assertEquals($returnvar,0,'email_expire_services_to_customers.php thirdparties'); |
|
205 | - |
|
206 | - $script=dirname(__FILE__).'/../../scripts/contracts/email_expire_services_to_customers.php test contacts -30'; |
|
207 | - $result=exec($script, $output, $returnvar); |
|
208 | - print __METHOD__." result=".$result."\n"; |
|
209 | - print __METHOD__." output=".join("\n",$output)."\n"; |
|
210 | - print __METHOD__." returnvar=".$returnvar."\n"; |
|
211 | - $this->assertEquals($returnvar,0,'email_expire_services_to_customers.php contacts'); |
|
212 | - |
|
213 | - $script=dirname(__FILE__).'/../../scripts/contracts/email_expire_services_to_representatives.php test -30'; |
|
214 | - $result=exec($script, $output, $returnvar); |
|
215 | - print __METHOD__." result=".$result."\n"; |
|
216 | - print __METHOD__." output=".join("\n",$output)."\n"; |
|
217 | - print __METHOD__." returnvar=".$returnvar."\n"; |
|
218 | - $this->assertEquals($returnvar,0,'email_expire_services_to_representatives.php'); |
|
219 | - |
|
220 | - return $result; |
|
193 | + global $conf,$user,$langs,$db; |
|
194 | + $conf=$this->savconf; |
|
195 | + $user=$this->savuser; |
|
196 | + $langs=$this->savlangs; |
|
197 | + $db=$this->savdb; |
|
198 | + |
|
199 | + $script=dirname(__FILE__).'/../../scripts/contracts/email_expire_services_to_customers.php test thirdparties'; |
|
200 | + $result=exec($script, $output, $returnvar); |
|
201 | + print __METHOD__." result=".$result."\n"; |
|
202 | + print __METHOD__." output=".join("\n",$output)."\n"; |
|
203 | + print __METHOD__." returnvar=".$returnvar."\n"; |
|
204 | + $this->assertEquals($returnvar,0,'email_expire_services_to_customers.php thirdparties'); |
|
205 | + |
|
206 | + $script=dirname(__FILE__).'/../../scripts/contracts/email_expire_services_to_customers.php test contacts -30'; |
|
207 | + $result=exec($script, $output, $returnvar); |
|
208 | + print __METHOD__." result=".$result."\n"; |
|
209 | + print __METHOD__." output=".join("\n",$output)."\n"; |
|
210 | + print __METHOD__." returnvar=".$returnvar."\n"; |
|
211 | + $this->assertEquals($returnvar,0,'email_expire_services_to_customers.php contacts'); |
|
212 | + |
|
213 | + $script=dirname(__FILE__).'/../../scripts/contracts/email_expire_services_to_representatives.php test -30'; |
|
214 | + $result=exec($script, $output, $returnvar); |
|
215 | + print __METHOD__." result=".$result."\n"; |
|
216 | + print __METHOD__." output=".join("\n",$output)."\n"; |
|
217 | + print __METHOD__." returnvar=".$returnvar."\n"; |
|
218 | + $this->assertEquals($returnvar,0,'email_expire_services_to_representatives.php'); |
|
219 | + |
|
220 | + return $result; |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | /** |
@@ -228,33 +228,33 @@ discard block |
||
228 | 228 | */ |
229 | 229 | public function testInvoices() |
230 | 230 | { |
231 | - global $conf,$user,$langs,$db; |
|
232 | - $conf=$this->savconf; |
|
233 | - $user=$this->savuser; |
|
234 | - $langs=$this->savlangs; |
|
235 | - $db=$this->savdb; |
|
236 | - |
|
237 | - $script=dirname(__FILE__).'/../../scripts/invoices/email_unpaid_invoices_to_customers.php test thirdparties'; |
|
238 | - $result=exec($script, $output, $returnvar); |
|
239 | - print __METHOD__." result=".$result."\n"; |
|
240 | - print __METHOD__." output=".join("\n",$output)."\n"; |
|
241 | - print __METHOD__." returnvar=".$returnvar."\n"; |
|
242 | - $this->assertEquals($returnvar,0,'email_unpaid_invoices_to_customers.php thirdparties'); |
|
243 | - |
|
244 | - $script=dirname(__FILE__).'/../../scripts/invoices/email_unpaid_invoices_to_customers.php test contacts -30'; |
|
245 | - $result=exec($script, $output, $returnvar); |
|
246 | - print __METHOD__." result=".$result."\n"; |
|
247 | - print __METHOD__." output=".join("\n",$output)."\n"; |
|
248 | - print __METHOD__." returnvar=".$returnvar."\n"; |
|
249 | - $this->assertEquals($returnvar,0,'email_unpaid_invoices_to_customers.php contacts'); |
|
250 | - |
|
251 | - $script=dirname(__FILE__).'/../../scripts/invoices/email_unpaid_invoices_to_representatives.php test thirdparties'; |
|
252 | - $result=exec($script, $output, $returnvar); |
|
253 | - print __METHOD__." result=".$result."\n"; |
|
254 | - print __METHOD__." output=".join("\n",$output)."\n"; |
|
255 | - print __METHOD__." returnvar=".$returnvar."\n"; |
|
256 | - $this->assertEquals($returnvar,0,'email_unpaid_invoices_to_customers.php thirdparties'); |
|
257 | - |
|
258 | - return $result; |
|
231 | + global $conf,$user,$langs,$db; |
|
232 | + $conf=$this->savconf; |
|
233 | + $user=$this->savuser; |
|
234 | + $langs=$this->savlangs; |
|
235 | + $db=$this->savdb; |
|
236 | + |
|
237 | + $script=dirname(__FILE__).'/../../scripts/invoices/email_unpaid_invoices_to_customers.php test thirdparties'; |
|
238 | + $result=exec($script, $output, $returnvar); |
|
239 | + print __METHOD__." result=".$result."\n"; |
|
240 | + print __METHOD__." output=".join("\n",$output)."\n"; |
|
241 | + print __METHOD__." returnvar=".$returnvar."\n"; |
|
242 | + $this->assertEquals($returnvar,0,'email_unpaid_invoices_to_customers.php thirdparties'); |
|
243 | + |
|
244 | + $script=dirname(__FILE__).'/../../scripts/invoices/email_unpaid_invoices_to_customers.php test contacts -30'; |
|
245 | + $result=exec($script, $output, $returnvar); |
|
246 | + print __METHOD__." result=".$result."\n"; |
|
247 | + print __METHOD__." output=".join("\n",$output)."\n"; |
|
248 | + print __METHOD__." returnvar=".$returnvar."\n"; |
|
249 | + $this->assertEquals($returnvar,0,'email_unpaid_invoices_to_customers.php contacts'); |
|
250 | + |
|
251 | + $script=dirname(__FILE__).'/../../scripts/invoices/email_unpaid_invoices_to_representatives.php test thirdparties'; |
|
252 | + $result=exec($script, $output, $returnvar); |
|
253 | + print __METHOD__." result=".$result."\n"; |
|
254 | + print __METHOD__." output=".join("\n",$output)."\n"; |
|
255 | + print __METHOD__." returnvar=".$returnvar."\n"; |
|
256 | + $this->assertEquals($returnvar,0,'email_unpaid_invoices_to_customers.php thirdparties'); |
|
257 | + |
|
258 | + return $result; |
|
259 | 259 | } |
260 | 260 | } |
@@ -23,23 +23,23 @@ discard block |
||
23 | 23 | * \remarks To run this script as CLI: phpunit filename.php |
24 | 24 | */ |
25 | 25 | |
26 | -global $conf,$user,$langs,$db; |
|
26 | +global $conf, $user, $langs, $db; |
|
27 | 27 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
28 | 28 | //require_once 'PHPUnit/Autoload.php'; |
29 | 29 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
30 | 30 | require_once dirname(__FILE__).'/../../htdocs/core/lib/security.lib.php'; |
31 | 31 | require_once dirname(__FILE__).'/../../htdocs/core/lib/security2.lib.php'; |
32 | 32 | |
33 | -if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); |
|
34 | -if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); |
|
35 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
36 | -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); |
|
37 | -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); |
|
38 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); |
|
39 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show |
|
40 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php |
|
41 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
42 | -if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) |
|
33 | +if (!defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); |
|
34 | +if (!defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); |
|
35 | +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); |
|
36 | +if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); |
|
37 | +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); |
|
38 | +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); |
|
39 | +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no menu to show |
|
40 | +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php |
|
41 | +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); |
|
42 | +if (!defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) |
|
43 | 43 | |
44 | 44 | if (empty($user->id)) |
45 | 45 | { |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $user->fetch(1); |
48 | 48 | $user->getrights(); |
49 | 49 | } |
50 | -$conf->global->MAIN_DISABLE_ALL_MAILS=1; |
|
50 | +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
|
51 | 51 | |
52 | 52 | |
53 | 53 | /** |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | parent::__construct(); |
76 | 76 | |
77 | 77 | //$this->sharedFixture |
78 | - global $conf,$user,$langs,$db; |
|
79 | - $this->savconf=$conf; |
|
80 | - $this->savuser=$user; |
|
81 | - $this->savlangs=$langs; |
|
82 | - $this->savdb=$db; |
|
78 | + global $conf, $user, $langs, $db; |
|
79 | + $this->savconf = $conf; |
|
80 | + $this->savuser = $user; |
|
81 | + $this->savlangs = $langs; |
|
82 | + $this->savdb = $db; |
|
83 | 83 | |
84 | 84 | print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
85 | 85 | //print " - db ".$db->db; |
@@ -89,8 +89,8 @@ discard block |
||
89 | 89 | // Static methods |
90 | 90 | public static function setUpBeforeClass() |
91 | 91 | { |
92 | - global $conf,$user,$langs,$db; |
|
93 | - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
92 | + global $conf, $user, $langs, $db; |
|
93 | + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
94 | 94 | |
95 | 95 | print __METHOD__."\n"; |
96 | 96 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | // tear down after class |
99 | 99 | public static function tearDownAfterClass() |
100 | 100 | { |
101 | - global $conf,$user,$langs,$db; |
|
101 | + global $conf, $user, $langs, $db; |
|
102 | 102 | $db->rollback(); |
103 | 103 | |
104 | 104 | print __METHOD__."\n"; |
@@ -111,11 +111,11 @@ discard block |
||
111 | 111 | */ |
112 | 112 | protected function setUp() |
113 | 113 | { |
114 | - global $conf,$user,$langs,$db; |
|
115 | - $conf=$this->savconf; |
|
116 | - $user=$this->savuser; |
|
117 | - $langs=$this->savlangs; |
|
118 | - $db=$this->savdb; |
|
114 | + global $conf, $user, $langs, $db; |
|
115 | + $conf = $this->savconf; |
|
116 | + $user = $this->savuser; |
|
117 | + $langs = $this->savlangs; |
|
118 | + $db = $this->savdb; |
|
119 | 119 | |
120 | 120 | print __METHOD__."\n"; |
121 | 121 | } |
@@ -137,20 +137,20 @@ discard block |
||
137 | 137 | */ |
138 | 138 | public function testBank() |
139 | 139 | { |
140 | - global $conf,$user,$langs,$db; |
|
141 | - $conf=$this->savconf; |
|
142 | - $user=$this->savuser; |
|
143 | - $langs=$this->savlangs; |
|
144 | - $db=$this->savdb; |
|
140 | + global $conf, $user, $langs, $db; |
|
141 | + $conf = $this->savconf; |
|
142 | + $user = $this->savuser; |
|
143 | + $langs = $this->savlangs; |
|
144 | + $db = $this->savdb; |
|
145 | 145 | |
146 | - $script=dirname(__FILE__).'/../../scripts/bank/export-bank-receipts.php BANKDUMMY RECEIPTDUMMY excel2007 lang=fr_FR'; |
|
147 | - $result=exec($script, $output, $returnvar); |
|
146 | + $script = dirname(__FILE__).'/../../scripts/bank/export-bank-receipts.php BANKDUMMY RECEIPTDUMMY excel2007 lang=fr_FR'; |
|
147 | + $result = exec($script, $output, $returnvar); |
|
148 | 148 | |
149 | 149 | print __METHOD__." result=".$result."\n"; |
150 | - print __METHOD__." output=".join("\n",$output)."\n"; |
|
150 | + print __METHOD__." output=".join("\n", $output)."\n"; |
|
151 | 151 | print __METHOD__." returnvar=".$returnvar."\n"; |
152 | - $this->assertEquals($result,'Failed to find bank account with ref BANKDUMMY.'); |
|
153 | - $this->assertEquals($returnvar,255); |
|
152 | + $this->assertEquals($result, 'Failed to find bank account with ref BANKDUMMY.'); |
|
153 | + $this->assertEquals($returnvar, 255); |
|
154 | 154 | |
155 | 155 | return $result; |
156 | 156 | } |
@@ -163,11 +163,11 @@ discard block |
||
163 | 163 | */ |
164 | 164 | public function testCompany() |
165 | 165 | { |
166 | - global $conf,$user,$langs,$db; |
|
167 | - $conf=$this->savconf; |
|
168 | - $user=$this->savuser; |
|
169 | - $langs=$this->savlangs; |
|
170 | - $db=$this->savdb; |
|
166 | + global $conf, $user, $langs, $db; |
|
167 | + $conf = $this->savconf; |
|
168 | + $user = $this->savuser; |
|
169 | + $langs = $this->savlangs; |
|
170 | + $db = $this->savdb; |
|
171 | 171 | |
172 | 172 | /* |
173 | 173 | $script=dirname(__FILE__).'/../../scripts/company/sync_contacts_dolibarr_2ldap now'; |
@@ -190,32 +190,32 @@ discard block |
||
190 | 190 | */ |
191 | 191 | public function testContracts() |
192 | 192 | { |
193 | - global $conf,$user,$langs,$db; |
|
194 | - $conf=$this->savconf; |
|
195 | - $user=$this->savuser; |
|
196 | - $langs=$this->savlangs; |
|
197 | - $db=$this->savdb; |
|
198 | - |
|
199 | - $script=dirname(__FILE__).'/../../scripts/contracts/email_expire_services_to_customers.php test thirdparties'; |
|
200 | - $result=exec($script, $output, $returnvar); |
|
193 | + global $conf, $user, $langs, $db; |
|
194 | + $conf = $this->savconf; |
|
195 | + $user = $this->savuser; |
|
196 | + $langs = $this->savlangs; |
|
197 | + $db = $this->savdb; |
|
198 | + |
|
199 | + $script = dirname(__FILE__).'/../../scripts/contracts/email_expire_services_to_customers.php test thirdparties'; |
|
200 | + $result = exec($script, $output, $returnvar); |
|
201 | 201 | print __METHOD__." result=".$result."\n"; |
202 | - print __METHOD__." output=".join("\n",$output)."\n"; |
|
202 | + print __METHOD__." output=".join("\n", $output)."\n"; |
|
203 | 203 | print __METHOD__." returnvar=".$returnvar."\n"; |
204 | - $this->assertEquals($returnvar,0,'email_expire_services_to_customers.php thirdparties'); |
|
204 | + $this->assertEquals($returnvar, 0, 'email_expire_services_to_customers.php thirdparties'); |
|
205 | 205 | |
206 | - $script=dirname(__FILE__).'/../../scripts/contracts/email_expire_services_to_customers.php test contacts -30'; |
|
207 | - $result=exec($script, $output, $returnvar); |
|
206 | + $script = dirname(__FILE__).'/../../scripts/contracts/email_expire_services_to_customers.php test contacts -30'; |
|
207 | + $result = exec($script, $output, $returnvar); |
|
208 | 208 | print __METHOD__." result=".$result."\n"; |
209 | - print __METHOD__." output=".join("\n",$output)."\n"; |
|
209 | + print __METHOD__." output=".join("\n", $output)."\n"; |
|
210 | 210 | print __METHOD__." returnvar=".$returnvar."\n"; |
211 | - $this->assertEquals($returnvar,0,'email_expire_services_to_customers.php contacts'); |
|
211 | + $this->assertEquals($returnvar, 0, 'email_expire_services_to_customers.php contacts'); |
|
212 | 212 | |
213 | - $script=dirname(__FILE__).'/../../scripts/contracts/email_expire_services_to_representatives.php test -30'; |
|
214 | - $result=exec($script, $output, $returnvar); |
|
213 | + $script = dirname(__FILE__).'/../../scripts/contracts/email_expire_services_to_representatives.php test -30'; |
|
214 | + $result = exec($script, $output, $returnvar); |
|
215 | 215 | print __METHOD__." result=".$result."\n"; |
216 | - print __METHOD__." output=".join("\n",$output)."\n"; |
|
216 | + print __METHOD__." output=".join("\n", $output)."\n"; |
|
217 | 217 | print __METHOD__." returnvar=".$returnvar."\n"; |
218 | - $this->assertEquals($returnvar,0,'email_expire_services_to_representatives.php'); |
|
218 | + $this->assertEquals($returnvar, 0, 'email_expire_services_to_representatives.php'); |
|
219 | 219 | |
220 | 220 | return $result; |
221 | 221 | } |
@@ -228,32 +228,32 @@ discard block |
||
228 | 228 | */ |
229 | 229 | public function testInvoices() |
230 | 230 | { |
231 | - global $conf,$user,$langs,$db; |
|
232 | - $conf=$this->savconf; |
|
233 | - $user=$this->savuser; |
|
234 | - $langs=$this->savlangs; |
|
235 | - $db=$this->savdb; |
|
236 | - |
|
237 | - $script=dirname(__FILE__).'/../../scripts/invoices/email_unpaid_invoices_to_customers.php test thirdparties'; |
|
238 | - $result=exec($script, $output, $returnvar); |
|
231 | + global $conf, $user, $langs, $db; |
|
232 | + $conf = $this->savconf; |
|
233 | + $user = $this->savuser; |
|
234 | + $langs = $this->savlangs; |
|
235 | + $db = $this->savdb; |
|
236 | + |
|
237 | + $script = dirname(__FILE__).'/../../scripts/invoices/email_unpaid_invoices_to_customers.php test thirdparties'; |
|
238 | + $result = exec($script, $output, $returnvar); |
|
239 | 239 | print __METHOD__." result=".$result."\n"; |
240 | - print __METHOD__." output=".join("\n",$output)."\n"; |
|
240 | + print __METHOD__." output=".join("\n", $output)."\n"; |
|
241 | 241 | print __METHOD__." returnvar=".$returnvar."\n"; |
242 | - $this->assertEquals($returnvar,0,'email_unpaid_invoices_to_customers.php thirdparties'); |
|
242 | + $this->assertEquals($returnvar, 0, 'email_unpaid_invoices_to_customers.php thirdparties'); |
|
243 | 243 | |
244 | - $script=dirname(__FILE__).'/../../scripts/invoices/email_unpaid_invoices_to_customers.php test contacts -30'; |
|
245 | - $result=exec($script, $output, $returnvar); |
|
244 | + $script = dirname(__FILE__).'/../../scripts/invoices/email_unpaid_invoices_to_customers.php test contacts -30'; |
|
245 | + $result = exec($script, $output, $returnvar); |
|
246 | 246 | print __METHOD__." result=".$result."\n"; |
247 | - print __METHOD__." output=".join("\n",$output)."\n"; |
|
247 | + print __METHOD__." output=".join("\n", $output)."\n"; |
|
248 | 248 | print __METHOD__." returnvar=".$returnvar."\n"; |
249 | - $this->assertEquals($returnvar,0,'email_unpaid_invoices_to_customers.php contacts'); |
|
249 | + $this->assertEquals($returnvar, 0, 'email_unpaid_invoices_to_customers.php contacts'); |
|
250 | 250 | |
251 | - $script=dirname(__FILE__).'/../../scripts/invoices/email_unpaid_invoices_to_representatives.php test thirdparties'; |
|
252 | - $result=exec($script, $output, $returnvar); |
|
251 | + $script = dirname(__FILE__).'/../../scripts/invoices/email_unpaid_invoices_to_representatives.php test thirdparties'; |
|
252 | + $result = exec($script, $output, $returnvar); |
|
253 | 253 | print __METHOD__." result=".$result."\n"; |
254 | - print __METHOD__." output=".join("\n",$output)."\n"; |
|
254 | + print __METHOD__." output=".join("\n", $output)."\n"; |
|
255 | 255 | print __METHOD__." returnvar=".$returnvar."\n"; |
256 | - $this->assertEquals($returnvar,0,'email_unpaid_invoices_to_customers.php thirdparties'); |
|
256 | + $this->assertEquals($returnvar, 0, 'email_unpaid_invoices_to_customers.php thirdparties'); |
|
257 | 257 | |
258 | 258 | return $result; |
259 | 259 | } |
@@ -30,16 +30,39 @@ |
||
30 | 30 | require_once dirname(__FILE__).'/../../htdocs/core/lib/security.lib.php'; |
31 | 31 | require_once dirname(__FILE__).'/../../htdocs/core/lib/security2.lib.php'; |
32 | 32 | |
33 | -if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); |
|
34 | -if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); |
|
35 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
36 | -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); |
|
37 | -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); |
|
38 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); |
|
39 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show |
|
40 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php |
|
41 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
42 | -if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) |
|
33 | +if (! defined('NOREQUIREUSER')) { |
|
34 | + define('NOREQUIREUSER','1'); |
|
35 | +} |
|
36 | +if (! defined('NOREQUIREDB')) { |
|
37 | + define('NOREQUIREDB','1'); |
|
38 | +} |
|
39 | +if (! defined('NOREQUIRESOC')) { |
|
40 | + define('NOREQUIRESOC','1'); |
|
41 | +} |
|
42 | +if (! defined('NOREQUIRETRAN')) { |
|
43 | + define('NOREQUIRETRAN','1'); |
|
44 | +} |
|
45 | +if (! defined('NOCSRFCHECK')) { |
|
46 | + define('NOCSRFCHECK','1'); |
|
47 | +} |
|
48 | +if (! defined('NOTOKENRENEWAL')) { |
|
49 | + define('NOTOKENRENEWAL','1'); |
|
50 | +} |
|
51 | +if (! defined('NOREQUIREMENU')) { |
|
52 | + define('NOREQUIREMENU','1'); |
|
53 | +} |
|
54 | +// If there is no menu to show |
|
55 | +if (! defined('NOREQUIREHTML')) { |
|
56 | + define('NOREQUIREHTML','1'); |
|
57 | +} |
|
58 | +// If we don't need to load the html.form.class.php |
|
59 | +if (! defined('NOREQUIREAJAX')) { |
|
60 | + define('NOREQUIREAJAX','1'); |
|
61 | +} |
|
62 | +if (! defined("NOLOGIN")) { |
|
63 | + define("NOLOGIN",'1'); |
|
64 | +} |
|
65 | +// If this page is public (can be called outside logged session) |
|
43 | 66 | |
44 | 67 | if (empty($user->id)) |
45 | 68 | { |