@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | } |
163 | 163 | |
164 | 164 | // Fetch optionals attributes and labels |
165 | -$extrafields->fetch_name_optionals_label('all'); // We load all extrafields definitions for all objects |
|
165 | +$extrafields->fetch_name_optionals_label('all'); // We load all extrafields definitions for all objects |
|
166 | 166 | //$extrafields->fetch_name_optionals_label($object->table_element_line); |
167 | 167 | |
168 | 168 | $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | |
176 | 176 | // If string is not an universal filter string, we try to convert it into universal filter syntax string |
177 | 177 | $errorstr = ''; |
178 | -forgeSQLFromUniversalSearchCriteria($search_component_params_input, $errorstr); // Try converstion UFS->SQL |
|
178 | +forgeSQLFromUniversalSearchCriteria($search_component_params_input, $errorstr); // Try converstion UFS->SQL |
|
179 | 179 | //var_dump($errorstr); |
180 | 180 | if ($errorstr) { |
181 | 181 | $value = $search_component_params_input; |
@@ -187,14 +187,14 @@ discard block |
||
187 | 187 | $crits = explode(' ', trim($value)); // the string after the name of the field. Explode on each AND |
188 | 188 | $res = ''; |
189 | 189 | |
190 | - $i1 = 0; // count the nb of and criteria added (all fields / criteria) |
|
190 | + $i1 = 0; // count the nb of and criteria added (all fields / criteria) |
|
191 | 191 | foreach ($crits as $crit) { // Loop on each AND criteria |
192 | 192 | $crit = trim($crit); |
193 | 193 | |
194 | - $i2 = 0; // count the nb of valid criteria added for this first criteria |
|
194 | + $i2 = 0; // count the nb of valid criteria added for this first criteria |
|
195 | 195 | $newres = ''; |
196 | 196 | $tmpcrits = explode('|', $crit); |
197 | - $i3 = 0; // count the nb of valid criteria added for this current field |
|
197 | + $i3 = 0; // count the nb of valid criteria added for this current field |
|
198 | 198 | foreach ($tmpcrits as $tmpcrit) { |
199 | 199 | if ($tmpcrit !== '0' && empty($tmpcrit)) { |
200 | 200 | continue; |
@@ -212,8 +212,8 @@ discard block |
||
212 | 212 | } |
213 | 213 | } |
214 | 214 | |
215 | - $field = preg_replace('/(:[!<>=\s]+:|:in:|:notin:|:like:|:notlike:).*$/', '', $tmpcrit); // the name of the field |
|
216 | - $tmpcrit = preg_replace('/^.*(:[!<>=\s]+:|:in:|:notin:|:like:|:notlike:)/', '\1', $tmpcrit); // the condition after the name of the field |
|
215 | + $field = preg_replace('/(:[!<>=\s]+:|:in:|:notin:|:like:|:notlike:).*$/', '', $tmpcrit); // the name of the field |
|
216 | + $tmpcrit = preg_replace('/^.*(:[!<>=\s]+:|:in:|:notin:|:like:|:notlike:)/', '\1', $tmpcrit); // the condition after the name of the field |
|
217 | 217 | //var_dump($field); var_dump($tmpcrit); var_dump($i3); |
218 | 218 | |
219 | 219 | $newres .= (($i2 > 0 || $i3 > 0) ? ' OR ' : ''); |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | foreach ($arrayofmesures as $key => $val) { |
573 | 573 | $simplearrayofmesures[$key] = $arrayofmesures[$key]['label']; |
574 | 574 | } |
575 | -print $form->multiselectarray('search_measures', $simplearrayofmesures, $search_measures, 0, 0, 'minwidth300', 1, 0, '', '', $langs->trans("Measures")); // Fill the array $arrayofmeasures with possible fields |
|
575 | +print $form->multiselectarray('search_measures', $simplearrayofmesures, $search_measures, 0, 0, 'minwidth300', 1, 0, '', '', $langs->trans("Measures")); // Fill the array $arrayofmeasures with possible fields |
|
576 | 576 | print '</div>'; |
577 | 577 | |
578 | 578 | // XAxis |
@@ -580,14 +580,14 @@ discard block |
||
580 | 580 | print '<div class="divadvancedsearchfield">'; |
581 | 581 | print '<div class="inline-block"><span class="fas fa-ruler-combined paddingright pictofixedwidth" title="'.dol_escape_htmltag($langs->trans("XAxis")).'"></span><span class="fas fa-caret-down caretdownaxis" title="'.dol_escape_htmltag($langs->trans("XAxis")).'"></span></div>'; |
582 | 582 | //var_dump($arrayofxaxis); |
583 | -print $formother->selectXAxisField($object, $search_xaxis, $arrayofxaxis, $langs->trans("XAxis"), 'minwidth300 maxwidth400'); // Fill the array $arrayofxaxis with possible fields |
|
583 | +print $formother->selectXAxisField($object, $search_xaxis, $arrayofxaxis, $langs->trans("XAxis"), 'minwidth300 maxwidth400'); // Fill the array $arrayofxaxis with possible fields |
|
584 | 584 | print '</div>'; |
585 | 585 | |
586 | 586 | // Group by |
587 | 587 | $count = 0; |
588 | 588 | print '<div class="divadvancedsearchfield">'; |
589 | 589 | print '<div class="inline-block opacitymedium"><span class="fas fa-ruler-horizontal paddingright pictofixedwidth" title="'.dol_escape_htmltag($langs->trans("GroupBy")).'"></span></div>'; |
590 | -print $formother->selectGroupByField($object, $search_groupby, $arrayofgroupby, 'minwidth250 maxwidth300', $langs->trans("GroupBy")); // Fill the array $arrayofgroupby with possible fields |
|
590 | +print $formother->selectGroupByField($object, $search_groupby, $arrayofgroupby, 'minwidth250 maxwidth300', $langs->trans("GroupBy")); // Fill the array $arrayofgroupby with possible fields |
|
591 | 591 | print '</div>'; |
592 | 592 | |
593 | 593 | |
@@ -743,7 +743,7 @@ discard block |
||
743 | 743 | //var_dump($arrayofgroupby); |
744 | 744 | $tmpforloop = dolExplodeIntoArray($arrayofxaxis[$val]['tablefromt'], ','); |
745 | 745 | foreach ($tmpforloop as $tmptable => $tmptablealias) { |
746 | - if (! in_array($tmptable, $listoftablesalreadyadded)) { // We do not add join for main table and tables already added |
|
746 | + if (!in_array($tmptable, $listoftablesalreadyadded)) { // We do not add join for main table and tables already added |
|
747 | 747 | $tmpforexplode = explode('__', $tmptablealias); |
748 | 748 | $endpart = end($tmpforexplode); |
749 | 749 | $parenttableandfield = preg_replace('/__'.$endpart.'$/', '', $tmptablealias).'.'.$endpart; |
@@ -770,7 +770,7 @@ discard block |
||
770 | 770 | //var_dump($arrayofgroupby[$val]); var_dump($tmpval); |
771 | 771 | $tmpforloop = dolExplodeIntoArray($arrayofgroupby[$val]['tablefromt'], ','); |
772 | 772 | foreach ($tmpforloop as $tmptable => $tmptablealias) { |
773 | - if (! in_array($tmptable, $listoftablesalreadyadded)) { // We do not add join for main table and tables already added |
|
773 | + if (!in_array($tmptable, $listoftablesalreadyadded)) { // We do not add join for main table and tables already added |
|
774 | 774 | $tmpforexplode = explode('__', $tmptablealias); |
775 | 775 | $endpart = end($tmpforexplode); |
776 | 776 | $parenttableandfield = preg_replace('/__'.$endpart.'$/', '', $tmptablealias).'.'.$endpart; |
@@ -797,7 +797,7 @@ discard block |
||
797 | 797 | //var_dump($arrayofgroupby); |
798 | 798 | $tmpforloop = dolExplodeIntoArray($arrayofmesures[$val]['tablefromt'], ','); |
799 | 799 | foreach ($tmpforloop as $tmptable => $tmptablealias) { |
800 | - if (! in_array($tmptable, $listoftablesalreadyadded)) { // We do not add join for main table and tables already added |
|
800 | + if (!in_array($tmptable, $listoftablesalreadyadded)) { // We do not add join for main table and tables already added |
|
801 | 801 | $tmpforexplode = explode('__', $tmptablealias); |
802 | 802 | $endpart = end($tmpforexplode); |
803 | 803 | $parenttableandfield = preg_replace('/__'.$endpart.'$/', '', $tmptablealias).'.'.$endpart; |
@@ -1185,28 +1185,28 @@ discard block |
||
1185 | 1185 | $arrayofmesures[preg_replace('/^t/', 'te', $tablealias).'.'.$key.'-sum'] = array( |
1186 | 1186 | 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' <span class="opacitymedium">('.$langs->trans("Sum").')</span>', |
1187 | 1187 | 'labelnohtml' => $labelofobject.': '.$langs->trans($val), |
1188 | - 'position' => ($position+($count * 100000)).'.1', |
|
1188 | + 'position' => ($position + ($count * 100000)).'.1', |
|
1189 | 1189 | 'table' => $object->table_element, |
1190 | 1190 | 'tablefromt' => $tablepath |
1191 | 1191 | ); |
1192 | 1192 | $arrayofmesures[preg_replace('/^t/', 'te', $tablealias).'.'.$key.'-average'] = array( |
1193 | 1193 | 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' <span class="opacitymedium">('.$langs->trans("Average").')</span>', |
1194 | 1194 | 'labelnohtml' => $labelofobject.': '.$langs->trans($val), |
1195 | - 'position' => ($position+($count * 100000)).'.2', |
|
1195 | + 'position' => ($position + ($count * 100000)).'.2', |
|
1196 | 1196 | 'table' => $object->table_element, |
1197 | 1197 | 'tablefromt' => $tablepath |
1198 | 1198 | ); |
1199 | 1199 | $arrayofmesures[preg_replace('/^t/', 'te', $tablealias).'.'.$key.'-min'] = array( |
1200 | 1200 | 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' <span class="opacitymedium">('.$langs->trans("Minimum").')</span>', |
1201 | 1201 | 'labelnohtml' => $labelofobject.': '.$langs->trans($val), |
1202 | - 'position' => ($position+($count * 100000)).'.3', |
|
1202 | + 'position' => ($position + ($count * 100000)).'.3', |
|
1203 | 1203 | 'table' => $object->table_element, |
1204 | 1204 | 'tablefromt' => $tablepath |
1205 | 1205 | ); |
1206 | 1206 | $arrayofmesures[preg_replace('/^t/', 'te', $tablealias).'.'.$key.'-max'] = array( |
1207 | 1207 | 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' <span class="opacitymedium">('.$langs->trans("Maximum").')</span>', |
1208 | 1208 | 'labelnohtml' => $labelofobject.': '.$langs->trans($val), |
1209 | - 'position' => ($position+($count * 100000)).'.4', |
|
1209 | + 'position' => ($position + ($count * 100000)).'.4', |
|
1210 | 1210 | 'table' => $object->table_element, |
1211 | 1211 | 'tablefromt' => $tablepath |
1212 | 1212 | ); |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | { |
78 | 78 | $str = str_replace('<?=', '<?php', $str); |
79 | 79 | $str = str_replace('<?php', '__LTINTPHP__', $str); |
80 | - $str = str_replace('<?', '<?php', $str); // replace the short_open_tag. It is recommended to set this is Off in php.ini |
|
80 | + $str = str_replace('<?', '<?php', $str); // replace the short_open_tag. It is recommended to set this is Off in php.ini |
|
81 | 81 | $str = str_replace('__LTINTPHP__', '<?php', $str); |
82 | 82 | |
83 | 83 | $newstr = ''; |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | } |
426 | 426 | |
427 | 427 | if (getDolGlobalString('WEBSITE_ADD_CSS_TO_BODY')) { |
428 | - $content = str_replace('<body id="bodywebsite" class="bodywebsite', '<body id="bodywebsite" class="bodywebsite ' . getDolGlobalString('WEBSITE_ADD_CSS_TO_BODY'), $content); |
|
428 | + $content = str_replace('<body id="bodywebsite" class="bodywebsite', '<body id="bodywebsite" class="bodywebsite '.getDolGlobalString('WEBSITE_ADD_CSS_TO_BODY'), $content); |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | $content = dolReplaceSmileyCodeWithUTF8($content); |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | $sql .= " WHERE rowid = ".((int) $websiteid); |
463 | 463 | |
464 | 464 | $resql = $db->query($sql); |
465 | - if (! $resql) { |
|
465 | + if (!$resql) { |
|
466 | 466 | return -1; |
467 | 467 | } |
468 | 468 | } |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | unset($tmpwebsitepage); |
547 | 547 | } |
548 | 548 | if ($result > 0) { |
549 | - $currenturi = $_SERVER["REQUEST_URI"]; // Example: /public/website/index.php?website=mywebsite.com&pageref=mywebsite-home&nocache=1708177483 |
|
549 | + $currenturi = $_SERVER["REQUEST_URI"]; // Example: /public/website/index.php?website=mywebsite.com&pageref=mywebsite-home&nocache=1708177483 |
|
550 | 550 | $regtmp = array(); |
551 | 551 | if (preg_match('/&pageref=([^&]+)/', $currenturi, $regtmp)) { |
552 | 552 | if ($regtmp[0] == $containerref) { |
@@ -875,7 +875,7 @@ discard block |
||
875 | 875 | $hashtags = trim(implode(' #', array_map('trim', explode(',', $websitepage->keywords)))); |
876 | 876 | |
877 | 877 | // Open Graph |
878 | - $out .= '<meta name="og:type" content="website">'."\n"; // TODO If blogpost, use type article |
|
878 | + $out .= '<meta name="og:type" content="website">'."\n"; // TODO If blogpost, use type article |
|
879 | 879 | $out .= '<meta name="og:title" content="'.$websitepage->title.'">'."\n"; |
880 | 880 | if ($websitepage->image) { |
881 | 881 | $out .= '<meta name="og:image" content="'.$website->virtualhost.$image.'">'."\n"; |
@@ -992,9 +992,9 @@ discard block |
||
992 | 992 | $sql = "SELECT COUNT(rowid) as nb"; |
993 | 993 | $sql .= " FROM ".MAIN_DB_PREFIX."ecm_files"; |
994 | 994 | $sql .= " WHERE entity IN (".getEntity($object->element).")"; |
995 | - $sql .= " AND src_object_type = '".$db->escape($object->element)."' AND src_object_id = ".((int) $object->id); // Filter on object |
|
995 | + $sql .= " AND src_object_type = '".$db->escape($object->element)."' AND src_object_id = ".((int) $object->id); // Filter on object |
|
996 | 996 | $sql .= " AND ".$db->regexpsql('filename', $regexforimg, 1); |
997 | - $sql .= " AND share IS NOT NULL"; // Only image that are public |
|
997 | + $sql .= " AND share IS NOT NULL"; // Only image that are public |
|
998 | 998 | |
999 | 999 | $resql = $db->query($sql); |
1000 | 1000 | if ($resql) { |
@@ -1029,7 +1029,7 @@ discard block |
||
1029 | 1029 | $sql = "SELECT rowid, ref, share, filename, cover, position"; |
1030 | 1030 | $sql .= " FROM ".MAIN_DB_PREFIX."ecm_files"; |
1031 | 1031 | $sql .= " WHERE entity IN (".getEntity($object->element).")"; |
1032 | - $sql .= " AND src_object_type = '".$db->escape($object->element)."' AND src_object_id = ".((int) $object->id); // Filter on object |
|
1032 | + $sql .= " AND src_object_type = '".$db->escape($object->element)."' AND src_object_id = ".((int) $object->id); // Filter on object |
|
1033 | 1033 | $sql .= " AND ".$db->regexpsql('filename', $regexforimg, 1); |
1034 | 1034 | $sql .= $db->order("cover,position,rowid", "ASC,ASC,ASC"); |
1035 | 1035 |
@@ -26,12 +26,12 @@ discard block |
||
26 | 26 | |
27 | 27 | $sapi_type = php_sapi_name(); |
28 | 28 | $script_file = basename(__FILE__); |
29 | -$path = dirname(__FILE__) . '/'; |
|
29 | +$path = dirname(__FILE__).'/'; |
|
30 | 30 | |
31 | 31 | // Test si mode batch |
32 | 32 | $sapi_type = php_sapi_name(); |
33 | 33 | if (substr($sapi_type, 0, 3) == 'cgi') { |
34 | - echo "Error: You are using PHP for CGI. To execute " . $script_file . " from command line, you must use PHP for CLI mode.\n"; |
|
34 | + echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; |
|
35 | 35 | exit(); |
36 | 36 | } |
37 | 37 | |
@@ -717,7 +717,7 @@ discard block |
||
717 | 717 | // Last security errors |
718 | 718 | |
719 | 719 | $html .= '<section class="chapter" id="linesofcode">'."\n"; |
720 | -$html .= '<h2><span class="fas fa-code pictofixedwidth"></span>Last security issues <span class="opacitymedium">(last '.($nbofmonth > 1 ? $nbofmonth.' months':'month').')</span></h2>'."\n"; |
|
720 | +$html .= '<h2><span class="fas fa-code pictofixedwidth"></span>Last security issues <span class="opacitymedium">(last '.($nbofmonth > 1 ? $nbofmonth.' months' : 'month').')</span></h2>'."\n"; |
|
721 | 721 | |
722 | 722 | $html .= '<div class="boxallwidth">'."\n"; |
723 | 723 | $html .= '<div class="div-table-responsive">'."\n"; |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * \brief PHPUnit test |
24 | 24 | * \remarks To run this script as CLI: phpunit filename.php. |
25 | 25 | */ |
26 | -global $conf,$user,$langs,$db; |
|
26 | +global $conf, $user, $langs, $db; |
|
27 | 27 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
28 | 28 | //require_once 'PHPUnit/Autoload.php'; |
29 | 29 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public static function setUpBeforeClass(): void |
61 | 61 | { |
62 | - global $conf,$user,$langs,$db; |
|
62 | + global $conf, $user, $langs, $db; |
|
63 | 63 | $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
64 | 64 | |
65 | 65 | if (!isModEnabled('api')) { |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | */ |
78 | 78 | protected function setUp(): void |
79 | 79 | { |
80 | - global $conf,$user,$langs,$db; |
|
80 | + global $conf, $user, $langs, $db; |
|
81 | 81 | $conf = $this->savconf; |
82 | 82 | $user = $this->savuser; |
83 | 83 | $langs = $this->savlangs; |
@@ -85,16 +85,16 @@ discard block |
||
85 | 85 | |
86 | 86 | $this->api_url = DOL_MAIN_URL_ROOT.'/api/index.php'; |
87 | 87 | |
88 | - $login='admin'; |
|
89 | - $password='admin'; |
|
90 | - $url=$this->api_url.'/login?login='.$login.'&password='.$password; |
|
88 | + $login = 'admin'; |
|
89 | + $password = 'admin'; |
|
90 | + $url = $this->api_url.'/login?login='.$login.'&password='.$password; |
|
91 | 91 | // Call the API login method to save api_key for this test class. |
92 | 92 | // At first call, if token is not defined a random value is generated and returned. |
93 | - $result=getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2); |
|
93 | + $result = getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2); |
|
94 | 94 | print __METHOD__." result = ".var_export($result, true)."\n"; |
95 | 95 | print __METHOD__." curl_error_no: ".$result['curl_error_no']."\n"; |
96 | 96 | $this->assertEquals($result['curl_error_no'], ''); |
97 | - $object = json_decode($result['content'], true); // If success content is just an id, if not an array |
|
97 | + $object = json_decode($result['content'], true); // If success content is just an id, if not an array |
|
98 | 98 | |
99 | 99 | $this->assertNotNull($object, "Parsing of json result must not be null"); |
100 | 100 | $this->assertNotEquals(500, (empty($object['error']['code']) ? 0 : $object['error']['code']), 'Error'.(empty($object['error']['message']) ? '' : ' '.$object['error']['message'])); |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public function testPushDocument() |
114 | 114 | { |
115 | - global $conf,$user,$langs,$db; |
|
115 | + global $conf, $user, $langs, $db; |
|
116 | 116 | |
117 | 117 | $url = $this->api_url.'/documents/upload?api_key='.$this->api_key; |
118 | 118 |
@@ -24,42 +24,42 @@ discard block |
||
24 | 24 | * \remarks To run this script as CLI: phpunit filename.php |
25 | 25 | */ |
26 | 26 | |
27 | -global $conf,$user,$langs,$db; |
|
27 | +global $conf, $user, $langs, $db; |
|
28 | 28 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
29 | 29 | //require_once 'PHPUnit/Autoload.php'; |
30 | 30 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
31 | 31 | require_once dirname(__FILE__).'/../../htdocs/core/lib/functions2.lib.php'; |
32 | 32 | require_once dirname(__FILE__).'/CommonClassTest.class.php'; |
33 | 33 | |
34 | -if (! defined('NOREQUIREUSER')) { |
|
34 | +if (!defined('NOREQUIREUSER')) { |
|
35 | 35 | define('NOREQUIREUSER', '1'); |
36 | 36 | } |
37 | -if (! defined('NOREQUIREDB')) { |
|
37 | +if (!defined('NOREQUIREDB')) { |
|
38 | 38 | define('NOREQUIREDB', '1'); |
39 | 39 | } |
40 | -if (! defined('NOREQUIRESOC')) { |
|
40 | +if (!defined('NOREQUIRESOC')) { |
|
41 | 41 | define('NOREQUIRESOC', '1'); |
42 | 42 | } |
43 | -if (! defined('NOREQUIRETRAN')) { |
|
43 | +if (!defined('NOREQUIRETRAN')) { |
|
44 | 44 | define('NOREQUIRETRAN', '1'); |
45 | 45 | } |
46 | -if (! defined('NOCSRFCHECK')) { |
|
46 | +if (!defined('NOCSRFCHECK')) { |
|
47 | 47 | define('NOCSRFCHECK', '1'); |
48 | 48 | } |
49 | -if (! defined('NOTOKENRENEWAL')) { |
|
49 | +if (!defined('NOTOKENRENEWAL')) { |
|
50 | 50 | define('NOTOKENRENEWAL', '1'); |
51 | 51 | } |
52 | -if (! defined('NOREQUIREMENU')) { |
|
52 | +if (!defined('NOREQUIREMENU')) { |
|
53 | 53 | define('NOREQUIREMENU', '1'); // If there is no menu to show |
54 | 54 | } |
55 | -if (! defined('NOREQUIREHTML')) { |
|
55 | +if (!defined('NOREQUIREHTML')) { |
|
56 | 56 | define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php |
57 | 57 | } |
58 | -if (! defined('NOREQUIREAJAX')) { |
|
58 | +if (!defined('NOREQUIREAJAX')) { |
|
59 | 59 | define('NOREQUIREAJAX', '1'); |
60 | 60 | } |
61 | -if (! defined("NOLOGIN")) { |
|
62 | - define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) |
|
61 | +if (!defined("NOLOGIN")) { |
|
62 | + define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function testJsUnEscape() |
81 | 81 | { |
82 | - $result=jsUnEscape('%u03BD%u03B5%u03BF'); |
|
82 | + $result = jsUnEscape('%u03BD%u03B5%u03BF'); |
|
83 | 83 | print __METHOD__." result=".$result."\n"; |
84 | 84 | $this->assertEquals('νεο', $result); |
85 | 85 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | $result = isValidUrl('http://google.com'); |
112 | 112 | $this->assertEquals(1, $result); |
113 | 113 | |
114 | - $result = isValidUrl('goo=gle'); // This is good, it might be an alias of hostname |
|
114 | + $result = isValidUrl('goo=gle'); // This is good, it might be an alias of hostname |
|
115 | 115 | $this->assertEquals(1, $result); |
116 | 116 | |
117 | 117 | //With scheme check |
@@ -173,35 +173,35 @@ discard block |
||
173 | 173 | public function testIsIP() |
174 | 174 | { |
175 | 175 | // Not valid |
176 | - $ip='a299.299.299.299'; |
|
177 | - $result=is_ip($ip); |
|
176 | + $ip = 'a299.299.299.299'; |
|
177 | + $result = is_ip($ip); |
|
178 | 178 | print __METHOD__." for ".$ip." result=".$result."\n"; |
179 | 179 | $this->assertEquals(0, $result, $ip); |
180 | 180 | |
181 | 181 | // Reserved IP range (not checked by is_ip function) |
182 | - $ip='169.254.0.0'; |
|
183 | - $result=is_ip($ip); |
|
182 | + $ip = '169.254.0.0'; |
|
183 | + $result = is_ip($ip); |
|
184 | 184 | print __METHOD__." for ".$ip." result=".$result."\n"; |
185 | 185 | //$this->assertEquals(2,$result,$ip); // Assertion disabled because returned value differs between PHP patch version |
186 | 186 | |
187 | - $ip='1.2.3.4'; |
|
188 | - $result=is_ip($ip); |
|
187 | + $ip = '1.2.3.4'; |
|
188 | + $result = is_ip($ip); |
|
189 | 189 | print __METHOD__." for ".$ip." result=".$result."\n"; |
190 | 190 | $this->assertEquals(1, $result, $ip); |
191 | 191 | |
192 | 192 | // Private IP ranges |
193 | - $ip='10.0.0.0'; |
|
194 | - $result=is_ip($ip); |
|
193 | + $ip = '10.0.0.0'; |
|
194 | + $result = is_ip($ip); |
|
195 | 195 | print __METHOD__." for ".$ip." result=".$result."\n"; |
196 | 196 | $this->assertEquals(2, $result, $ip); |
197 | 197 | |
198 | - $ip='172.16.0.0'; |
|
199 | - $result=is_ip($ip); |
|
198 | + $ip = '172.16.0.0'; |
|
199 | + $result = is_ip($ip); |
|
200 | 200 | print __METHOD__." for ".$ip." result=".$result."\n"; |
201 | 201 | $this->assertEquals(2, $result, $ip); |
202 | 202 | |
203 | - $ip='192.168.0.0'; |
|
204 | - $result=is_ip($ip); |
|
203 | + $ip = '192.168.0.0'; |
|
204 | + $result = is_ip($ip); |
|
205 | 205 | print __METHOD__." for ".$ip." result=".$result."\n"; |
206 | 206 | $this->assertEquals(2, $result, $ip); |
207 | 207 | } |
@@ -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'; |
@@ -32,35 +32,35 @@ discard block |
||
32 | 32 | require_once dirname(__FILE__).'/../../htdocs/core/lib/files.lib.php'; |
33 | 33 | require_once dirname(__FILE__).'/CommonClassTest.class.php'; |
34 | 34 | |
35 | -if (! defined('NOREQUIREUSER')) { |
|
35 | +if (!defined('NOREQUIREUSER')) { |
|
36 | 36 | define('NOREQUIREUSER', '1'); |
37 | 37 | } |
38 | -if (! defined('NOREQUIREDB')) { |
|
38 | +if (!defined('NOREQUIREDB')) { |
|
39 | 39 | define('NOREQUIREDB', '1'); |
40 | 40 | } |
41 | -if (! defined('NOREQUIRESOC')) { |
|
41 | +if (!defined('NOREQUIRESOC')) { |
|
42 | 42 | define('NOREQUIRESOC', '1'); |
43 | 43 | } |
44 | -if (! defined('NOREQUIRETRAN')) { |
|
44 | +if (!defined('NOREQUIRETRAN')) { |
|
45 | 45 | define('NOREQUIRETRAN', '1'); |
46 | 46 | } |
47 | -if (! defined('NOCSRFCHECK')) { |
|
47 | +if (!defined('NOCSRFCHECK')) { |
|
48 | 48 | define('NOCSRFCHECK', '1'); |
49 | 49 | } |
50 | -if (! defined('NOTOKENRENEWAL')) { |
|
50 | +if (!defined('NOTOKENRENEWAL')) { |
|
51 | 51 | define('NOTOKENRENEWAL', '1'); |
52 | 52 | } |
53 | -if (! defined('NOREQUIREMENU')) { |
|
53 | +if (!defined('NOREQUIREMENU')) { |
|
54 | 54 | define('NOREQUIREMENU', '1'); // If there is no menu to show |
55 | 55 | } |
56 | -if (! defined('NOREQUIREHTML')) { |
|
56 | +if (!defined('NOREQUIREHTML')) { |
|
57 | 57 | define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php |
58 | 58 | } |
59 | -if (! defined('NOREQUIREAJAX')) { |
|
59 | +if (!defined('NOREQUIREAJAX')) { |
|
60 | 60 | define('NOREQUIREAJAX', '1'); |
61 | 61 | } |
62 | -if (! defined("NOLOGIN")) { |
|
63 | - define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) |
|
62 | +if (!defined("NOLOGIN")) { |
|
63 | + define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | |
@@ -80,15 +80,15 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public function testExportCsvUtf() |
82 | 82 | { |
83 | - global $conf,$user,$langs,$db; |
|
83 | + global $conf, $user, $langs, $db; |
|
84 | 84 | |
85 | - $model='csvutf8'; |
|
85 | + $model = 'csvutf8'; |
|
86 | 86 | |
87 | 87 | $conf->global->EXPORT_CSV_SEPARATOR_TO_USE = ','; |
88 | - print 'EXPORT_CSV_SEPARATOR_TO_USE = ' . getDolGlobalString('EXPORT_CSV_SEPARATOR_TO_USE'); |
|
88 | + print 'EXPORT_CSV_SEPARATOR_TO_USE = '.getDolGlobalString('EXPORT_CSV_SEPARATOR_TO_USE'); |
|
89 | 89 | |
90 | 90 | // Creation of class to export using model ExportXXX |
91 | - $dir = DOL_DOCUMENT_ROOT . "/core/modules/export/"; |
|
91 | + $dir = DOL_DOCUMENT_ROOT."/core/modules/export/"; |
|
92 | 92 | $file = "export_".$model.".modules.php"; |
93 | 93 | $classname = "Export".$model; |
94 | 94 | require_once $dir.$file; |
@@ -97,31 +97,31 @@ discard block |
||
97 | 97 | // First test without option USE_STRICT_CSV_RULES |
98 | 98 | unset($conf->global->USE_STRICT_CSV_RULES); |
99 | 99 | |
100 | - $valtotest='A simple string'; |
|
100 | + $valtotest = 'A simple string'; |
|
101 | 101 | print __METHOD__." valtotest=".$valtotest."\n"; |
102 | 102 | $result = $objmodel->csvClean($valtotest, $langs->charset_output); |
103 | 103 | print __METHOD__." result=".$result."\n"; |
104 | 104 | $this->assertEquals($result, 'A simple string'); |
105 | 105 | |
106 | - $valtotest='A string with , and ; inside'; |
|
106 | + $valtotest = 'A string with , and ; inside'; |
|
107 | 107 | print __METHOD__." valtotest=".$valtotest."\n"; |
108 | 108 | $result = $objmodel->csvClean($valtotest, $langs->charset_output); |
109 | 109 | print __METHOD__." result=".$result."\n"; |
110 | 110 | $this->assertEquals($result, '"A string with , and ; inside"', 'Error in csvClean for '.$file); |
111 | 111 | |
112 | - $valtotest='A string with " inside'; |
|
112 | + $valtotest = 'A string with " inside'; |
|
113 | 113 | print __METHOD__." valtotest=".$valtotest."\n"; |
114 | 114 | $result = $objmodel->csvClean($valtotest, $langs->charset_output); |
115 | 115 | print __METHOD__." result=".$result."\n"; |
116 | 116 | $this->assertEquals($result, '"A string with "" inside"'); |
117 | 117 | |
118 | - $valtotest='A string with " inside and '."\r\n".' carriage returns'; |
|
118 | + $valtotest = 'A string with " inside and '."\r\n".' carriage returns'; |
|
119 | 119 | print __METHOD__." valtotest=".$valtotest."\n"; |
120 | 120 | $result = $objmodel->csvClean($valtotest, $langs->charset_output); |
121 | 121 | print __METHOD__." result=".$result."\n"; |
122 | 122 | $this->assertEquals($result, '"A string with "" inside and \n carriage returns"'); |
123 | 123 | |
124 | - $valtotest='A string with <a href="aaa"><strong>html<br>content</strong></a> inside<br>'."\n"; |
|
124 | + $valtotest = 'A string with <a href="aaa"><strong>html<br>content</strong></a> inside<br>'."\n"; |
|
125 | 125 | print __METHOD__." valtotest=".$valtotest."\n"; |
126 | 126 | $result = $objmodel->csvClean($valtotest, $langs->charset_output); |
127 | 127 | print __METHOD__." result=".$result."\n"; |
@@ -130,31 +130,31 @@ discard block |
||
130 | 130 | // Same tests with strict mode |
131 | 131 | $conf->global->USE_STRICT_CSV_RULES = 1; |
132 | 132 | |
133 | - $valtotest='A simple string'; |
|
133 | + $valtotest = 'A simple string'; |
|
134 | 134 | print __METHOD__." valtotest=".$valtotest."\n"; |
135 | 135 | $result = $objmodel->csvClean($valtotest, $langs->charset_output); |
136 | 136 | print __METHOD__." result=".$result."\n"; |
137 | 137 | $this->assertEquals($result, 'A simple string'); |
138 | 138 | |
139 | - $valtotest='A string with , and ; inside'; |
|
139 | + $valtotest = 'A string with , and ; inside'; |
|
140 | 140 | print __METHOD__." valtotest=".$valtotest."\n"; |
141 | 141 | $result = $objmodel->csvClean($valtotest, $langs->charset_output); |
142 | 142 | print __METHOD__." result=".$result."\n"; |
143 | 143 | $this->assertEquals($result, '"A string with , and ; inside"'); |
144 | 144 | |
145 | - $valtotest='A string with " inside'; |
|
145 | + $valtotest = 'A string with " inside'; |
|
146 | 146 | print __METHOD__." valtotest=".$valtotest."\n"; |
147 | 147 | $result = $objmodel->csvClean($valtotest, $langs->charset_output); |
148 | 148 | print __METHOD__." result=".$result."\n"; |
149 | 149 | $this->assertEquals($result, '"A string with "" inside"'); |
150 | 150 | |
151 | - $valtotest='A string with " inside and '."\r\n".' carriage returns'; |
|
151 | + $valtotest = 'A string with " inside and '."\r\n".' carriage returns'; |
|
152 | 152 | print __METHOD__." valtotest=".$valtotest."\n"; |
153 | 153 | $result = $objmodel->csvClean($valtotest, $langs->charset_output); |
154 | 154 | print __METHOD__." result=".$result."\n"; |
155 | 155 | $this->assertEquals($result, "\"A string with \"\" inside and \r\n carriage returns\""); |
156 | 156 | |
157 | - $valtotest='A string with <a href="aaa"><strong>html<br>content</strong></a> inside<br>'."\n"; |
|
157 | + $valtotest = 'A string with <a href="aaa"><strong>html<br>content</strong></a> inside<br>'."\n"; |
|
158 | 158 | print __METHOD__." valtotest=".$valtotest."\n"; |
159 | 159 | $result = $objmodel->csvClean($valtotest, $langs->charset_output); |
160 | 160 | print __METHOD__." result=".$result."\n"; |
@@ -169,15 +169,15 @@ discard block |
||
169 | 169 | */ |
170 | 170 | public function testExportOther() |
171 | 171 | { |
172 | - global $conf,$user,$langs,$db; |
|
172 | + global $conf, $user, $langs, $db; |
|
173 | 173 | |
174 | - $model='csviso'; |
|
174 | + $model = 'csviso'; |
|
175 | 175 | |
176 | 176 | $conf->global->EXPORT_CSV_SEPARATOR_TO_USE = ','; |
177 | - print 'EXPORT_CSV_SEPARATOR_TO_USE = ' . getDolGlobalString('EXPORT_CSV_SEPARATOR_TO_USE'); |
|
177 | + print 'EXPORT_CSV_SEPARATOR_TO_USE = '.getDolGlobalString('EXPORT_CSV_SEPARATOR_TO_USE'); |
|
178 | 178 | |
179 | 179 | // Creation of class to export using model ExportXXX |
180 | - $dir = DOL_DOCUMENT_ROOT . "/core/modules/export/"; |
|
180 | + $dir = DOL_DOCUMENT_ROOT."/core/modules/export/"; |
|
181 | 181 | $file = "export_".$model.".modules.php"; |
182 | 182 | $classname = "Export".$model; |
183 | 183 | require_once $dir.$file; |
@@ -186,31 +186,31 @@ discard block |
||
186 | 186 | // First test without option USE_STRICT_CSV_RULES |
187 | 187 | unset($conf->global->USE_STRICT_CSV_RULES); |
188 | 188 | |
189 | - $valtotest='A simple string'; |
|
189 | + $valtotest = 'A simple string'; |
|
190 | 190 | print __METHOD__." valtotest=".$valtotest."\n"; |
191 | 191 | $result = $objmodel->csvClean($valtotest, $langs->charset_output); |
192 | 192 | print __METHOD__." result=".$result."\n"; |
193 | 193 | $this->assertEquals($result, 'A simple string'); |
194 | 194 | |
195 | - $valtotest='A string with , and ; inside'; |
|
195 | + $valtotest = 'A string with , and ; inside'; |
|
196 | 196 | print __METHOD__." valtotest=".$valtotest."\n"; |
197 | 197 | $result = $objmodel->csvClean($valtotest, $langs->charset_output); |
198 | 198 | print __METHOD__." result=".$result."\n"; |
199 | 199 | $this->assertEquals($result, '"A string with , and ; inside"', 'Error in csvClean for '.$file); |
200 | 200 | |
201 | - $valtotest='A string with " inside'; |
|
201 | + $valtotest = 'A string with " inside'; |
|
202 | 202 | print __METHOD__." valtotest=".$valtotest."\n"; |
203 | 203 | $result = $objmodel->csvClean($valtotest, $langs->charset_output); |
204 | 204 | print __METHOD__." result=".$result."\n"; |
205 | 205 | $this->assertEquals($result, '"A string with "" inside"'); |
206 | 206 | |
207 | - $valtotest='A string with " inside and '."\r\n".' carriage returns'; |
|
207 | + $valtotest = 'A string with " inside and '."\r\n".' carriage returns'; |
|
208 | 208 | print __METHOD__." valtotest=".$valtotest."\n"; |
209 | 209 | $result = $objmodel->csvClean($valtotest, $langs->charset_output); |
210 | 210 | print __METHOD__." result=".$result."\n"; |
211 | 211 | $this->assertEquals($result, '"A string with "" inside and \n carriage returns"'); |
212 | 212 | |
213 | - $valtotest='A string with <a href="aaa"><strong>html<br>content</strong></a> inside<br>'."\n"; |
|
213 | + $valtotest = 'A string with <a href="aaa"><strong>html<br>content</strong></a> inside<br>'."\n"; |
|
214 | 214 | print __METHOD__." valtotest=".$valtotest."\n"; |
215 | 215 | $result = $objmodel->csvClean($valtotest, $langs->charset_output); |
216 | 216 | print __METHOD__." result=".$result."\n"; |
@@ -219,31 +219,31 @@ discard block |
||
219 | 219 | // Same tests with strict mode |
220 | 220 | $conf->global->USE_STRICT_CSV_RULES = 1; |
221 | 221 | |
222 | - $valtotest='A simple string'; |
|
222 | + $valtotest = 'A simple string'; |
|
223 | 223 | print __METHOD__." valtotest=".$valtotest."\n"; |
224 | 224 | $result = $objmodel->csvClean($valtotest, $langs->charset_output); |
225 | 225 | print __METHOD__." result=".$result."\n"; |
226 | 226 | $this->assertEquals($result, 'A simple string'); |
227 | 227 | |
228 | - $valtotest='A string with , and ; inside'; |
|
228 | + $valtotest = 'A string with , and ; inside'; |
|
229 | 229 | print __METHOD__." valtotest=".$valtotest."\n"; |
230 | 230 | $result = $objmodel->csvClean($valtotest, $langs->charset_output); |
231 | 231 | print __METHOD__." result=".$result."\n"; |
232 | 232 | $this->assertEquals($result, '"A string with , and ; inside"'); |
233 | 233 | |
234 | - $valtotest='A string with " inside'; |
|
234 | + $valtotest = 'A string with " inside'; |
|
235 | 235 | print __METHOD__." valtotest=".$valtotest."\n"; |
236 | 236 | $result = $objmodel->csvClean($valtotest, $langs->charset_output); |
237 | 237 | print __METHOD__." result=".$result."\n"; |
238 | 238 | $this->assertEquals($result, '"A string with "" inside"'); |
239 | 239 | |
240 | - $valtotest='A string with " inside and '."\r\n".' carriage returns'; |
|
240 | + $valtotest = 'A string with " inside and '."\r\n".' carriage returns'; |
|
241 | 241 | print __METHOD__." valtotest=".$valtotest."\n"; |
242 | 242 | $result = $objmodel->csvClean($valtotest, $langs->charset_output); |
243 | 243 | print __METHOD__." result=".$result."\n"; |
244 | 244 | $this->assertEquals($result, "\"A string with \"\" inside and \r\n carriage returns\""); |
245 | 245 | |
246 | - $valtotest='A string with <a href="aaa"><strong>html<br>content</strong></a> inside<br>'."\n"; |
|
246 | + $valtotest = 'A string with <a href="aaa"><strong>html<br>content</strong></a> inside<br>'."\n"; |
|
247 | 247 | print __METHOD__." valtotest=".$valtotest."\n"; |
248 | 248 | $result = $objmodel->csvClean($valtotest, $langs->charset_output); |
249 | 249 | print __METHOD__." result=".$result."\n"; |
@@ -258,54 +258,54 @@ discard block |
||
258 | 258 | */ |
259 | 259 | public function testExportPersonalizedExport() |
260 | 260 | { |
261 | - global $conf,$user,$langs,$db; |
|
261 | + global $conf, $user, $langs, $db; |
|
262 | 262 | |
263 | 263 | $sql = "SELECT f.ref as f_ref, f.total_ht as f_total, f.total_tva as f_tva FROM ".MAIN_DB_PREFIX."facture f"; |
264 | 264 | |
265 | - $objexport=new Export($db); |
|
265 | + $objexport = new Export($db); |
|
266 | 266 | //$objexport->load_arrays($user,$datatoexport); |
267 | 267 | |
268 | 268 | // Define properties |
269 | - $datatoexport='test'; |
|
269 | + $datatoexport = 'test'; |
|
270 | 270 | $array_selected = array("f.ref"=>1, "f.total"=>2, "f.tva"=>3); |
271 | 271 | $array_export_fields = array("f.ref"=>"FacNumber", "f.total"=>"FacTotal", "f.tva"=>"FacVat"); |
272 | 272 | $array_alias = array("f_ref"=>"ref", "f_total"=>"total", "f_tva"=>"tva"); |
273 | - $objexport->array_export_fields[0]=$array_export_fields; |
|
274 | - $objexport->array_export_alias[0]=$array_alias; |
|
273 | + $objexport->array_export_fields[0] = $array_export_fields; |
|
274 | + $objexport->array_export_alias[0] = $array_alias; |
|
275 | 275 | |
276 | 276 | dol_mkdir($conf->export->dir_temp); |
277 | 277 | |
278 | - $model='csviso'; |
|
278 | + $model = 'csviso'; |
|
279 | 279 | |
280 | 280 | // Build export file |
281 | 281 | print "Process build_file for model = ".$model."\n"; |
282 | - $result=$objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql); |
|
282 | + $result = $objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql); |
|
283 | 283 | $expectedresult = 1; |
284 | 284 | $this->assertEquals($expectedresult, $result, 'Error in CSV export'); |
285 | 285 | |
286 | - $model='csvutf8'; |
|
286 | + $model = 'csvutf8'; |
|
287 | 287 | |
288 | 288 | // Build export file |
289 | 289 | print "Process build_file for model = ".$model."\n"; |
290 | - $result=$objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql); |
|
290 | + $result = $objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql); |
|
291 | 291 | $expectedresult = 1; |
292 | 292 | $this->assertEquals($expectedresult, $result, 'Error in CSV export'); |
293 | 293 | |
294 | - $model='tsv'; |
|
294 | + $model = 'tsv'; |
|
295 | 295 | |
296 | 296 | // Build export file |
297 | 297 | print "Process build_file for model = ".$model."\n"; |
298 | - $result=$objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql); |
|
299 | - $expectedresult=1; |
|
298 | + $result = $objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql); |
|
299 | + $expectedresult = 1; |
|
300 | 300 | $this->assertEquals($expectedresult, $result, 'Error in TSV export'); |
301 | 301 | |
302 | - $model='excel2007'; |
|
302 | + $model = 'excel2007'; |
|
303 | 303 | |
304 | 304 | // Build export file |
305 | 305 | /* ko on php 7.4 on travis (zip not available) */ |
306 | 306 | print "Process build_file for model = ".$model."\n"; |
307 | - $result=$objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql); |
|
308 | - $expectedresult=1; |
|
307 | + $result = $objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql); |
|
308 | + $expectedresult = 1; |
|
309 | 309 | $this->assertEquals($expectedresult, $result, 'Error in Excel2007 export'); |
310 | 310 | |
311 | 311 | return true; |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | */ |
320 | 320 | public function testExportPersonalizedWithFilter() |
321 | 321 | { |
322 | - global $conf,$user,$langs,$db; |
|
322 | + global $conf, $user, $langs, $db; |
|
323 | 323 | /* |
324 | 324 | $sql = "SELECT f.ref as f_ref, f.total_ht as f_total_ht, f.total_tva as f_total_tva FROM ".MAIN_DB_PREFIX."facture f"; |
325 | 325 | |
@@ -371,38 +371,38 @@ discard block |
||
371 | 371 | */ |
372 | 372 | public function testExportModulesDatasets() |
373 | 373 | { |
374 | - global $conf,$user,$langs,$db; |
|
374 | + global $conf, $user, $langs, $db; |
|
375 | 375 | |
376 | - $model='csviso'; |
|
376 | + $model = 'csviso'; |
|
377 | 377 | |
378 | - $filterdatatoexport=''; |
|
378 | + $filterdatatoexport = ''; |
|
379 | 379 | //$filterdatatoexport=''; |
380 | 380 | //$array_selected = array("s.rowid"=>1, "s.nom"=>2); // Must be fields found into declaration of dataset |
381 | 381 | |
382 | 382 | // Load properties of arrays to make export |
383 | - $objexport=new Export($db); |
|
384 | - $result=$objexport->load_arrays($user, $filterdatatoexport); // This load ->array_export_xxx properties for datatoexport |
|
383 | + $objexport = new Export($db); |
|
384 | + $result = $objexport->load_arrays($user, $filterdatatoexport); // This load ->array_export_xxx properties for datatoexport |
|
385 | 385 | |
386 | 386 | // Loop on each dataset |
387 | 387 | foreach ($objexport->array_export_code as $key => $datatoexport) { |
388 | - $exportfile=$conf->export->dir_temp.'/'.$user->id.'/export_'.$datatoexport.'.csv'; |
|
388 | + $exportfile = $conf->export->dir_temp.'/'.$user->id.'/export_'.$datatoexport.'.csv'; |
|
389 | 389 | print "Process export for dataset ".$datatoexport." into ".$exportfile."\n"; |
390 | 390 | dol_delete_file($exportfile); |
391 | 391 | |
392 | 392 | // Generate $array_selected |
393 | - $i=0; |
|
394 | - $array_selected=array(); |
|
393 | + $i = 0; |
|
394 | + $array_selected = array(); |
|
395 | 395 | foreach ($objexport->array_export_fields[$key] as $key => $val) { |
396 | - $array_selected[$key]=$i++; |
|
396 | + $array_selected[$key] = $i++; |
|
397 | 397 | } |
398 | 398 | //var_dump($array_selected); |
399 | 399 | |
400 | 400 | // Build export file |
401 | 401 | $sql = ""; |
402 | - $result=$objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql); |
|
402 | + $result = $objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql); |
|
403 | 403 | $expectedresult = 1; |
404 | 404 | $this->assertEquals($expectedresult, $result, "Call build_file() to export ".$exportfile.' failed: '.$objexport->error); |
405 | - $result=dol_is_file($exportfile); |
|
405 | + $result = dol_is_file($exportfile); |
|
406 | 406 | $this->assertTrue($result, 'File '.$exportfile.' not found'); |
407 | 407 | } |
408 | 408 |
@@ -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,15 +56,15 @@ discard block |
||
56 | 56 | */ |
57 | 57 | public function testInventoryCreate() |
58 | 58 | { |
59 | - global $conf,$user,$langs,$db; |
|
60 | - $conf=$this->savconf; |
|
61 | - $user=$this->savuser; |
|
62 | - $langs=$this->savlangs; |
|
63 | - $db=$this->savdb; |
|
59 | + global $conf, $user, $langs, $db; |
|
60 | + $conf = $this->savconf; |
|
61 | + $user = $this->savuser; |
|
62 | + $langs = $this->savlangs; |
|
63 | + $db = $this->savdb; |
|
64 | 64 | |
65 | - $localobject=new Inventory($db); |
|
65 | + $localobject = new Inventory($db); |
|
66 | 66 | $localobject->initAsSpecimen(); |
67 | - $result=$localobject->create($user); |
|
67 | + $result = $localobject->create($user); |
|
68 | 68 | $this->assertLessThan($result, 0); |
69 | 69 | print __METHOD__." result=".$result."\n"; |
70 | 70 | return $result; |
@@ -81,14 +81,14 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function testInventoryFetch($id) |
83 | 83 | { |
84 | - global $conf,$user,$langs,$db; |
|
85 | - $conf=$this->savconf; |
|
86 | - $user=$this->savuser; |
|
87 | - $langs=$this->savlangs; |
|
88 | - $db=$this->savdb; |
|
84 | + global $conf, $user, $langs, $db; |
|
85 | + $conf = $this->savconf; |
|
86 | + $user = $this->savuser; |
|
87 | + $langs = $this->savlangs; |
|
88 | + $db = $this->savdb; |
|
89 | 89 | |
90 | - $localobject=new Inventory($db); |
|
91 | - $result=$localobject->fetch($id); |
|
90 | + $localobject = new Inventory($db); |
|
91 | + $result = $localobject->fetch($id); |
|
92 | 92 | |
93 | 93 | $this->assertLessThan($result, 0); |
94 | 94 | print __METHOD__." id=".$id." result=".$result."\n"; |
@@ -106,15 +106,15 @@ discard block |
||
106 | 106 | */ |
107 | 107 | public function testInventoryUpdate($localobject) |
108 | 108 | { |
109 | - global $conf,$user,$langs,$db; |
|
110 | - $conf=$this->savconf; |
|
111 | - $user=$this->savuser; |
|
112 | - $langs=$this->savlangs; |
|
113 | - $db=$this->savdb; |
|
109 | + global $conf, $user, $langs, $db; |
|
110 | + $conf = $this->savconf; |
|
111 | + $user = $this->savuser; |
|
112 | + $langs = $this->savlangs; |
|
113 | + $db = $this->savdb; |
|
114 | 114 | |
115 | 115 | $localobject->status = 9; |
116 | 116 | $localobject->title = 'test'; |
117 | - $result=$localobject->update($user, $user); |
|
117 | + $result = $localobject->update($user, $user); |
|
118 | 118 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
119 | 119 | $this->assertLessThan($result, 0); |
120 | 120 | return $localobject; |
@@ -132,13 +132,13 @@ discard block |
||
132 | 132 | */ |
133 | 133 | public function testInventoryValidate($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 | - $result=$localobject->validate($user); |
|
141 | + $result = $localobject->validate($user); |
|
142 | 142 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
143 | 143 | |
144 | 144 | $this->assertLessThan($result, 0); |
@@ -157,13 +157,13 @@ discard block |
||
157 | 157 | */ |
158 | 158 | public function testInventorySetDraft($localobject) |
159 | 159 | { |
160 | - global $conf,$user,$langs,$db; |
|
161 | - $conf=$this->savconf; |
|
162 | - $user=$this->savuser; |
|
163 | - $langs=$this->savlangs; |
|
164 | - $db=$this->savdb; |
|
160 | + global $conf, $user, $langs, $db; |
|
161 | + $conf = $this->savconf; |
|
162 | + $user = $this->savuser; |
|
163 | + $langs = $this->savlangs; |
|
164 | + $db = $this->savdb; |
|
165 | 165 | |
166 | - $result=$localobject->setDraft($user); |
|
166 | + $result = $localobject->setDraft($user); |
|
167 | 167 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
168 | 168 | |
169 | 169 | $this->assertLessThan($result, 0); |
@@ -182,13 +182,13 @@ discard block |
||
182 | 182 | */ |
183 | 183 | public function testInventorySetRecorded($localobject) |
184 | 184 | { |
185 | - global $conf,$user,$langs,$db; |
|
186 | - $conf=$this->savconf; |
|
187 | - $user=$this->savuser; |
|
188 | - $langs=$this->savlangs; |
|
189 | - $db=$this->savdb; |
|
185 | + global $conf, $user, $langs, $db; |
|
186 | + $conf = $this->savconf; |
|
187 | + $user = $this->savuser; |
|
188 | + $langs = $this->savlangs; |
|
189 | + $db = $this->savdb; |
|
190 | 190 | |
191 | - $result=$localobject->setRecorded($user); |
|
191 | + $result = $localobject->setRecorded($user); |
|
192 | 192 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
193 | 193 | |
194 | 194 | $this->assertLessThan($result, 0); |
@@ -207,13 +207,13 @@ discard block |
||
207 | 207 | */ |
208 | 208 | public function testInventorySetCanceled($localobject) |
209 | 209 | { |
210 | - global $conf,$user,$langs,$db; |
|
211 | - $conf=$this->savconf; |
|
212 | - $user=$this->savuser; |
|
213 | - $langs=$this->savlangs; |
|
214 | - $db=$this->savdb; |
|
210 | + global $conf, $user, $langs, $db; |
|
211 | + $conf = $this->savconf; |
|
212 | + $user = $this->savuser; |
|
213 | + $langs = $this->savlangs; |
|
214 | + $db = $this->savdb; |
|
215 | 215 | |
216 | - $result=$localobject->setCanceled($user); |
|
216 | + $result = $localobject->setCanceled($user); |
|
217 | 217 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
218 | 218 | |
219 | 219 | $this->assertLessThan($result, 0); |
@@ -231,11 +231,11 @@ discard block |
||
231 | 231 | */ |
232 | 232 | public function testInventoryOther($localobject) |
233 | 233 | { |
234 | - global $conf,$user,$langs,$db; |
|
235 | - $conf=$this->savconf; |
|
236 | - $user=$this->savuser; |
|
237 | - $langs=$this->savlangs; |
|
238 | - $db=$this->savdb; |
|
234 | + global $conf, $user, $langs, $db; |
|
235 | + $conf = $this->savconf; |
|
236 | + $user = $this->savuser; |
|
237 | + $langs = $this->savlangs; |
|
238 | + $db = $this->savdb; |
|
239 | 239 | |
240 | 240 | $localobject->info($localobject->id); |
241 | 241 | print __METHOD__." localobject->date_creation=".$localobject->date_creation."\n"; |
@@ -253,15 +253,15 @@ discard block |
||
253 | 253 | */ |
254 | 254 | public function testInventoryDelete($id) |
255 | 255 | { |
256 | - global $conf,$user,$langs,$db; |
|
257 | - $conf=$this->savconf; |
|
258 | - $user=$this->savuser; |
|
259 | - $langs=$this->savlangs; |
|
260 | - $db=$this->savdb; |
|
256 | + global $conf, $user, $langs, $db; |
|
257 | + $conf = $this->savconf; |
|
258 | + $user = $this->savuser; |
|
259 | + $langs = $this->savlangs; |
|
260 | + $db = $this->savdb; |
|
261 | 261 | |
262 | - $localobject=new Inventory($db); |
|
263 | - $result=$localobject->fetch($id); |
|
264 | - $result=$localobject->delete($user); |
|
262 | + $localobject = new Inventory($db); |
|
263 | + $result = $localobject->fetch($id); |
|
264 | + $result = $localobject->delete($user); |
|
265 | 265 | print __METHOD__." id=".$id." result=".$result."\n"; |
266 | 266 | $this->assertLessThan($result, 0); |
267 | 267 | |
@@ -279,23 +279,23 @@ discard block |
||
279 | 279 | */ |
280 | 280 | public function objCompare($oA, $oB, $ignoretype = true, $fieldstoignorearray = array('id')) |
281 | 281 | { |
282 | - $retAr=array(); |
|
282 | + $retAr = array(); |
|
283 | 283 | |
284 | 284 | if (get_class($oA) !== get_class($oB)) { |
285 | - $retAr[]="Supplied objects are not of same class."; |
|
285 | + $retAr[] = "Supplied objects are not of same class."; |
|
286 | 286 | } else { |
287 | - $oVarsA=get_object_vars($oA); |
|
288 | - $oVarsB=get_object_vars($oB); |
|
289 | - $aKeys=array_keys($oVarsA); |
|
287 | + $oVarsA = get_object_vars($oA); |
|
288 | + $oVarsB = get_object_vars($oB); |
|
289 | + $aKeys = array_keys($oVarsA); |
|
290 | 290 | foreach ($aKeys as $sKey) { |
291 | 291 | if (in_array($sKey, $fieldstoignorearray)) { |
292 | 292 | continue; |
293 | 293 | } |
294 | - if (! $ignoretype && ($oVarsA[$sKey] !== $oVarsB[$sKey])) { |
|
295 | - $retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey]) ? get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ? get_class($oVarsB[$sKey]) : $oVarsB[$sKey]); |
|
294 | + if (!$ignoretype && ($oVarsA[$sKey] !== $oVarsB[$sKey])) { |
|
295 | + $retAr[] = $sKey.' : '.(is_object($oVarsA[$sKey]) ? get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ? get_class($oVarsB[$sKey]) : $oVarsB[$sKey]); |
|
296 | 296 | } |
297 | 297 | if ($ignoretype && ($oVarsA[$sKey] != $oVarsB[$sKey])) { |
298 | - $retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey]) ? get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ? get_class($oVarsB[$sKey]) : $oVarsB[$sKey]); |
|
298 | + $retAr[] = $sKey.' : '.(is_object($oVarsA[$sKey]) ? get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ? get_class($oVarsB[$sKey]) : $oVarsB[$sKey]); |
|
299 | 299 | } |
300 | 300 | } |
301 | 301 | } |
@@ -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 | print "\n".$langs->trans("CurrentTimeZone").' : '.getServerTimeZoneString(); |
42 | 42 | print "\n".$langs->trans("CurrentHour").' : '.dol_print_date(dol_now('gmt'), 'dayhour', 'tzserver'); |
@@ -59,45 +59,45 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function testNumBetweenDay() |
61 | 61 | { |
62 | - global $conf,$user,$langs,$db; |
|
63 | - $conf=$this->savconf; |
|
64 | - $user=$this->savuser; |
|
65 | - $langs=$this->savlangs; |
|
66 | - $db=$this->savdb; |
|
62 | + global $conf, $user, $langs, $db; |
|
63 | + $conf = $this->savconf; |
|
64 | + $user = $this->savuser; |
|
65 | + $langs = $this->savlangs; |
|
66 | + $db = $this->savdb; |
|
67 | 67 | |
68 | 68 | // With same hours |
69 | - $date1=dol_mktime(0, 0, 0, 1, 1, 2012, 'gmt'); |
|
70 | - $date2=dol_mktime(0, 0, 0, 1, 2, 2012, 'gmt'); |
|
69 | + $date1 = dol_mktime(0, 0, 0, 1, 1, 2012, 'gmt'); |
|
70 | + $date2 = dol_mktime(0, 0, 0, 1, 2, 2012, 'gmt'); |
|
71 | 71 | |
72 | - $result=num_between_day($date1, $date2, 1); |
|
72 | + $result = num_between_day($date1, $date2, 1); |
|
73 | 73 | print __METHOD__." result=".$result."\n"; |
74 | 74 | $this->assertEquals(2, $result); |
75 | 75 | |
76 | - $result=num_between_day($date1, $date2, 0); |
|
76 | + $result = num_between_day($date1, $date2, 0); |
|
77 | 77 | print __METHOD__." result=".$result."\n"; |
78 | 78 | $this->assertEquals(1, $result); |
79 | 79 | |
80 | 80 | // With different hours |
81 | - $date1=dol_mktime(0, 0, 0, 1, 1, 2012, 'gmt'); |
|
82 | - $date2=dol_mktime(12, 0, 0, 1, 2, 2012, 'gmt'); |
|
81 | + $date1 = dol_mktime(0, 0, 0, 1, 1, 2012, 'gmt'); |
|
82 | + $date2 = dol_mktime(12, 0, 0, 1, 2, 2012, 'gmt'); |
|
83 | 83 | |
84 | - $result=num_between_day($date1, $date2, 1); |
|
84 | + $result = num_between_day($date1, $date2, 1); |
|
85 | 85 | print __METHOD__." result=".$result."\n"; |
86 | 86 | $this->assertEquals(2, $result); |
87 | 87 | |
88 | - $result=num_between_day($date1, $date2, 0); |
|
88 | + $result = num_between_day($date1, $date2, 0); |
|
89 | 89 | print __METHOD__." result=".$result."\n"; |
90 | 90 | $this->assertEquals(1, $result); |
91 | 91 | |
92 | 92 | // With different date before and after sunlight hour (day to change sunlight hour is 2014-03-30) |
93 | - $date1=dol_mktime(0, 0, 0, 3, 28, 2014, true); |
|
94 | - $date2=dol_mktime(0, 0, 0, 3, 31, 2014, true); |
|
93 | + $date1 = dol_mktime(0, 0, 0, 3, 28, 2014, true); |
|
94 | + $date2 = dol_mktime(0, 0, 0, 3, 31, 2014, true); |
|
95 | 95 | |
96 | - $result=num_between_day($date1, $date2, 1); |
|
96 | + $result = num_between_day($date1, $date2, 1); |
|
97 | 97 | print __METHOD__." result=".$result."\n"; |
98 | 98 | $this->assertEquals(4, $result); |
99 | 99 | |
100 | - $result=num_between_day($date1, $date2, 0); |
|
100 | + $result = num_between_day($date1, $date2, 0); |
|
101 | 101 | print __METHOD__." result=".$result."\n"; |
102 | 102 | $this->assertEquals(3, $result); |
103 | 103 | |
@@ -111,65 +111,65 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function testNumPublicHoliday() |
113 | 113 | { |
114 | - global $conf,$user,$langs,$db; |
|
115 | - $conf=$this->savconf; |
|
116 | - $user=$this->savuser; |
|
117 | - $langs=$this->savlangs; |
|
118 | - $db=$this->savdb; |
|
114 | + global $conf, $user, $langs, $db; |
|
115 | + $conf = $this->savconf; |
|
116 | + $user = $this->savuser; |
|
117 | + $langs = $this->savlangs; |
|
118 | + $db = $this->savdb; |
|
119 | 119 | |
120 | 120 | // With same hours - Tuesday/Wednesday jan 2013 |
121 | - $date1=dol_mktime(0, 0, 0, 1, 1, 2013, 'gmt'); |
|
122 | - $date2=dol_mktime(0, 0, 0, 1, 2, 2013, 'gmt'); |
|
123 | - $date3=dol_mktime(0, 0, 0, 1, 3, 2013, 'gmt'); |
|
121 | + $date1 = dol_mktime(0, 0, 0, 1, 1, 2013, 'gmt'); |
|
122 | + $date2 = dol_mktime(0, 0, 0, 1, 2, 2013, 'gmt'); |
|
123 | + $date3 = dol_mktime(0, 0, 0, 1, 3, 2013, 'gmt'); |
|
124 | 124 | |
125 | - $result=num_public_holiday($date1, $date2, 'FR', 1); |
|
125 | + $result = num_public_holiday($date1, $date2, 'FR', 1); |
|
126 | 126 | print __METHOD__." for Tuesday 1 - Wednesday 2 jan 2013 for FR result=".$result."\n"; |
127 | - $this->assertEquals(1, $result, 'NumPublicHoliday for Tuesday 1 - Wednesday 2 jan 2013 for FR'); // 1 closed days (country france) |
|
127 | + $this->assertEquals(1, $result, 'NumPublicHoliday for Tuesday 1 - Wednesday 2 jan 2013 for FR'); // 1 closed days (country france) |
|
128 | 128 | |
129 | - $result=num_public_holiday($date1, $date2, 'XX', 1); |
|
129 | + $result = num_public_holiday($date1, $date2, 'XX', 1); |
|
130 | 130 | print __METHOD__." for Tuesday 1 - Wednesday 2 jan 2013 for XX result=".$result."\n"; |
131 | - $this->assertEquals(1, $result, 'NumPublicHoliday for Tuesday 1 - Wednesday 2 jan 2013 for XX'); // 1 closed days (country unknown) |
|
131 | + $this->assertEquals(1, $result, 'NumPublicHoliday for Tuesday 1 - Wednesday 2 jan 2013 for XX'); // 1 closed days (country unknown) |
|
132 | 132 | |
133 | 133 | print '----'."\n"; |
134 | - $result=num_public_holiday($date2, $date3, 'FR', 1); |
|
134 | + $result = num_public_holiday($date2, $date3, 'FR', 1); |
|
135 | 135 | print __METHOD__." for Wednesday 2 - Thursday 3 jan 2013 for FR result=".$result."\n"; |
136 | - $this->assertEquals(0, $result, 'NumPublicHoliday for Wednesday 2 - Thursday 3 jan 2013 for FR'); // no closed days |
|
136 | + $this->assertEquals(0, $result, 'NumPublicHoliday for Wednesday 2 - Thursday 3 jan 2013 for FR'); // no closed days |
|
137 | 137 | |
138 | 138 | // Check with easter monday |
139 | - $date1=dol_mktime(0, 0, 0, 4, 21, 2019, 'gmt'); |
|
140 | - $date2=dol_mktime(0, 0, 0, 4, 23, 2019, 'gmt'); |
|
139 | + $date1 = dol_mktime(0, 0, 0, 4, 21, 2019, 'gmt'); |
|
140 | + $date2 = dol_mktime(0, 0, 0, 4, 23, 2019, 'gmt'); |
|
141 | 141 | |
142 | - $result=num_public_holiday($date1, $date2, 'XX', 1); |
|
142 | + $result = num_public_holiday($date1, $date2, 'XX', 1); |
|
143 | 143 | print __METHOD__." result=".$result."\n"; |
144 | - $this->assertEquals(1, $result, 'NumPublicHoliday including eastermonday for XX'); // 2 opened day, 1 closed days (sunday) |
|
144 | + $this->assertEquals(1, $result, 'NumPublicHoliday including eastermonday for XX'); // 2 opened day, 1 closed days (sunday) |
|
145 | 145 | |
146 | - $result=num_public_holiday($date1, $date2, 'FR', 1); |
|
146 | + $result = num_public_holiday($date1, $date2, 'FR', 1); |
|
147 | 147 | print __METHOD__." result=".$result."\n"; |
148 | - $this->assertEquals(2, $result, 'NumPublicHoliday including eastermonday for FR'); // 1 opened day, 2 closed days (sunday + easter monday) |
|
148 | + $this->assertEquals(2, $result, 'NumPublicHoliday including eastermonday for FR'); // 1 opened day, 2 closed days (sunday + easter monday) |
|
149 | 149 | |
150 | 150 | // Check for sunday/saturday - Friday 4 - Sunday 6 jan 2013 |
151 | - $date1=dol_mktime(0, 0, 0, 1, 4, 2013, 'gmt'); |
|
152 | - $date2=dol_mktime(0, 0, 0, 1, 6, 2013, 'gmt'); |
|
151 | + $date1 = dol_mktime(0, 0, 0, 1, 4, 2013, 'gmt'); |
|
152 | + $date2 = dol_mktime(0, 0, 0, 1, 6, 2013, 'gmt'); |
|
153 | 153 | |
154 | - $result=num_public_holiday($date1, $date2, 'FR', 1); |
|
154 | + $result = num_public_holiday($date1, $date2, 'FR', 1); |
|
155 | 155 | print __METHOD__." result=".$result."\n"; |
156 | - $this->assertEquals(2, $result, 'NumPublicHoliday for FR'); // 1 opened day, 2 closed days |
|
156 | + $this->assertEquals(2, $result, 'NumPublicHoliday for FR'); // 1 opened day, 2 closed days |
|
157 | 157 | |
158 | - $result=num_public_holiday($date1, $date2, 'FR', 1, 1, 1); |
|
158 | + $result = num_public_holiday($date1, $date2, 'FR', 1, 1, 1); |
|
159 | 159 | print __METHOD__." result=".$result."\n"; |
160 | - $this->assertEquals(2, $result, 'NumPublicHoliday for FR'); // 1 opened day, 2 closed days |
|
160 | + $this->assertEquals(2, $result, 'NumPublicHoliday for FR'); // 1 opened day, 2 closed days |
|
161 | 161 | |
162 | - $result=num_public_holiday($date1, $date2, 'FR', 1, 1, 0); |
|
162 | + $result = num_public_holiday($date1, $date2, 'FR', 1, 1, 0); |
|
163 | 163 | print __METHOD__." result=".$result."\n"; |
164 | - $this->assertEquals(1, $result, 'NumPublicHoliday for FR'); // 2 opened day, 1 closed days |
|
164 | + $this->assertEquals(1, $result, 'NumPublicHoliday for FR'); // 2 opened day, 1 closed days |
|
165 | 165 | |
166 | - $result=num_public_holiday($date1, $date2, 'FR', 1, 0, 0); |
|
166 | + $result = num_public_holiday($date1, $date2, 'FR', 1, 0, 0); |
|
167 | 167 | print __METHOD__." result=".$result."\n"; |
168 | - $this->assertEquals(0, $result, 'NumPublicHoliday for FR'); // 3 opened day, 0 closed days |
|
168 | + $this->assertEquals(0, $result, 'NumPublicHoliday for FR'); // 3 opened day, 0 closed days |
|
169 | 169 | |
170 | - $result=num_public_holiday($date1, $date2, 'XX', 1); |
|
170 | + $result = num_public_holiday($date1, $date2, 'XX', 1); |
|
171 | 171 | print __METHOD__." result=".$result."\n"; |
172 | - $this->assertEquals(2, $result, 'NumPublicHoliday for XX'); // 1 opened day, 2 closed days (even if country unknown) |
|
172 | + $this->assertEquals(2, $result, 'NumPublicHoliday for XX'); // 1 opened day, 2 closed days (even if country unknown) |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | /** |
@@ -179,51 +179,51 @@ discard block |
||
179 | 179 | */ |
180 | 180 | public function testNumOpenDay() |
181 | 181 | { |
182 | - global $conf,$user,$langs,$db; |
|
183 | - $conf=$this->savconf; |
|
184 | - $user=$this->savuser; |
|
185 | - $langs=$this->savlangs; |
|
186 | - $db=$this->savdb; |
|
182 | + global $conf, $user, $langs, $db; |
|
183 | + $conf = $this->savconf; |
|
184 | + $user = $this->savuser; |
|
185 | + $langs = $this->savlangs; |
|
186 | + $db = $this->savdb; |
|
187 | 187 | |
188 | 188 | // With same hours - Tuesday/Wednesday jan 2013 |
189 | - $date1=dol_mktime(0, 0, 0, 1, 1, 2013, 'gmt'); // tuesday |
|
190 | - $date2=dol_mktime(0, 0, 0, 1, 2, 2013, 'gmt'); // wednesday |
|
191 | - $date3=dol_mktime(0, 0, 0, 1, 3, 2013, 'gmt'); // thursday |
|
189 | + $date1 = dol_mktime(0, 0, 0, 1, 1, 2013, 'gmt'); // tuesday |
|
190 | + $date2 = dol_mktime(0, 0, 0, 1, 2, 2013, 'gmt'); // wednesday |
|
191 | + $date3 = dol_mktime(0, 0, 0, 1, 3, 2013, 'gmt'); // thursday |
|
192 | 192 | |
193 | - $result=num_open_day($date1, $date2, 0, 1, 0, 'FR'); |
|
193 | + $result = num_open_day($date1, $date2, 0, 1, 0, 'FR'); |
|
194 | 194 | print __METHOD__." result=".$result."\n"; |
195 | - $this->assertEquals(1, $result, 'NumOpenDay Tuesday 1 - Wednesday 2 jan 2013 for FR'); // 1 opened days (country france) |
|
195 | + $this->assertEquals(1, $result, 'NumOpenDay Tuesday 1 - Wednesday 2 jan 2013 for FR'); // 1 opened days (country france) |
|
196 | 196 | |
197 | - $result=num_open_day($date1, $date2, 0, 1, 0, 'XX'); |
|
197 | + $result = num_open_day($date1, $date2, 0, 1, 0, 'XX'); |
|
198 | 198 | print __METHOD__." result=".$result."\n"; |
199 | - $this->assertEquals(1, $result, 'NumOpenDay Tuesday 1 - Wednesday 2 jan 2013 for XX'); // 1 opened days (country unknown) |
|
199 | + $this->assertEquals(1, $result, 'NumOpenDay Tuesday 1 - Wednesday 2 jan 2013 for XX'); // 1 opened days (country unknown) |
|
200 | 200 | |
201 | - $result=num_open_day($date2, $date3, 0, 1, 0, 'FR'); |
|
201 | + $result = num_open_day($date2, $date3, 0, 1, 0, 'FR'); |
|
202 | 202 | print __METHOD__." result=".$result."\n"; |
203 | - $this->assertEquals(2, $result, 'NumOpenDay Wednesday 2 - Thursday 3 jan 2013 for FR'); // 2 opened days |
|
203 | + $this->assertEquals(2, $result, 'NumOpenDay Wednesday 2 - Thursday 3 jan 2013 for FR'); // 2 opened days |
|
204 | 204 | |
205 | 205 | // With same hours - Friday/Sunday jan 2013 |
206 | - $date1=dol_mktime(0, 0, 0, 1, 4, 2013, 'gmt'); // friday |
|
207 | - $date2=dol_mktime(0, 0, 0, 1, 6, 2013, 'gmt'); // sunday |
|
206 | + $date1 = dol_mktime(0, 0, 0, 1, 4, 2013, 'gmt'); // friday |
|
207 | + $date2 = dol_mktime(0, 0, 0, 1, 6, 2013, 'gmt'); // sunday |
|
208 | 208 | |
209 | - $result=num_open_day($date1, $date2, 0, 1, 0, 'FR'); |
|
209 | + $result = num_open_day($date1, $date2, 0, 1, 0, 'FR'); |
|
210 | 210 | print __METHOD__." result=".$result."\n"; |
211 | - $this->assertEquals(1, $result, 'NumOpenDay for FR'); // 1 opened day, 2 closed |
|
211 | + $this->assertEquals(1, $result, 'NumOpenDay for FR'); // 1 opened day, 2 closed |
|
212 | 212 | |
213 | - $result=num_open_day($date1, $date2, 'XX', 1); |
|
213 | + $result = num_open_day($date1, $date2, 'XX', 1); |
|
214 | 214 | print __METHOD__." result=".$result."\n"; |
215 | - $this->assertEquals(1, $result, 'NumOpenDay for XX'); // 1 opened day, 2 closes (even if country unknown) |
|
215 | + $this->assertEquals(1, $result, 'NumOpenDay for XX'); // 1 opened day, 2 closes (even if country unknown) |
|
216 | 216 | |
217 | 217 | // Test option MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY and MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY |
218 | 218 | $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY = 0; |
219 | - $result=num_open_day($date1, $date2, 0, 1, 0, 'FR'); |
|
219 | + $result = num_open_day($date1, $date2, 0, 1, 0, 'FR'); |
|
220 | 220 | print __METHOD__." result=".$result."\n"; |
221 | - $this->assertEquals(2, $result, 'NumOpenDay for FR when saturday is a working day'); //2 opened day, 1 closed |
|
221 | + $this->assertEquals(2, $result, 'NumOpenDay for FR when saturday is a working day'); //2 opened day, 1 closed |
|
222 | 222 | |
223 | 223 | $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY = 0; |
224 | - $result=num_open_day($date1, $date2, 'XX', 1); |
|
224 | + $result = num_open_day($date1, $date2, 'XX', 1); |
|
225 | 225 | print __METHOD__." result=".$result."\n"; |
226 | - $this->assertEquals(3, $result, 'NumOpenDay for XX when saturday + sunday are working days'); // 3 opened day, 0 closes (even if country unknown) |
|
226 | + $this->assertEquals(3, $result, 'NumOpenDay for XX when saturday + sunday are working days'); // 3 opened day, 0 closes (even if country unknown) |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | /** |
@@ -233,13 +233,13 @@ discard block |
||
233 | 233 | */ |
234 | 234 | public function testConvertTime2Seconds() |
235 | 235 | { |
236 | - global $conf,$user,$langs,$db; |
|
237 | - $conf=$this->savconf; |
|
238 | - $user=$this->savuser; |
|
239 | - $langs=$this->savlangs; |
|
240 | - $db=$this->savdb; |
|
236 | + global $conf, $user, $langs, $db; |
|
237 | + $conf = $this->savconf; |
|
238 | + $user = $this->savuser; |
|
239 | + $langs = $this->savlangs; |
|
240 | + $db = $this->savdb; |
|
241 | 241 | |
242 | - $result=convertTime2Seconds(1, 1, 2); |
|
242 | + $result = convertTime2Seconds(1, 1, 2); |
|
243 | 243 | print __METHOD__." result=".$result."\n"; |
244 | 244 | $this->assertEquals(3662, $result); |
245 | 245 | |
@@ -253,17 +253,17 @@ discard block |
||
253 | 253 | */ |
254 | 254 | public function testConvertSecondToTime() |
255 | 255 | { |
256 | - global $conf,$user,$langs,$db; |
|
257 | - $conf=$this->savconf; |
|
258 | - $user=$this->savuser; |
|
259 | - $langs=$this->savlangs; |
|
260 | - $db=$this->savdb; |
|
256 | + global $conf, $user, $langs, $db; |
|
257 | + $conf = $this->savconf; |
|
258 | + $user = $this->savuser; |
|
259 | + $langs = $this->savlangs; |
|
260 | + $db = $this->savdb; |
|
261 | 261 | |
262 | - $result=convertSecondToTime(0, 'all', 86400); |
|
262 | + $result = convertSecondToTime(0, 'all', 86400); |
|
263 | 263 | print __METHOD__." result=".$result."\n"; |
264 | 264 | $this->assertEquals('0', $result); |
265 | 265 | |
266 | - $result=convertSecondToTime(86400, 'all', 86400); |
|
266 | + $result = convertSecondToTime(86400, 'all', 86400); |
|
267 | 267 | print __METHOD__." result=".$result."\n"; |
268 | 268 | $this->assertSame('1 '.$langs->trans("d"), $result); |
269 | 269 | |
@@ -277,64 +277,64 @@ discard block |
||
277 | 277 | */ |
278 | 278 | public function testDolPrintDate() |
279 | 279 | { |
280 | - global $conf,$user,$langs,$db; |
|
281 | - $conf=$this->savconf; |
|
282 | - $user=$this->savuser; |
|
283 | - $langs=$this->savlangs; |
|
284 | - $db=$this->savdb; |
|
280 | + global $conf, $user, $langs, $db; |
|
281 | + $conf = $this->savconf; |
|
282 | + $user = $this->savuser; |
|
283 | + $langs = $this->savlangs; |
|
284 | + $db = $this->savdb; |
|
285 | 285 | |
286 | 286 | // Check %Y-%m-%d %H:%M:%S format |
287 | - $result=dol_print_date('1970-01-01', '%Y-%m-%d %H:%M:%S', true); // A case for compatibility check |
|
287 | + $result = dol_print_date('1970-01-01', '%Y-%m-%d %H:%M:%S', true); // A case for compatibility check |
|
288 | 288 | print __METHOD__." result=".$result."\n"; |
289 | 289 | $this->assertEquals('1970-01-01 00:00:00', $result); |
290 | 290 | |
291 | 291 | |
292 | 292 | // Check %Y-%m-%d %H:%M:%S format |
293 | - $result=dol_print_date(0, '%Y-%m-%d %H:%M:%S', true); |
|
293 | + $result = dol_print_date(0, '%Y-%m-%d %H:%M:%S', true); |
|
294 | 294 | print __METHOD__." result=".$result."\n"; |
295 | 295 | $this->assertEquals('1970-01-01 00:00:00', $result); |
296 | 296 | |
297 | 297 | // Same with T and Z |
298 | - $result=dol_print_date(0, '%Y-%m-%dT%H:%M:%SZ', true); |
|
298 | + $result = dol_print_date(0, '%Y-%m-%dT%H:%M:%SZ', true); |
|
299 | 299 | print __METHOD__." result=".$result."\n"; |
300 | 300 | $this->assertEquals('1970-01-01T00:00:00Z', $result); |
301 | 301 | |
302 | 302 | // Check %Y-%m-%d %H:%M:%S format |
303 | - $result=dol_print_date(16725225600, '%Y-%m-%d %H:%M:%S', true); // http://www.epochconverter.com/ |
|
303 | + $result = dol_print_date(16725225600, '%Y-%m-%d %H:%M:%S', true); // http://www.epochconverter.com/ |
|
304 | 304 | print __METHOD__." result=".$result."\n"; |
305 | 305 | $this->assertEquals('2500-01-01 00:00:00', $result); |
306 | 306 | |
307 | 307 | // Check %Y-%m-%d %H:%M:%S format |
308 | - $result=dol_print_date(-1830384000, '%Y-%m-%d %H:%M:%S', true); // http://www.epochconverter.com/ |
|
308 | + $result = dol_print_date(-1830384000, '%Y-%m-%d %H:%M:%S', true); // http://www.epochconverter.com/ |
|
309 | 309 | print __METHOD__." result=".$result."\n"; |
310 | - $this->assertEquals('1912-01-01 00:00:00', $result); // dol_print_date use TZ (good) but epoch converter does not use it. |
|
310 | + $this->assertEquals('1912-01-01 00:00:00', $result); // dol_print_date use TZ (good) but epoch converter does not use it. |
|
311 | 311 | |
312 | 312 | // Check %Y-%m-%d %H:%M:%S format |
313 | - $result=dol_print_date(-11676096000, '%Y-%m-%d %H:%M:%S', true); // http://www.epochconverter.com/ |
|
313 | + $result = dol_print_date(-11676096000, '%Y-%m-%d %H:%M:%S', true); // http://www.epochconverter.com/ |
|
314 | 314 | print __METHOD__." result=".$result."\n"; |
315 | 315 | $this->assertEquals('1600-01-01 00:00:00', $result); |
316 | 316 | |
317 | 317 | // test with negative timezone |
318 | - $result=dol_print_date(-1, '%Y-%m-%d %H:%M:%S', true); // http://www.epochconverter.com/ |
|
318 | + $result = dol_print_date(-1, '%Y-%m-%d %H:%M:%S', true); // http://www.epochconverter.com/ |
|
319 | 319 | print __METHOD__." result=".$result."\n"; |
320 | 320 | $this->assertEquals('1969-12-31 23:59:59', $result); |
321 | 321 | |
322 | 322 | // Check dayhour format for fr_FR |
323 | - $outputlangs=new Translate('', $conf); |
|
323 | + $outputlangs = new Translate('', $conf); |
|
324 | 324 | $outputlangs->setDefaultLang('fr_FR'); |
325 | 325 | $outputlangs->load("main"); |
326 | 326 | |
327 | - $result=dol_print_date(0+24*3600, 'dayhour', true, $outputlangs); |
|
327 | + $result = dol_print_date(0 + 24 * 3600, 'dayhour', true, $outputlangs); |
|
328 | 328 | print __METHOD__." result=".$result."\n"; |
329 | 329 | $this->assertEquals('02/01/1970 00:00', $result); |
330 | 330 | |
331 | 331 | // Check %a and %b format for fr_FR |
332 | - $result=dol_print_date(0, '%a %b %B', true, $outputlangs); |
|
332 | + $result = dol_print_date(0, '%a %b %B', true, $outputlangs); |
|
333 | 333 | print __METHOD__." result=".$result."\n"; |
334 | 334 | $this->assertEquals('Jeu Jan. Janvier', $result); |
335 | 335 | |
336 | 336 | |
337 | - $result=dol_print_date(1619388000, '%Y-%m-%d %a', 'gmt', $outputlangs); |
|
337 | + $result = dol_print_date(1619388000, '%Y-%m-%d %a', 'gmt', $outputlangs); |
|
338 | 338 | print __METHOD__." result=".$result."\n"; |
339 | 339 | $this->assertEquals('2021-04-25 Dim', $result); |
340 | 340 | |
@@ -345,16 +345,16 @@ discard block |
||
345 | 345 | */ |
346 | 346 | |
347 | 347 | // Check day format for en_US |
348 | - $outputlangs=new Translate('', $conf); |
|
348 | + $outputlangs = new Translate('', $conf); |
|
349 | 349 | $outputlangs->setDefaultLang('en_US'); |
350 | 350 | $outputlangs->load("main"); |
351 | 351 | |
352 | - $result=dol_print_date(0+24*3600, 'day', true, $outputlangs); |
|
352 | + $result = dol_print_date(0 + 24 * 3600, 'day', true, $outputlangs); |
|
353 | 353 | print __METHOD__." result=".$result."\n"; |
354 | 354 | $this->assertEquals('01/02/1970', $result); |
355 | 355 | |
356 | 356 | // Check %a and %b format for en_US |
357 | - $result=dol_print_date(0, '%a %b %B', true, $outputlangs); |
|
357 | + $result = dol_print_date(0, '%a %b %B', true, $outputlangs); |
|
358 | 358 | print __METHOD__." result=".$result."\n"; |
359 | 359 | $this->assertEquals('Thu Jan January', $result); |
360 | 360 | |
@@ -368,18 +368,18 @@ discard block |
||
368 | 368 | */ |
369 | 369 | public function testDolTimePlusDuree() |
370 | 370 | { |
371 | - global $conf,$user,$langs,$db; |
|
372 | - $conf=$this->savconf; |
|
373 | - $user=$this->savuser; |
|
374 | - $langs=$this->savlangs; |
|
375 | - $db=$this->savdb; |
|
371 | + global $conf, $user, $langs, $db; |
|
372 | + $conf = $this->savconf; |
|
373 | + $user = $this->savuser; |
|
374 | + $langs = $this->savlangs; |
|
375 | + $db = $this->savdb; |
|
376 | 376 | |
377 | 377 | // Check dayhour format for fr_FR |
378 | - $outputlangs=new Translate('', $conf); |
|
378 | + $outputlangs = new Translate('', $conf); |
|
379 | 379 | $outputlangs->setDefaultLang('fr_FR'); |
380 | 380 | $outputlangs->load("main"); |
381 | 381 | |
382 | - $result=dol_print_date(dol_time_plus_duree(dol_time_plus_duree(dol_time_plus_duree(0, 1, 'm'), 1, 'y'), 1, 'd'), 'dayhour', true, $outputlangs); |
|
382 | + $result = dol_print_date(dol_time_plus_duree(dol_time_plus_duree(dol_time_plus_duree(0, 1, 'm'), 1, 'y'), 1, 'd'), 'dayhour', true, $outputlangs); |
|
383 | 383 | print __METHOD__." result=".$result."\n"; |
384 | 384 | $this->assertEquals('02/02/1971 00:00', $result); |
385 | 385 | |
@@ -393,34 +393,34 @@ discard block |
||
393 | 393 | */ |
394 | 394 | public function testDolStringToTime() |
395 | 395 | { |
396 | - global $conf,$user,$langs,$db; |
|
397 | - $conf=$this->savconf; |
|
398 | - $user=$this->savuser; |
|
399 | - $langs=$this->savlangs; |
|
400 | - $db=$this->savdb; |
|
396 | + global $conf, $user, $langs, $db; |
|
397 | + $conf = $this->savconf; |
|
398 | + $user = $this->savuser; |
|
399 | + $langs = $this->savlangs; |
|
400 | + $db = $this->savdb; |
|
401 | 401 | |
402 | - $stime='19700102'; |
|
403 | - $result=dol_stringtotime($stime); |
|
402 | + $stime = '19700102'; |
|
403 | + $result = dol_stringtotime($stime); |
|
404 | 404 | print __METHOD__." result=".$result."\n"; |
405 | 405 | $this->assertEquals(86400, $result); |
406 | 406 | |
407 | - $stime='1970-01-01T02:00:00Z'; |
|
408 | - $result=dol_stringtotime($stime); |
|
407 | + $stime = '1970-01-01T02:00:00Z'; |
|
408 | + $result = dol_stringtotime($stime); |
|
409 | 409 | print __METHOD__." result=".$result."\n"; |
410 | 410 | $this->assertEquals(7200, $result); |
411 | 411 | |
412 | - $stime='1970-01-01 02:00:00'; |
|
413 | - $result=dol_stringtotime($stime); |
|
412 | + $stime = '1970-01-01 02:00:00'; |
|
413 | + $result = dol_stringtotime($stime); |
|
414 | 414 | print __METHOD__." result=".$result."\n"; |
415 | 415 | $this->assertEquals(7200, $result); |
416 | 416 | |
417 | - $stime='19700101T020000Z'; |
|
418 | - $result=dol_stringtotime($stime); |
|
417 | + $stime = '19700101T020000Z'; |
|
418 | + $result = dol_stringtotime($stime); |
|
419 | 419 | print __METHOD__." result=".$result."\n"; |
420 | 420 | $this->assertEquals(7200, $result); |
421 | 421 | |
422 | - $stime='19700101020000'; |
|
423 | - $result=dol_stringtotime($stime); |
|
422 | + $stime = '19700101020000'; |
|
423 | + $result = dol_stringtotime($stime); |
|
424 | 424 | print __METHOD__." result=".$result."\n"; |
425 | 425 | $this->assertEquals(7200, $result); |
426 | 426 | |
@@ -436,19 +436,19 @@ discard block |
||
436 | 436 | { |
437 | 437 | global $conf; |
438 | 438 | |
439 | - $day=3; |
|
440 | - $month=2; |
|
441 | - $year=2015; |
|
442 | - $conf->global->MAIN_START_WEEK = 1; // start on monday |
|
439 | + $day = 3; |
|
440 | + $month = 2; |
|
441 | + $year = 2015; |
|
442 | + $conf->global->MAIN_START_WEEK = 1; // start on monday |
|
443 | 443 | $prev = dol_get_first_day_week($day, $month, $year); |
444 | - $this->assertEquals(2, (int) $prev['first_day']); // monday for month 2, year 2014 is the 2 |
|
444 | + $this->assertEquals(2, (int) $prev['first_day']); // monday for month 2, year 2014 is the 2 |
|
445 | 445 | |
446 | - $day=3; |
|
447 | - $month=2; |
|
448 | - $year=2015; |
|
449 | - $conf->global->MAIN_START_WEEK = 0; // start on sunday |
|
446 | + $day = 3; |
|
447 | + $month = 2; |
|
448 | + $year = 2015; |
|
449 | + $conf->global->MAIN_START_WEEK = 0; // start on sunday |
|
450 | 450 | $prev = dol_get_first_day_week($day, $month, $year); |
451 | - $this->assertEquals(1, (int) $prev['first_day']); // sunday for month 2, year 2015 is the 1st |
|
451 | + $this->assertEquals(1, (int) $prev['first_day']); // sunday for month 2, year 2015 is the 1st |
|
452 | 452 | |
453 | 453 | return 1; |
454 | 454 | } |
@@ -463,15 +463,15 @@ discard block |
||
463 | 463 | { |
464 | 464 | global $conf; |
465 | 465 | |
466 | - $now = 1800 + (24 * 3600 * 10); // The 11th of january 1970 at 0:30 in UTC |
|
466 | + $now = 1800 + (24 * 3600 * 10); // The 11th of january 1970 at 0:30 in UTC |
|
467 | 467 | $result = dol_get_first_hour($now, 'gmt'); |
468 | 468 | print __METHOD__." now = ".$now.", dol_print_date(now, 'dayhourrfc', 'gmt') = ".dol_print_date($now, 'dayhourrfc', 'gmt').", result = ".$result.", dol_print_date(result, 'dayhourrfc', 'gmt') = ".dol_print_date($result, 'dayhourrfc', 'gmt')."\n"; |
469 | - $this->assertEquals('1970-01-11T00:00:00Z', dol_print_date($result, 'dayhourrfc', 'gmt')); // monday for month 2, year 2014 is the 2 |
|
469 | + $this->assertEquals('1970-01-11T00:00:00Z', dol_print_date($result, 'dayhourrfc', 'gmt')); // monday for month 2, year 2014 is the 2 |
|
470 | 470 | |
471 | - $now = 23.5 * 3600 + (24 * 3600 * 10); // The 11th of january 1970 at 23:30 in UTC |
|
471 | + $now = 23.5 * 3600 + (24 * 3600 * 10); // The 11th of january 1970 at 23:30 in UTC |
|
472 | 472 | $result = dol_get_first_hour($now, 'gmt'); |
473 | 473 | print __METHOD__." now = ".$now.", dol_print_date(now, 'dayhourrfc', 'gmt') = ".dol_print_date($now, 'dayhourrfc', 'gmt').", result = ".$result.", dol_print_date(result, 'dayhourrfc', 'gmt') = ".dol_print_date($result, 'dayhourrfc', 'gmt')."\n"; |
474 | - $this->assertEquals('1970-01-11T00:00:00Z', dol_print_date($result, 'dayhourrfc', 'gmt')); // monday for month 2, year 2014 is the 2 |
|
474 | + $this->assertEquals('1970-01-11T00:00:00Z', dol_print_date($result, 'dayhourrfc', 'gmt')); // monday for month 2, year 2014 is the 2 |
|
475 | 475 | |
476 | 476 | return 1; |
477 | 477 | } |
@@ -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,11 +55,11 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public function testDDLUpdateField() |
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 | print __METHOD__.' db->type = '.$db->type."\n"; |
65 | 65 |