@@ -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'; |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | $user->fetch(1); |
38 | 38 | $user->getrights(); |
39 | 39 | } |
40 | -$conf->global->MAIN_DISABLE_ALL_MAILS=1; |
|
41 | -$conf->global->MAIN_UMASK='0666'; |
|
40 | +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
|
41 | +$conf->global->MAIN_UMASK = '0666'; |
|
42 | 42 | |
43 | 43 | |
44 | 44 | /** |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public static function setUpBeforeClass(): void |
62 | 62 | { |
63 | - global $conf,$user,$langs,$db; |
|
63 | + global $conf, $user, $langs, $db; |
|
64 | 64 | $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
65 | 65 | |
66 | 66 | if (!isModEnabled('api')) { |
@@ -78,24 +78,24 @@ discard block |
||
78 | 78 | */ |
79 | 79 | protected function setUp(): void |
80 | 80 | { |
81 | - global $conf,$user,$langs,$db; |
|
82 | - $conf=$this->savconf; |
|
83 | - $user=$this->savuser; |
|
84 | - $langs=$this->savlangs; |
|
85 | - $db=$this->savdb; |
|
81 | + global $conf, $user, $langs, $db; |
|
82 | + $conf = $this->savconf; |
|
83 | + $user = $this->savuser; |
|
84 | + $langs = $this->savlangs; |
|
85 | + $db = $this->savdb; |
|
86 | 86 | |
87 | 87 | $this->api_url = DOL_MAIN_URL_ROOT.'/api/index.php'; |
88 | 88 | |
89 | - $login='admin'; |
|
90 | - $password='admin'; |
|
91 | - $url=$this->api_url.'/login?login='.$login.'&password='.$password; |
|
89 | + $login = 'admin'; |
|
90 | + $password = 'admin'; |
|
91 | + $url = $this->api_url.'/login?login='.$login.'&password='.$password; |
|
92 | 92 | // Call the API login method to save api_key for this test class. |
93 | 93 | // At first call, if token is not defined a random value is generated and returned. |
94 | - $result=getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2); |
|
94 | + $result = getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2); |
|
95 | 95 | print __METHOD__." result = ".var_export($result, true)."\n"; |
96 | 96 | print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n"; |
97 | 97 | $this->assertEquals($result['curl_error_no'], ''); |
98 | - $object = json_decode($result['content'], true); // If success content is just an id, if not an array |
|
98 | + $object = json_decode($result['content'], true); // If success content is just an id, if not an array |
|
99 | 99 | |
100 | 100 | $this->assertNotNull($object, "Parsing of json result must not be null"); |
101 | 101 | $this->assertNotEquals(500, (empty($object['error']['code']) ? 0 : $object['error']['code']), 'Error'.(empty($object['error']['message']) ? '' : ' '.$object['error']['message'])); |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | */ |
115 | 115 | public function testRestGetContact() |
116 | 116 | { |
117 | - global $conf,$user,$langs,$db; |
|
117 | + global $conf, $user, $langs, $db; |
|
118 | 118 | //fetch Non-Existent contact |
119 | 119 | $url = $this->api_url.'/contacts/123456789?api_key='.$this->api_key; |
120 | 120 | //$addheaders=array('Content-Type: application/json'); |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | print __METHOD__." result for get on unexisting contact: ".var_export($result, true)."\n"; |
125 | 125 | print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n"; |
126 | 126 | $this->assertEquals($result['curl_error_no'], ''); |
127 | - $object=json_decode($result['content'], true); |
|
127 | + $object = json_decode($result['content'], true); |
|
128 | 128 | $this->assertNotNull($object, "Parsing of json result must not be null"); |
129 | 129 | $this->assertEquals(404, $object['error']['code'], 'Error code is not 404'); |
130 | 130 | |
@@ -132,11 +132,11 @@ discard block |
||
132 | 132 | $url = $this->api_url.'/contacts/1?api_key='.$this->api_key; |
133 | 133 | |
134 | 134 | print __METHOD__." Request GET url=".$url."\n"; |
135 | - $result=getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2); |
|
135 | + $result = getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2); |
|
136 | 136 | print __METHOD__." result for get on an existing contact: ".var_export($result, true)."\n"; |
137 | 137 | print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n"; |
138 | 138 | $this->assertEquals($result['curl_error_no'], ''); |
139 | - $object=json_decode($result['content'], true); |
|
139 | + $object = json_decode($result['content'], true); |
|
140 | 140 | $this->assertNotNull($object, "Parsing of json result must not be null"); |
141 | 141 | $this->assertEquals(1, $object['statut']); |
142 | 142 | } |
@@ -151,23 +151,23 @@ discard block |
||
151 | 151 | */ |
152 | 152 | public function testRestCreateContact() |
153 | 153 | { |
154 | - global $conf,$user,$langs,$db; |
|
154 | + global $conf, $user, $langs, $db; |
|
155 | 155 | // attempt to create without mandatory fields |
156 | 156 | $url = $this->api_url.'/contacts?api_key='.$this->api_key; |
157 | - $addheaders=array('Content-Type: application/json'); |
|
157 | + $addheaders = array('Content-Type: application/json'); |
|
158 | 158 | |
159 | - $bodyobj= array( |
|
159 | + $bodyobj = array( |
|
160 | 160 | "firstname" => "firstname" |
161 | 161 | ); |
162 | 162 | |
163 | 163 | $body = json_encode($bodyobj); |
164 | 164 | |
165 | 165 | //print __METHOD__." Request POST url=".$url."\n"; |
166 | - $result=getURLContent($url, 'POST', $body, 1, $addheaders, array('http', 'https'), 2); |
|
166 | + $result = getURLContent($url, 'POST', $body, 1, $addheaders, array('http', 'https'), 2); |
|
167 | 167 | //print __METHOD__." Result for creating incomplete contact".var_export($result, true)."\n"; |
168 | 168 | //print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n"; |
169 | 169 | $this->assertEquals($result['curl_error_no'], ''); |
170 | - $object = json_decode($result['content'], true); // If success content is just an id, if not an array |
|
170 | + $object = json_decode($result['content'], true); // If success content is just an id, if not an array |
|
171 | 171 | $this->assertNotNull($object, "Parsing of json result must no be null"); |
172 | 172 | $this->assertEquals(400, (empty($object['error']['code']) ? 0 : $object['error']['code']), 'Error'.(empty($object['error']['message']) ? '' : ' '.$object['error']['message'])); |
173 | 173 | |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | unset($result); |
178 | 178 | // Creating a Contact |
179 | 179 | $bodyobj = array( |
180 | - "firstname" => "testRestContact" . mt_rand(), |
|
180 | + "firstname" => "testRestContact".mt_rand(), |
|
181 | 181 | "lastname" => "testRestContact", |
182 | 182 | ); |
183 | 183 | |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | |
188 | 188 | $this->assertEquals($result['curl_error_no'], ''); |
189 | 189 | |
190 | - $object = json_decode($result['content'], true); // If success content is just an id, if not an array |
|
190 | + $object = json_decode($result['content'], true); // If success content is just an id, if not an array |
|
191 | 191 | $this->assertNotNull($object, "Parsing of json result must not be null"); |
192 | 192 | $this->assertNotEquals(500, (empty($object['error']['code']) ? 0 : $object['error']['code']), 'Error'.(empty($object['error']['message']) ? '' : ' '.$object['error']['message'])); |
193 | 193 | $this->assertGreaterThan(0, $object, 'ID return is no > 0'); |
@@ -206,10 +206,10 @@ discard block |
||
206 | 206 | */ |
207 | 207 | public function testRestUpdateContact($objid) |
208 | 208 | { |
209 | - global $conf,$user,$langs,$db; |
|
209 | + global $conf, $user, $langs, $db; |
|
210 | 210 | // attempt to create without mandatory fields |
211 | 211 | $url = $this->api_url.'/contacts?api_key='.$this->api_key; |
212 | - $addheaders=array('Content-Type: application/json'); |
|
212 | + $addheaders = array('Content-Type: application/json'); |
|
213 | 213 | |
214 | 214 | //update the contact |
215 | 215 | |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | ); |
220 | 220 | |
221 | 221 | $updateRequestBody = json_encode($updateBody); |
222 | - $updateUrl = $this->api_url . '/contacts/' . $objid. '?api_key=' . $this->api_key; |
|
222 | + $updateUrl = $this->api_url.'/contacts/'.$objid.'?api_key='.$this->api_key; |
|
223 | 223 | $updateResult = getURLContent($updateUrl, 'PUTALREADYFORMATED', $updateRequestBody, 1, $addheaders, array('http', 'https'), 2); |
224 | 224 | $this->assertEquals($updateResult['curl_error_no'], ''); |
225 | 225 |
@@ -25,7 +25,7 @@ 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'; |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | $user->fetch(1); |
38 | 38 | $user->getrights(); |
39 | 39 | } |
40 | -$conf->global->MAIN_DISABLE_ALL_MAILS=1; |
|
40 | +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
|
41 | 41 | |
42 | 42 | |
43 | 43 | /** |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | */ |
57 | 57 | public static function setUpBeforeClass(): void |
58 | 58 | { |
59 | - global $conf,$user,$langs,$db; |
|
59 | + global $conf, $user, $langs, $db; |
|
60 | 60 | |
61 | 61 | if (!isModEnabled('facture')) { |
62 | 62 | print __METHOD__." module customer invoice must be enabled.\n"; |
@@ -80,15 +80,15 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public function testFactureCreate() |
82 | 82 | { |
83 | - global $conf,$user,$langs,$db; |
|
84 | - $conf=$this->savconf; |
|
85 | - $user=$this->savuser; |
|
86 | - $langs=$this->savlangs; |
|
87 | - $db=$this->savdb; |
|
83 | + global $conf, $user, $langs, $db; |
|
84 | + $conf = $this->savconf; |
|
85 | + $user = $this->savuser; |
|
86 | + $langs = $this->savlangs; |
|
87 | + $db = $this->savdb; |
|
88 | 88 | |
89 | - $localobject=new Facture($db); |
|
89 | + $localobject = new Facture($db); |
|
90 | 90 | $localobject->initAsSpecimen(); |
91 | - $result=$localobject->create($user); |
|
91 | + $result = $localobject->create($user); |
|
92 | 92 | $this->assertLessThan($result, 0); |
93 | 93 | print __METHOD__." result=".$result."\n"; |
94 | 94 | return $result; |
@@ -105,14 +105,14 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public function testFactureFetch($id) |
107 | 107 | { |
108 | - global $conf,$user,$langs,$db; |
|
109 | - $conf=$this->savconf; |
|
110 | - $user=$this->savuser; |
|
111 | - $langs=$this->savlangs; |
|
112 | - $db=$this->savdb; |
|
108 | + global $conf, $user, $langs, $db; |
|
109 | + $conf = $this->savconf; |
|
110 | + $user = $this->savuser; |
|
111 | + $langs = $this->savlangs; |
|
112 | + $db = $this->savdb; |
|
113 | 113 | |
114 | - $localobject=new Facture($db); |
|
115 | - $result=$localobject->fetch($id); |
|
114 | + $localobject = new Facture($db); |
|
115 | + $result = $localobject->fetch($id); |
|
116 | 116 | |
117 | 117 | $this->assertLessThan($result, 0); |
118 | 118 | print __METHOD__." id=".$id." result=".$result."\n"; |
@@ -130,14 +130,14 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function testFactureUpdate($localobject) |
132 | 132 | { |
133 | - global $conf,$user,$langs,$db; |
|
134 | - $conf=$this->savconf; |
|
135 | - $user=$this->savuser; |
|
136 | - $langs=$this->savlangs; |
|
137 | - $db=$this->savdb; |
|
133 | + global $conf, $user, $langs, $db; |
|
134 | + $conf = $this->savconf; |
|
135 | + $user = $this->savuser; |
|
136 | + $langs = $this->savlangs; |
|
137 | + $db = $this->savdb; |
|
138 | 138 | |
139 | 139 | $this->changeProperties($localobject); |
140 | - $result=$localobject->update($user); |
|
140 | + $result = $localobject->update($user); |
|
141 | 141 | |
142 | 142 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
143 | 143 | $this->assertLessThan($result, 0); |
@@ -155,19 +155,19 @@ discard block |
||
155 | 155 | */ |
156 | 156 | public function testFactureValid($localobject) |
157 | 157 | { |
158 | - global $conf,$user,$langs,$db; |
|
159 | - $conf=$this->savconf; |
|
160 | - $user=$this->savuser; |
|
161 | - $langs=$this->savlangs; |
|
162 | - $db=$this->savdb; |
|
158 | + global $conf, $user, $langs, $db; |
|
159 | + $conf = $this->savconf; |
|
160 | + $user = $this->savuser; |
|
161 | + $langs = $this->savlangs; |
|
162 | + $db = $this->savdb; |
|
163 | 163 | |
164 | - $result=$localobject->validate($user); |
|
164 | + $result = $localobject->validate($user); |
|
165 | 165 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
166 | 166 | |
167 | 167 | $this->assertLessThan($result, 0); |
168 | 168 | |
169 | 169 | // Test everything are still same than specimen |
170 | - $newlocalobject=new Facture($db); |
|
170 | + $newlocalobject = new Facture($db); |
|
171 | 171 | $newlocalobject->initAsSpecimen(); |
172 | 172 | $this->changeProperties($newlocalobject); |
173 | 173 | |
@@ -180,15 +180,15 @@ discard block |
||
180 | 180 | $newlocalobject, |
181 | 181 | true, |
182 | 182 | array( |
183 | - 'newref','oldref','id','lines','client','thirdparty','brouillon','user_creation_id','date_creation','date_validation','datem','date_modification', |
|
184 | - 'ref','statut','status','paye','specimen','ref','actiontypecode','actionmsg2','actionmsg','mode_reglement','cond_reglement', |
|
183 | + 'newref', 'oldref', 'id', 'lines', 'client', 'thirdparty', 'brouillon', 'user_creation_id', 'date_creation', 'date_validation', 'datem', 'date_modification', |
|
184 | + 'ref', 'statut', 'status', 'paye', 'specimen', 'ref', 'actiontypecode', 'actionmsg2', 'actionmsg', 'mode_reglement', 'cond_reglement', |
|
185 | 185 | 'cond_reglement_doc', 'modelpdf', |
186 | - 'multicurrency_total_ht','multicurrency_total_tva', 'multicurrency_total_ttc','fk_multicurrency','multicurrency_code','multicurrency_tx', |
|
187 | - 'retained_warranty' ,'retained_warranty_date_limit', 'retained_warranty_fk_cond_reglement', 'specimen', 'situation_cycle_ref', 'situation_counter', 'situation_final', |
|
188 | - 'trackid','user_creat','user_valid' |
|
186 | + 'multicurrency_total_ht', 'multicurrency_total_tva', 'multicurrency_total_ttc', 'fk_multicurrency', 'multicurrency_code', 'multicurrency_tx', |
|
187 | + 'retained_warranty', 'retained_warranty_date_limit', 'retained_warranty_fk_cond_reglement', 'specimen', 'situation_cycle_ref', 'situation_counter', 'situation_final', |
|
188 | + 'trackid', 'user_creat', 'user_valid' |
|
189 | 189 | ) |
190 | 190 | ); |
191 | - $this->assertEquals($arraywithdiff, array()); // Actual, Expected |
|
191 | + $this->assertEquals($arraywithdiff, array()); // Actual, Expected |
|
192 | 192 | |
193 | 193 | return $localobject; |
194 | 194 | } |
@@ -204,11 +204,11 @@ discard block |
||
204 | 204 | */ |
205 | 205 | public function testFactureOther($localobject) |
206 | 206 | { |
207 | - global $conf,$user,$langs,$db; |
|
208 | - $conf=$this->savconf; |
|
209 | - $user=$this->savuser; |
|
210 | - $langs=$this->savlangs; |
|
211 | - $db=$this->savdb; |
|
207 | + global $conf, $user, $langs, $db; |
|
208 | + $conf = $this->savconf; |
|
209 | + $user = $this->savuser; |
|
210 | + $langs = $this->savlangs; |
|
211 | + $db = $this->savdb; |
|
212 | 212 | |
213 | 213 | /*$result=$localobject->setstatus(0); |
214 | 214 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | print __METHOD__." localobject->date_creation=".$localobject->date_creation."\n"; |
220 | 220 | $this->assertNotEquals($localobject->date_creation, ''); |
221 | 221 | |
222 | - $result=$localobject->demande_prelevement($user); |
|
222 | + $result = $localobject->demande_prelevement($user); |
|
223 | 223 | print __METHOD__." result=".$result."\n"; |
224 | 224 | $this->assertLessThan($result, 0); |
225 | 225 | |
@@ -237,44 +237,44 @@ discard block |
||
237 | 237 | */ |
238 | 238 | public function testFactureDelete($id) |
239 | 239 | { |
240 | - global $conf,$user,$langs,$db; |
|
241 | - $conf=$this->savconf; |
|
242 | - $user=$this->savuser; |
|
243 | - $langs=$this->savlangs; |
|
244 | - $db=$this->savdb; |
|
240 | + global $conf, $user, $langs, $db; |
|
241 | + $conf = $this->savconf; |
|
242 | + $user = $this->savuser; |
|
243 | + $langs = $this->savlangs; |
|
244 | + $db = $this->savdb; |
|
245 | 245 | |
246 | 246 | // Force default setup |
247 | 247 | unset($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED); |
248 | 248 | unset($conf->global->INVOICE_CAN_NEVER_BE_REMOVED); |
249 | 249 | |
250 | - $localobject=new Facture($db); |
|
251 | - $result=$localobject->fetch($id); |
|
250 | + $localobject = new Facture($db); |
|
251 | + $result = $localobject->fetch($id); |
|
252 | 252 | |
253 | 253 | // Create another invoice and validate it after $localobject |
254 | - $localobject2=new Facture($db); |
|
255 | - $result=$localobject2->initAsSpecimen(); |
|
256 | - $result=$localobject2->create($user); |
|
257 | - $result=$localobject2->validate($user); |
|
254 | + $localobject2 = new Facture($db); |
|
255 | + $result = $localobject2->initAsSpecimen(); |
|
256 | + $result = $localobject2->create($user); |
|
257 | + $result = $localobject2->validate($user); |
|
258 | 258 | print 'Invoice $localobject ref = '.$localobject->ref."\n"; |
259 | 259 | print 'Invoice $localobject2 created with ref = '.$localobject2->ref."\n"; |
260 | 260 | |
261 | 261 | $conf->global->INVOICE_CAN_NEVER_BE_REMOVED = 1; |
262 | 262 | |
263 | - $result=$localobject2->delete($user); // Deletion is KO, option INVOICE_CAN_NEVER_BE_REMOVED is on |
|
263 | + $result = $localobject2->delete($user); // Deletion is KO, option INVOICE_CAN_NEVER_BE_REMOVED is on |
|
264 | 264 | print __METHOD__." id=".$localobject2->id." ref=".$localobject2->ref." result=".$result."\n"; |
265 | 265 | $this->assertEquals(0, $result, 'Deletion should fail, option INVOICE_CAN_NEVER_BE_REMOVED is on'); |
266 | 266 | |
267 | 267 | unset($conf->global->INVOICE_CAN_NEVER_BE_REMOVED); |
268 | 268 | |
269 | - $result=$localobject->delete($user); // Deletion is KO, it is not last invoice |
|
269 | + $result = $localobject->delete($user); // Deletion is KO, it is not last invoice |
|
270 | 270 | print __METHOD__." id=".$localobject->id." ref=".$localobject->ref." result=".$result."\n"; |
271 | 271 | $this->assertEquals(0, $result, 'Deletion should fail, it is not last invoice'); |
272 | 272 | |
273 | - $result=$localobject2->delete($user); // Deletion is OK, it is last invoice |
|
273 | + $result = $localobject2->delete($user); // Deletion is OK, it is last invoice |
|
274 | 274 | print __METHOD__." id=".$localobject2->id." ref=".$localobject2->ref." result=".$result."\n"; |
275 | 275 | $this->assertGreaterThan(0, $result, 'Deletion should work, it is last invoice'); |
276 | 276 | |
277 | - $result=$localobject->delete($user); // Deletion is KO, it is not last invoice |
|
277 | + $result = $localobject->delete($user); // Deletion is KO, it is not last invoice |
|
278 | 278 | print __METHOD__." id=".$localobject->id." ref=".$localobject->ref." result=".$result."\n"; |
279 | 279 | $this->assertGreaterThan(0, $result, 'Deletion should work, it is again last invoice'); |
280 | 280 | |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | */ |
290 | 290 | public function changeProperties(&$localobject) |
291 | 291 | { |
292 | - $localobject->note_private='New note'; |
|
292 | + $localobject->note_private = 'New note'; |
|
293 | 293 | //$localobject->note='New note after update'; |
294 | 294 | } |
295 | 295 | |
@@ -304,23 +304,23 @@ discard block |
||
304 | 304 | */ |
305 | 305 | public function objCompare($oA, $oB, $ignoretype = true, $fieldstoignorearray = array('id')) |
306 | 306 | { |
307 | - $retAr=array(); |
|
307 | + $retAr = array(); |
|
308 | 308 | |
309 | 309 | if (get_class($oA) !== get_class($oB)) { |
310 | - $retAr[]="Supplied objects are not of same class."; |
|
310 | + $retAr[] = "Supplied objects are not of same class."; |
|
311 | 311 | } else { |
312 | - $oVarsA=get_object_vars($oA); |
|
313 | - $oVarsB=get_object_vars($oB); |
|
314 | - $aKeys=array_keys($oVarsA); |
|
312 | + $oVarsA = get_object_vars($oA); |
|
313 | + $oVarsB = get_object_vars($oB); |
|
314 | + $aKeys = array_keys($oVarsA); |
|
315 | 315 | foreach ($aKeys as $sKey) { |
316 | 316 | if (in_array($sKey, $fieldstoignorearray)) { |
317 | 317 | continue; |
318 | 318 | } |
319 | - if (! $ignoretype && ($oVarsA[$sKey] !== $oVarsB[$sKey])) { |
|
320 | - $retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey]) ? get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ? get_class($oVarsB[$sKey]) : $oVarsB[$sKey]); |
|
319 | + if (!$ignoretype && ($oVarsA[$sKey] !== $oVarsB[$sKey])) { |
|
320 | + $retAr[] = $sKey.' : '.(is_object($oVarsA[$sKey]) ? get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ? get_class($oVarsB[$sKey]) : $oVarsB[$sKey]); |
|
321 | 321 | } |
322 | 322 | if ($ignoretype && ($oVarsA[$sKey] != $oVarsB[$sKey])) { |
323 | - $retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey]) ? get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ? get_class($oVarsB[$sKey]) : $oVarsB[$sKey]); |
|
323 | + $retAr[] = $sKey.' : '.(is_object($oVarsA[$sKey]) ? get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ? get_class($oVarsB[$sKey]) : $oVarsB[$sKey]); |
|
324 | 324 | } |
325 | 325 | } |
326 | 326 | } |
@@ -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'; |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | $user->fetch(1); |
38 | 38 | $user->getrights(); |
39 | 39 | } |
40 | -$conf->global->MAIN_DISABLE_ALL_MAILS=1; |
|
40 | +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
|
41 | 41 | |
42 | 42 | |
43 | 43 | |
@@ -57,72 +57,72 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function testCommandeFournisseurCreate() |
59 | 59 | { |
60 | - global $conf,$user,$langs,$db; |
|
61 | - $conf=$this->savconf; |
|
62 | - $user=$this->savuser; |
|
63 | - $langs=$this->savlangs; |
|
64 | - $db=$this->savdb; |
|
60 | + global $conf, $user, $langs, $db; |
|
61 | + $conf = $this->savconf; |
|
62 | + $user = $this->savuser; |
|
63 | + $langs = $this->savlangs; |
|
64 | + $db = $this->savdb; |
|
65 | 65 | |
66 | 66 | // Set supplier and product to use |
67 | - $socid=1; |
|
68 | - $societe=new Societe($db); |
|
67 | + $socid = 1; |
|
68 | + $societe = new Societe($db); |
|
69 | 69 | $societe->fetch($socid); |
70 | - $product=new ProductFournisseur($db); |
|
70 | + $product = new ProductFournisseur($db); |
|
71 | 71 | $product->fetch(0, 'PINKDRESS'); |
72 | 72 | if ($product->id <= 0) { |
73 | 73 | print "\n".__METHOD__." A product with ref PINKDRESS must exists into database"; |
74 | 74 | die(1); |
75 | 75 | } |
76 | 76 | |
77 | - $quantity=10; |
|
78 | - $ref_fourn='SUPPLIER_REF_PHPUNIT'; |
|
79 | - $tva_tx=19.6; |
|
77 | + $quantity = 10; |
|
78 | + $ref_fourn = 'SUPPLIER_REF_PHPUNIT'; |
|
79 | + $tva_tx = 19.6; |
|
80 | 80 | |
81 | 81 | // Delete existing supplier prices |
82 | 82 | // TODO |
83 | 83 | |
84 | 84 | // Create 1 supplier price with min qty = 10; |
85 | - $result=$product->add_fournisseur($user, $societe->id, $ref_fourn, $quantity); // This insert record with no value for price. Values are update later with update_buyprice |
|
85 | + $result = $product->add_fournisseur($user, $societe->id, $ref_fourn, $quantity); // This insert record with no value for price. Values are update later with update_buyprice |
|
86 | 86 | print __METHOD__." add_fournisseur result=".$result."\n"; |
87 | 87 | $this->assertGreaterThanOrEqual(0, $result, 'Create 1 supplier price with min qty = 10 if not exists'); |
88 | - $result=$product->update_buyprice($quantity, 20, $user, 'HT', $societe, '', $ref_fourn, $tva_tx, 0, 0); |
|
88 | + $result = $product->update_buyprice($quantity, 20, $user, 'HT', $societe, '', $ref_fourn, $tva_tx, 0, 0); |
|
89 | 89 | print __METHOD__." update_buyprice result=".$result."\n"; |
90 | 90 | $this->assertGreaterThanOrEqual(0, $result, 'Update buyprice'); |
91 | 91 | |
92 | 92 | // Create purchase order with a too low quantity and option SUPPLIER_ORDER_WITH_PREDEFINED_PRICES_ONLY is on |
93 | 93 | $conf->global->SUPPLIER_ORDER_WITH_PREDEFINED_PRICES_ONLY = 1; |
94 | 94 | |
95 | - $localobject=new CommandeFournisseur($db); |
|
95 | + $localobject = new CommandeFournisseur($db); |
|
96 | 96 | $localobject->initAsSpecimen(); |
97 | - $localobject->lines=array(); // Overwrite lines of order |
|
98 | - $line=new CommandeFournisseurLigne($db); |
|
99 | - $line->desc=$langs->trans("Description")." specimen line with qty too low"; |
|
100 | - $line->qty=1; // So lower than $quantity |
|
101 | - $line->subprice=100; |
|
102 | - $line->fk_product=$product->id; |
|
103 | - $line->ref_fourn=$ref_fourn; |
|
104 | - $localobject->lines[]=$line; |
|
105 | - |
|
106 | - $result=$localobject->create($user); |
|
97 | + $localobject->lines = array(); // Overwrite lines of order |
|
98 | + $line = new CommandeFournisseurLigne($db); |
|
99 | + $line->desc = $langs->trans("Description")." specimen line with qty too low"; |
|
100 | + $line->qty = 1; // So lower than $quantity |
|
101 | + $line->subprice = 100; |
|
102 | + $line->fk_product = $product->id; |
|
103 | + $line->ref_fourn = $ref_fourn; |
|
104 | + $localobject->lines[] = $line; |
|
105 | + |
|
106 | + $result = $localobject->create($user); |
|
107 | 107 | print __METHOD__." result=".$result."\n"; |
108 | - $this->assertEquals(-1, $result, 'Creation of too low quantity'); // must be -1 because quantity is lower than minimum of supplier price |
|
108 | + $this->assertEquals(-1, $result, 'Creation of too low quantity'); // must be -1 because quantity is lower than minimum of supplier price |
|
109 | 109 | |
110 | - $sql="DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseur where ref IN ('', '(PROV)')"; |
|
110 | + $sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseur where ref IN ('', '(PROV)')"; |
|
111 | 111 | $db->query($sql); |
112 | 112 | |
113 | 113 | // Create purchase order |
114 | - $localobject2=new CommandeFournisseur($db); |
|
115 | - $localobject2->initAsSpecimen(); // This create 5 lines of first product found for socid 1 |
|
116 | - $localobject2->lines=array(); // Overwrite lines of order |
|
117 | - $line=new CommandeFournisseurLigne($db); |
|
118 | - $line->desc=$langs->trans("Description")." specimen line ok"; |
|
119 | - $line->qty=10; // So enough quantity |
|
120 | - $line->subprice=100; |
|
121 | - $line->fk_product=$product->id; |
|
122 | - $line->ref_fourn=$ref_fourn; |
|
123 | - $localobject2->lines[]=$line; |
|
124 | - |
|
125 | - $result=$localobject2->create($user); |
|
114 | + $localobject2 = new CommandeFournisseur($db); |
|
115 | + $localobject2->initAsSpecimen(); // This create 5 lines of first product found for socid 1 |
|
116 | + $localobject2->lines = array(); // Overwrite lines of order |
|
117 | + $line = new CommandeFournisseurLigne($db); |
|
118 | + $line->desc = $langs->trans("Description")." specimen line ok"; |
|
119 | + $line->qty = 10; // So enough quantity |
|
120 | + $line->subprice = 100; |
|
121 | + $line->fk_product = $product->id; |
|
122 | + $line->ref_fourn = $ref_fourn; |
|
123 | + $localobject2->lines[] = $line; |
|
124 | + |
|
125 | + $result = $localobject2->create($user); |
|
126 | 126 | print __METHOD__." result=".$result."\n"; |
127 | 127 | $this->assertGreaterThan(0, $result); |
128 | 128 | |
@@ -130,37 +130,37 @@ discard block |
||
130 | 130 | // Create purchase order with a too low quantity but option SUPPLIER_ORDER_WITH_PREDEFINED_PRICES_ONLY is off |
131 | 131 | $conf->global->SUPPLIER_ORDER_WITH_PREDEFINED_PRICES_ONLY = 0; |
132 | 132 | |
133 | - $localobject3=new CommandeFournisseur($db); |
|
133 | + $localobject3 = new CommandeFournisseur($db); |
|
134 | 134 | $localobject3->initAsSpecimen(); |
135 | - $localobject3->lines=array(); // Overwrite lines of order |
|
136 | - $line=new CommandeFournisseurLigne($db); |
|
137 | - $line->desc=$langs->trans("Description")." specimen line with qty too low"; |
|
138 | - $line->qty=1; // So lower than $quantity |
|
139 | - $line->subprice=100; |
|
140 | - $line->fk_product=$product->id; |
|
141 | - $line->ref_fourn=$ref_fourn; |
|
142 | - $localobject3->lines[]=$line; |
|
143 | - |
|
144 | - $result=$localobject3->create($user); |
|
135 | + $localobject3->lines = array(); // Overwrite lines of order |
|
136 | + $line = new CommandeFournisseurLigne($db); |
|
137 | + $line->desc = $langs->trans("Description")." specimen line with qty too low"; |
|
138 | + $line->qty = 1; // So lower than $quantity |
|
139 | + $line->subprice = 100; |
|
140 | + $line->fk_product = $product->id; |
|
141 | + $line->ref_fourn = $ref_fourn; |
|
142 | + $localobject3->lines[] = $line; |
|
143 | + |
|
144 | + $result = $localobject3->create($user); |
|
145 | 145 | print __METHOD__." result=".$result."\n"; |
146 | - $this->assertGreaterThan(0, $result, 'Creation of too low quantity should be ok'); // must be id of line because there is no test on minimum quantity |
|
146 | + $this->assertGreaterThan(0, $result, 'Creation of too low quantity should be ok'); // must be id of line because there is no test on minimum quantity |
|
147 | 147 | |
148 | - $sql="DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseur where ref=''"; |
|
148 | + $sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseur where ref=''"; |
|
149 | 149 | $db->query($sql); |
150 | 150 | |
151 | 151 | // Create purchase order |
152 | - $localobject4=new CommandeFournisseur($db); |
|
153 | - $localobject4->initAsSpecimen(); // This create 5 lines of first product found for socid 1 |
|
154 | - $localobject4->lines=array(); // Overwrite lines of order |
|
155 | - $line=new CommandeFournisseurLigne($db); |
|
156 | - $line->desc=$langs->trans("Description")." specimen line ok"; |
|
157 | - $line->qty=10; // So enough quantity |
|
158 | - $line->subprice=100; |
|
159 | - $line->fk_product=$product->id; |
|
160 | - $line->ref_fourn=$ref_fourn; |
|
161 | - $localobject4->lines[]=$line; |
|
162 | - |
|
163 | - $result=$localobject4->create($user); |
|
152 | + $localobject4 = new CommandeFournisseur($db); |
|
153 | + $localobject4->initAsSpecimen(); // This create 5 lines of first product found for socid 1 |
|
154 | + $localobject4->lines = array(); // Overwrite lines of order |
|
155 | + $line = new CommandeFournisseurLigne($db); |
|
156 | + $line->desc = $langs->trans("Description")." specimen line ok"; |
|
157 | + $line->qty = 10; // So enough quantity |
|
158 | + $line->subprice = 100; |
|
159 | + $line->fk_product = $product->id; |
|
160 | + $line->ref_fourn = $ref_fourn; |
|
161 | + $localobject4->lines[] = $line; |
|
162 | + |
|
163 | + $result = $localobject4->create($user); |
|
164 | 164 | print __METHOD__." id for purchase order created by testCommandeFournisseurCreate = ".$result."\n"; |
165 | 165 | $this->assertGreaterThan(0, $result, 'Test to create a purchase order by testCommandeFournisseurCreate'); |
166 | 166 | |
@@ -179,14 +179,14 @@ discard block |
||
179 | 179 | */ |
180 | 180 | public function testCommandeFournisseurFetch($id) |
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 | - $localobject=new CommandeFournisseur($db); |
|
189 | - $result=$localobject->fetch($id); |
|
188 | + $localobject = new CommandeFournisseur($db); |
|
189 | + $result = $localobject->fetch($id); |
|
190 | 190 | |
191 | 191 | print __METHOD__." id=".$id." result=".$result."\n"; |
192 | 192 | $this->assertLessThan($result, 0, 'Failed to fetch supplier order with id '.$id); |
@@ -204,13 +204,13 @@ discard block |
||
204 | 204 | */ |
205 | 205 | public function testCommandeFournisseurValid($localobject) |
206 | 206 | { |
207 | - global $conf,$user,$langs,$db; |
|
208 | - $conf=$this->savconf; |
|
209 | - $user=$this->savuser; |
|
210 | - $langs=$this->savlangs; |
|
211 | - $db=$this->savdb; |
|
207 | + global $conf, $user, $langs, $db; |
|
208 | + $conf = $this->savconf; |
|
209 | + $user = $this->savuser; |
|
210 | + $langs = $this->savlangs; |
|
211 | + $db = $this->savdb; |
|
212 | 212 | |
213 | - $result=$localobject->valid($user); |
|
213 | + $result = $localobject->valid($user); |
|
214 | 214 | |
215 | 215 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
216 | 216 | $this->assertLessThan($result, 0); |
@@ -228,13 +228,13 @@ discard block |
||
228 | 228 | */ |
229 | 229 | public function testCommandeFournisseurApprove($localobject) |
230 | 230 | { |
231 | - global $conf,$user,$langs,$db; |
|
232 | - $conf=$this->savconf; |
|
233 | - $user=$this->savuser; |
|
234 | - $langs=$this->savlangs; |
|
235 | - $db=$this->savdb; |
|
231 | + global $conf, $user, $langs, $db; |
|
232 | + $conf = $this->savconf; |
|
233 | + $user = $this->savuser; |
|
234 | + $langs = $this->savlangs; |
|
235 | + $db = $this->savdb; |
|
236 | 236 | |
237 | - $result=$localobject->approve($user); |
|
237 | + $result = $localobject->approve($user); |
|
238 | 238 | |
239 | 239 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
240 | 240 | $this->assertLessThan($result, 0); |
@@ -252,13 +252,13 @@ discard block |
||
252 | 252 | */ |
253 | 253 | public function testCommandeFournisseurCancel($localobject) |
254 | 254 | { |
255 | - global $conf,$user,$langs,$db; |
|
256 | - $conf=$this->savconf; |
|
257 | - $user=$this->savuser; |
|
258 | - $langs=$this->savlangs; |
|
259 | - $db=$this->savdb; |
|
255 | + global $conf, $user, $langs, $db; |
|
256 | + $conf = $this->savconf; |
|
257 | + $user = $this->savuser; |
|
258 | + $langs = $this->savlangs; |
|
259 | + $db = $this->savdb; |
|
260 | 260 | |
261 | - $result=$localobject->cancel($user); |
|
261 | + $result = $localobject->cancel($user); |
|
262 | 262 | |
263 | 263 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
264 | 264 | $this->assertLessThan($result, 0); |
@@ -276,11 +276,11 @@ discard block |
||
276 | 276 | */ |
277 | 277 | public function testCommandeFournisseurOther($localobject) |
278 | 278 | { |
279 | - global $conf,$user,$langs,$db; |
|
280 | - $conf=$this->savconf; |
|
281 | - $user=$this->savuser; |
|
282 | - $langs=$this->savlangs; |
|
283 | - $db=$this->savdb; |
|
279 | + global $conf, $user, $langs, $db; |
|
280 | + $conf = $this->savconf; |
|
281 | + $user = $this->savuser; |
|
282 | + $langs = $this->savlangs; |
|
283 | + $db = $this->savdb; |
|
284 | 284 | |
285 | 285 | /*$result=$localobject->setstatus(0); |
286 | 286 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
@@ -307,15 +307,15 @@ discard block |
||
307 | 307 | */ |
308 | 308 | public function testCommandeFournisseurDelete($id) |
309 | 309 | { |
310 | - global $conf,$user,$langs,$db; |
|
311 | - $conf=$this->savconf; |
|
312 | - $user=$this->savuser; |
|
313 | - $langs=$this->savlangs; |
|
314 | - $db=$this->savdb; |
|
315 | - |
|
316 | - $localobject=new CommandeFournisseur($db); |
|
317 | - $result=$localobject->fetch($id); |
|
318 | - $result=$localobject->delete($user); |
|
310 | + global $conf, $user, $langs, $db; |
|
311 | + $conf = $this->savconf; |
|
312 | + $user = $this->savuser; |
|
313 | + $langs = $this->savlangs; |
|
314 | + $db = $this->savdb; |
|
315 | + |
|
316 | + $localobject = new CommandeFournisseur($db); |
|
317 | + $result = $localobject->fetch($id); |
|
318 | + $result = $localobject->delete($user); |
|
319 | 319 | |
320 | 320 | print __METHOD__." id=".$id." result=".$result."\n"; |
321 | 321 | $this->assertLessThan($result, 0); |
@@ -25,7 +25,7 @@ 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'; |
@@ -38,7 +38,7 @@ 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 | 43 | |
44 | 44 | /** |
@@ -57,14 +57,14 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function testgetImageSize() |
59 | 59 | { |
60 | - $file=dirname(__FILE__).'/img250x50.jpg'; |
|
61 | - $tmp=dol_getImageSize($file); |
|
60 | + $file = dirname(__FILE__).'/img250x50.jpg'; |
|
61 | + $tmp = dol_getImageSize($file); |
|
62 | 62 | print __METHOD__." result=".$tmp['width'].'/'.$tmp['height']."\n"; |
63 | 63 | $this->assertEquals($tmp['width'], 250); |
64 | 64 | $this->assertEquals($tmp['height'], 50); |
65 | 65 | |
66 | - $file=dirname(__FILE__).'/img250x20.png'; |
|
67 | - $tmp=dol_getImageSize($file); |
|
66 | + $file = dirname(__FILE__).'/img250x20.png'; |
|
67 | + $tmp = dol_getImageSize($file); |
|
68 | 68 | print __METHOD__." result=".$tmp['width'].'/'.$tmp['height']."\n"; |
69 | 69 | $this->assertEquals($tmp['width'], 250); |
70 | 70 | $this->assertEquals($tmp['height'], 20); |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | { |
88 | 88 | global $conf; |
89 | 89 | |
90 | - $file=dirname(__FILE__).'/img250x20.png'; |
|
91 | - $filetarget=$conf->admin->dir_temp.'/img250x20.jpg'; |
|
90 | + $file = dirname(__FILE__).'/img250x20.png'; |
|
91 | + $filetarget = $conf->admin->dir_temp.'/img250x20.jpg'; |
|
92 | 92 | dol_delete_file($filetarget); |
93 | 93 | $result = dol_imageResizeOrCrop($file, 0, 0, 0, 0, 0, $filetarget); |
94 | 94 | print __METHOD__." result=".$result."\n"; |
@@ -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 | /** |
@@ -55,13 +55,13 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public function testCalculateDateLimReglement() |
57 | 57 | { |
58 | - global $conf,$user,$langs,$db; |
|
59 | - $conf=$this->savconf; |
|
60 | - $user=$this->savuser; |
|
61 | - $langs=$this->savlangs; |
|
62 | - $db=$this->savdb; |
|
58 | + global $conf, $user, $langs, $db; |
|
59 | + $conf = $this->savconf; |
|
60 | + $user = $this->savuser; |
|
61 | + $langs = $this->savlangs; |
|
62 | + $db = $this->savdb; |
|
63 | 63 | |
64 | - $localobject=new Facture($db); |
|
64 | + $localobject = new Facture($db); |
|
65 | 65 | $localobject->fetch(1); |
66 | 66 | $localobject->date = dol_mktime(12, 0, 0, 1, 1, 2010); |
67 | 67 |
@@ -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 | /** |
@@ -55,15 +55,15 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public function testEntrepotCreate() |
57 | 57 | { |
58 | - global $conf,$user,$langs,$db; |
|
59 | - $conf=$this->savconf; |
|
60 | - $user=$this->savuser; |
|
61 | - $langs=$this->savlangs; |
|
62 | - $db=$this->savdb; |
|
58 | + global $conf, $user, $langs, $db; |
|
59 | + $conf = $this->savconf; |
|
60 | + $user = $this->savuser; |
|
61 | + $langs = $this->savlangs; |
|
62 | + $db = $this->savdb; |
|
63 | 63 | |
64 | - $localobject=new Entrepot($db); |
|
64 | + $localobject = new Entrepot($db); |
|
65 | 65 | $localobject->initAsSpecimen(); |
66 | - $result=$localobject->create($user); |
|
66 | + $result = $localobject->create($user); |
|
67 | 67 | |
68 | 68 | print __METHOD__." result=".$result."\n"; |
69 | 69 | $this->assertGreaterThan(0, $result); |
@@ -82,14 +82,14 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function testEntrepotFetch($id) |
84 | 84 | { |
85 | - global $conf,$user,$langs,$db; |
|
86 | - $conf=$this->savconf; |
|
87 | - $user=$this->savuser; |
|
88 | - $langs=$this->savlangs; |
|
89 | - $db=$this->savdb; |
|
90 | - |
|
91 | - $localobject=new Entrepot($db); |
|
92 | - $result=$localobject->fetch($id); |
|
85 | + global $conf, $user, $langs, $db; |
|
86 | + $conf = $this->savconf; |
|
87 | + $user = $this->savuser; |
|
88 | + $langs = $this->savlangs; |
|
89 | + $db = $this->savdb; |
|
90 | + |
|
91 | + $localobject = new Entrepot($db); |
|
92 | + $result = $localobject->fetch($id); |
|
93 | 93 | print __METHOD__." id=".$id." result=".$result."\n"; |
94 | 94 | $this->assertLessThan($result, 0); |
95 | 95 | |
@@ -107,14 +107,14 @@ discard block |
||
107 | 107 | */ |
108 | 108 | public function testEntrepotUpdate($localobject) |
109 | 109 | { |
110 | - global $conf,$user,$langs,$db; |
|
111 | - $conf=$this->savconf; |
|
112 | - $user=$this->savuser; |
|
113 | - $langs=$this->savlangs; |
|
114 | - $db=$this->savdb; |
|
115 | - |
|
116 | - $localobject->note='New note after update'; |
|
117 | - $result=$localobject->update($localobject->id, $user); |
|
110 | + global $conf, $user, $langs, $db; |
|
111 | + $conf = $this->savconf; |
|
112 | + $user = $this->savuser; |
|
113 | + $langs = $this->savlangs; |
|
114 | + $db = $this->savdb; |
|
115 | + |
|
116 | + $localobject->note = 'New note after update'; |
|
117 | + $result = $localobject->update($localobject->id, $user); |
|
118 | 118 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
119 | 119 | $this->assertLessThan($result, 0); |
120 | 120 | |
@@ -132,11 +132,11 @@ discard block |
||
132 | 132 | */ |
133 | 133 | public function testEntrepotOther($localobject) |
134 | 134 | { |
135 | - global $conf,$user,$langs,$db; |
|
136 | - $conf=$this->savconf; |
|
137 | - $user=$this->savuser; |
|
138 | - $langs=$this->savlangs; |
|
139 | - $db=$this->savdb; |
|
135 | + global $conf, $user, $langs, $db; |
|
136 | + $conf = $this->savconf; |
|
137 | + $user = $this->savuser; |
|
138 | + $langs = $this->savlangs; |
|
139 | + $db = $this->savdb; |
|
140 | 140 | |
141 | 141 | $result = $localobject->get_full_arbo(); |
142 | 142 | $this->assertEquals('WAREHOUSE SPECIMEN', $result); |
@@ -155,16 +155,16 @@ discard block |
||
155 | 155 | */ |
156 | 156 | public function testEntrepotDelete($id) |
157 | 157 | { |
158 | - global $conf,$user,$langs,$db; |
|
159 | - $conf=$this->savconf; |
|
160 | - $user=$this->savuser; |
|
161 | - $langs=$this->savlangs; |
|
162 | - $db=$this->savdb; |
|
158 | + global $conf, $user, $langs, $db; |
|
159 | + $conf = $this->savconf; |
|
160 | + $user = $this->savuser; |
|
161 | + $langs = $this->savlangs; |
|
162 | + $db = $this->savdb; |
|
163 | 163 | |
164 | - $localobject=new Entrepot($db); |
|
165 | - $result=$localobject->fetch($id); |
|
164 | + $localobject = new Entrepot($db); |
|
165 | + $result = $localobject->fetch($id); |
|
166 | 166 | |
167 | - $result=$localobject->delete($user); |
|
167 | + $result = $localobject->delete($user); |
|
168 | 168 | print __METHOD__." id=".$id." result=".$result."\n"; |
169 | 169 | $this->assertLessThan($result, 0, $localobject->errorsToString()); |
170 | 170 |
@@ -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'; |
@@ -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 | /** |
@@ -54,527 +54,527 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function testFactureMercure() |
56 | 56 | { |
57 | - global $conf,$user,$langs,$db,$mysoc; |
|
58 | - $conf=$this->savconf; |
|
59 | - $user=$this->savuser; |
|
60 | - $langs=$this->savlangs; |
|
61 | - $db=$this->savdb; |
|
57 | + global $conf, $user, $langs, $db, $mysoc; |
|
58 | + $conf = $this->savconf; |
|
59 | + $user = $this->savuser; |
|
60 | + $langs = $this->savlangs; |
|
61 | + $db = $this->savdb; |
|
62 | 62 | |
63 | 63 | require_once dirname(__FILE__).'/../../htdocs/compta/facture/class/facture.class.php'; |
64 | 64 | require_once dirname(__FILE__).'/../../htdocs/core/modules/facture/mod_facture_mercure.php'; |
65 | 65 | |
66 | 66 | // First we try with a simple mask, with no reset |
67 | 67 | // and we test counter is still increase second year. |
68 | - $conf->global->FACTURE_ADDON='mercure'; |
|
69 | - $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}-{0000}'; |
|
70 | - $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}-{0000}'; |
|
71 | - $conf->global->FACTURE_MERCURE_MASK_DEPOSIT='{yyyy}-{0000}'; |
|
72 | - $conf->global->FACTURE_MERCURE_MASK_REPLACEMENT='{yyyy}-{0000}'; |
|
73 | - $conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED=0; |
|
74 | - |
|
75 | - $localobject=new Facture($db); |
|
68 | + $conf->global->FACTURE_ADDON = 'mercure'; |
|
69 | + $conf->global->FACTURE_MERCURE_MASK_INVOICE = '{yyyy}-{0000}'; |
|
70 | + $conf->global->FACTURE_MERCURE_MASK_CREDIT = '{yyyy}-{0000}'; |
|
71 | + $conf->global->FACTURE_MERCURE_MASK_DEPOSIT = '{yyyy}-{0000}'; |
|
72 | + $conf->global->FACTURE_MERCURE_MASK_REPLACEMENT = '{yyyy}-{0000}'; |
|
73 | + $conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED = 0; |
|
74 | + |
|
75 | + $localobject = new Facture($db); |
|
76 | 76 | $localobject->initAsSpecimen(); |
77 | 77 | $localobject->fetch_thirdparty(); |
78 | 78 | |
79 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1915); // we use year 1915 to be sure to not have existing invoice for this year (useful only if numbering is {0000@1} |
|
80 | - $numbering=new mod_facture_mercure(); |
|
81 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
79 | + $localobject->date = dol_mktime(12, 0, 0, 1, 1, 1915); // we use year 1915 to be sure to not have existing invoice for this year (useful only if numbering is {0000@1} |
|
80 | + $numbering = new mod_facture_mercure(); |
|
81 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
82 | 82 | print __METHOD__." result=".$result."\n"; |
83 | - $this->assertEquals('1915-0001', $result, 'Test for {yyyy}-{0000}, 1st invoice'); // counter must start to 1 |
|
84 | - $result2=$localobject->create($user, 1); |
|
83 | + $this->assertEquals('1915-0001', $result, 'Test for {yyyy}-{0000}, 1st invoice'); // counter must start to 1 |
|
84 | + $result2 = $localobject->create($user, 1); |
|
85 | 85 | print __METHOD__." result2=".$result."\n"; |
86 | - $result3=$localobject->validate($user, $result); // create invoice by forcing ref |
|
86 | + $result3 = $localobject->validate($user, $result); // create invoice by forcing ref |
|
87 | 87 | print __METHOD__." result3=".$result."\n"; |
88 | - $this->assertEquals(1, $result3, 'Test validation of invoice with forced ref is ok'); // counter must start to 1 |
|
89 | - $result=$localobject->is_erasable(); |
|
88 | + $this->assertEquals(1, $result3, 'Test validation of invoice with forced ref is ok'); // counter must start to 1 |
|
89 | + $result = $localobject->is_erasable(); |
|
90 | 90 | print __METHOD__." is_erasable=".$result."\n"; |
91 | - $this->assertGreaterThanOrEqual(1, $result, 'Test for is_erasable, 1st invoice'); // Can be deleted |
|
91 | + $this->assertGreaterThanOrEqual(1, $result, 'Test for is_erasable, 1st invoice'); // Can be deleted |
|
92 | 92 | |
93 | - $localobject2=new Facture($db); |
|
93 | + $localobject2 = new Facture($db); |
|
94 | 94 | $localobject2->initAsSpecimen(); |
95 | 95 | $localobject2->fetch_thirdparty(); |
96 | 96 | |
97 | - $localobject2->date=dol_mktime(12, 0, 0, 1, 1, 1916); // we use following year for second invoice (there is no reset into mask) |
|
98 | - $numbering=new mod_facture_mercure(); |
|
99 | - $result=$numbering->getNextValue($mysoc, $localobject2, 'last'); |
|
97 | + $localobject2->date = dol_mktime(12, 0, 0, 1, 1, 1916); // we use following year for second invoice (there is no reset into mask) |
|
98 | + $numbering = new mod_facture_mercure(); |
|
99 | + $result = $numbering->getNextValue($mysoc, $localobject2, 'last'); |
|
100 | 100 | print __METHOD__." result=".$result."\n"; |
101 | 101 | $this->assertEquals('1915-0001', $result, "Test to get last value with param 'last'"); |
102 | - $result=$numbering->getNextValue($mysoc, $localobject2); |
|
102 | + $result = $numbering->getNextValue($mysoc, $localobject2); |
|
103 | 103 | print __METHOD__." result=".$result."\n"; |
104 | - $this->assertEquals('1916-0002', $result); // counter must be now 2 (not reset) |
|
105 | - $result2=$localobject2->create($user, 1); |
|
104 | + $this->assertEquals('1916-0002', $result); // counter must be now 2 (not reset) |
|
105 | + $result2 = $localobject2->create($user, 1); |
|
106 | 106 | print __METHOD__." result2=".$result."\n"; |
107 | - $result3=$localobject2->validate($user, $result); // create invoice by forcing ref |
|
107 | + $result3 = $localobject2->validate($user, $result); // create invoice by forcing ref |
|
108 | 108 | print __METHOD__." result3=".$result."\n"; |
109 | - $this->assertEquals(1, $result3, 'Test validation of invoice with forced ref is ok'); // counter must start to 1 |
|
110 | - $result=$localobject2->is_erasable(); |
|
109 | + $this->assertEquals(1, $result3, 'Test validation of invoice with forced ref is ok'); // counter must start to 1 |
|
110 | + $result = $localobject2->is_erasable(); |
|
111 | 111 | print __METHOD__." is_erasable=".$result."\n"; |
112 | - $this->assertGreaterThanOrEqual(1, $result); // Can be deleted |
|
113 | - $result=$localobject->is_erasable(); |
|
112 | + $this->assertGreaterThanOrEqual(1, $result); // Can be deleted |
|
113 | + $result = $localobject->is_erasable(); |
|
114 | 114 | print __METHOD__." is_erasable=".$result."\n"; |
115 | - $this->assertLessThanOrEqual(0, $result, 'Test for {yyyy}-{0000} that is_erasable is 0 for 1st invoice'); // 1 can no more be deleted (2 is more recent) |
|
115 | + $this->assertLessThanOrEqual(0, $result, 'Test for {yyyy}-{0000} that is_erasable is 0 for 1st invoice'); // 1 can no more be deleted (2 is more recent) |
|
116 | 116 | |
117 | 117 | // Now we try with a reset |
118 | - $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}-{0000@1}'; |
|
119 | - $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}-{0000@1}'; |
|
118 | + $conf->global->FACTURE_MERCURE_MASK_CREDIT = '{yyyy}-{0000@1}'; |
|
119 | + $conf->global->FACTURE_MERCURE_MASK_INVOICE = '{yyyy}-{0000@1}'; |
|
120 | 120 | |
121 | - $localobject=new Facture($db); |
|
121 | + $localobject = new Facture($db); |
|
122 | 122 | $localobject->initAsSpecimen(); |
123 | 123 | $localobject->fetch_thirdparty(); |
124 | 124 | |
125 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1910); // we use year 1910 to be sure to not have existing invoice for this year |
|
126 | - $numbering=new mod_facture_mercure(); |
|
127 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
128 | - $result2=$localobject->create($user, 1); |
|
129 | - $result3=$localobject->validate($user, $result); |
|
125 | + $localobject->date = dol_mktime(12, 0, 0, 1, 1, 1910); // we use year 1910 to be sure to not have existing invoice for this year |
|
126 | + $numbering = new mod_facture_mercure(); |
|
127 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
128 | + $result2 = $localobject->create($user, 1); |
|
129 | + $result3 = $localobject->validate($user, $result); |
|
130 | 130 | print __METHOD__." result=".$result."\n"; |
131 | - $this->assertEquals('1910-0001', $result, 'Test for {yyyy}-{0000@1} 1st invoice'); // counter must start to 1 |
|
131 | + $this->assertEquals('1910-0001', $result, 'Test for {yyyy}-{0000@1} 1st invoice'); // counter must start to 1 |
|
132 | 132 | |
133 | - $localobject2=new Facture($db); |
|
133 | + $localobject2 = new Facture($db); |
|
134 | 134 | $localobject2->initAsSpecimen(); |
135 | 135 | $localobject2->fetch_thirdparty(); |
136 | 136 | |
137 | - $localobject2->date=dol_mktime(12, 0, 0, 1, 1, 1910); // we use same year for second invoice (and there is a reset required) |
|
138 | - $numbering=new mod_facture_mercure(); |
|
139 | - $result=$numbering->getNextValue($mysoc, $localobject2); |
|
137 | + $localobject2->date = dol_mktime(12, 0, 0, 1, 1, 1910); // we use same year for second invoice (and there is a reset required) |
|
138 | + $numbering = new mod_facture_mercure(); |
|
139 | + $result = $numbering->getNextValue($mysoc, $localobject2); |
|
140 | 140 | print __METHOD__." result=".$result."\n"; |
141 | - $this->assertEquals('1910-0002', $result, 'Test for {yyyy}-{0000@1} 2nd invoice, same day'); // counter must be now 2 |
|
141 | + $this->assertEquals('1910-0002', $result, 'Test for {yyyy}-{0000@1} 2nd invoice, same day'); // counter must be now 2 |
|
142 | 142 | |
143 | - $localobject3=new Facture($db); |
|
143 | + $localobject3 = new Facture($db); |
|
144 | 144 | $localobject3->initAsSpecimen(); |
145 | 145 | $localobject3->fetch_thirdparty(); |
146 | 146 | |
147 | - $localobject3->date=dol_mktime(12, 0, 0, 1, 1, 1911); // we use next year for third invoice (and there is a reset required) |
|
148 | - $numbering=new mod_facture_mercure(); |
|
149 | - $result=$numbering->getNextValue($mysoc, $localobject3); |
|
147 | + $localobject3->date = dol_mktime(12, 0, 0, 1, 1, 1911); // we use next year for third invoice (and there is a reset required) |
|
148 | + $numbering = new mod_facture_mercure(); |
|
149 | + $result = $numbering->getNextValue($mysoc, $localobject3); |
|
150 | 150 | print __METHOD__." result=".$result."\n"; |
151 | - $this->assertEquals('1911-0001', $result, 'Test for {yyyy}-{0000@1} 3rd invoice, same day'); // counter must be now 1 |
|
151 | + $this->assertEquals('1911-0001', $result, 'Test for {yyyy}-{0000@1} 3rd invoice, same day'); // counter must be now 1 |
|
152 | 152 | |
153 | 153 | // Same but we add month after year |
154 | - $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@1}'; |
|
155 | - $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@1}'; |
|
154 | + $conf->global->FACTURE_MERCURE_MASK_CREDIT = '{yyyy}{mm}-{0000@1}'; |
|
155 | + $conf->global->FACTURE_MERCURE_MASK_INVOICE = '{yyyy}{mm}-{0000@1}'; |
|
156 | 156 | |
157 | - $localobject=new Facture($db); |
|
157 | + $localobject = new Facture($db); |
|
158 | 158 | $localobject->initAsSpecimen(); |
159 | 159 | $localobject->fetch_thirdparty(); |
160 | 160 | |
161 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1920); // we use year 1920 to be sure to not have existing invoice for this year |
|
162 | - $numbering=new mod_facture_mercure(); |
|
163 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
164 | - $result2=$localobject->create($user, 1); |
|
165 | - $result3=$localobject->validate($user, $result); |
|
161 | + $localobject->date = dol_mktime(12, 0, 0, 1, 1, 1920); // we use year 1920 to be sure to not have existing invoice for this year |
|
162 | + $numbering = new mod_facture_mercure(); |
|
163 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
164 | + $result2 = $localobject->create($user, 1); |
|
165 | + $result3 = $localobject->validate($user, $result); |
|
166 | 166 | print __METHOD__." result=".$result."\n"; |
167 | - $this->assertEquals('192001-0001', $result, 'Test for {yyyy}{mm}-{0000@1} 1st invoice'); // counter must start to 1 |
|
168 | - $result=$localobject->is_erasable(); |
|
167 | + $this->assertEquals('192001-0001', $result, 'Test for {yyyy}{mm}-{0000@1} 1st invoice'); // counter must start to 1 |
|
168 | + $result = $localobject->is_erasable(); |
|
169 | 169 | print __METHOD__." is_erasable=".$result."\n"; |
170 | - $this->assertGreaterThanOrEqual(1, $result); // Can be deleted |
|
170 | + $this->assertGreaterThanOrEqual(1, $result); // Can be deleted |
|
171 | 171 | |
172 | - $localobject2=new Facture($db); |
|
172 | + $localobject2 = new Facture($db); |
|
173 | 173 | $localobject2->initAsSpecimen(); |
174 | 174 | $localobject2->fetch_thirdparty(); |
175 | 175 | |
176 | - $localobject2->date=dol_mktime(12, 0, 0, 1, 1, 1921); // we use following year for second invoice (and there is a reset required) |
|
177 | - $numbering=new mod_facture_mercure(); |
|
178 | - $result=$numbering->getNextValue($mysoc, $localobject2); |
|
179 | - $result2=$localobject2->create($user, 1); |
|
180 | - $result3=$localobject2->validate($user, $result); |
|
176 | + $localobject2->date = dol_mktime(12, 0, 0, 1, 1, 1921); // we use following year for second invoice (and there is a reset required) |
|
177 | + $numbering = new mod_facture_mercure(); |
|
178 | + $result = $numbering->getNextValue($mysoc, $localobject2); |
|
179 | + $result2 = $localobject2->create($user, 1); |
|
180 | + $result3 = $localobject2->validate($user, $result); |
|
181 | 181 | print __METHOD__." result=".$result."\n"; |
182 | - $this->assertEquals('192101-0001', $result); // counter must be reset to 1 |
|
183 | - $result=$localobject2->is_erasable(); |
|
182 | + $this->assertEquals('192101-0001', $result); // counter must be reset to 1 |
|
183 | + $result = $localobject2->is_erasable(); |
|
184 | 184 | print __METHOD__." is_erasable=".$result."\n"; |
185 | - $this->assertGreaterThanOrEqual(1, $result); // Can be deleted |
|
186 | - $result=$localobject->is_erasable(); |
|
185 | + $this->assertGreaterThanOrEqual(1, $result); // Can be deleted |
|
186 | + $result = $localobject->is_erasable(); |
|
187 | 187 | print __METHOD__." is_erasable=".$result."\n"; |
188 | - $this->assertGreaterThanOrEqual(1, $result); // Case 1 can be deleted (because there was a reset for case 2) |
|
188 | + $this->assertGreaterThanOrEqual(1, $result); // Case 1 can be deleted (because there was a reset for case 2) |
|
189 | 189 | |
190 | 190 | // Same but we add month before year and use a year on 2 digits |
191 | - $conf->global->FACTURE_MERCURE_MASK_CREDIT='[mm}{yy}-{0000@1}'; |
|
192 | - $conf->global->FACTURE_MERCURE_MASK_INVOICE='{mm}{yy}-{0000@1}'; |
|
193 | - $localobject=new Facture($db); |
|
191 | + $conf->global->FACTURE_MERCURE_MASK_CREDIT = '[mm}{yy}-{0000@1}'; |
|
192 | + $conf->global->FACTURE_MERCURE_MASK_INVOICE = '{mm}{yy}-{0000@1}'; |
|
193 | + $localobject = new Facture($db); |
|
194 | 194 | $localobject->initAsSpecimen(); |
195 | 195 | $localobject->fetch_thirdparty(); |
196 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1925); // we use year 1925 to be sure to not have existing invoice for this year |
|
197 | - $numbering=new mod_facture_mercure(); |
|
198 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
199 | - $result2=$localobject->create($user, 1); |
|
200 | - $result3=$localobject->validate($user, $result); |
|
201 | - print __METHOD__." result=".$result."\n"; |
|
202 | - $this->assertEquals('0125-0001', $result, 'Test for {mm}{yy}-{0000@1} 1st invoice'); // counter must start to 1 |
|
203 | - $result=$localobject->is_erasable(); // This call get getNextNumRef with param 'last' |
|
196 | + $localobject->date = dol_mktime(12, 0, 0, 1, 1, 1925); // we use year 1925 to be sure to not have existing invoice for this year |
|
197 | + $numbering = new mod_facture_mercure(); |
|
198 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
199 | + $result2 = $localobject->create($user, 1); |
|
200 | + $result3 = $localobject->validate($user, $result); |
|
201 | + print __METHOD__." result=".$result."\n"; |
|
202 | + $this->assertEquals('0125-0001', $result, 'Test for {mm}{yy}-{0000@1} 1st invoice'); // counter must start to 1 |
|
203 | + $result = $localobject->is_erasable(); // This call get getNextNumRef with param 'last' |
|
204 | 204 | print __METHOD__." is_erasable=".$result."\n"; |
205 | - $this->assertGreaterThanOrEqual(1, $result); // Can be deleted |
|
205 | + $this->assertGreaterThanOrEqual(1, $result); // Can be deleted |
|
206 | 206 | |
207 | - $localobject2=new Facture($db); |
|
207 | + $localobject2 = new Facture($db); |
|
208 | 208 | $localobject2->initAsSpecimen(); |
209 | 209 | $localobject2->fetch_thirdparty(); |
210 | - $localobject2->date=dol_mktime(12, 0, 0, 1, 1, 1925); // we use same year 1925 for second invoice (and there is a reset required) |
|
211 | - $numbering=new mod_facture_mercure(); |
|
212 | - $result=$numbering->getNextValue($mysoc, $localobject2); |
|
213 | - $result2=$localobject2->create($user, 1); |
|
214 | - $result3=$localobject2->validate($user, $result); |
|
215 | - print __METHOD__." result=".$result."\n"; |
|
216 | - $this->assertEquals('0125-0002', $result, 'Test for {mm}{yy}-{0000@1} 2nd invoice'); // counter must be now 2 |
|
217 | - $result=$localobject2->is_erasable(); |
|
210 | + $localobject2->date = dol_mktime(12, 0, 0, 1, 1, 1925); // we use same year 1925 for second invoice (and there is a reset required) |
|
211 | + $numbering = new mod_facture_mercure(); |
|
212 | + $result = $numbering->getNextValue($mysoc, $localobject2); |
|
213 | + $result2 = $localobject2->create($user, 1); |
|
214 | + $result3 = $localobject2->validate($user, $result); |
|
215 | + print __METHOD__." result=".$result."\n"; |
|
216 | + $this->assertEquals('0125-0002', $result, 'Test for {mm}{yy}-{0000@1} 2nd invoice'); // counter must be now 2 |
|
217 | + $result = $localobject2->is_erasable(); |
|
218 | 218 | print __METHOD__." is_erasable=".$result."\n"; |
219 | - $this->assertGreaterThanOrEqual(1, $result); // Can be deleted |
|
220 | - $result=$localobject->is_erasable(); |
|
219 | + $this->assertGreaterThanOrEqual(1, $result); // Can be deleted |
|
220 | + $result = $localobject->is_erasable(); |
|
221 | 221 | print __METHOD__." is_erasable=".$result."\n"; |
222 | - $this->assertLessThanOrEqual(0, $result); // Case 1 can not be deleted (because there is an invoice 2) |
|
222 | + $this->assertLessThanOrEqual(0, $result); // Case 1 can not be deleted (because there is an invoice 2) |
|
223 | 223 | |
224 | - $localobject3=new Facture($db); |
|
224 | + $localobject3 = new Facture($db); |
|
225 | 225 | $localobject3->initAsSpecimen(); |
226 | 226 | $localobject3->fetch_thirdparty(); |
227 | - $localobject3->date=dol_mktime(12, 0, 0, 1, 1, 1926); // we use following year for third invoice (and there is a reset required) |
|
228 | - $numbering=new mod_facture_mercure(); |
|
229 | - $result=$numbering->getNextValue($mysoc, $localobject3); |
|
227 | + $localobject3->date = dol_mktime(12, 0, 0, 1, 1, 1926); // we use following year for third invoice (and there is a reset required) |
|
228 | + $numbering = new mod_facture_mercure(); |
|
229 | + $result = $numbering->getNextValue($mysoc, $localobject3); |
|
230 | 230 | print __METHOD__." result=".$result."\n"; |
231 | - $this->assertEquals('0126-0001', $result, 'Test for {mm}{yy}-{0000@1} 3rd invoice'); // counter must be now 1 |
|
231 | + $this->assertEquals('0126-0001', $result, 'Test for {mm}{yy}-{0000@1} 3rd invoice'); // counter must be now 1 |
|
232 | 232 | |
233 | 233 | // Try an offset when an invoice already exists |
234 | - $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000+9990}'; |
|
235 | - $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000+9990}'; |
|
236 | - $result=$numbering->getNextValue($mysoc, $localobject2); |
|
234 | + $conf->global->FACTURE_MERCURE_MASK_CREDIT = '{yyyy}{mm}-{0000+9990}'; |
|
235 | + $conf->global->FACTURE_MERCURE_MASK_INVOICE = '{yyyy}{mm}-{0000+9990}'; |
|
236 | + $result = $numbering->getNextValue($mysoc, $localobject2); |
|
237 | 237 | |
238 | 238 | // Now we try with a different fiscal month (forced by mask) |
239 | - $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@6}'; |
|
240 | - $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@6}'; |
|
239 | + $conf->global->FACTURE_MERCURE_MASK_CREDIT = '{yyyy}{mm}-{0000@6}'; |
|
240 | + $conf->global->FACTURE_MERCURE_MASK_INVOICE = '{yyyy}{mm}-{0000@6}'; |
|
241 | 241 | |
242 | - $localobject=new Facture($db); |
|
242 | + $localobject = new Facture($db); |
|
243 | 243 | $localobject->initAsSpecimen(); |
244 | 244 | $localobject->fetch_thirdparty(); |
245 | 245 | |
246 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1930); // we use year 1930 to be sure to not have existing invoice for this year |
|
247 | - $numbering=new mod_facture_mercure(); |
|
248 | - $result=$numbering->getNextValue($mysoc, $localobject, 'last'); |
|
246 | + $localobject->date = dol_mktime(12, 0, 0, 1, 1, 1930); // we use year 1930 to be sure to not have existing invoice for this year |
|
247 | + $numbering = new mod_facture_mercure(); |
|
248 | + $result = $numbering->getNextValue($mysoc, $localobject, 'last'); |
|
249 | 249 | print __METHOD__." result for last=".$result."\n"; |
250 | - $this->assertEquals('', $result); // no existing ref into reset range |
|
251 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
252 | - $result2=$localobject->create($user, 1); |
|
253 | - $result3=$localobject->validate($user, $result); |
|
250 | + $this->assertEquals('', $result); // no existing ref into reset range |
|
251 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
252 | + $result2 = $localobject->create($user, 1); |
|
253 | + $result3 = $localobject->validate($user, $result); |
|
254 | 254 | print __METHOD__." result=".$result."\n"; |
255 | - $this->assertEquals('193001-0001', $result); // counter must start to 1 |
|
256 | - $result=$numbering->getNextValue($mysoc, $localobject, 'last'); |
|
255 | + $this->assertEquals('193001-0001', $result); // counter must start to 1 |
|
256 | + $result = $numbering->getNextValue($mysoc, $localobject, 'last'); |
|
257 | 257 | print __METHOD__." result for last=".$result."\n"; |
258 | - $this->assertEquals('193001-0001', $result); // last ref into reset range should be same than last created |
|
258 | + $this->assertEquals('193001-0001', $result); // last ref into reset range should be same than last created |
|
259 | 259 | |
260 | - $localobject=new Facture($db); |
|
260 | + $localobject = new Facture($db); |
|
261 | 261 | $localobject->initAsSpecimen(); |
262 | 262 | $localobject->fetch_thirdparty(); |
263 | 263 | |
264 | - $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1930); // we use same year but fiscal month after |
|
265 | - $numbering=new mod_facture_mercure(); |
|
266 | - $result=$numbering->getNextValue($mysoc, $localobject, 'last'); |
|
264 | + $localobject->date = dol_mktime(12, 0, 0, 12, 1, 1930); // we use same year but fiscal month after |
|
265 | + $numbering = new mod_facture_mercure(); |
|
266 | + $result = $numbering->getNextValue($mysoc, $localobject, 'last'); |
|
267 | 267 | print __METHOD__." result for last=".$result."\n"; |
268 | - $this->assertEquals('', $result); // last ref into reset range should be '' |
|
269 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
270 | - $result2=$localobject->create($user, 1); |
|
271 | - $result3=$localobject->validate($user, $result); |
|
268 | + $this->assertEquals('', $result); // last ref into reset range should be '' |
|
269 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
270 | + $result2 = $localobject->create($user, 1); |
|
271 | + $result3 = $localobject->validate($user, $result); |
|
272 | 272 | print __METHOD__." result=".$result."\n"; |
273 | - $this->assertEquals('193012-0001', $result); // counter must be reset to 1 |
|
273 | + $this->assertEquals('193012-0001', $result); // counter must be reset to 1 |
|
274 | 274 | |
275 | - $localobject=new Facture($db); |
|
275 | + $localobject = new Facture($db); |
|
276 | 276 | $localobject->initAsSpecimen(); |
277 | 277 | $localobject->fetch_thirdparty(); |
278 | 278 | |
279 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1931); // we use same fiscal year but different year |
|
280 | - $numbering=new mod_facture_mercure(); |
|
281 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
282 | - $result2=$localobject->create($user, 1); |
|
283 | - $result3=$localobject->validate($user, $result); |
|
279 | + $localobject->date = dol_mktime(12, 0, 0, 1, 1, 1931); // we use same fiscal year but different year |
|
280 | + $numbering = new mod_facture_mercure(); |
|
281 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
282 | + $result2 = $localobject->create($user, 1); |
|
283 | + $result3 = $localobject->validate($user, $result); |
|
284 | 284 | print __METHOD__." result=".$result."\n"; |
285 | - $this->assertEquals('193101-0002', $result); // counter must be 2 |
|
285 | + $this->assertEquals('193101-0002', $result); // counter must be 2 |
|
286 | 286 | |
287 | - $localobject=new Facture($db); |
|
287 | + $localobject = new Facture($db); |
|
288 | 288 | $localobject->initAsSpecimen(); |
289 | 289 | $localobject->fetch_thirdparty(); |
290 | 290 | |
291 | - $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1931); // we use different fiscal year but same year |
|
292 | - $numbering=new mod_facture_mercure(); |
|
293 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
291 | + $localobject->date = dol_mktime(12, 0, 0, 12, 1, 1931); // we use different fiscal year but same year |
|
292 | + $numbering = new mod_facture_mercure(); |
|
293 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
294 | 294 | print __METHOD__." result=".$result."\n"; |
295 | - $this->assertEquals('193112-0001', $result); // counter must be reset to 1 |
|
295 | + $this->assertEquals('193112-0001', $result); // counter must be reset to 1 |
|
296 | 296 | |
297 | 297 | |
298 | 298 | // Now we try with a different fiscal month (defined by SOCIETE_FISCAL_MONTH_START) |
299 | - $conf->global->SOCIETE_FISCAL_MONTH_START=6; |
|
300 | - $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@0}'; |
|
301 | - $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@0}'; |
|
299 | + $conf->global->SOCIETE_FISCAL_MONTH_START = 6; |
|
300 | + $conf->global->FACTURE_MERCURE_MASK_CREDIT = '{yyyy}{mm}-{0000@0}'; |
|
301 | + $conf->global->FACTURE_MERCURE_MASK_INVOICE = '{yyyy}{mm}-{0000@0}'; |
|
302 | 302 | |
303 | - $localobject=new Facture($db); |
|
303 | + $localobject = new Facture($db); |
|
304 | 304 | $localobject->initAsSpecimen(); |
305 | 305 | $localobject->fetch_thirdparty(); |
306 | 306 | |
307 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1940); // we use year 1940 to be sure to not have existing invoice for this year |
|
308 | - $numbering=new mod_facture_mercure(); |
|
309 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
310 | - $result2=$localobject->create($user, 1); |
|
311 | - $result3=$localobject->validate($user, $result); |
|
307 | + $localobject->date = dol_mktime(12, 0, 0, 1, 1, 1940); // we use year 1940 to be sure to not have existing invoice for this year |
|
308 | + $numbering = new mod_facture_mercure(); |
|
309 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
310 | + $result2 = $localobject->create($user, 1); |
|
311 | + $result3 = $localobject->validate($user, $result); |
|
312 | 312 | print __METHOD__." result=".$result."\n"; |
313 | - $this->assertEquals('194001-0001', $result); // counter must start to 1 |
|
313 | + $this->assertEquals('194001-0001', $result); // counter must start to 1 |
|
314 | 314 | |
315 | - $localobject=new Facture($db); |
|
315 | + $localobject = new Facture($db); |
|
316 | 316 | $localobject->initAsSpecimen(); |
317 | 317 | $localobject->fetch_thirdparty(); |
318 | 318 | |
319 | - $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1940); // we use same year but fiscal month after |
|
320 | - $numbering=new mod_facture_mercure(); |
|
321 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
322 | - $result2=$localobject->create($user, 1); |
|
323 | - $result3=$localobject->validate($user, $result); |
|
319 | + $localobject->date = dol_mktime(12, 0, 0, 12, 1, 1940); // we use same year but fiscal month after |
|
320 | + $numbering = new mod_facture_mercure(); |
|
321 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
322 | + $result2 = $localobject->create($user, 1); |
|
323 | + $result3 = $localobject->validate($user, $result); |
|
324 | 324 | print __METHOD__." result=".$result."\n"; |
325 | - $this->assertEquals('194012-0001', $result); // counter must be reset to 1 |
|
325 | + $this->assertEquals('194012-0001', $result); // counter must be reset to 1 |
|
326 | 326 | |
327 | - $localobject=new Facture($db); |
|
327 | + $localobject = new Facture($db); |
|
328 | 328 | $localobject->initAsSpecimen(); |
329 | 329 | $localobject->fetch_thirdparty(); |
330 | 330 | |
331 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1941); // we use same fiscal year but different year |
|
332 | - $numbering=new mod_facture_mercure(); |
|
333 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
334 | - $result2=$localobject->create($user, 1); |
|
335 | - $result3=$localobject->validate($user, $result); |
|
331 | + $localobject->date = dol_mktime(12, 0, 0, 1, 1, 1941); // we use same fiscal year but different year |
|
332 | + $numbering = new mod_facture_mercure(); |
|
333 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
334 | + $result2 = $localobject->create($user, 1); |
|
335 | + $result3 = $localobject->validate($user, $result); |
|
336 | 336 | print __METHOD__." result=".$result."\n"; |
337 | - $this->assertEquals('194101-0002', $result); // counter must be 2 |
|
337 | + $this->assertEquals('194101-0002', $result); // counter must be 2 |
|
338 | 338 | |
339 | - $localobject=new Facture($db); |
|
339 | + $localobject = new Facture($db); |
|
340 | 340 | $localobject->initAsSpecimen(); |
341 | 341 | $localobject->fetch_thirdparty(); |
342 | 342 | |
343 | - $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1941); // we use different discal year but same year |
|
344 | - $numbering=new mod_facture_mercure(); |
|
345 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
343 | + $localobject->date = dol_mktime(12, 0, 0, 12, 1, 1941); // we use different discal year but same year |
|
344 | + $numbering = new mod_facture_mercure(); |
|
345 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
346 | 346 | print __METHOD__." result=".$result."\n"; |
347 | - $this->assertEquals('194112-0001', $result); // counter must be reset to 1 |
|
347 | + $this->assertEquals('194112-0001', $result); // counter must be reset to 1 |
|
348 | 348 | |
349 | 349 | |
350 | 350 | // Now we try with a different fiscal month (defined by SOCIETE_FISCAL_MONTH_START) and we always want year of element |
351 | - $conf->global->SOCIETE_FISCAL_MONTH_START=6; |
|
352 | - $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@=}'; |
|
353 | - $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@=}'; |
|
351 | + $conf->global->SOCIETE_FISCAL_MONTH_START = 6; |
|
352 | + $conf->global->FACTURE_MERCURE_MASK_CREDIT = '{yyyy}{mm}-{0000@=}'; |
|
353 | + $conf->global->FACTURE_MERCURE_MASK_INVOICE = '{yyyy}{mm}-{0000@=}'; |
|
354 | 354 | |
355 | - $localobject=new Facture($db); |
|
355 | + $localobject = new Facture($db); |
|
356 | 356 | $localobject->initAsSpecimen(); |
357 | 357 | $localobject->fetch_thirdparty(); |
358 | 358 | |
359 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1950); // we use year 1950 to be sure to not have existing invoice for this year |
|
360 | - $numbering=new mod_facture_mercure(); |
|
361 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
362 | - $result2=$localobject->create($user, 1); |
|
363 | - $result3=$localobject->validate($user, $result); |
|
359 | + $localobject->date = dol_mktime(12, 0, 0, 1, 1, 1950); // we use year 1950 to be sure to not have existing invoice for this year |
|
360 | + $numbering = new mod_facture_mercure(); |
|
361 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
362 | + $result2 = $localobject->create($user, 1); |
|
363 | + $result3 = $localobject->validate($user, $result); |
|
364 | 364 | print __METHOD__." result=".$result."\n"; |
365 | - $this->assertEquals('195001-0001', $result); // counter must start to 1 |
|
365 | + $this->assertEquals('195001-0001', $result); // counter must start to 1 |
|
366 | 366 | |
367 | - $localobject=new Facture($db); |
|
367 | + $localobject = new Facture($db); |
|
368 | 368 | $localobject->initAsSpecimen(); |
369 | 369 | $localobject->fetch_thirdparty(); |
370 | 370 | |
371 | - $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1950); // we use same year but fiscal month after |
|
372 | - $numbering=new mod_facture_mercure(); |
|
373 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
374 | - $result2=$localobject->create($user, 1); |
|
375 | - $result3=$localobject->validate($user, $result); |
|
371 | + $localobject->date = dol_mktime(12, 0, 0, 12, 1, 1950); // we use same year but fiscal month after |
|
372 | + $numbering = new mod_facture_mercure(); |
|
373 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
374 | + $result2 = $localobject->create($user, 1); |
|
375 | + $result3 = $localobject->validate($user, $result); |
|
376 | 376 | print __METHOD__." result=".$result."\n"; |
377 | - $this->assertEquals('195012-0001', $result); // counter must be reset to 1 |
|
377 | + $this->assertEquals('195012-0001', $result); // counter must be reset to 1 |
|
378 | 378 | |
379 | - $localobject=new Facture($db); |
|
379 | + $localobject = new Facture($db); |
|
380 | 380 | $localobject->initAsSpecimen(); |
381 | 381 | $localobject->fetch_thirdparty(); |
382 | 382 | |
383 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1951); // we use same fiscal year but different year |
|
384 | - $numbering=new mod_facture_mercure(); |
|
385 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
386 | - $result2=$localobject->create($user, 1); |
|
387 | - $result3=$localobject->validate($user, $result); |
|
383 | + $localobject->date = dol_mktime(12, 0, 0, 1, 1, 1951); // we use same fiscal year but different year |
|
384 | + $numbering = new mod_facture_mercure(); |
|
385 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
386 | + $result2 = $localobject->create($user, 1); |
|
387 | + $result3 = $localobject->validate($user, $result); |
|
388 | 388 | print __METHOD__." result=".$result."\n"; |
389 | - $this->assertEquals('195101-0002', $result); // counter must be 2 |
|
389 | + $this->assertEquals('195101-0002', $result); // counter must be 2 |
|
390 | 390 | |
391 | - $localobject=new Facture($db); |
|
391 | + $localobject = new Facture($db); |
|
392 | 392 | $localobject->initAsSpecimen(); |
393 | 393 | $localobject->fetch_thirdparty(); |
394 | 394 | |
395 | - $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1951); // we use different discal year but same year |
|
396 | - $numbering=new mod_facture_mercure(); |
|
397 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
395 | + $localobject->date = dol_mktime(12, 0, 0, 12, 1, 1951); // we use different discal year but same year |
|
396 | + $numbering = new mod_facture_mercure(); |
|
397 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
398 | 398 | print __METHOD__." result=".$result."\n"; |
399 | - $this->assertEquals('195112-0001', $result); // counter must be reset to 1 |
|
399 | + $this->assertEquals('195112-0001', $result); // counter must be reset to 1 |
|
400 | 400 | |
401 | 401 | |
402 | 402 | // Now we try with a different fiscal month (defined by SOCIETE_FISCAL_MONTH_START) and we always want start year |
403 | - $conf->global->SOCIETE_FISCAL_MONTH_START=6; |
|
404 | - $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@-}'; |
|
405 | - $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@-}'; |
|
403 | + $conf->global->SOCIETE_FISCAL_MONTH_START = 6; |
|
404 | + $conf->global->FACTURE_MERCURE_MASK_CREDIT = '{yyyy}{mm}-{0000@-}'; |
|
405 | + $conf->global->FACTURE_MERCURE_MASK_INVOICE = '{yyyy}{mm}-{0000@-}'; |
|
406 | 406 | |
407 | - $localobject=new Facture($db); |
|
407 | + $localobject = new Facture($db); |
|
408 | 408 | $localobject->initAsSpecimen(); |
409 | 409 | $localobject->fetch_thirdparty(); |
410 | 410 | |
411 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1960); // we use year 1960 to be sure to not have existing invoice for this year |
|
412 | - $numbering=new mod_facture_mercure(); |
|
413 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
414 | - $result2=$localobject->create($user, 1); |
|
415 | - $result3=$localobject->validate($user, $result); |
|
411 | + $localobject->date = dol_mktime(12, 0, 0, 1, 1, 1960); // we use year 1960 to be sure to not have existing invoice for this year |
|
412 | + $numbering = new mod_facture_mercure(); |
|
413 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
414 | + $result2 = $localobject->create($user, 1); |
|
415 | + $result3 = $localobject->validate($user, $result); |
|
416 | 416 | print __METHOD__." result=".$result."\n"; |
417 | - $this->assertEquals('195901-0001', $result); // counter must start to 1 |
|
417 | + $this->assertEquals('195901-0001', $result); // counter must start to 1 |
|
418 | 418 | |
419 | - $localobject=new Facture($db); |
|
419 | + $localobject = new Facture($db); |
|
420 | 420 | $localobject->initAsSpecimen(); |
421 | 421 | $localobject->fetch_thirdparty(); |
422 | 422 | |
423 | - $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1960); // we use same year but fiscal month after |
|
424 | - $numbering=new mod_facture_mercure(); |
|
425 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
426 | - $result2=$localobject->create($user, 1); |
|
427 | - $result3=$localobject->validate($user, $result); |
|
423 | + $localobject->date = dol_mktime(12, 0, 0, 12, 1, 1960); // we use same year but fiscal month after |
|
424 | + $numbering = new mod_facture_mercure(); |
|
425 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
426 | + $result2 = $localobject->create($user, 1); |
|
427 | + $result3 = $localobject->validate($user, $result); |
|
428 | 428 | print __METHOD__." result=".$result."\n"; |
429 | - $this->assertEquals('196012-0001', $result); // counter must be reset to 1 |
|
429 | + $this->assertEquals('196012-0001', $result); // counter must be reset to 1 |
|
430 | 430 | |
431 | - $localobject=new Facture($db); |
|
431 | + $localobject = new Facture($db); |
|
432 | 432 | $localobject->initAsSpecimen(); |
433 | 433 | $localobject->fetch_thirdparty(); |
434 | 434 | |
435 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1961); // we use same fiscal year but different year |
|
436 | - $numbering=new mod_facture_mercure(); |
|
437 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
438 | - $result2=$localobject->create($user, 1); |
|
439 | - $result3=$localobject->validate($user, $result); |
|
435 | + $localobject->date = dol_mktime(12, 0, 0, 1, 1, 1961); // we use same fiscal year but different year |
|
436 | + $numbering = new mod_facture_mercure(); |
|
437 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
438 | + $result2 = $localobject->create($user, 1); |
|
439 | + $result3 = $localobject->validate($user, $result); |
|
440 | 440 | print __METHOD__." result=".$result."\n"; |
441 | - $this->assertEquals('196001-0002', $result); // counter must be 2 |
|
441 | + $this->assertEquals('196001-0002', $result); // counter must be 2 |
|
442 | 442 | |
443 | - $localobject=new Facture($db); |
|
443 | + $localobject = new Facture($db); |
|
444 | 444 | $localobject->initAsSpecimen(); |
445 | 445 | $localobject->fetch_thirdparty(); |
446 | 446 | |
447 | - $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1961); // we use different discal year but same year |
|
448 | - $numbering=new mod_facture_mercure(); |
|
449 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
447 | + $localobject->date = dol_mktime(12, 0, 0, 12, 1, 1961); // we use different discal year but same year |
|
448 | + $numbering = new mod_facture_mercure(); |
|
449 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
450 | 450 | print __METHOD__." result=".$result."\n"; |
451 | - $this->assertEquals('196112-0001', $result); // counter must be reset to 1 |
|
451 | + $this->assertEquals('196112-0001', $result); // counter must be reset to 1 |
|
452 | 452 | |
453 | 453 | |
454 | 454 | // Now we try with a different fiscal month (defined by SOCIETE_FISCAL_MONTH_START) and we always want end year |
455 | - $conf->global->SOCIETE_FISCAL_MONTH_START=6; |
|
456 | - $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@+}'; |
|
457 | - $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@+}'; |
|
455 | + $conf->global->SOCIETE_FISCAL_MONTH_START = 6; |
|
456 | + $conf->global->FACTURE_MERCURE_MASK_CREDIT = '{yyyy}{mm}-{0000@+}'; |
|
457 | + $conf->global->FACTURE_MERCURE_MASK_INVOICE = '{yyyy}{mm}-{0000@+}'; |
|
458 | 458 | |
459 | - $localobject=new Facture($db); |
|
459 | + $localobject = new Facture($db); |
|
460 | 460 | $localobject->initAsSpecimen(); |
461 | 461 | $localobject->fetch_thirdparty(); |
462 | 462 | |
463 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1970); // we use year 1970 to be sure to not have existing invoice for this year |
|
464 | - $numbering=new mod_facture_mercure(); |
|
465 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
466 | - $result2=$localobject->create($user, 1); |
|
467 | - $result3=$localobject->validate($user, $result); |
|
463 | + $localobject->date = dol_mktime(12, 0, 0, 1, 1, 1970); // we use year 1970 to be sure to not have existing invoice for this year |
|
464 | + $numbering = new mod_facture_mercure(); |
|
465 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
466 | + $result2 = $localobject->create($user, 1); |
|
467 | + $result3 = $localobject->validate($user, $result); |
|
468 | 468 | print __METHOD__." result=".$result."\n"; |
469 | - $this->assertEquals('197001-0001', $result); // counter must start to 1 |
|
469 | + $this->assertEquals('197001-0001', $result); // counter must start to 1 |
|
470 | 470 | |
471 | - $localobject=new Facture($db); |
|
471 | + $localobject = new Facture($db); |
|
472 | 472 | $localobject->initAsSpecimen(); |
473 | 473 | $localobject->fetch_thirdparty(); |
474 | 474 | |
475 | - $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1970); // we use same year but fiscal month after |
|
476 | - $numbering=new mod_facture_mercure(); |
|
477 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
478 | - $result2=$localobject->create($user, 1); |
|
479 | - $result3=$localobject->validate($user, $result); |
|
475 | + $localobject->date = dol_mktime(12, 0, 0, 12, 1, 1970); // we use same year but fiscal month after |
|
476 | + $numbering = new mod_facture_mercure(); |
|
477 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
478 | + $result2 = $localobject->create($user, 1); |
|
479 | + $result3 = $localobject->validate($user, $result); |
|
480 | 480 | print __METHOD__." result=".$result."\n"; |
481 | - $this->assertEquals('197112-0001', $result); // counter must be reset to 1 |
|
481 | + $this->assertEquals('197112-0001', $result); // counter must be reset to 1 |
|
482 | 482 | |
483 | - $localobject=new Facture($db); |
|
483 | + $localobject = new Facture($db); |
|
484 | 484 | $localobject->initAsSpecimen(); |
485 | 485 | $localobject->fetch_thirdparty(); |
486 | 486 | |
487 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1971); // we use same fiscal year but different year |
|
488 | - $numbering=new mod_facture_mercure(); |
|
489 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
490 | - $result2=$localobject->create($user, 1); |
|
491 | - $result3=$localobject->validate($user, $result); |
|
487 | + $localobject->date = dol_mktime(12, 0, 0, 1, 1, 1971); // we use same fiscal year but different year |
|
488 | + $numbering = new mod_facture_mercure(); |
|
489 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
490 | + $result2 = $localobject->create($user, 1); |
|
491 | + $result3 = $localobject->validate($user, $result); |
|
492 | 492 | print __METHOD__." result=".$result."\n"; |
493 | - $this->assertEquals('197101-0002', $result); // counter must be 2 |
|
493 | + $this->assertEquals('197101-0002', $result); // counter must be 2 |
|
494 | 494 | |
495 | - $localobject=new Facture($db); |
|
495 | + $localobject = new Facture($db); |
|
496 | 496 | $localobject->initAsSpecimen(); |
497 | 497 | $localobject->fetch_thirdparty(); |
498 | 498 | |
499 | - $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1971); // we use different fiscal year but same year |
|
500 | - $numbering=new mod_facture_mercure(); |
|
501 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
499 | + $localobject->date = dol_mktime(12, 0, 0, 12, 1, 1971); // we use different fiscal year but same year |
|
500 | + $numbering = new mod_facture_mercure(); |
|
501 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
502 | 502 | print __METHOD__." result=".$result."\n"; |
503 | - $this->assertEquals('197212-0001', $result); // counter must be reset to 1 |
|
503 | + $this->assertEquals('197212-0001', $result); // counter must be reset to 1 |
|
504 | 504 | |
505 | 505 | // Now we try with a reset every month (@99) |
506 | - $conf->global->SOCIETE_FISCAL_MONTH_START=6; |
|
507 | - $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@99}'; |
|
508 | - $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@99}'; |
|
506 | + $conf->global->SOCIETE_FISCAL_MONTH_START = 6; |
|
507 | + $conf->global->FACTURE_MERCURE_MASK_CREDIT = '{yyyy}{mm}-{0000@99}'; |
|
508 | + $conf->global->FACTURE_MERCURE_MASK_INVOICE = '{yyyy}{mm}-{0000@99}'; |
|
509 | 509 | |
510 | - $localobject=new Facture($db); |
|
510 | + $localobject = new Facture($db); |
|
511 | 511 | $localobject->initAsSpecimen(); |
512 | 512 | $localobject->fetch_thirdparty(); |
513 | 513 | |
514 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1980); // we use year 1980 to be sure to not have existing invoice for this year |
|
515 | - $numbering=new mod_facture_mercure(); |
|
516 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
517 | - $result2=$localobject->create($user, 1); |
|
518 | - $result3=$localobject->validate($user, $result); |
|
514 | + $localobject->date = dol_mktime(12, 0, 0, 1, 1, 1980); // we use year 1980 to be sure to not have existing invoice for this year |
|
515 | + $numbering = new mod_facture_mercure(); |
|
516 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
517 | + $result2 = $localobject->create($user, 1); |
|
518 | + $result3 = $localobject->validate($user, $result); |
|
519 | 519 | print __METHOD__." result=".$result."\n"; |
520 | - $this->assertEquals('198001-0001', $result); // counter must start to 1 |
|
520 | + $this->assertEquals('198001-0001', $result); // counter must start to 1 |
|
521 | 521 | |
522 | - $localobject=new Facture($db); |
|
522 | + $localobject = new Facture($db); |
|
523 | 523 | $localobject->initAsSpecimen(); |
524 | 524 | $localobject->fetch_thirdparty(); |
525 | 525 | |
526 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1980); // we use year 1980 to be sure to not have existing invoice for this year |
|
527 | - $numbering=new mod_facture_mercure(); |
|
528 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
529 | - $result2=$localobject->create($user, 1); |
|
530 | - $result3=$localobject->validate($user, $result); |
|
526 | + $localobject->date = dol_mktime(12, 0, 0, 1, 1, 1980); // we use year 1980 to be sure to not have existing invoice for this year |
|
527 | + $numbering = new mod_facture_mercure(); |
|
528 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
529 | + $result2 = $localobject->create($user, 1); |
|
530 | + $result3 = $localobject->validate($user, $result); |
|
531 | 531 | print __METHOD__." result=".$result."\n"; |
532 | - $this->assertEquals('198001-0002', $result); // counter must start to 2 |
|
532 | + $this->assertEquals('198001-0002', $result); // counter must start to 2 |
|
533 | 533 | |
534 | - $localobject=new Facture($db); |
|
534 | + $localobject = new Facture($db); |
|
535 | 535 | $localobject->initAsSpecimen(); |
536 | 536 | $localobject->fetch_thirdparty(); |
537 | 537 | |
538 | - $localobject->date=dol_mktime(12, 0, 0, 2, 1, 1980); // we use year 1980 to be sure to not have existing invoice for this year |
|
539 | - $numbering=new mod_facture_mercure(); |
|
540 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
541 | - $result2=$localobject->create($user, 1); |
|
542 | - $result3=$localobject->validate($user, $result); |
|
538 | + $localobject->date = dol_mktime(12, 0, 0, 2, 1, 1980); // we use year 1980 to be sure to not have existing invoice for this year |
|
539 | + $numbering = new mod_facture_mercure(); |
|
540 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
541 | + $result2 = $localobject->create($user, 1); |
|
542 | + $result3 = $localobject->validate($user, $result); |
|
543 | 543 | print __METHOD__." result=".$result."\n"; |
544 | - $this->assertEquals('198002-0001', $result); // counter must start to 1 |
|
544 | + $this->assertEquals('198002-0001', $result); // counter must start to 1 |
|
545 | 545 | |
546 | - $localobject=new Facture($db); |
|
546 | + $localobject = new Facture($db); |
|
547 | 547 | $localobject->initAsSpecimen(); |
548 | 548 | $localobject->fetch_thirdparty(); |
549 | 549 | |
550 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1981); // we use year 1981 to be sure to not have existing invoice for this year |
|
551 | - $numbering=new mod_facture_mercure(); |
|
552 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
553 | - $result2=$localobject->create($user, 1); |
|
554 | - $result3=$localobject->validate($user, $result); |
|
550 | + $localobject->date = dol_mktime(12, 0, 0, 1, 1, 1981); // we use year 1981 to be sure to not have existing invoice for this year |
|
551 | + $numbering = new mod_facture_mercure(); |
|
552 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
553 | + $result2 = $localobject->create($user, 1); |
|
554 | + $result3 = $localobject->validate($user, $result); |
|
555 | 555 | print __METHOD__." result=".$result."\n"; |
556 | - $this->assertEquals('198101-0001', $result); // counter must start to 1 |
|
556 | + $this->assertEquals('198101-0001', $result); // counter must start to 1 |
|
557 | 557 | |
558 | 558 | // Test with {t} tag |
559 | - $conf->global->SOCIETE_FISCAL_MONTH_START=1; |
|
560 | - $conf->global->FACTURE_MERCURE_MASK_CREDIT='{t}{yyyy}{mm}-{0000}'; |
|
561 | - $conf->global->FACTURE_MERCURE_MASK_INVOICE='{t}{yyyy}{mm}-{0000}'; |
|
559 | + $conf->global->SOCIETE_FISCAL_MONTH_START = 1; |
|
560 | + $conf->global->FACTURE_MERCURE_MASK_CREDIT = '{t}{yyyy}{mm}-{0000}'; |
|
561 | + $conf->global->FACTURE_MERCURE_MASK_INVOICE = '{t}{yyyy}{mm}-{0000}'; |
|
562 | 562 | |
563 | - $tmpthirdparty=new Societe($db); |
|
563 | + $tmpthirdparty = new Societe($db); |
|
564 | 564 | $tmpthirdparty->initAsSpecimen(); |
565 | 565 | $tmpthirdparty->typent_code = 'TE_ABC'; |
566 | 566 | |
567 | - $localobject=new Facture($db); |
|
567 | + $localobject = new Facture($db); |
|
568 | 568 | $localobject->initAsSpecimen(); |
569 | 569 | $localobject->fetch_thirdparty(); |
570 | 570 | |
571 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1982); // we use year 1982 to be sure to not have existing invoice for this year |
|
572 | - $numbering=new mod_facture_mercure(); |
|
573 | - $result=$numbering->getNextValue($tmpthirdparty, $localobject); |
|
574 | - $result2=$localobject->create($user, 1); |
|
575 | - $result3=$localobject->validate($user, $result); |
|
571 | + $localobject->date = dol_mktime(12, 0, 0, 1, 1, 1982); // we use year 1982 to be sure to not have existing invoice for this year |
|
572 | + $numbering = new mod_facture_mercure(); |
|
573 | + $result = $numbering->getNextValue($tmpthirdparty, $localobject); |
|
574 | + $result2 = $localobject->create($user, 1); |
|
575 | + $result3 = $localobject->validate($user, $result); |
|
576 | 576 | print __METHOD__." result=".$result."\n"; |
577 | - $this->assertEquals('A198201-0001', $result); // counter must start to 1 |
|
577 | + $this->assertEquals('A198201-0001', $result); // counter must start to 1 |
|
578 | 578 | |
579 | 579 | |
580 | 580 | return $result; |
@@ -588,24 +588,24 @@ discard block |
||
588 | 588 | */ |
589 | 589 | public function testShipmentSafor() |
590 | 590 | { |
591 | - global $conf,$user,$langs,$db,$mysoc; |
|
592 | - $conf=$this->savconf; |
|
593 | - $user=$this->savuser; |
|
594 | - $langs=$this->savlangs; |
|
595 | - $db=$this->savdb; |
|
591 | + global $conf, $user, $langs, $db, $mysoc; |
|
592 | + $conf = $this->savconf; |
|
593 | + $user = $this->savuser; |
|
594 | + $langs = $this->savlangs; |
|
595 | + $db = $this->savdb; |
|
596 | 596 | |
597 | 597 | require_once dirname(__FILE__).'/../../htdocs/expedition/class/expedition.class.php'; |
598 | 598 | require_once dirname(__FILE__).'/../../htdocs/core/modules/expedition/mod_expedition_safor.php'; |
599 | 599 | |
600 | - $localobject=new Expedition($db); |
|
600 | + $localobject = new Expedition($db); |
|
601 | 601 | $localobject->initAsSpecimen(); |
602 | 602 | $localobject->fetch_thirdparty(); |
603 | 603 | |
604 | - $localobject->date_creation = dol_mktime(12, 0, 0, 1, 1, 1980); // we use year 1915 to be sure to not have existing invoice for this year (useful only if numbering is {0000@1} |
|
605 | - $numbering=new mod_expedition_safor(); |
|
606 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
604 | + $localobject->date_creation = dol_mktime(12, 0, 0, 1, 1, 1980); // we use year 1915 to be sure to not have existing invoice for this year (useful only if numbering is {0000@1} |
|
605 | + $numbering = new mod_expedition_safor(); |
|
606 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
607 | 607 | |
608 | 608 | print __METHOD__." result=".$result."\n"; |
609 | - $this->assertEquals('SH8001-0003', $result); // counter must start to 1 |
|
609 | + $this->assertEquals('SH8001-0003', $result); // counter must start to 1 |
|
610 | 610 | } |
611 | 611 | } |
@@ -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 | $langs->load("main"); |
42 | 42 | |
@@ -57,11 +57,11 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function testBonPrelevementCreate() |
59 | 59 | { |
60 | - global $conf,$user,$langs,$db; |
|
61 | - $conf=$this->savconf; |
|
62 | - $user=$this->savuser; |
|
63 | - $langs=$this->savlangs; |
|
64 | - $db=$this->savdb; |
|
60 | + global $conf, $user, $langs, $db; |
|
61 | + $conf = $this->savconf; |
|
62 | + $user = $this->savuser; |
|
63 | + $langs = $this->savlangs; |
|
64 | + $db = $this->savdb; |
|
65 | 65 | |
66 | 66 | // TODO |
67 | 67 | // Create invoice |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | |
75 | 75 | |
76 | 76 | // Create withdraw record and generate SEPA file |
77 | - $localobject=new BonPrelevement($db); |
|
77 | + $localobject = new BonPrelevement($db); |
|
78 | 78 | //$localobject->date_solde=dol_now(); |
79 | - $result=$localobject->Create(0, 0, 'simu'); |
|
79 | + $result = $localobject->Create(0, 0, 'simu'); |
|
80 | 80 | |
81 | 81 | print __METHOD__." result=".$result."\n"; |
82 | 82 | $this->assertEquals($result, 0); |
@@ -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 | /** |
@@ -55,21 +55,21 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public function testFichinterCreate() |
57 | 57 | { |
58 | - global $conf,$user,$langs,$db; |
|
59 | - $conf=$this->savconf; |
|
60 | - $user=$this->savuser; |
|
61 | - $langs=$this->savlangs; |
|
62 | - $db=$this->savdb; |
|
58 | + global $conf, $user, $langs, $db; |
|
59 | + $conf = $this->savconf; |
|
60 | + $user = $this->savuser; |
|
61 | + $langs = $this->savlangs; |
|
62 | + $db = $this->savdb; |
|
63 | 63 | |
64 | 64 | $soc = new Societe($db); |
65 | 65 | $soc->name = "FichinterTest Unittest"; |
66 | 66 | $socid = $soc->create($user); |
67 | 67 | $this->assertLessThan($socid, 0, $soc->errorsToString()); |
68 | 68 | |
69 | - $localobject=new Fichinter($db); |
|
69 | + $localobject = new Fichinter($db); |
|
70 | 70 | $localobject->initAsSpecimen(); |
71 | 71 | $localobject->socid = $socid; |
72 | - $result=$localobject->create($user); |
|
72 | + $result = $localobject->create($user); |
|
73 | 73 | |
74 | 74 | print __METHOD__." result=".$result."\n"; |
75 | 75 | $this->assertLessThan($result, 0, $localobject->errorsToString()); |
@@ -88,14 +88,14 @@ discard block |
||
88 | 88 | */ |
89 | 89 | public function testFichinterFetch($id) |
90 | 90 | { |
91 | - global $conf,$user,$langs,$db; |
|
92 | - $conf=$this->savconf; |
|
93 | - $user=$this->savuser; |
|
94 | - $langs=$this->savlangs; |
|
95 | - $db=$this->savdb; |
|
91 | + global $conf, $user, $langs, $db; |
|
92 | + $conf = $this->savconf; |
|
93 | + $user = $this->savuser; |
|
94 | + $langs = $this->savlangs; |
|
95 | + $db = $this->savdb; |
|
96 | 96 | |
97 | - $localobject=new Fichinter($db); |
|
98 | - $result=$localobject->fetch($id); |
|
97 | + $localobject = new Fichinter($db); |
|
98 | + $result = $localobject->fetch($id); |
|
99 | 99 | |
100 | 100 | print __METHOD__." id=".$id." result=".$result."\n"; |
101 | 101 | $this->assertLessThan($result, 0, $localobject->errorsToString()); |
@@ -114,13 +114,13 @@ discard block |
||
114 | 114 | */ |
115 | 115 | public function testFichinterValid($localobject) |
116 | 116 | { |
117 | - global $conf,$user,$langs,$db; |
|
118 | - $conf=$this->savconf; |
|
119 | - $user=$this->savuser; |
|
120 | - $langs=$this->savlangs; |
|
121 | - $db=$this->savdb; |
|
117 | + global $conf, $user, $langs, $db; |
|
118 | + $conf = $this->savconf; |
|
119 | + $user = $this->savuser; |
|
120 | + $langs = $this->savlangs; |
|
121 | + $db = $this->savdb; |
|
122 | 122 | |
123 | - $result=$localobject->setValid($user); |
|
123 | + $result = $localobject->setValid($user); |
|
124 | 124 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
125 | 125 | |
126 | 126 | $this->assertLessThan($result, 0, $localobject->errorsToString()); |
@@ -138,11 +138,11 @@ discard block |
||
138 | 138 | */ |
139 | 139 | public function testFichinterOther($localobject) |
140 | 140 | { |
141 | - global $conf,$user,$langs,$db; |
|
142 | - $conf=$this->savconf; |
|
143 | - $user=$this->savuser; |
|
144 | - $langs=$this->savlangs; |
|
145 | - $db=$this->savdb; |
|
141 | + global $conf, $user, $langs, $db; |
|
142 | + $conf = $this->savconf; |
|
143 | + $user = $this->savuser; |
|
144 | + $langs = $this->savlangs; |
|
145 | + $db = $this->savdb; |
|
146 | 146 | |
147 | 147 | /*$result=$localobject->setstatus(0); |
148 | 148 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
@@ -167,15 +167,15 @@ discard block |
||
167 | 167 | */ |
168 | 168 | public function testFichinterDelete($id) |
169 | 169 | { |
170 | - global $conf,$user,$langs,$db; |
|
171 | - $conf=$this->savconf; |
|
172 | - $user=$this->savuser; |
|
173 | - $langs=$this->savlangs; |
|
174 | - $db=$this->savdb; |
|
175 | - |
|
176 | - $localobject=new Fichinter($db); |
|
177 | - $result=$localobject->fetch($id); |
|
178 | - $result=$localobject->delete($user); |
|
170 | + global $conf, $user, $langs, $db; |
|
171 | + $conf = $this->savconf; |
|
172 | + $user = $this->savuser; |
|
173 | + $langs = $this->savlangs; |
|
174 | + $db = $this->savdb; |
|
175 | + |
|
176 | + $localobject = new Fichinter($db); |
|
177 | + $result = $localobject->fetch($id); |
|
178 | + $result = $localobject->delete($user); |
|
179 | 179 | |
180 | 180 | print __METHOD__." id=".$id." result=".$result."\n"; |
181 | 181 | $this->assertLessThan($result, 0, $localobject->errorsToString()); |