@@ -27,8 +27,8 @@ discard block |
||
| 27 | 27 | // Test si mode batch |
| 28 | 28 | $sapi_type = php_sapi_name(); |
| 29 | 29 | if (substr($sapi_type, 0, 3) == 'cgi') { |
| 30 | - echo "Erreur: Vous utilisez l'interpreteur PHP pour le mode CGI. Pour executer mailing-send.php en ligne de commande, vous devez utiliser l'interpreteur PHP pour le mode CLI.\n"; |
|
| 31 | - exit; |
|
| 30 | + echo "Erreur: Vous utilisez l'interpreteur PHP pour le mode CGI. Pour executer mailing-send.php en ligne de commande, vous devez utiliser l'interpreteur PHP pour le mode CLI.\n"; |
|
| 31 | + exit; |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | // Recupere root dolibarr |
@@ -100,8 +100,8 @@ discard block |
||
| 100 | 100 | $ret=$user->fetch('','admin'); |
| 101 | 101 | if (! $ret > 0) |
| 102 | 102 | { |
| 103 | - print 'A user with login "admin" and all permissions must be created to use this script.'."\n"; |
|
| 104 | - exit; |
|
| 103 | + print 'A user with login "admin" and all permissions must be created to use this script.'."\n"; |
|
| 104 | + exit; |
|
| 105 | 105 | } |
| 106 | 106 | $user->getrights(); |
| 107 | 107 | |
@@ -111,14 +111,14 @@ discard block |
||
| 111 | 111 | $resql = $db->query($sql); |
| 112 | 112 | if ($resql) |
| 113 | 113 | { |
| 114 | - $num_thirdparties = $db->num_rows($resql); |
|
| 115 | - $i = 0; |
|
| 116 | - while ($i < $num_thirdparties) |
|
| 117 | - { |
|
| 118 | - $i++; |
|
| 119 | - $row = $db->fetch_row($resql); |
|
| 120 | - $socids[$i] = $row[0]; |
|
| 121 | - } |
|
| 114 | + $num_thirdparties = $db->num_rows($resql); |
|
| 115 | + $i = 0; |
|
| 116 | + while ($i < $num_thirdparties) |
|
| 117 | + { |
|
| 118 | + $i++; |
|
| 119 | + $row = $db->fetch_row($resql); |
|
| 120 | + $socids[$i] = $row[0]; |
|
| 121 | + } |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | $contids = array(); |
@@ -126,14 +126,14 @@ discard block |
||
| 126 | 126 | $resql = $db->query($sql); |
| 127 | 127 | if ($resql) |
| 128 | 128 | { |
| 129 | - $num_conts = $db->num_rows($resql); |
|
| 130 | - $i = 0; |
|
| 131 | - while ($i < $num_conts) |
|
| 132 | - { |
|
| 133 | - $i++; |
|
| 134 | - $row = $db->fetch_row($resql); |
|
| 135 | - $contids[$row[1]][0] = $row[0]; // A ameliorer |
|
| 136 | - } |
|
| 129 | + $num_conts = $db->num_rows($resql); |
|
| 130 | + $i = 0; |
|
| 131 | + while ($i < $num_conts) |
|
| 132 | + { |
|
| 133 | + $i++; |
|
| 134 | + $row = $db->fetch_row($resql); |
|
| 135 | + $contids[$row[1]][0] = $row[0]; // A ameliorer |
|
| 136 | + } |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | $prodids = array(); |
@@ -141,14 +141,14 @@ discard block |
||
| 141 | 141 | $resql = $db->query($sql); |
| 142 | 142 | if ($resql) |
| 143 | 143 | { |
| 144 | - $num_prods = $db->num_rows($resql); |
|
| 145 | - $i = 0; |
|
| 146 | - while ($i < $num_prods) |
|
| 147 | - { |
|
| 148 | - $i++; |
|
| 149 | - $row = $db->fetch_row($resql); |
|
| 150 | - $prodids[$i] = $row[0]; |
|
| 151 | - } |
|
| 144 | + $num_prods = $db->num_rows($resql); |
|
| 145 | + $i = 0; |
|
| 146 | + while ($i < $num_prods) |
|
| 147 | + { |
|
| 148 | + $i++; |
|
| 149 | + $row = $db->fetch_row($resql); |
|
| 150 | + $prodids[$i] = $row[0]; |
|
| 151 | + } |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | $user->rights->propal->creer=1; |
@@ -157,65 +157,65 @@ discard block |
||
| 157 | 157 | |
| 158 | 158 | if (! empty($conf->global->PROPALE_ADDON) && is_readable(DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.".php")) |
| 159 | 159 | { |
| 160 | - require_once DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.".php"; |
|
| 160 | + require_once DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.".php"; |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | $i=0; |
| 164 | 164 | $result=0; |
| 165 | 165 | while ($i < GEN_NUMBER_PROPAL && $result >= 0) |
| 166 | 166 | { |
| 167 | - $i++; |
|
| 168 | - $socid = mt_rand(1, $num_thirdparties); |
|
| 169 | - print "Proposal ".$i." for socid ".$socid; |
|
| 167 | + $i++; |
|
| 168 | + $socid = mt_rand(1, $num_thirdparties); |
|
| 169 | + print "Proposal ".$i." for socid ".$socid; |
|
| 170 | 170 | |
| 171 | - $soc = new Societe($db); |
|
| 171 | + $soc = new Societe($db); |
|
| 172 | 172 | |
| 173 | 173 | |
| 174 | - $object = new Propal($db); |
|
| 174 | + $object = new Propal($db); |
|
| 175 | 175 | |
| 176 | 176 | $fuser = new User($db); |
| 177 | 177 | $fuser->fetch(mt_rand(1,2)); |
| 178 | 178 | $fuser->getRights(); |
| 179 | 179 | |
| 180 | - $object->contactid = $contids[$socids[$socid]][0]; |
|
| 181 | - $object->socid = $socids[$socid]; |
|
| 182 | - $object->datep = $dates[mt_rand(1, count($dates)-1)]; |
|
| 183 | - $object->cond_reglement_id = 3; |
|
| 184 | - $object->mode_reglement_id = 3; |
|
| 185 | - |
|
| 186 | - $result=$object->create($fuser); |
|
| 187 | - if ($result >= 0) |
|
| 188 | - { |
|
| 189 | - $nbp = mt_rand(2, 5); |
|
| 190 | - $xnbp = 0; |
|
| 191 | - while ($xnbp < $nbp) |
|
| 192 | - { |
|
| 193 | - $prodid = mt_rand(1, $num_prods); |
|
| 194 | - $product=new Product($db); |
|
| 195 | - $result=$product->fetch($prodids[$prodid]); |
|
| 196 | - $result=$object->addline($product->description, $product->price, mt_rand(1,5), 0, 0, 0, $prodids[$prodid], 0); |
|
| 197 | - if ($result < 0) |
|
| 198 | - { |
|
| 199 | - dol_print_error($db,$object->error); |
|
| 200 | - } |
|
| 201 | - $xnbp++; |
|
| 202 | - } |
|
| 180 | + $object->contactid = $contids[$socids[$socid]][0]; |
|
| 181 | + $object->socid = $socids[$socid]; |
|
| 182 | + $object->datep = $dates[mt_rand(1, count($dates)-1)]; |
|
| 183 | + $object->cond_reglement_id = 3; |
|
| 184 | + $object->mode_reglement_id = 3; |
|
| 185 | + |
|
| 186 | + $result=$object->create($fuser); |
|
| 187 | + if ($result >= 0) |
|
| 188 | + { |
|
| 189 | + $nbp = mt_rand(2, 5); |
|
| 190 | + $xnbp = 0; |
|
| 191 | + while ($xnbp < $nbp) |
|
| 192 | + { |
|
| 193 | + $prodid = mt_rand(1, $num_prods); |
|
| 194 | + $product=new Product($db); |
|
| 195 | + $result=$product->fetch($prodids[$prodid]); |
|
| 196 | + $result=$object->addline($product->description, $product->price, mt_rand(1,5), 0, 0, 0, $prodids[$prodid], 0); |
|
| 197 | + if ($result < 0) |
|
| 198 | + { |
|
| 199 | + dol_print_error($db,$object->error); |
|
| 200 | + } |
|
| 201 | + $xnbp++; |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | - $result=$object->valid($fuser); |
|
| 205 | - if ($result > 0) |
|
| 206 | - { |
|
| 207 | - $db->commit(); |
|
| 208 | - print " OK with ref ".$object->ref."\n"; |
|
| 209 | - } |
|
| 210 | - else |
|
| 211 | - { |
|
| 212 | - print " KO\n"; |
|
| 213 | - $db->rollback(); |
|
| 214 | - dol_print_error($db,$object->error); |
|
| 215 | - } |
|
| 216 | - } |
|
| 217 | - else |
|
| 218 | - { |
|
| 219 | - dol_print_error($db,$object->error); |
|
| 220 | - } |
|
| 204 | + $result=$object->valid($fuser); |
|
| 205 | + if ($result > 0) |
|
| 206 | + { |
|
| 207 | + $db->commit(); |
|
| 208 | + print " OK with ref ".$object->ref."\n"; |
|
| 209 | + } |
|
| 210 | + else |
|
| 211 | + { |
|
| 212 | + print " KO\n"; |
|
| 213 | + $db->rollback(); |
|
| 214 | + dol_print_error($db,$object->error); |
|
| 215 | + } |
|
| 216 | + } |
|
| 217 | + else |
|
| 218 | + { |
|
| 219 | + dol_print_error($db,$object->error); |
|
| 220 | + } |
|
| 221 | 221 | } |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | // Recupere root dolibarr |
| 35 | 35 | //$path=preg_replace('/generate-propale.php/i','',$_SERVER["PHP_SELF"]); |
| 36 | -require __DIR__. '/../../htdocs/master.inc.php'; |
|
| 36 | +require __DIR__.'/../../htdocs/master.inc.php'; |
|
| 37 | 37 | require_once DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php"; |
| 38 | 38 | require_once DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php"; |
| 39 | 39 | require_once DOL_DOCUMENT_ROOT."/commande/class/commande.class.php"; |
@@ -45,60 +45,60 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | define(GEN_NUMBER_PROPAL, 10); |
| 47 | 47 | $year = 2016; |
| 48 | -$dates = array (mktime(12,0,0,1,3,$year), |
|
| 49 | - mktime(12,0,0,1,9,$year), |
|
| 50 | - mktime(12,0,0,2,13,$year), |
|
| 51 | - mktime(12,0,0,2,23,$year), |
|
| 52 | - mktime(12,0,0,3,30,$year), |
|
| 53 | - mktime(12,0,0,4,3,$year), |
|
| 54 | - mktime(12,0,0,4,3,$year), |
|
| 55 | - mktime(12,0,0,5,9,$year), |
|
| 56 | - mktime(12,0,0,5,1,$year), |
|
| 57 | - mktime(12,0,0,5,13,$year), |
|
| 58 | - mktime(12,0,0,5,19,$year), |
|
| 59 | - mktime(12,0,0,5,23,$year), |
|
| 60 | - mktime(12,0,0,6,3,$year), |
|
| 61 | - mktime(12,0,0,6,19,$year), |
|
| 62 | - mktime(12,0,0,6,24,$year), |
|
| 63 | - mktime(12,0,0,7,3,$year), |
|
| 64 | - mktime(12,0,0,7,9,$year), |
|
| 65 | - mktime(12,0,0,7,23,$year), |
|
| 66 | - mktime(12,0,0,7,30,$year), |
|
| 67 | - mktime(12,0,0,8,9,$year), |
|
| 68 | - mktime(12,0,0,9,23,$year), |
|
| 69 | - mktime(12,0,0,10,3,$year), |
|
| 70 | - mktime(12,0,0,11,12,$year), |
|
| 71 | - mktime(12,0,0,11,13,$year), |
|
| 72 | - mktime(12,0,0,1,3,($year - 1)), |
|
| 73 | - mktime(12,0,0,1,9,($year - 1)), |
|
| 74 | - mktime(12,0,0,2,13,($year - 1)), |
|
| 75 | - mktime(12,0,0,2,23,($year - 1)), |
|
| 76 | - mktime(12,0,0,3,30,($year - 1)), |
|
| 77 | - mktime(12,0,0,4,3,($year - 1)), |
|
| 78 | - mktime(12,0,0,4,3,($year - 1)), |
|
| 79 | - mktime(12,0,0,5,9,($year - 1)), |
|
| 80 | - mktime(12,0,0,5,1,($year - 1)), |
|
| 81 | - mktime(12,0,0,5,13,($year - 1)), |
|
| 82 | - mktime(12,0,0,5,19,($year - 1)), |
|
| 83 | - mktime(12,0,0,5,23,($year - 1)), |
|
| 84 | - mktime(12,0,0,6,3,($year - 1)), |
|
| 85 | - mktime(12,0,0,6,19,($year - 1)), |
|
| 86 | - mktime(12,0,0,6,24,($year - 1)), |
|
| 87 | - mktime(12,0,0,7,3,($year - 1)), |
|
| 88 | - mktime(12,0,0,7,9,($year - 1)), |
|
| 89 | - mktime(12,0,0,7,23,($year - 1)), |
|
| 90 | - mktime(12,0,0,7,30,($year - 1)), |
|
| 91 | - mktime(12,0,0,8,9,($year - 1)), |
|
| 92 | - mktime(12,0,0,9,23,($year - 1)), |
|
| 93 | - mktime(12,0,0,10,3,($year - 1)), |
|
| 94 | - mktime(12,0,0,11,12,$year), |
|
| 95 | - mktime(12,0,0,11,13,$year), |
|
| 96 | - mktime(12,0,0,12,12,$year), |
|
| 97 | - mktime(12,0,0,12,13,$year), |
|
| 48 | +$dates = array(mktime(12, 0, 0, 1, 3, $year), |
|
| 49 | + mktime(12, 0, 0, 1, 9, $year), |
|
| 50 | + mktime(12, 0, 0, 2, 13, $year), |
|
| 51 | + mktime(12, 0, 0, 2, 23, $year), |
|
| 52 | + mktime(12, 0, 0, 3, 30, $year), |
|
| 53 | + mktime(12, 0, 0, 4, 3, $year), |
|
| 54 | + mktime(12, 0, 0, 4, 3, $year), |
|
| 55 | + mktime(12, 0, 0, 5, 9, $year), |
|
| 56 | + mktime(12, 0, 0, 5, 1, $year), |
|
| 57 | + mktime(12, 0, 0, 5, 13, $year), |
|
| 58 | + mktime(12, 0, 0, 5, 19, $year), |
|
| 59 | + mktime(12, 0, 0, 5, 23, $year), |
|
| 60 | + mktime(12, 0, 0, 6, 3, $year), |
|
| 61 | + mktime(12, 0, 0, 6, 19, $year), |
|
| 62 | + mktime(12, 0, 0, 6, 24, $year), |
|
| 63 | + mktime(12, 0, 0, 7, 3, $year), |
|
| 64 | + mktime(12, 0, 0, 7, 9, $year), |
|
| 65 | + mktime(12, 0, 0, 7, 23, $year), |
|
| 66 | + mktime(12, 0, 0, 7, 30, $year), |
|
| 67 | + mktime(12, 0, 0, 8, 9, $year), |
|
| 68 | + mktime(12, 0, 0, 9, 23, $year), |
|
| 69 | + mktime(12, 0, 0, 10, 3, $year), |
|
| 70 | + mktime(12, 0, 0, 11, 12, $year), |
|
| 71 | + mktime(12, 0, 0, 11, 13, $year), |
|
| 72 | + mktime(12, 0, 0, 1, 3, ($year - 1)), |
|
| 73 | + mktime(12, 0, 0, 1, 9, ($year - 1)), |
|
| 74 | + mktime(12, 0, 0, 2, 13, ($year - 1)), |
|
| 75 | + mktime(12, 0, 0, 2, 23, ($year - 1)), |
|
| 76 | + mktime(12, 0, 0, 3, 30, ($year - 1)), |
|
| 77 | + mktime(12, 0, 0, 4, 3, ($year - 1)), |
|
| 78 | + mktime(12, 0, 0, 4, 3, ($year - 1)), |
|
| 79 | + mktime(12, 0, 0, 5, 9, ($year - 1)), |
|
| 80 | + mktime(12, 0, 0, 5, 1, ($year - 1)), |
|
| 81 | + mktime(12, 0, 0, 5, 13, ($year - 1)), |
|
| 82 | + mktime(12, 0, 0, 5, 19, ($year - 1)), |
|
| 83 | + mktime(12, 0, 0, 5, 23, ($year - 1)), |
|
| 84 | + mktime(12, 0, 0, 6, 3, ($year - 1)), |
|
| 85 | + mktime(12, 0, 0, 6, 19, ($year - 1)), |
|
| 86 | + mktime(12, 0, 0, 6, 24, ($year - 1)), |
|
| 87 | + mktime(12, 0, 0, 7, 3, ($year - 1)), |
|
| 88 | + mktime(12, 0, 0, 7, 9, ($year - 1)), |
|
| 89 | + mktime(12, 0, 0, 7, 23, ($year - 1)), |
|
| 90 | + mktime(12, 0, 0, 7, 30, ($year - 1)), |
|
| 91 | + mktime(12, 0, 0, 8, 9, ($year - 1)), |
|
| 92 | + mktime(12, 0, 0, 9, 23, ($year - 1)), |
|
| 93 | + mktime(12, 0, 0, 10, 3, ($year - 1)), |
|
| 94 | + mktime(12, 0, 0, 11, 12, $year), |
|
| 95 | + mktime(12, 0, 0, 11, 13, $year), |
|
| 96 | + mktime(12, 0, 0, 12, 12, $year), |
|
| 97 | + mktime(12, 0, 0, 12, 13, $year), |
|
| 98 | 98 | ); |
| 99 | 99 | |
| 100 | -$ret=$user->fetch('','admin'); |
|
| 101 | -if (! $ret > 0) |
|
| 100 | +$ret = $user->fetch('', 'admin'); |
|
| 101 | +if (!$ret > 0) |
|
| 102 | 102 | { |
| 103 | 103 | print 'A user with login "admin" and all permissions must be created to use this script.'."\n"; |
| 104 | 104 | exit; |
@@ -151,17 +151,17 @@ discard block |
||
| 151 | 151 | } |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | -$user->rights->propal->creer=1; |
|
| 155 | -$user->rights->propal->propal_advance->validate=1; |
|
| 154 | +$user->rights->propal->creer = 1; |
|
| 155 | +$user->rights->propal->propal_advance->validate = 1; |
|
| 156 | 156 | |
| 157 | 157 | |
| 158 | -if (! empty($conf->global->PROPALE_ADDON) && is_readable(DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.".php")) |
|
| 158 | +if (!empty($conf->global->PROPALE_ADDON) && is_readable(DOL_DOCUMENT_ROOT."/core/modules/propale/".$conf->global->PROPALE_ADDON.".php")) |
|
| 159 | 159 | { |
| 160 | - require_once DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.".php"; |
|
| 160 | + require_once DOL_DOCUMENT_ROOT."/core/modules/propale/".$conf->global->PROPALE_ADDON.".php"; |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | -$i=0; |
|
| 164 | -$result=0; |
|
| 163 | +$i = 0; |
|
| 164 | +$result = 0; |
|
| 165 | 165 | while ($i < GEN_NUMBER_PROPAL && $result >= 0) |
| 166 | 166 | { |
| 167 | 167 | $i++; |
@@ -174,16 +174,16 @@ discard block |
||
| 174 | 174 | $object = new Propal($db); |
| 175 | 175 | |
| 176 | 176 | $fuser = new User($db); |
| 177 | - $fuser->fetch(mt_rand(1,2)); |
|
| 177 | + $fuser->fetch(mt_rand(1, 2)); |
|
| 178 | 178 | $fuser->getRights(); |
| 179 | 179 | |
| 180 | 180 | $object->contactid = $contids[$socids[$socid]][0]; |
| 181 | 181 | $object->socid = $socids[$socid]; |
| 182 | - $object->datep = $dates[mt_rand(1, count($dates)-1)]; |
|
| 182 | + $object->datep = $dates[mt_rand(1, count($dates) - 1)]; |
|
| 183 | 183 | $object->cond_reglement_id = 3; |
| 184 | 184 | $object->mode_reglement_id = 3; |
| 185 | 185 | |
| 186 | - $result=$object->create($fuser); |
|
| 186 | + $result = $object->create($fuser); |
|
| 187 | 187 | if ($result >= 0) |
| 188 | 188 | { |
| 189 | 189 | $nbp = mt_rand(2, 5); |
@@ -191,17 +191,17 @@ discard block |
||
| 191 | 191 | while ($xnbp < $nbp) |
| 192 | 192 | { |
| 193 | 193 | $prodid = mt_rand(1, $num_prods); |
| 194 | - $product=new Product($db); |
|
| 195 | - $result=$product->fetch($prodids[$prodid]); |
|
| 196 | - $result=$object->addline($product->description, $product->price, mt_rand(1,5), 0, 0, 0, $prodids[$prodid], 0); |
|
| 194 | + $product = new Product($db); |
|
| 195 | + $result = $product->fetch($prodids[$prodid]); |
|
| 196 | + $result = $object->addline($product->description, $product->price, mt_rand(1, 5), 0, 0, 0, $prodids[$prodid], 0); |
|
| 197 | 197 | if ($result < 0) |
| 198 | 198 | { |
| 199 | - dol_print_error($db,$object->error); |
|
| 199 | + dol_print_error($db, $object->error); |
|
| 200 | 200 | } |
| 201 | 201 | $xnbp++; |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | - $result=$object->valid($fuser); |
|
| 204 | + $result = $object->valid($fuser); |
|
| 205 | 205 | if ($result > 0) |
| 206 | 206 | { |
| 207 | 207 | $db->commit(); |
@@ -211,11 +211,11 @@ discard block |
||
| 211 | 211 | { |
| 212 | 212 | print " KO\n"; |
| 213 | 213 | $db->rollback(); |
| 214 | - dol_print_error($db,$object->error); |
|
| 214 | + dol_print_error($db, $object->error); |
|
| 215 | 215 | } |
| 216 | 216 | } |
| 217 | 217 | else |
| 218 | 218 | { |
| 219 | - dol_print_error($db,$object->error); |
|
| 219 | + dol_print_error($db, $object->error); |
|
| 220 | 220 | } |
| 221 | 221 | } |
@@ -206,15 +206,13 @@ |
||
| 206 | 206 | { |
| 207 | 207 | $db->commit(); |
| 208 | 208 | print " OK with ref ".$object->ref."\n"; |
| 209 | - } |
|
| 210 | - else |
|
| 209 | + } else |
|
| 211 | 210 | { |
| 212 | 211 | print " KO\n"; |
| 213 | 212 | $db->rollback(); |
| 214 | 213 | dol_print_error($db,$object->error); |
| 215 | 214 | } |
| 216 | - } |
|
| 217 | - else |
|
| 215 | + } else |
|
| 218 | 216 | { |
| 219 | 217 | dol_print_error($db,$object->error); |
| 220 | 218 | } |
@@ -33,9 +33,9 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | if (empty($user->id)) |
| 35 | 35 | { |
| 36 | - print "Load permissions for admin user nb 1\n"; |
|
| 37 | - $user->fetch(1); |
|
| 38 | - $user->getrights(); |
|
| 36 | + print "Load permissions for admin user nb 1\n"; |
|
| 37 | + $user->fetch(1); |
|
| 38 | + $user->getrights(); |
|
| 39 | 39 | } |
| 40 | 40 | $conf->global->MAIN_DISABLE_ALL_MAILS=1; |
| 41 | 41 | |
@@ -49,74 +49,74 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | class MouvementStockTest extends PHPUnit_Framework_TestCase |
| 51 | 51 | { |
| 52 | - protected $savconf; |
|
| 53 | - protected $savuser; |
|
| 54 | - protected $savlangs; |
|
| 55 | - protected $savdb; |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * Constructor |
|
| 59 | - * We save global variables into local variables |
|
| 60 | - * |
|
| 61 | - * @return ContratTest |
|
| 62 | - */ |
|
| 63 | - function __construct() |
|
| 64 | - { |
|
| 65 | - parent::__construct(); |
|
| 66 | - |
|
| 67 | - //$this->sharedFixture |
|
| 68 | - global $conf,$user,$langs,$db; |
|
| 69 | - $this->savconf=$conf; |
|
| 70 | - $this->savuser=$user; |
|
| 71 | - $this->savlangs=$langs; |
|
| 72 | - $this->savdb=$db; |
|
| 73 | - |
|
| 74 | - print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
|
| 75 | - //print " - db ".$db->db; |
|
| 76 | - print "\n"; |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - // Static methods |
|
| 80 | - public static function setUpBeforeClass() |
|
| 52 | + protected $savconf; |
|
| 53 | + protected $savuser; |
|
| 54 | + protected $savlangs; |
|
| 55 | + protected $savdb; |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * Constructor |
|
| 59 | + * We save global variables into local variables |
|
| 60 | + * |
|
| 61 | + * @return ContratTest |
|
| 62 | + */ |
|
| 63 | + function __construct() |
|
| 64 | + { |
|
| 65 | + parent::__construct(); |
|
| 66 | + |
|
| 67 | + //$this->sharedFixture |
|
| 68 | + global $conf,$user,$langs,$db; |
|
| 69 | + $this->savconf=$conf; |
|
| 70 | + $this->savuser=$user; |
|
| 71 | + $this->savlangs=$langs; |
|
| 72 | + $this->savdb=$db; |
|
| 73 | + |
|
| 74 | + print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
|
| 75 | + //print " - db ".$db->db; |
|
| 76 | + print "\n"; |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + // Static methods |
|
| 80 | + public static function setUpBeforeClass() |
|
| 81 | 81 | { |
| 82 | - global $conf,$user,$langs,$db; |
|
| 83 | - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
| 82 | + global $conf,$user,$langs,$db; |
|
| 83 | + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
| 84 | 84 | |
| 85 | - print __METHOD__."\n"; |
|
| 85 | + print __METHOD__."\n"; |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | // tear down after class |
| 89 | 89 | public static function tearDownAfterClass() |
| 90 | 90 | { |
| 91 | - global $conf,$user,$langs,$db; |
|
| 92 | - $db->rollback(); |
|
| 91 | + global $conf,$user,$langs,$db; |
|
| 92 | + $db->rollback(); |
|
| 93 | 93 | |
| 94 | - print __METHOD__."\n"; |
|
| 94 | + print __METHOD__."\n"; |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - /** |
|
| 98 | - * Init phpunit tests |
|
| 99 | - * |
|
| 100 | - * @return void |
|
| 101 | - */ |
|
| 97 | + /** |
|
| 98 | + * Init phpunit tests |
|
| 99 | + * |
|
| 100 | + * @return void |
|
| 101 | + */ |
|
| 102 | 102 | protected function setUp() |
| 103 | 103 | { |
| 104 | - global $conf,$user,$langs,$db; |
|
| 105 | - $conf=$this->savconf; |
|
| 106 | - $user=$this->savuser; |
|
| 107 | - $langs=$this->savlangs; |
|
| 108 | - $db=$this->savdb; |
|
| 104 | + global $conf,$user,$langs,$db; |
|
| 105 | + $conf=$this->savconf; |
|
| 106 | + $user=$this->savuser; |
|
| 107 | + $langs=$this->savlangs; |
|
| 108 | + $db=$this->savdb; |
|
| 109 | 109 | |
| 110 | - print __METHOD__."\n"; |
|
| 110 | + print __METHOD__."\n"; |
|
| 111 | 111 | } |
| 112 | - /** |
|
| 113 | - * End phpunit tests |
|
| 114 | - * |
|
| 115 | - * @return void |
|
| 116 | - */ |
|
| 112 | + /** |
|
| 113 | + * End phpunit tests |
|
| 114 | + * |
|
| 115 | + * @return void |
|
| 116 | + */ |
|
| 117 | 117 | protected function tearDown() |
| 118 | 118 | { |
| 119 | - print __METHOD__."\n"; |
|
| 119 | + print __METHOD__."\n"; |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | /** |
@@ -126,97 +126,97 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | public function testMouvementCreate() |
| 128 | 128 | { |
| 129 | - global $conf,$user,$langs,$db; |
|
| 130 | - $conf=$this->savconf; |
|
| 131 | - $user=$this->savuser; |
|
| 132 | - $langs=$this->savlangs; |
|
| 133 | - $db=$this->savdb; |
|
| 134 | - |
|
| 135 | - // We create a product for tests |
|
| 136 | - $product1=new Product($db); |
|
| 137 | - $product1->initAsSpecimen(); |
|
| 138 | - $product1->ref.=' 1'; |
|
| 139 | - $product1->label.=' 1'; |
|
| 140 | - $product1id=$product1->create($user); |
|
| 141 | - |
|
| 142 | - $product2=new Product($db); |
|
| 143 | - $product2->initAsSpecimen(); |
|
| 144 | - $product2->ref.=' 2'; |
|
| 145 | - $product2->label.=' 2'; |
|
| 146 | - $product2id=$product2->create($user); |
|
| 147 | - |
|
| 148 | - // We create a product for tests |
|
| 149 | - $warehouse1=new Entrepot($db); |
|
| 150 | - $warehouse1->initAsSpecimen(); |
|
| 151 | - $warehouse1->libelle.=' 1'; |
|
| 152 | - $warehouse1->description.=' 1'; |
|
| 153 | - $warehouse1id=$warehouse1->create($user); |
|
| 154 | - |
|
| 155 | - $warehouse2=new Entrepot($db); |
|
| 156 | - $warehouse2->initAsSpecimen(); |
|
| 157 | - $warehouse2->libelle.=' 2'; |
|
| 158 | - $warehouse2->description.=' 2'; |
|
| 159 | - $warehouse2id=$warehouse2->create($user); |
|
| 160 | - |
|
| 161 | - $localobject=new MouvementStock($this->savdb); |
|
| 162 | - |
|
| 163 | - // Do a list of movement into warehouse 1 |
|
| 164 | - |
|
| 165 | - // Create an input movement (type = 3) of price 9.9 -> shoul dupdate PMP to 9.9 |
|
| 166 | - $result=$localobject->_create($user, $product1id, $warehouse1id, 10, 3, 9.9, 'Movement for unit test 1', 'Inventory Code Test'); |
|
| 167 | - print __METHOD__." result=".$result."\n"; |
|
| 168 | - $this->assertLessThan($result, 0); |
|
| 169 | - |
|
| 170 | - // Create an input movement (type = 3) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8 |
|
| 171 | - $result=$localobject->_create($user, $product1id, $warehouse1id, 10, 3, 9.7, 'Movement for unit test 2', 'Inventory Code Test'); |
|
| 172 | - print __METHOD__." result=".$result."\n"; |
|
| 173 | - $this->assertLessThan($result, 0); |
|
| 174 | - |
|
| 175 | - // Create an output movement (type = 2) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8 |
|
| 176 | - $result=$localobject->_create($user, $product1id, $warehouse1id, -5, 2, 999, 'Movement for unit test 3', 'Inventory Code Test'); |
|
| 177 | - print __METHOD__." result=".$result."\n"; |
|
| 178 | - $this->assertLessThan($result, 0); |
|
| 179 | - |
|
| 180 | - // Create an output movement (type = 1) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8 |
|
| 181 | - $result=$localobject->_create($user, $product1id, $warehouse1id, 1, 0, 0, 'Input from transfer', 'Transfert X'); |
|
| 182 | - print __METHOD__." result=".$result."\n"; |
|
| 183 | - $this->assertLessThan($result, 0); |
|
| 184 | - |
|
| 185 | - // Create an output movement (type = 1) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8 |
|
| 186 | - $result=$localobject->_create($user, $product1id, $warehouse1id, -2, 1, 0, 'Output from transfer', 'Transfert Y'); |
|
| 187 | - print __METHOD__." result=".$result."\n"; |
|
| 188 | - $this->assertLessThan($result, 0); |
|
| 189 | - |
|
| 190 | - |
|
| 191 | - // Do same but into warehouse 2 |
|
| 192 | - |
|
| 193 | - // Create an input movement (type = 3) of price 9.9 -> shoul dupdate PMP to 9.9 |
|
| 194 | - $result=$localobject->_create($user, $product1id, $warehouse2id, 10, 3, 9.9, 'Movement for unit test 1 wh 2', 'Inventory Code Test 2'); |
|
| 195 | - print __METHOD__." result=".$result."\n"; |
|
| 196 | - $this->assertLessThan($result, 0); |
|
| 197 | - |
|
| 198 | - // Create an input movement (type = 3) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8 |
|
| 199 | - $result=$localobject->_create($user, $product1id, $warehouse2id, 10, 3, 9.7, 'Movement for unit test 2 wh 2', 'Inventory Code Test 2'); |
|
| 200 | - print __METHOD__." result=".$result."\n"; |
|
| 201 | - $this->assertLessThan($result, 0); |
|
| 202 | - |
|
| 203 | - // Create an output movement (type = 2) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8 |
|
| 204 | - $result=$localobject->_create($user, $product1id, $warehouse2id, -5, 2, 999, 'Movement for unit test 3 wh 2', 'Inventory Code Test 2'); |
|
| 205 | - print __METHOD__." result=".$result."\n"; |
|
| 206 | - $this->assertLessThan($result, 0); |
|
| 207 | - |
|
| 208 | - // Create an output movement (type = 1) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8 |
|
| 209 | - $result=$localobject->_create($user, $product1id, $warehouse2id, 1, 0, 0, 'Input from transfer wh 2', 'Transfert X 2'); |
|
| 210 | - print __METHOD__." result=".$result."\n"; |
|
| 211 | - $this->assertLessThan($result, 0); |
|
| 212 | - |
|
| 213 | - // Create an output movement (type = 1) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8 |
|
| 214 | - $result=$localobject->_create($user, $product1id, $warehouse2id, -2, 1, 0, 'Output from transfer wh 2', 'Transfert Y 2'); |
|
| 215 | - print __METHOD__." result=".$result."\n"; |
|
| 216 | - $this->assertLessThan($result, 0); |
|
| 217 | - |
|
| 218 | - |
|
| 219 | - return $localobject; |
|
| 129 | + global $conf,$user,$langs,$db; |
|
| 130 | + $conf=$this->savconf; |
|
| 131 | + $user=$this->savuser; |
|
| 132 | + $langs=$this->savlangs; |
|
| 133 | + $db=$this->savdb; |
|
| 134 | + |
|
| 135 | + // We create a product for tests |
|
| 136 | + $product1=new Product($db); |
|
| 137 | + $product1->initAsSpecimen(); |
|
| 138 | + $product1->ref.=' 1'; |
|
| 139 | + $product1->label.=' 1'; |
|
| 140 | + $product1id=$product1->create($user); |
|
| 141 | + |
|
| 142 | + $product2=new Product($db); |
|
| 143 | + $product2->initAsSpecimen(); |
|
| 144 | + $product2->ref.=' 2'; |
|
| 145 | + $product2->label.=' 2'; |
|
| 146 | + $product2id=$product2->create($user); |
|
| 147 | + |
|
| 148 | + // We create a product for tests |
|
| 149 | + $warehouse1=new Entrepot($db); |
|
| 150 | + $warehouse1->initAsSpecimen(); |
|
| 151 | + $warehouse1->libelle.=' 1'; |
|
| 152 | + $warehouse1->description.=' 1'; |
|
| 153 | + $warehouse1id=$warehouse1->create($user); |
|
| 154 | + |
|
| 155 | + $warehouse2=new Entrepot($db); |
|
| 156 | + $warehouse2->initAsSpecimen(); |
|
| 157 | + $warehouse2->libelle.=' 2'; |
|
| 158 | + $warehouse2->description.=' 2'; |
|
| 159 | + $warehouse2id=$warehouse2->create($user); |
|
| 160 | + |
|
| 161 | + $localobject=new MouvementStock($this->savdb); |
|
| 162 | + |
|
| 163 | + // Do a list of movement into warehouse 1 |
|
| 164 | + |
|
| 165 | + // Create an input movement (type = 3) of price 9.9 -> shoul dupdate PMP to 9.9 |
|
| 166 | + $result=$localobject->_create($user, $product1id, $warehouse1id, 10, 3, 9.9, 'Movement for unit test 1', 'Inventory Code Test'); |
|
| 167 | + print __METHOD__." result=".$result."\n"; |
|
| 168 | + $this->assertLessThan($result, 0); |
|
| 169 | + |
|
| 170 | + // Create an input movement (type = 3) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8 |
|
| 171 | + $result=$localobject->_create($user, $product1id, $warehouse1id, 10, 3, 9.7, 'Movement for unit test 2', 'Inventory Code Test'); |
|
| 172 | + print __METHOD__." result=".$result."\n"; |
|
| 173 | + $this->assertLessThan($result, 0); |
|
| 174 | + |
|
| 175 | + // Create an output movement (type = 2) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8 |
|
| 176 | + $result=$localobject->_create($user, $product1id, $warehouse1id, -5, 2, 999, 'Movement for unit test 3', 'Inventory Code Test'); |
|
| 177 | + print __METHOD__." result=".$result."\n"; |
|
| 178 | + $this->assertLessThan($result, 0); |
|
| 179 | + |
|
| 180 | + // Create an output movement (type = 1) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8 |
|
| 181 | + $result=$localobject->_create($user, $product1id, $warehouse1id, 1, 0, 0, 'Input from transfer', 'Transfert X'); |
|
| 182 | + print __METHOD__." result=".$result."\n"; |
|
| 183 | + $this->assertLessThan($result, 0); |
|
| 184 | + |
|
| 185 | + // Create an output movement (type = 1) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8 |
|
| 186 | + $result=$localobject->_create($user, $product1id, $warehouse1id, -2, 1, 0, 'Output from transfer', 'Transfert Y'); |
|
| 187 | + print __METHOD__." result=".$result."\n"; |
|
| 188 | + $this->assertLessThan($result, 0); |
|
| 189 | + |
|
| 190 | + |
|
| 191 | + // Do same but into warehouse 2 |
|
| 192 | + |
|
| 193 | + // Create an input movement (type = 3) of price 9.9 -> shoul dupdate PMP to 9.9 |
|
| 194 | + $result=$localobject->_create($user, $product1id, $warehouse2id, 10, 3, 9.9, 'Movement for unit test 1 wh 2', 'Inventory Code Test 2'); |
|
| 195 | + print __METHOD__." result=".$result."\n"; |
|
| 196 | + $this->assertLessThan($result, 0); |
|
| 197 | + |
|
| 198 | + // Create an input movement (type = 3) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8 |
|
| 199 | + $result=$localobject->_create($user, $product1id, $warehouse2id, 10, 3, 9.7, 'Movement for unit test 2 wh 2', 'Inventory Code Test 2'); |
|
| 200 | + print __METHOD__." result=".$result."\n"; |
|
| 201 | + $this->assertLessThan($result, 0); |
|
| 202 | + |
|
| 203 | + // Create an output movement (type = 2) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8 |
|
| 204 | + $result=$localobject->_create($user, $product1id, $warehouse2id, -5, 2, 999, 'Movement for unit test 3 wh 2', 'Inventory Code Test 2'); |
|
| 205 | + print __METHOD__." result=".$result."\n"; |
|
| 206 | + $this->assertLessThan($result, 0); |
|
| 207 | + |
|
| 208 | + // Create an output movement (type = 1) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8 |
|
| 209 | + $result=$localobject->_create($user, $product1id, $warehouse2id, 1, 0, 0, 'Input from transfer wh 2', 'Transfert X 2'); |
|
| 210 | + print __METHOD__." result=".$result."\n"; |
|
| 211 | + $this->assertLessThan($result, 0); |
|
| 212 | + |
|
| 213 | + // Create an output movement (type = 1) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8 |
|
| 214 | + $result=$localobject->_create($user, $product1id, $warehouse2id, -2, 1, 0, 'Output from transfer wh 2', 'Transfert Y 2'); |
|
| 215 | + print __METHOD__." result=".$result."\n"; |
|
| 216 | + $this->assertLessThan($result, 0); |
|
| 217 | + |
|
| 218 | + |
|
| 219 | + return $localobject; |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | /** |
@@ -230,26 +230,26 @@ discard block |
||
| 230 | 230 | */ |
| 231 | 231 | public function testMouvementCheck($localobject) |
| 232 | 232 | { |
| 233 | - global $conf,$user,$langs,$db; |
|
| 234 | - $conf=$this->savconf; |
|
| 235 | - $user=$this->savuser; |
|
| 236 | - $langs=$this->savlangs; |
|
| 237 | - $db=$this->savdb; |
|
| 233 | + global $conf,$user,$langs,$db; |
|
| 234 | + $conf=$this->savconf; |
|
| 235 | + $user=$this->savuser; |
|
| 236 | + $langs=$this->savlangs; |
|
| 237 | + $db=$this->savdb; |
|
| 238 | 238 | |
| 239 | - $productid = $localobject->product_id; |
|
| 240 | - $warehouseid = $localobject->entrepot_id; |
|
| 239 | + $productid = $localobject->product_id; |
|
| 240 | + $warehouseid = $localobject->entrepot_id; |
|
| 241 | 241 | |
| 242 | - print __METHOD__." productid=".$productid."\n"; |
|
| 242 | + print __METHOD__." productid=".$productid."\n"; |
|
| 243 | 243 | |
| 244 | - $producttotest = new Product($db); |
|
| 245 | - $producttotest->fetch($productid); |
|
| 244 | + $producttotest = new Product($db); |
|
| 245 | + $producttotest->fetch($productid); |
|
| 246 | 246 | |
| 247 | - print __METHOD__." producttotest->stock_reel=".$producttotest->stock_reel."\n"; |
|
| 248 | - $this->assertEquals($producttotest->stock_reel, 28); // 28 is result of stock movement defined into testMouvementCreate |
|
| 247 | + print __METHOD__." producttotest->stock_reel=".$producttotest->stock_reel."\n"; |
|
| 248 | + $this->assertEquals($producttotest->stock_reel, 28); // 28 is result of stock movement defined into testMouvementCreate |
|
| 249 | 249 | |
| 250 | - print __METHOD__." producttotest->pmp=".$producttotest->pmp."\n"; |
|
| 251 | - $this->assertEquals($producttotest->pmp, 9.8); |
|
| 250 | + print __METHOD__." producttotest->pmp=".$producttotest->pmp."\n"; |
|
| 251 | + $this->assertEquals($producttotest->pmp, 9.8); |
|
| 252 | 252 | |
| 253 | - return $localobject; |
|
| 253 | + return $localobject; |
|
| 254 | 254 | } |
| 255 | 255 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * \remarks To run this script as CLI: phpunit filename.php |
| 24 | 24 | */ |
| 25 | 25 | |
| 26 | -global $conf,$user,$langs,$db; |
|
| 26 | +global $conf, $user, $langs, $db; |
|
| 27 | 27 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
| 28 | 28 | //require_once 'PHPUnit/Autoload.php'; |
| 29 | 29 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
@@ -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 | /** |
@@ -65,11 +65,11 @@ discard block |
||
| 65 | 65 | parent::__construct(); |
| 66 | 66 | |
| 67 | 67 | //$this->sharedFixture |
| 68 | - global $conf,$user,$langs,$db; |
|
| 69 | - $this->savconf=$conf; |
|
| 70 | - $this->savuser=$user; |
|
| 71 | - $this->savlangs=$langs; |
|
| 72 | - $this->savdb=$db; |
|
| 68 | + global $conf, $user, $langs, $db; |
|
| 69 | + $this->savconf = $conf; |
|
| 70 | + $this->savuser = $user; |
|
| 71 | + $this->savlangs = $langs; |
|
| 72 | + $this->savdb = $db; |
|
| 73 | 73 | |
| 74 | 74 | print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
| 75 | 75 | //print " - db ".$db->db; |
@@ -79,8 +79,8 @@ discard block |
||
| 79 | 79 | // Static methods |
| 80 | 80 | public static function setUpBeforeClass() |
| 81 | 81 | { |
| 82 | - global $conf,$user,$langs,$db; |
|
| 83 | - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
| 82 | + global $conf, $user, $langs, $db; |
|
| 83 | + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
| 84 | 84 | |
| 85 | 85 | print __METHOD__."\n"; |
| 86 | 86 | } |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | // tear down after class |
| 89 | 89 | public static function tearDownAfterClass() |
| 90 | 90 | { |
| 91 | - global $conf,$user,$langs,$db; |
|
| 91 | + global $conf, $user, $langs, $db; |
|
| 92 | 92 | $db->rollback(); |
| 93 | 93 | |
| 94 | 94 | print __METHOD__."\n"; |
@@ -101,11 +101,11 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | protected function setUp() |
| 103 | 103 | { |
| 104 | - global $conf,$user,$langs,$db; |
|
| 105 | - $conf=$this->savconf; |
|
| 106 | - $user=$this->savuser; |
|
| 107 | - $langs=$this->savlangs; |
|
| 108 | - $db=$this->savdb; |
|
| 104 | + global $conf, $user, $langs, $db; |
|
| 105 | + $conf = $this->savconf; |
|
| 106 | + $user = $this->savuser; |
|
| 107 | + $langs = $this->savlangs; |
|
| 108 | + $db = $this->savdb; |
|
| 109 | 109 | |
| 110 | 110 | print __METHOD__."\n"; |
| 111 | 111 | } |
@@ -126,64 +126,64 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | public function testMouvementCreate() |
| 128 | 128 | { |
| 129 | - global $conf,$user,$langs,$db; |
|
| 130 | - $conf=$this->savconf; |
|
| 131 | - $user=$this->savuser; |
|
| 132 | - $langs=$this->savlangs; |
|
| 133 | - $db=$this->savdb; |
|
| 129 | + global $conf, $user, $langs, $db; |
|
| 130 | + $conf = $this->savconf; |
|
| 131 | + $user = $this->savuser; |
|
| 132 | + $langs = $this->savlangs; |
|
| 133 | + $db = $this->savdb; |
|
| 134 | 134 | |
| 135 | 135 | // We create a product for tests |
| 136 | - $product1=new Product($db); |
|
| 136 | + $product1 = new Product($db); |
|
| 137 | 137 | $product1->initAsSpecimen(); |
| 138 | - $product1->ref.=' 1'; |
|
| 139 | - $product1->label.=' 1'; |
|
| 140 | - $product1id=$product1->create($user); |
|
| 138 | + $product1->ref .= ' 1'; |
|
| 139 | + $product1->label .= ' 1'; |
|
| 140 | + $product1id = $product1->create($user); |
|
| 141 | 141 | |
| 142 | - $product2=new Product($db); |
|
| 142 | + $product2 = new Product($db); |
|
| 143 | 143 | $product2->initAsSpecimen(); |
| 144 | - $product2->ref.=' 2'; |
|
| 145 | - $product2->label.=' 2'; |
|
| 146 | - $product2id=$product2->create($user); |
|
| 144 | + $product2->ref .= ' 2'; |
|
| 145 | + $product2->label .= ' 2'; |
|
| 146 | + $product2id = $product2->create($user); |
|
| 147 | 147 | |
| 148 | 148 | // We create a product for tests |
| 149 | - $warehouse1=new Entrepot($db); |
|
| 149 | + $warehouse1 = new Entrepot($db); |
|
| 150 | 150 | $warehouse1->initAsSpecimen(); |
| 151 | - $warehouse1->libelle.=' 1'; |
|
| 152 | - $warehouse1->description.=' 1'; |
|
| 153 | - $warehouse1id=$warehouse1->create($user); |
|
| 151 | + $warehouse1->libelle .= ' 1'; |
|
| 152 | + $warehouse1->description .= ' 1'; |
|
| 153 | + $warehouse1id = $warehouse1->create($user); |
|
| 154 | 154 | |
| 155 | - $warehouse2=new Entrepot($db); |
|
| 155 | + $warehouse2 = new Entrepot($db); |
|
| 156 | 156 | $warehouse2->initAsSpecimen(); |
| 157 | - $warehouse2->libelle.=' 2'; |
|
| 158 | - $warehouse2->description.=' 2'; |
|
| 159 | - $warehouse2id=$warehouse2->create($user); |
|
| 157 | + $warehouse2->libelle .= ' 2'; |
|
| 158 | + $warehouse2->description .= ' 2'; |
|
| 159 | + $warehouse2id = $warehouse2->create($user); |
|
| 160 | 160 | |
| 161 | - $localobject=new MouvementStock($this->savdb); |
|
| 161 | + $localobject = new MouvementStock($this->savdb); |
|
| 162 | 162 | |
| 163 | 163 | // Do a list of movement into warehouse 1 |
| 164 | 164 | |
| 165 | 165 | // Create an input movement (type = 3) of price 9.9 -> shoul dupdate PMP to 9.9 |
| 166 | - $result=$localobject->_create($user, $product1id, $warehouse1id, 10, 3, 9.9, 'Movement for unit test 1', 'Inventory Code Test'); |
|
| 166 | + $result = $localobject->_create($user, $product1id, $warehouse1id, 10, 3, 9.9, 'Movement for unit test 1', 'Inventory Code Test'); |
|
| 167 | 167 | print __METHOD__." result=".$result."\n"; |
| 168 | 168 | $this->assertLessThan($result, 0); |
| 169 | 169 | |
| 170 | 170 | // Create an input movement (type = 3) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8 |
| 171 | - $result=$localobject->_create($user, $product1id, $warehouse1id, 10, 3, 9.7, 'Movement for unit test 2', 'Inventory Code Test'); |
|
| 171 | + $result = $localobject->_create($user, $product1id, $warehouse1id, 10, 3, 9.7, 'Movement for unit test 2', 'Inventory Code Test'); |
|
| 172 | 172 | print __METHOD__." result=".$result."\n"; |
| 173 | 173 | $this->assertLessThan($result, 0); |
| 174 | 174 | |
| 175 | 175 | // Create an output movement (type = 2) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8 |
| 176 | - $result=$localobject->_create($user, $product1id, $warehouse1id, -5, 2, 999, 'Movement for unit test 3', 'Inventory Code Test'); |
|
| 176 | + $result = $localobject->_create($user, $product1id, $warehouse1id, -5, 2, 999, 'Movement for unit test 3', 'Inventory Code Test'); |
|
| 177 | 177 | print __METHOD__." result=".$result."\n"; |
| 178 | 178 | $this->assertLessThan($result, 0); |
| 179 | 179 | |
| 180 | 180 | // Create an output movement (type = 1) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8 |
| 181 | - $result=$localobject->_create($user, $product1id, $warehouse1id, 1, 0, 0, 'Input from transfer', 'Transfert X'); |
|
| 181 | + $result = $localobject->_create($user, $product1id, $warehouse1id, 1, 0, 0, 'Input from transfer', 'Transfert X'); |
|
| 182 | 182 | print __METHOD__." result=".$result."\n"; |
| 183 | 183 | $this->assertLessThan($result, 0); |
| 184 | 184 | |
| 185 | 185 | // Create an output movement (type = 1) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8 |
| 186 | - $result=$localobject->_create($user, $product1id, $warehouse1id, -2, 1, 0, 'Output from transfer', 'Transfert Y'); |
|
| 186 | + $result = $localobject->_create($user, $product1id, $warehouse1id, -2, 1, 0, 'Output from transfer', 'Transfert Y'); |
|
| 187 | 187 | print __METHOD__." result=".$result."\n"; |
| 188 | 188 | $this->assertLessThan($result, 0); |
| 189 | 189 | |
@@ -191,27 +191,27 @@ discard block |
||
| 191 | 191 | // Do same but into warehouse 2 |
| 192 | 192 | |
| 193 | 193 | // Create an input movement (type = 3) of price 9.9 -> shoul dupdate PMP to 9.9 |
| 194 | - $result=$localobject->_create($user, $product1id, $warehouse2id, 10, 3, 9.9, 'Movement for unit test 1 wh 2', 'Inventory Code Test 2'); |
|
| 194 | + $result = $localobject->_create($user, $product1id, $warehouse2id, 10, 3, 9.9, 'Movement for unit test 1 wh 2', 'Inventory Code Test 2'); |
|
| 195 | 195 | print __METHOD__." result=".$result."\n"; |
| 196 | 196 | $this->assertLessThan($result, 0); |
| 197 | 197 | |
| 198 | 198 | // Create an input movement (type = 3) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8 |
| 199 | - $result=$localobject->_create($user, $product1id, $warehouse2id, 10, 3, 9.7, 'Movement for unit test 2 wh 2', 'Inventory Code Test 2'); |
|
| 199 | + $result = $localobject->_create($user, $product1id, $warehouse2id, 10, 3, 9.7, 'Movement for unit test 2 wh 2', 'Inventory Code Test 2'); |
|
| 200 | 200 | print __METHOD__." result=".$result."\n"; |
| 201 | 201 | $this->assertLessThan($result, 0); |
| 202 | 202 | |
| 203 | 203 | // Create an output movement (type = 2) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8 |
| 204 | - $result=$localobject->_create($user, $product1id, $warehouse2id, -5, 2, 999, 'Movement for unit test 3 wh 2', 'Inventory Code Test 2'); |
|
| 204 | + $result = $localobject->_create($user, $product1id, $warehouse2id, -5, 2, 999, 'Movement for unit test 3 wh 2', 'Inventory Code Test 2'); |
|
| 205 | 205 | print __METHOD__." result=".$result."\n"; |
| 206 | 206 | $this->assertLessThan($result, 0); |
| 207 | 207 | |
| 208 | 208 | // Create an output movement (type = 1) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8 |
| 209 | - $result=$localobject->_create($user, $product1id, $warehouse2id, 1, 0, 0, 'Input from transfer wh 2', 'Transfert X 2'); |
|
| 209 | + $result = $localobject->_create($user, $product1id, $warehouse2id, 1, 0, 0, 'Input from transfer wh 2', 'Transfert X 2'); |
|
| 210 | 210 | print __METHOD__." result=".$result."\n"; |
| 211 | 211 | $this->assertLessThan($result, 0); |
| 212 | 212 | |
| 213 | 213 | // Create an output movement (type = 1) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8 |
| 214 | - $result=$localobject->_create($user, $product1id, $warehouse2id, -2, 1, 0, 'Output from transfer wh 2', 'Transfert Y 2'); |
|
| 214 | + $result = $localobject->_create($user, $product1id, $warehouse2id, -2, 1, 0, 'Output from transfer wh 2', 'Transfert Y 2'); |
|
| 215 | 215 | print __METHOD__." result=".$result."\n"; |
| 216 | 216 | $this->assertLessThan($result, 0); |
| 217 | 217 | |
@@ -230,11 +230,11 @@ discard block |
||
| 230 | 230 | */ |
| 231 | 231 | public function testMouvementCheck($localobject) |
| 232 | 232 | { |
| 233 | - global $conf,$user,$langs,$db; |
|
| 234 | - $conf=$this->savconf; |
|
| 235 | - $user=$this->savuser; |
|
| 236 | - $langs=$this->savlangs; |
|
| 237 | - $db=$this->savdb; |
|
| 233 | + global $conf, $user, $langs, $db; |
|
| 234 | + $conf = $this->savconf; |
|
| 235 | + $user = $this->savuser; |
|
| 236 | + $langs = $this->savlangs; |
|
| 237 | + $db = $this->savdb; |
|
| 238 | 238 | |
| 239 | 239 | $productid = $localobject->product_id; |
| 240 | 240 | $warehouseid = $localobject->entrepot_id; |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | $producttotest->fetch($productid); |
| 246 | 246 | |
| 247 | 247 | print __METHOD__." producttotest->stock_reel=".$producttotest->stock_reel."\n"; |
| 248 | - $this->assertEquals($producttotest->stock_reel, 28); // 28 is result of stock movement defined into testMouvementCreate |
|
| 248 | + $this->assertEquals($producttotest->stock_reel, 28); // 28 is result of stock movement defined into testMouvementCreate |
|
| 249 | 249 | |
| 250 | 250 | print __METHOD__." producttotest->pmp=".$producttotest->pmp."\n"; |
| 251 | 251 | $this->assertEquals($producttotest->pmp, 9.8); |
@@ -59,9 +59,9 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | function __construct() |
| 61 | 61 | { |
| 62 | - parent::__construct(); |
|
| 62 | + parent::__construct(); |
|
| 63 | 63 | |
| 64 | - //$this->sharedFixture |
|
| 64 | + //$this->sharedFixture |
|
| 65 | 65 | global $conf,$user,$langs,$db; |
| 66 | 66 | $this->savconf=$conf; |
| 67 | 67 | $this->savuser=$user; |
@@ -205,18 +205,18 @@ discard block |
||
| 205 | 205 | */ |
| 206 | 206 | public function testActionCommUpdate($localobject) |
| 207 | 207 | { |
| 208 | - global $conf,$user,$langs,$db; |
|
| 209 | - $conf=$this->savconf; |
|
| 210 | - $user=$this->savuser; |
|
| 211 | - $langs=$this->savlangs; |
|
| 212 | - $db=$this->savdb; |
|
| 213 | - |
|
| 214 | - $localobject->label='New label'; |
|
| 215 | - $result=$localobject->update($user); |
|
| 216 | - |
|
| 217 | - $this->assertLessThan($result, 0); |
|
| 218 | - print __METHOD__." id=".$id." result=".$result."\n"; |
|
| 219 | - return $localobject->id; |
|
| 208 | + global $conf,$user,$langs,$db; |
|
| 209 | + $conf=$this->savconf; |
|
| 210 | + $user=$this->savuser; |
|
| 211 | + $langs=$this->savlangs; |
|
| 212 | + $db=$this->savdb; |
|
| 213 | + |
|
| 214 | + $localobject->label='New label'; |
|
| 215 | + $result=$localobject->update($user); |
|
| 216 | + |
|
| 217 | + $this->assertLessThan($result, 0); |
|
| 218 | + print __METHOD__." id=".$id." result=".$result."\n"; |
|
| 219 | + return $localobject->id; |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | /** |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * \remarks To run this script as CLI: phpunit filename.php |
| 24 | 24 | */ |
| 25 | 25 | |
| 26 | -global $conf,$user,$langs,$db; |
|
| 26 | +global $conf, $user, $langs, $db; |
|
| 27 | 27 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
| 28 | 28 | //require_once 'PHPUnit/Autoload.php'; |
| 29 | 29 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | $user->fetch(1); |
| 35 | 35 | $user->getrights(); |
| 36 | 36 | } |
| 37 | -$conf->global->MAIN_DISABLE_ALL_MAILS=1; |
|
| 37 | +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
|
| 38 | 38 | |
| 39 | 39 | |
| 40 | 40 | /** |
@@ -62,11 +62,11 @@ discard block |
||
| 62 | 62 | parent::__construct(); |
| 63 | 63 | |
| 64 | 64 | //$this->sharedFixture |
| 65 | - global $conf,$user,$langs,$db; |
|
| 66 | - $this->savconf=$conf; |
|
| 67 | - $this->savuser=$user; |
|
| 68 | - $this->savlangs=$langs; |
|
| 69 | - $this->savdb=$db; |
|
| 65 | + global $conf, $user, $langs, $db; |
|
| 66 | + $this->savconf = $conf; |
|
| 67 | + $this->savuser = $user; |
|
| 68 | + $this->savlangs = $langs; |
|
| 69 | + $this->savdb = $db; |
|
| 70 | 70 | |
| 71 | 71 | print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
| 72 | 72 | //print " - db ".$db->db; |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | // Static methods |
| 77 | 77 | public static function setUpBeforeClass() |
| 78 | 78 | { |
| 79 | - global $conf,$user,$langs,$db; |
|
| 79 | + global $conf, $user, $langs, $db; |
|
| 80 | 80 | $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
| 81 | 81 | |
| 82 | 82 | if (empty($conf->agenda->enabled)) { print __METHOD__." module agenda must be enabled.\n"; die(); } |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | // tear down after class |
| 88 | 88 | public static function tearDownAfterClass() |
| 89 | 89 | { |
| 90 | - global $conf,$user,$langs,$db; |
|
| 90 | + global $conf, $user, $langs, $db; |
|
| 91 | 91 | $db->rollback(); |
| 92 | 92 | |
| 93 | 93 | print __METHOD__."\n"; |
@@ -100,11 +100,11 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | protected function setUp() |
| 102 | 102 | { |
| 103 | - global $conf,$user,$langs,$db; |
|
| 104 | - $conf=$this->savconf; |
|
| 105 | - $user=$this->savuser; |
|
| 106 | - $langs=$this->savlangs; |
|
| 107 | - $db=$this->savdb; |
|
| 103 | + global $conf, $user, $langs, $db; |
|
| 104 | + $conf = $this->savconf; |
|
| 105 | + $user = $this->savuser; |
|
| 106 | + $langs = $this->savlangs; |
|
| 107 | + $db = $this->savdb; |
|
| 108 | 108 | |
| 109 | 109 | print __METHOD__."\n"; |
| 110 | 110 | //print $db->getVersion()."\n"; |
@@ -127,28 +127,28 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | public function testActionCommCreate() |
| 129 | 129 | { |
| 130 | - global $conf,$user,$langs,$db; |
|
| 131 | - $conf=$this->savconf; |
|
| 132 | - $user=$this->savuser; |
|
| 133 | - $langs=$this->savlangs; |
|
| 134 | - $db=$this->savdb; |
|
| 130 | + global $conf, $user, $langs, $db; |
|
| 131 | + $conf = $this->savconf; |
|
| 132 | + $user = $this->savuser; |
|
| 133 | + $langs = $this->savlangs; |
|
| 134 | + $db = $this->savdb; |
|
| 135 | 135 | |
| 136 | 136 | $now = dol_now(); |
| 137 | 137 | |
| 138 | - $localobject=new ActionComm($this->savdb); |
|
| 138 | + $localobject = new ActionComm($this->savdb); |
|
| 139 | 139 | |
| 140 | - $localobject->type_code = 'AC_OTH_AUTO'; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) |
|
| 140 | + $localobject->type_code = 'AC_OTH_AUTO'; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) |
|
| 141 | 141 | $localobject->code = 'AC_PHPUNITTEST'; |
| 142 | 142 | $localobject->label = 'This is a description'; |
| 143 | 143 | $localobject->note = 'This is note'; |
| 144 | 144 | $localobject->fk_project = 0; |
| 145 | 145 | $localobject->datep = $now; |
| 146 | 146 | $localobject->datef = $now; |
| 147 | - $localobject->percentage = -1; // Not applicable |
|
| 147 | + $localobject->percentage = -1; // Not applicable |
|
| 148 | 148 | $localobject->socid = 0; |
| 149 | 149 | $localobject->contactid = 0; |
| 150 | - $localobject->authorid = $user->id; // User saving action |
|
| 151 | - $localobject->userownerid = $user->id; // Owner of action |
|
| 150 | + $localobject->authorid = $user->id; // User saving action |
|
| 151 | + $localobject->userownerid = $user->id; // Owner of action |
|
| 152 | 152 | // Fields when action is en email (content should be added into note) |
| 153 | 153 | /*$localobject->email_msgid = $object->email_msgid; |
| 154 | 154 | $localobject->email_from = $object->email_from; |
@@ -180,14 +180,14 @@ discard block |
||
| 180 | 180 | */ |
| 181 | 181 | public function testActionCommFetch($id) |
| 182 | 182 | { |
| 183 | - global $conf,$user,$langs,$db; |
|
| 184 | - $conf=$this->savconf; |
|
| 185 | - $user=$this->savuser; |
|
| 186 | - $langs=$this->savlangs; |
|
| 187 | - $db=$this->savdb; |
|
| 183 | + global $conf, $user, $langs, $db; |
|
| 184 | + $conf = $this->savconf; |
|
| 185 | + $user = $this->savuser; |
|
| 186 | + $langs = $this->savlangs; |
|
| 187 | + $db = $this->savdb; |
|
| 188 | 188 | |
| 189 | - $localobject=new ActionComm($this->savdb); |
|
| 190 | - $result=$localobject->fetch($id); |
|
| 189 | + $localobject = new ActionComm($this->savdb); |
|
| 190 | + $result = $localobject->fetch($id); |
|
| 191 | 191 | |
| 192 | 192 | $this->assertLessThan($result, 0); |
| 193 | 193 | print __METHOD__." id=".$id." result=".$result."\n"; |
@@ -205,14 +205,14 @@ discard block |
||
| 205 | 205 | */ |
| 206 | 206 | public function testActionCommUpdate($localobject) |
| 207 | 207 | { |
| 208 | - global $conf,$user,$langs,$db; |
|
| 209 | - $conf=$this->savconf; |
|
| 210 | - $user=$this->savuser; |
|
| 211 | - $langs=$this->savlangs; |
|
| 212 | - $db=$this->savdb; |
|
| 208 | + global $conf, $user, $langs, $db; |
|
| 209 | + $conf = $this->savconf; |
|
| 210 | + $user = $this->savuser; |
|
| 211 | + $langs = $this->savlangs; |
|
| 212 | + $db = $this->savdb; |
|
| 213 | 213 | |
| 214 | - $localobject->label='New label'; |
|
| 215 | - $result=$localobject->update($user); |
|
| 214 | + $localobject->label = 'New label'; |
|
| 215 | + $result = $localobject->update($user); |
|
| 216 | 216 | |
| 217 | 217 | $this->assertLessThan($result, 0); |
| 218 | 218 | print __METHOD__." id=".$id." result=".$result."\n"; |
@@ -230,15 +230,15 @@ discard block |
||
| 230 | 230 | */ |
| 231 | 231 | public function testActionCommDelete($id) |
| 232 | 232 | { |
| 233 | - global $conf,$user,$langs,$db; |
|
| 234 | - $conf=$this->savconf; |
|
| 235 | - $user=$this->savuser; |
|
| 236 | - $langs=$this->savlangs; |
|
| 237 | - $db=$this->savdb; |
|
| 238 | - |
|
| 239 | - $localobject=new ActionComm($this->savdb); |
|
| 240 | - $result=$localobject->fetch($id); |
|
| 241 | - $result=$localobject->delete($user); |
|
| 233 | + global $conf, $user, $langs, $db; |
|
| 234 | + $conf = $this->savconf; |
|
| 235 | + $user = $this->savuser; |
|
| 236 | + $langs = $this->savlangs; |
|
| 237 | + $db = $this->savdb; |
|
| 238 | + |
|
| 239 | + $localobject = new ActionComm($this->savdb); |
|
| 240 | + $result = $localobject->fetch($id); |
|
| 241 | + $result = $localobject->delete($user); |
|
| 242 | 242 | |
| 243 | 243 | print __METHOD__." id=".$id." result=".$result."\n"; |
| 244 | 244 | $this->assertLessThan($result, 0); |
@@ -33,9 +33,9 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | if (empty($user->id)) |
| 35 | 35 | { |
| 36 | - print "Load permissions for admin user nb 1\n"; |
|
| 37 | - $user->fetch(1); |
|
| 38 | - $user->getrights(); |
|
| 36 | + print "Load permissions for admin user nb 1\n"; |
|
| 37 | + $user->fetch(1); |
|
| 38 | + $user->getrights(); |
|
| 39 | 39 | } |
| 40 | 40 | $conf->global->MAIN_DISABLE_ALL_MAILS=1; |
| 41 | 41 | |
@@ -51,47 +51,47 @@ discard block |
||
| 51 | 51 | */ |
| 52 | 52 | class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase |
| 53 | 53 | { |
| 54 | - protected $savconf; |
|
| 55 | - protected $savuser; |
|
| 56 | - protected $savlangs; |
|
| 57 | - protected $savdb; |
|
| 58 | - protected $soapclient; |
|
| 59 | - |
|
| 60 | - private static $socid; |
|
| 61 | - |
|
| 62 | - protected $ns = 'http://www.dolibarr.org/ns/'; |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * Constructor |
|
| 66 | - * We save global variables into local variables |
|
| 67 | - * |
|
| 68 | - * @return DateLibTest |
|
| 69 | - */ |
|
| 70 | - function __construct() |
|
| 71 | - { |
|
| 72 | - parent::__construct(); |
|
| 73 | - |
|
| 74 | - //$this->sharedFixture |
|
| 75 | - global $conf,$user,$langs,$db; |
|
| 76 | - $this->savconf=$conf; |
|
| 77 | - $this->savuser=$user; |
|
| 78 | - $this->savlangs=$langs; |
|
| 79 | - $this->savdb=$db; |
|
| 80 | - |
|
| 81 | - // Set the WebService URL |
|
| 82 | - $WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_invoice.php'; |
|
| 83 | - print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n"; |
|
| 84 | - $this->soapclient = new nusoap_client($WS_DOL_URL); |
|
| 85 | - if ($this->soapclient) |
|
| 86 | - { |
|
| 87 | - $this->soapclient->soap_defencoding='UTF-8'; |
|
| 88 | - $this->soapclient->decodeUTF8(false); |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
|
| 92 | - //print " - db ".$db->db; |
|
| 93 | - print "\n"; |
|
| 94 | - } |
|
| 54 | + protected $savconf; |
|
| 55 | + protected $savuser; |
|
| 56 | + protected $savlangs; |
|
| 57 | + protected $savdb; |
|
| 58 | + protected $soapclient; |
|
| 59 | + |
|
| 60 | + private static $socid; |
|
| 61 | + |
|
| 62 | + protected $ns = 'http://www.dolibarr.org/ns/'; |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * Constructor |
|
| 66 | + * We save global variables into local variables |
|
| 67 | + * |
|
| 68 | + * @return DateLibTest |
|
| 69 | + */ |
|
| 70 | + function __construct() |
|
| 71 | + { |
|
| 72 | + parent::__construct(); |
|
| 73 | + |
|
| 74 | + //$this->sharedFixture |
|
| 75 | + global $conf,$user,$langs,$db; |
|
| 76 | + $this->savconf=$conf; |
|
| 77 | + $this->savuser=$user; |
|
| 78 | + $this->savlangs=$langs; |
|
| 79 | + $this->savdb=$db; |
|
| 80 | + |
|
| 81 | + // Set the WebService URL |
|
| 82 | + $WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_invoice.php'; |
|
| 83 | + print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n"; |
|
| 84 | + $this->soapclient = new nusoap_client($WS_DOL_URL); |
|
| 85 | + if ($this->soapclient) |
|
| 86 | + { |
|
| 87 | + $this->soapclient->soap_defencoding='UTF-8'; |
|
| 88 | + $this->soapclient->decodeUTF8(false); |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
|
| 92 | + //print " - db ".$db->db; |
|
| 93 | + print "\n"; |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | 96 | /** |
| 97 | 97 | * setUpBeforeClass |
@@ -102,38 +102,38 @@ discard block |
||
| 102 | 102 | { |
| 103 | 103 | global $conf,$user,$langs,$db; |
| 104 | 104 | |
| 105 | - // create a third_party, needed to create an invoice |
|
| 106 | - // |
|
| 107 | - // The third party is created in setUpBeforeClass() and not in the |
|
| 108 | - // constructor to avoid creating several objects (the constructor is |
|
| 109 | - // called for each test). |
|
| 110 | - // |
|
| 111 | - // The third party must be created before beginning the DB transaction |
|
| 112 | - // because there is a foreign key constraint between invoices and third |
|
| 113 | - // parties (tables: lx_facture and llx_societe) and with MySQL, |
|
| 114 | - // constraints are checked immediately, they are not deferred to |
|
| 115 | - // transaction commit. So if the invoice is created in the same |
|
| 116 | - // transaction than the third party, the FK constraint fails. |
|
| 117 | - // See this post for more detail: http://stackoverflow.com/a/5014744/5187108 |
|
| 118 | - $societe=new Societe($db); |
|
| 119 | - $societe->ref=''; |
|
| 120 | - $societe->name='name'; |
|
| 121 | - $societe->ref_ext='ref-phpunit'; |
|
| 122 | - $societe->status=1; |
|
| 123 | - $societe->client=1; |
|
| 124 | - $societe->code_client='CU0901-1234'; |
|
| 125 | - $societe->code_fournisseur='SU0901-1234'; |
|
| 126 | - $societe->fournisseur=0; |
|
| 127 | - $societe->date_creation=$now; |
|
| 128 | - $societe->tva_assuj=0; |
|
| 129 | - $societe->particulier=0; |
|
| 130 | - |
|
| 131 | - $societe->create($user); |
|
| 132 | - |
|
| 133 | - self::$socid = $societe->id; |
|
| 134 | - print __METHOD__." societe created id=".$societe->id."\n"; |
|
| 135 | - |
|
| 136 | - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
| 105 | + // create a third_party, needed to create an invoice |
|
| 106 | + // |
|
| 107 | + // The third party is created in setUpBeforeClass() and not in the |
|
| 108 | + // constructor to avoid creating several objects (the constructor is |
|
| 109 | + // called for each test). |
|
| 110 | + // |
|
| 111 | + // The third party must be created before beginning the DB transaction |
|
| 112 | + // because there is a foreign key constraint between invoices and third |
|
| 113 | + // parties (tables: lx_facture and llx_societe) and with MySQL, |
|
| 114 | + // constraints are checked immediately, they are not deferred to |
|
| 115 | + // transaction commit. So if the invoice is created in the same |
|
| 116 | + // transaction than the third party, the FK constraint fails. |
|
| 117 | + // See this post for more detail: http://stackoverflow.com/a/5014744/5187108 |
|
| 118 | + $societe=new Societe($db); |
|
| 119 | + $societe->ref=''; |
|
| 120 | + $societe->name='name'; |
|
| 121 | + $societe->ref_ext='ref-phpunit'; |
|
| 122 | + $societe->status=1; |
|
| 123 | + $societe->client=1; |
|
| 124 | + $societe->code_client='CU0901-1234'; |
|
| 125 | + $societe->code_fournisseur='SU0901-1234'; |
|
| 126 | + $societe->fournisseur=0; |
|
| 127 | + $societe->date_creation=$now; |
|
| 128 | + $societe->tva_assuj=0; |
|
| 129 | + $societe->particulier=0; |
|
| 130 | + |
|
| 131 | + $societe->create($user); |
|
| 132 | + |
|
| 133 | + self::$socid = $societe->id; |
|
| 134 | + print __METHOD__." societe created id=".$societe->id."\n"; |
|
| 135 | + |
|
| 136 | + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
| 137 | 137 | |
| 138 | 138 | print __METHOD__."\n"; |
| 139 | 139 | } |
@@ -145,36 +145,36 @@ discard block |
||
| 145 | 145 | */ |
| 146 | 146 | public static function tearDownAfterClass() |
| 147 | 147 | { |
| 148 | - global $conf,$user,$langs,$db; |
|
| 149 | - $db->rollback(); |
|
| 148 | + global $conf,$user,$langs,$db; |
|
| 149 | + $db->rollback(); |
|
| 150 | 150 | |
| 151 | - print __METHOD__."\n"; |
|
| 151 | + print __METHOD__."\n"; |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - /** |
|
| 155 | - * Init phpunit tests |
|
| 156 | - * |
|
| 157 | - * @return void |
|
| 158 | - */ |
|
| 154 | + /** |
|
| 155 | + * Init phpunit tests |
|
| 156 | + * |
|
| 157 | + * @return void |
|
| 158 | + */ |
|
| 159 | 159 | protected function setUp() |
| 160 | 160 | { |
| 161 | - global $conf,$user,$langs,$db; |
|
| 162 | - $conf=$this->savconf; |
|
| 163 | - $user=$this->savuser; |
|
| 164 | - $langs=$this->savlangs; |
|
| 165 | - $db=$this->savdb; |
|
| 161 | + global $conf,$user,$langs,$db; |
|
| 162 | + $conf=$this->savconf; |
|
| 163 | + $user=$this->savuser; |
|
| 164 | + $langs=$this->savlangs; |
|
| 165 | + $db=$this->savdb; |
|
| 166 | 166 | |
| 167 | - print __METHOD__."\n"; |
|
| 167 | + print __METHOD__."\n"; |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - /** |
|
| 171 | - * End phpunit tests |
|
| 172 | - * |
|
| 173 | - * @return void |
|
| 174 | - */ |
|
| 170 | + /** |
|
| 171 | + * End phpunit tests |
|
| 172 | + * |
|
| 173 | + * @return void |
|
| 174 | + */ |
|
| 175 | 175 | protected function tearDown() |
| 176 | 176 | { |
| 177 | - print __METHOD__."\n"; |
|
| 177 | + print __METHOD__."\n"; |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | |
@@ -185,93 +185,93 @@ discard block |
||
| 185 | 185 | */ |
| 186 | 186 | public function testWSInvoicesCreateInvoice() |
| 187 | 187 | { |
| 188 | - global $conf,$user,$langs,$db; |
|
| 189 | - $conf=$this->savconf; |
|
| 190 | - $user=$this->savuser; |
|
| 191 | - $langs=$this->savlangs; |
|
| 192 | - $db=$this->savdb; |
|
| 193 | - |
|
| 194 | - $WS_METHOD = 'createInvoice'; |
|
| 195 | - |
|
| 196 | - $body = array ( |
|
| 197 | - "id" => null, |
|
| 198 | - "ref" => null, |
|
| 199 | - "ref_ext" => "ref-phpunit-2", |
|
| 200 | - "thirdparty_id" => self::$socid, |
|
| 201 | - "fk_user_author" => null, |
|
| 202 | - "fk_user_valid" => null, |
|
| 203 | - "date" => "2015-04-19 20:16:53", |
|
| 204 | - "date_due" => "", |
|
| 205 | - "date_creation" => "", |
|
| 206 | - "date_validation" => "", |
|
| 207 | - "date_modification" => "", |
|
| 208 | - "type" => "", |
|
| 209 | - "total_net" => "36.30", |
|
| 210 | - "total_vat" => "6.00", |
|
| 211 | - "total" => "42.30", |
|
| 212 | - "payment_mode_id" => 50, |
|
| 213 | - "note_private" => "Synchronised from Prestashop", |
|
| 214 | - "note_public" => "", |
|
| 215 | - "status" => "1", |
|
| 216 | - "close_code" => null , |
|
| 217 | - "close_note" => null, |
|
| 218 | - "project_id" => null, |
|
| 219 | - "lines" => array( |
|
| 220 | - array("id" => null, |
|
| 221 | - "type" => 0, |
|
| 222 | - "desc" => "Horloge Vinyle Serge", |
|
| 223 | - "vat_rate" => 20, |
|
| 224 | - "qty" => 1, |
|
| 225 | - "unitprice" => "30.000000", |
|
| 226 | - "total_net" => "30.000000", |
|
| 227 | - "total_vat" => "6.00", |
|
| 228 | - "total" => "36.000000", |
|
| 229 | - "date_start" => "", |
|
| 230 | - "date_end" => "", |
|
| 231 | - "payment_mode_id" => "", |
|
| 232 | - "product_id" => "", |
|
| 233 | - "product_ref" => "", |
|
| 234 | - "product_label" => "", |
|
| 235 | - "product_desc" => "" )) |
|
| 236 | - ); |
|
| 237 | - |
|
| 238 | - // Call the WebService method and store its result in $result. |
|
| 239 | - $authentication=array( |
|
| 240 | - 'dolibarrkey'=>$conf->global->WEBSERVICES_KEY, |
|
| 241 | - 'sourceapplication'=>'DEMO', |
|
| 242 | - 'login'=>'admin', |
|
| 243 | - 'password'=>'admin', |
|
| 244 | - 'entity'=>''); |
|
| 245 | - |
|
| 246 | - // Test URL |
|
| 247 | - $result=''; |
|
| 248 | - $parameters = array('authentication'=>$authentication,'invoice'=>$body); |
|
| 249 | - print __METHOD__." call method ".$WS_METHOD."\n"; |
|
| 250 | - try { |
|
| 251 | - $result = $this->soapclient->call($WS_METHOD,$parameters,$this->ns,''); |
|
| 252 | - } |
|
| 253 | - catch(SoapFault $exception) |
|
| 254 | - { |
|
| 255 | - echo $exception; |
|
| 256 | - $result=0; |
|
| 257 | - } |
|
| 258 | - if (! $result || ! empty($result['faultstring'])) |
|
| 259 | - { |
|
| 260 | - //var_dump($soapclient); |
|
| 261 | - print $this->soapclient->error_str; |
|
| 262 | - print "\n<br>\n"; |
|
| 263 | - print $this->soapclient->request; |
|
| 264 | - print "\n<br>\n"; |
|
| 265 | - print $this->soapclient->response; |
|
| 266 | - print "\n"; |
|
| 267 | - } |
|
| 268 | - |
|
| 269 | - print __METHOD__." result=".$result['result']['result_code']."\n"; |
|
| 270 | - $this->assertEquals('OK',$result['result']['result_code']); |
|
| 271 | - $this->assertEquals('ref-phpunit-2', $result['ref_ext']); |
|
| 272 | - |
|
| 273 | - |
|
| 274 | - return $result; |
|
| 188 | + global $conf,$user,$langs,$db; |
|
| 189 | + $conf=$this->savconf; |
|
| 190 | + $user=$this->savuser; |
|
| 191 | + $langs=$this->savlangs; |
|
| 192 | + $db=$this->savdb; |
|
| 193 | + |
|
| 194 | + $WS_METHOD = 'createInvoice'; |
|
| 195 | + |
|
| 196 | + $body = array ( |
|
| 197 | + "id" => null, |
|
| 198 | + "ref" => null, |
|
| 199 | + "ref_ext" => "ref-phpunit-2", |
|
| 200 | + "thirdparty_id" => self::$socid, |
|
| 201 | + "fk_user_author" => null, |
|
| 202 | + "fk_user_valid" => null, |
|
| 203 | + "date" => "2015-04-19 20:16:53", |
|
| 204 | + "date_due" => "", |
|
| 205 | + "date_creation" => "", |
|
| 206 | + "date_validation" => "", |
|
| 207 | + "date_modification" => "", |
|
| 208 | + "type" => "", |
|
| 209 | + "total_net" => "36.30", |
|
| 210 | + "total_vat" => "6.00", |
|
| 211 | + "total" => "42.30", |
|
| 212 | + "payment_mode_id" => 50, |
|
| 213 | + "note_private" => "Synchronised from Prestashop", |
|
| 214 | + "note_public" => "", |
|
| 215 | + "status" => "1", |
|
| 216 | + "close_code" => null , |
|
| 217 | + "close_note" => null, |
|
| 218 | + "project_id" => null, |
|
| 219 | + "lines" => array( |
|
| 220 | + array("id" => null, |
|
| 221 | + "type" => 0, |
|
| 222 | + "desc" => "Horloge Vinyle Serge", |
|
| 223 | + "vat_rate" => 20, |
|
| 224 | + "qty" => 1, |
|
| 225 | + "unitprice" => "30.000000", |
|
| 226 | + "total_net" => "30.000000", |
|
| 227 | + "total_vat" => "6.00", |
|
| 228 | + "total" => "36.000000", |
|
| 229 | + "date_start" => "", |
|
| 230 | + "date_end" => "", |
|
| 231 | + "payment_mode_id" => "", |
|
| 232 | + "product_id" => "", |
|
| 233 | + "product_ref" => "", |
|
| 234 | + "product_label" => "", |
|
| 235 | + "product_desc" => "" )) |
|
| 236 | + ); |
|
| 237 | + |
|
| 238 | + // Call the WebService method and store its result in $result. |
|
| 239 | + $authentication=array( |
|
| 240 | + 'dolibarrkey'=>$conf->global->WEBSERVICES_KEY, |
|
| 241 | + 'sourceapplication'=>'DEMO', |
|
| 242 | + 'login'=>'admin', |
|
| 243 | + 'password'=>'admin', |
|
| 244 | + 'entity'=>''); |
|
| 245 | + |
|
| 246 | + // Test URL |
|
| 247 | + $result=''; |
|
| 248 | + $parameters = array('authentication'=>$authentication,'invoice'=>$body); |
|
| 249 | + print __METHOD__." call method ".$WS_METHOD."\n"; |
|
| 250 | + try { |
|
| 251 | + $result = $this->soapclient->call($WS_METHOD,$parameters,$this->ns,''); |
|
| 252 | + } |
|
| 253 | + catch(SoapFault $exception) |
|
| 254 | + { |
|
| 255 | + echo $exception; |
|
| 256 | + $result=0; |
|
| 257 | + } |
|
| 258 | + if (! $result || ! empty($result['faultstring'])) |
|
| 259 | + { |
|
| 260 | + //var_dump($soapclient); |
|
| 261 | + print $this->soapclient->error_str; |
|
| 262 | + print "\n<br>\n"; |
|
| 263 | + print $this->soapclient->request; |
|
| 264 | + print "\n<br>\n"; |
|
| 265 | + print $this->soapclient->response; |
|
| 266 | + print "\n"; |
|
| 267 | + } |
|
| 268 | + |
|
| 269 | + print __METHOD__." result=".$result['result']['result_code']."\n"; |
|
| 270 | + $this->assertEquals('OK',$result['result']['result_code']); |
|
| 271 | + $this->assertEquals('ref-phpunit-2', $result['ref_ext']); |
|
| 272 | + |
|
| 273 | + |
|
| 274 | + return $result; |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | /** |
@@ -285,49 +285,49 @@ discard block |
||
| 285 | 285 | */ |
| 286 | 286 | public function testWSInvoicesGetInvoiceByRefExt($result) |
| 287 | 287 | { |
| 288 | - global $conf,$user,$langs,$db; |
|
| 289 | - $conf=$this->savconf; |
|
| 290 | - $user=$this->savuser; |
|
| 291 | - $langs=$this->savlangs; |
|
| 292 | - $db=$this->savdb; |
|
| 293 | - |
|
| 294 | - $WS_METHOD = 'getInvoice'; |
|
| 295 | - |
|
| 296 | - // Call the WebService method and store its result in $result. |
|
| 297 | - $authentication=array( |
|
| 298 | - 'dolibarrkey'=>$conf->global->WEBSERVICES_KEY, |
|
| 299 | - 'sourceapplication'=>'DEMO', |
|
| 300 | - 'login'=>'admin', |
|
| 301 | - 'password'=>'admin', |
|
| 302 | - 'entity'=>''); |
|
| 303 | - |
|
| 304 | - // Test URL |
|
| 305 | - $result=''; |
|
| 306 | - $parameters = array('authentication'=>$authentication, 'id'=>null, 'ref'=>null, 'ref_ext'=>'ref-phpunit-2'); |
|
| 307 | - print __METHOD__." call method ".$WS_METHOD."\n"; |
|
| 308 | - try { |
|
| 309 | - $result = $this->soapclient->call($WS_METHOD,$parameters,$this->ns,''); |
|
| 310 | - } |
|
| 311 | - catch(SoapFault $exception) |
|
| 312 | - { |
|
| 313 | - echo $exception; |
|
| 314 | - $result=0; |
|
| 315 | - } |
|
| 316 | - if (! $result || ! empty($result['faultstring'])) |
|
| 317 | - { |
|
| 318 | - print $this->soapclient->error_str; |
|
| 319 | - print "\n<br>\n"; |
|
| 320 | - print $this->soapclient->request; |
|
| 321 | - print "\n<br>\n"; |
|
| 322 | - print $this->soapclient->response; |
|
| 323 | - print "\n"; |
|
| 324 | - } |
|
| 325 | - print __METHOD__." result=".$result['result']['result_code']."\n"; |
|
| 326 | - $this->assertEquals('OK',$result['result']['result_code']); |
|
| 327 | - $this->assertEquals('ref-phpunit-2', $result['invoice']['ref_ext']); |
|
| 328 | - |
|
| 329 | - |
|
| 330 | - return $result; |
|
| 288 | + global $conf,$user,$langs,$db; |
|
| 289 | + $conf=$this->savconf; |
|
| 290 | + $user=$this->savuser; |
|
| 291 | + $langs=$this->savlangs; |
|
| 292 | + $db=$this->savdb; |
|
| 293 | + |
|
| 294 | + $WS_METHOD = 'getInvoice'; |
|
| 295 | + |
|
| 296 | + // Call the WebService method and store its result in $result. |
|
| 297 | + $authentication=array( |
|
| 298 | + 'dolibarrkey'=>$conf->global->WEBSERVICES_KEY, |
|
| 299 | + 'sourceapplication'=>'DEMO', |
|
| 300 | + 'login'=>'admin', |
|
| 301 | + 'password'=>'admin', |
|
| 302 | + 'entity'=>''); |
|
| 303 | + |
|
| 304 | + // Test URL |
|
| 305 | + $result=''; |
|
| 306 | + $parameters = array('authentication'=>$authentication, 'id'=>null, 'ref'=>null, 'ref_ext'=>'ref-phpunit-2'); |
|
| 307 | + print __METHOD__." call method ".$WS_METHOD."\n"; |
|
| 308 | + try { |
|
| 309 | + $result = $this->soapclient->call($WS_METHOD,$parameters,$this->ns,''); |
|
| 310 | + } |
|
| 311 | + catch(SoapFault $exception) |
|
| 312 | + { |
|
| 313 | + echo $exception; |
|
| 314 | + $result=0; |
|
| 315 | + } |
|
| 316 | + if (! $result || ! empty($result['faultstring'])) |
|
| 317 | + { |
|
| 318 | + print $this->soapclient->error_str; |
|
| 319 | + print "\n<br>\n"; |
|
| 320 | + print $this->soapclient->request; |
|
| 321 | + print "\n<br>\n"; |
|
| 322 | + print $this->soapclient->response; |
|
| 323 | + print "\n"; |
|
| 324 | + } |
|
| 325 | + print __METHOD__." result=".$result['result']['result_code']."\n"; |
|
| 326 | + $this->assertEquals('OK',$result['result']['result_code']); |
|
| 327 | + $this->assertEquals('ref-phpunit-2', $result['invoice']['ref_ext']); |
|
| 328 | + |
|
| 329 | + |
|
| 330 | + return $result; |
|
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | /** |
@@ -341,93 +341,93 @@ discard block |
||
| 341 | 341 | */ |
| 342 | 342 | public function testWSInvoicesUpdateInvoiceByRefExt($result) |
| 343 | 343 | { |
| 344 | - global $conf,$user,$langs,$db; |
|
| 345 | - $conf=$this->savconf; |
|
| 346 | - $user=$this->savuser; |
|
| 347 | - $langs=$this->savlangs; |
|
| 348 | - $db=$this->savdb; |
|
| 349 | - |
|
| 350 | - $WS_METHOD = 'updateInvoice'; |
|
| 351 | - |
|
| 352 | - // update status to 2 |
|
| 353 | - $body = array ( |
|
| 354 | - "id" => null, |
|
| 355 | - "ref" => null, |
|
| 356 | - "ref_ext" => "ref-phpunit-2", |
|
| 357 | - "thirdparty_id" => self::$socid, |
|
| 358 | - "fk_user_author" => null, |
|
| 359 | - "fk_user_valid" => null, |
|
| 360 | - "date" => "2015-04-19 20:16:53", |
|
| 361 | - "date_due" => "", |
|
| 362 | - "date_creation" => "", |
|
| 363 | - "date_validation" => "", |
|
| 364 | - "date_modification" => "", |
|
| 365 | - "type" => "", |
|
| 366 | - "total_net" => "36.30", |
|
| 367 | - "total_vat" => "6.00", |
|
| 368 | - "total" => "42.30", |
|
| 369 | - "payment_mode_id" => 50, |
|
| 370 | - "note_private" => "Synchronised from Prestashop", |
|
| 371 | - "note_public" => "", |
|
| 372 | - "status" => "2", |
|
| 373 | - "close_code" => null , |
|
| 374 | - "close_note" => null, |
|
| 375 | - "project_id" => null, |
|
| 376 | - "lines" => array( |
|
| 377 | - array( |
|
| 378 | - "id" => null, |
|
| 379 | - "type" => 0, |
|
| 380 | - "desc" => "Horloge Vinyle Serge", |
|
| 381 | - "vat_rate" => 20, |
|
| 382 | - "qty" => "1", |
|
| 383 | - "unitprice" => "30.000000", |
|
| 384 | - "total_net" => "30.000000", |
|
| 385 | - "total_vat" => "6.00", |
|
| 386 | - "total" => "36.000000", |
|
| 387 | - "date_start" => "", |
|
| 388 | - "date_end" => "", |
|
| 389 | - "payment_mode_id" => "", |
|
| 390 | - "product_id" => "", |
|
| 391 | - "product_ref" => "", |
|
| 392 | - "product_label" => "", |
|
| 393 | - "product_desc" => "" )) |
|
| 394 | - ); |
|
| 395 | - |
|
| 396 | - // Call the WebService method and store its result in $result. |
|
| 397 | - $authentication=array( |
|
| 398 | - 'dolibarrkey'=>$conf->global->WEBSERVICES_KEY, |
|
| 399 | - 'sourceapplication'=>'DEMO', |
|
| 400 | - 'login'=>'admin', |
|
| 401 | - 'password'=>'admin', |
|
| 402 | - 'entity'=>''); |
|
| 403 | - |
|
| 404 | - // Test URL |
|
| 405 | - $result=''; |
|
| 406 | - $parameters = array('authentication'=>$authentication,'invoice'=>$body); |
|
| 407 | - print __METHOD__." call method ".$WS_METHOD."\n"; |
|
| 408 | - try { |
|
| 409 | - $result = $this->soapclient->call($WS_METHOD,$parameters,$this->ns,''); |
|
| 410 | - } |
|
| 411 | - catch(SoapFault $exception) |
|
| 412 | - { |
|
| 413 | - echo $exception; |
|
| 414 | - $result=0; |
|
| 415 | - } |
|
| 416 | - if (! $result || ! empty($result['faultstring'])) |
|
| 417 | - { |
|
| 418 | - print $this->soapclient->error_str; |
|
| 419 | - print "\n<br>\n"; |
|
| 420 | - print $this->soapclient->request; |
|
| 421 | - print "\n<br>\n"; |
|
| 422 | - print $this->soapclient->response; |
|
| 423 | - print "\n"; |
|
| 424 | - } |
|
| 425 | - |
|
| 426 | - print __METHOD__." result=".$result['result']['result_code'].$result['result']['result_label']."\n"; |
|
| 427 | - $this->assertEquals('OK',$result['result']['result_code']); |
|
| 428 | - $this->assertEquals('ref-phpunit-2', $result['ref_ext']); |
|
| 429 | - |
|
| 430 | - |
|
| 431 | - return $result; |
|
| 344 | + global $conf,$user,$langs,$db; |
|
| 345 | + $conf=$this->savconf; |
|
| 346 | + $user=$this->savuser; |
|
| 347 | + $langs=$this->savlangs; |
|
| 348 | + $db=$this->savdb; |
|
| 349 | + |
|
| 350 | + $WS_METHOD = 'updateInvoice'; |
|
| 351 | + |
|
| 352 | + // update status to 2 |
|
| 353 | + $body = array ( |
|
| 354 | + "id" => null, |
|
| 355 | + "ref" => null, |
|
| 356 | + "ref_ext" => "ref-phpunit-2", |
|
| 357 | + "thirdparty_id" => self::$socid, |
|
| 358 | + "fk_user_author" => null, |
|
| 359 | + "fk_user_valid" => null, |
|
| 360 | + "date" => "2015-04-19 20:16:53", |
|
| 361 | + "date_due" => "", |
|
| 362 | + "date_creation" => "", |
|
| 363 | + "date_validation" => "", |
|
| 364 | + "date_modification" => "", |
|
| 365 | + "type" => "", |
|
| 366 | + "total_net" => "36.30", |
|
| 367 | + "total_vat" => "6.00", |
|
| 368 | + "total" => "42.30", |
|
| 369 | + "payment_mode_id" => 50, |
|
| 370 | + "note_private" => "Synchronised from Prestashop", |
|
| 371 | + "note_public" => "", |
|
| 372 | + "status" => "2", |
|
| 373 | + "close_code" => null , |
|
| 374 | + "close_note" => null, |
|
| 375 | + "project_id" => null, |
|
| 376 | + "lines" => array( |
|
| 377 | + array( |
|
| 378 | + "id" => null, |
|
| 379 | + "type" => 0, |
|
| 380 | + "desc" => "Horloge Vinyle Serge", |
|
| 381 | + "vat_rate" => 20, |
|
| 382 | + "qty" => "1", |
|
| 383 | + "unitprice" => "30.000000", |
|
| 384 | + "total_net" => "30.000000", |
|
| 385 | + "total_vat" => "6.00", |
|
| 386 | + "total" => "36.000000", |
|
| 387 | + "date_start" => "", |
|
| 388 | + "date_end" => "", |
|
| 389 | + "payment_mode_id" => "", |
|
| 390 | + "product_id" => "", |
|
| 391 | + "product_ref" => "", |
|
| 392 | + "product_label" => "", |
|
| 393 | + "product_desc" => "" )) |
|
| 394 | + ); |
|
| 395 | + |
|
| 396 | + // Call the WebService method and store its result in $result. |
|
| 397 | + $authentication=array( |
|
| 398 | + 'dolibarrkey'=>$conf->global->WEBSERVICES_KEY, |
|
| 399 | + 'sourceapplication'=>'DEMO', |
|
| 400 | + 'login'=>'admin', |
|
| 401 | + 'password'=>'admin', |
|
| 402 | + 'entity'=>''); |
|
| 403 | + |
|
| 404 | + // Test URL |
|
| 405 | + $result=''; |
|
| 406 | + $parameters = array('authentication'=>$authentication,'invoice'=>$body); |
|
| 407 | + print __METHOD__." call method ".$WS_METHOD."\n"; |
|
| 408 | + try { |
|
| 409 | + $result = $this->soapclient->call($WS_METHOD,$parameters,$this->ns,''); |
|
| 410 | + } |
|
| 411 | + catch(SoapFault $exception) |
|
| 412 | + { |
|
| 413 | + echo $exception; |
|
| 414 | + $result=0; |
|
| 415 | + } |
|
| 416 | + if (! $result || ! empty($result['faultstring'])) |
|
| 417 | + { |
|
| 418 | + print $this->soapclient->error_str; |
|
| 419 | + print "\n<br>\n"; |
|
| 420 | + print $this->soapclient->request; |
|
| 421 | + print "\n<br>\n"; |
|
| 422 | + print $this->soapclient->response; |
|
| 423 | + print "\n"; |
|
| 424 | + } |
|
| 425 | + |
|
| 426 | + print __METHOD__." result=".$result['result']['result_code'].$result['result']['result_label']."\n"; |
|
| 427 | + $this->assertEquals('OK',$result['result']['result_code']); |
|
| 428 | + $this->assertEquals('ref-phpunit-2', $result['ref_ext']); |
|
| 429 | + |
|
| 430 | + |
|
| 431 | + return $result; |
|
| 432 | 432 | } |
| 433 | 433 | } |
@@ -23,12 +23,12 @@ discard block |
||
| 23 | 23 | * \remarks To run this script as CLI: phpunit filename.php |
| 24 | 24 | */ |
| 25 | 25 | |
| 26 | -global $conf,$user,$langs,$db; |
|
| 26 | +global $conf, $user, $langs, $db; |
|
| 27 | 27 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
| 28 | 28 | //require_once 'PHPUnit/Autoload.php'; |
| 29 | 29 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
| 30 | 30 | require_once dirname(__FILE__).'/../../htdocs/core/lib/date.lib.php'; |
| 31 | -require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP |
|
| 31 | +require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP |
|
| 32 | 32 | |
| 33 | 33 | |
| 34 | 34 | if (empty($user->id)) |
@@ -37,9 +37,9 @@ 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 | -$conf->global->MAIN_UMASK='0666'; |
|
| 42 | +$conf->global->MAIN_UMASK = '0666'; |
|
| 43 | 43 | |
| 44 | 44 | |
| 45 | 45 | /** |
@@ -72,11 +72,11 @@ discard block |
||
| 72 | 72 | parent::__construct(); |
| 73 | 73 | |
| 74 | 74 | //$this->sharedFixture |
| 75 | - global $conf,$user,$langs,$db; |
|
| 76 | - $this->savconf=$conf; |
|
| 77 | - $this->savuser=$user; |
|
| 78 | - $this->savlangs=$langs; |
|
| 79 | - $this->savdb=$db; |
|
| 75 | + global $conf, $user, $langs, $db; |
|
| 76 | + $this->savconf = $conf; |
|
| 77 | + $this->savuser = $user; |
|
| 78 | + $this->savlangs = $langs; |
|
| 79 | + $this->savdb = $db; |
|
| 80 | 80 | |
| 81 | 81 | // Set the WebService URL |
| 82 | 82 | $WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_invoice.php'; |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | $this->soapclient = new nusoap_client($WS_DOL_URL); |
| 85 | 85 | if ($this->soapclient) |
| 86 | 86 | { |
| 87 | - $this->soapclient->soap_defencoding='UTF-8'; |
|
| 87 | + $this->soapclient->soap_defencoding = 'UTF-8'; |
|
| 88 | 88 | $this->soapclient->decodeUTF8(false); |
| 89 | 89 | } |
| 90 | 90 | |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | public static function setUpBeforeClass() |
| 102 | 102 | { |
| 103 | - global $conf,$user,$langs,$db; |
|
| 103 | + global $conf, $user, $langs, $db; |
|
| 104 | 104 | |
| 105 | 105 | // create a third_party, needed to create an invoice |
| 106 | 106 | // |
@@ -115,25 +115,25 @@ discard block |
||
| 115 | 115 | // transaction commit. So if the invoice is created in the same |
| 116 | 116 | // transaction than the third party, the FK constraint fails. |
| 117 | 117 | // See this post for more detail: http://stackoverflow.com/a/5014744/5187108 |
| 118 | - $societe=new Societe($db); |
|
| 119 | - $societe->ref=''; |
|
| 120 | - $societe->name='name'; |
|
| 121 | - $societe->ref_ext='ref-phpunit'; |
|
| 122 | - $societe->status=1; |
|
| 123 | - $societe->client=1; |
|
| 124 | - $societe->code_client='CU0901-1234'; |
|
| 125 | - $societe->code_fournisseur='SU0901-1234'; |
|
| 126 | - $societe->fournisseur=0; |
|
| 127 | - $societe->date_creation=$now; |
|
| 128 | - $societe->tva_assuj=0; |
|
| 129 | - $societe->particulier=0; |
|
| 118 | + $societe = new Societe($db); |
|
| 119 | + $societe->ref = ''; |
|
| 120 | + $societe->name = 'name'; |
|
| 121 | + $societe->ref_ext = 'ref-phpunit'; |
|
| 122 | + $societe->status = 1; |
|
| 123 | + $societe->client = 1; |
|
| 124 | + $societe->code_client = 'CU0901-1234'; |
|
| 125 | + $societe->code_fournisseur = 'SU0901-1234'; |
|
| 126 | + $societe->fournisseur = 0; |
|
| 127 | + $societe->date_creation = $now; |
|
| 128 | + $societe->tva_assuj = 0; |
|
| 129 | + $societe->particulier = 0; |
|
| 130 | 130 | |
| 131 | 131 | $societe->create($user); |
| 132 | 132 | |
| 133 | 133 | self::$socid = $societe->id; |
| 134 | 134 | print __METHOD__." societe created id=".$societe->id."\n"; |
| 135 | 135 | |
| 136 | - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
| 136 | + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
| 137 | 137 | |
| 138 | 138 | print __METHOD__."\n"; |
| 139 | 139 | } |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | */ |
| 146 | 146 | public static function tearDownAfterClass() |
| 147 | 147 | { |
| 148 | - global $conf,$user,$langs,$db; |
|
| 148 | + global $conf, $user, $langs, $db; |
|
| 149 | 149 | $db->rollback(); |
| 150 | 150 | |
| 151 | 151 | print __METHOD__."\n"; |
@@ -158,11 +158,11 @@ discard block |
||
| 158 | 158 | */ |
| 159 | 159 | protected function setUp() |
| 160 | 160 | { |
| 161 | - global $conf,$user,$langs,$db; |
|
| 162 | - $conf=$this->savconf; |
|
| 163 | - $user=$this->savuser; |
|
| 164 | - $langs=$this->savlangs; |
|
| 165 | - $db=$this->savdb; |
|
| 161 | + global $conf, $user, $langs, $db; |
|
| 162 | + $conf = $this->savconf; |
|
| 163 | + $user = $this->savuser; |
|
| 164 | + $langs = $this->savlangs; |
|
| 165 | + $db = $this->savdb; |
|
| 166 | 166 | |
| 167 | 167 | print __METHOD__."\n"; |
| 168 | 168 | } |
@@ -185,15 +185,15 @@ discard block |
||
| 185 | 185 | */ |
| 186 | 186 | public function testWSInvoicesCreateInvoice() |
| 187 | 187 | { |
| 188 | - global $conf,$user,$langs,$db; |
|
| 189 | - $conf=$this->savconf; |
|
| 190 | - $user=$this->savuser; |
|
| 191 | - $langs=$this->savlangs; |
|
| 192 | - $db=$this->savdb; |
|
| 188 | + global $conf, $user, $langs, $db; |
|
| 189 | + $conf = $this->savconf; |
|
| 190 | + $user = $this->savuser; |
|
| 191 | + $langs = $this->savlangs; |
|
| 192 | + $db = $this->savdb; |
|
| 193 | 193 | |
| 194 | - $WS_METHOD = 'createInvoice'; |
|
| 194 | + $WS_METHOD = 'createInvoice'; |
|
| 195 | 195 | |
| 196 | - $body = array ( |
|
| 196 | + $body = array( |
|
| 197 | 197 | "id" => null, |
| 198 | 198 | "ref" => null, |
| 199 | 199 | "ref_ext" => "ref-phpunit-2", |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | "note_private" => "Synchronised from Prestashop", |
| 214 | 214 | "note_public" => "", |
| 215 | 215 | "status" => "1", |
| 216 | - "close_code" => null , |
|
| 216 | + "close_code" => null, |
|
| 217 | 217 | "close_note" => null, |
| 218 | 218 | "project_id" => null, |
| 219 | 219 | "lines" => array( |
@@ -232,11 +232,11 @@ discard block |
||
| 232 | 232 | "product_id" => "", |
| 233 | 233 | "product_ref" => "", |
| 234 | 234 | "product_label" => "", |
| 235 | - "product_desc" => "" )) |
|
| 235 | + "product_desc" => "")) |
|
| 236 | 236 | ); |
| 237 | 237 | |
| 238 | 238 | // Call the WebService method and store its result in $result. |
| 239 | - $authentication=array( |
|
| 239 | + $authentication = array( |
|
| 240 | 240 | 'dolibarrkey'=>$conf->global->WEBSERVICES_KEY, |
| 241 | 241 | 'sourceapplication'=>'DEMO', |
| 242 | 242 | 'login'=>'admin', |
@@ -244,18 +244,18 @@ discard block |
||
| 244 | 244 | 'entity'=>''); |
| 245 | 245 | |
| 246 | 246 | // Test URL |
| 247 | - $result=''; |
|
| 248 | - $parameters = array('authentication'=>$authentication,'invoice'=>$body); |
|
| 247 | + $result = ''; |
|
| 248 | + $parameters = array('authentication'=>$authentication, 'invoice'=>$body); |
|
| 249 | 249 | print __METHOD__." call method ".$WS_METHOD."\n"; |
| 250 | 250 | try { |
| 251 | - $result = $this->soapclient->call($WS_METHOD,$parameters,$this->ns,''); |
|
| 251 | + $result = $this->soapclient->call($WS_METHOD, $parameters, $this->ns, ''); |
|
| 252 | 252 | } |
| 253 | - catch(SoapFault $exception) |
|
| 253 | + catch (SoapFault $exception) |
|
| 254 | 254 | { |
| 255 | 255 | echo $exception; |
| 256 | - $result=0; |
|
| 256 | + $result = 0; |
|
| 257 | 257 | } |
| 258 | - if (! $result || ! empty($result['faultstring'])) |
|
| 258 | + if (!$result || !empty($result['faultstring'])) |
|
| 259 | 259 | { |
| 260 | 260 | //var_dump($soapclient); |
| 261 | 261 | print $this->soapclient->error_str; |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | print __METHOD__." result=".$result['result']['result_code']."\n"; |
| 270 | - $this->assertEquals('OK',$result['result']['result_code']); |
|
| 270 | + $this->assertEquals('OK', $result['result']['result_code']); |
|
| 271 | 271 | $this->assertEquals('ref-phpunit-2', $result['ref_ext']); |
| 272 | 272 | |
| 273 | 273 | |
@@ -285,16 +285,16 @@ discard block |
||
| 285 | 285 | */ |
| 286 | 286 | public function testWSInvoicesGetInvoiceByRefExt($result) |
| 287 | 287 | { |
| 288 | - global $conf,$user,$langs,$db; |
|
| 289 | - $conf=$this->savconf; |
|
| 290 | - $user=$this->savuser; |
|
| 291 | - $langs=$this->savlangs; |
|
| 292 | - $db=$this->savdb; |
|
| 288 | + global $conf, $user, $langs, $db; |
|
| 289 | + $conf = $this->savconf; |
|
| 290 | + $user = $this->savuser; |
|
| 291 | + $langs = $this->savlangs; |
|
| 292 | + $db = $this->savdb; |
|
| 293 | 293 | |
| 294 | - $WS_METHOD = 'getInvoice'; |
|
| 294 | + $WS_METHOD = 'getInvoice'; |
|
| 295 | 295 | |
| 296 | 296 | // Call the WebService method and store its result in $result. |
| 297 | - $authentication=array( |
|
| 297 | + $authentication = array( |
|
| 298 | 298 | 'dolibarrkey'=>$conf->global->WEBSERVICES_KEY, |
| 299 | 299 | 'sourceapplication'=>'DEMO', |
| 300 | 300 | 'login'=>'admin', |
@@ -302,18 +302,18 @@ discard block |
||
| 302 | 302 | 'entity'=>''); |
| 303 | 303 | |
| 304 | 304 | // Test URL |
| 305 | - $result=''; |
|
| 305 | + $result = ''; |
|
| 306 | 306 | $parameters = array('authentication'=>$authentication, 'id'=>null, 'ref'=>null, 'ref_ext'=>'ref-phpunit-2'); |
| 307 | 307 | print __METHOD__." call method ".$WS_METHOD."\n"; |
| 308 | 308 | try { |
| 309 | - $result = $this->soapclient->call($WS_METHOD,$parameters,$this->ns,''); |
|
| 309 | + $result = $this->soapclient->call($WS_METHOD, $parameters, $this->ns, ''); |
|
| 310 | 310 | } |
| 311 | - catch(SoapFault $exception) |
|
| 311 | + catch (SoapFault $exception) |
|
| 312 | 312 | { |
| 313 | 313 | echo $exception; |
| 314 | - $result=0; |
|
| 314 | + $result = 0; |
|
| 315 | 315 | } |
| 316 | - if (! $result || ! empty($result['faultstring'])) |
|
| 316 | + if (!$result || !empty($result['faultstring'])) |
|
| 317 | 317 | { |
| 318 | 318 | print $this->soapclient->error_str; |
| 319 | 319 | print "\n<br>\n"; |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | print "\n"; |
| 324 | 324 | } |
| 325 | 325 | print __METHOD__." result=".$result['result']['result_code']."\n"; |
| 326 | - $this->assertEquals('OK',$result['result']['result_code']); |
|
| 326 | + $this->assertEquals('OK', $result['result']['result_code']); |
|
| 327 | 327 | $this->assertEquals('ref-phpunit-2', $result['invoice']['ref_ext']); |
| 328 | 328 | |
| 329 | 329 | |
@@ -341,16 +341,16 @@ discard block |
||
| 341 | 341 | */ |
| 342 | 342 | public function testWSInvoicesUpdateInvoiceByRefExt($result) |
| 343 | 343 | { |
| 344 | - global $conf,$user,$langs,$db; |
|
| 345 | - $conf=$this->savconf; |
|
| 346 | - $user=$this->savuser; |
|
| 347 | - $langs=$this->savlangs; |
|
| 348 | - $db=$this->savdb; |
|
| 344 | + global $conf, $user, $langs, $db; |
|
| 345 | + $conf = $this->savconf; |
|
| 346 | + $user = $this->savuser; |
|
| 347 | + $langs = $this->savlangs; |
|
| 348 | + $db = $this->savdb; |
|
| 349 | 349 | |
| 350 | - $WS_METHOD = 'updateInvoice'; |
|
| 350 | + $WS_METHOD = 'updateInvoice'; |
|
| 351 | 351 | |
| 352 | 352 | // update status to 2 |
| 353 | - $body = array ( |
|
| 353 | + $body = array( |
|
| 354 | 354 | "id" => null, |
| 355 | 355 | "ref" => null, |
| 356 | 356 | "ref_ext" => "ref-phpunit-2", |
@@ -370,7 +370,7 @@ discard block |
||
| 370 | 370 | "note_private" => "Synchronised from Prestashop", |
| 371 | 371 | "note_public" => "", |
| 372 | 372 | "status" => "2", |
| 373 | - "close_code" => null , |
|
| 373 | + "close_code" => null, |
|
| 374 | 374 | "close_note" => null, |
| 375 | 375 | "project_id" => null, |
| 376 | 376 | "lines" => array( |
@@ -394,7 +394,7 @@ discard block |
||
| 394 | 394 | ); |
| 395 | 395 | |
| 396 | 396 | // Call the WebService method and store its result in $result. |
| 397 | - $authentication=array( |
|
| 397 | + $authentication = array( |
|
| 398 | 398 | 'dolibarrkey'=>$conf->global->WEBSERVICES_KEY, |
| 399 | 399 | 'sourceapplication'=>'DEMO', |
| 400 | 400 | 'login'=>'admin', |
@@ -402,18 +402,18 @@ discard block |
||
| 402 | 402 | 'entity'=>''); |
| 403 | 403 | |
| 404 | 404 | // Test URL |
| 405 | - $result=''; |
|
| 406 | - $parameters = array('authentication'=>$authentication,'invoice'=>$body); |
|
| 405 | + $result = ''; |
|
| 406 | + $parameters = array('authentication'=>$authentication, 'invoice'=>$body); |
|
| 407 | 407 | print __METHOD__." call method ".$WS_METHOD."\n"; |
| 408 | 408 | try { |
| 409 | - $result = $this->soapclient->call($WS_METHOD,$parameters,$this->ns,''); |
|
| 409 | + $result = $this->soapclient->call($WS_METHOD, $parameters, $this->ns, ''); |
|
| 410 | 410 | } |
| 411 | - catch(SoapFault $exception) |
|
| 411 | + catch (SoapFault $exception) |
|
| 412 | 412 | { |
| 413 | 413 | echo $exception; |
| 414 | - $result=0; |
|
| 414 | + $result = 0; |
|
| 415 | 415 | } |
| 416 | - if (! $result || ! empty($result['faultstring'])) |
|
| 416 | + if (!$result || !empty($result['faultstring'])) |
|
| 417 | 417 | { |
| 418 | 418 | print $this->soapclient->error_str; |
| 419 | 419 | print "\n<br>\n"; |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | } |
| 425 | 425 | |
| 426 | 426 | print __METHOD__." result=".$result['result']['result_code'].$result['result']['result_label']."\n"; |
| 427 | - $this->assertEquals('OK',$result['result']['result_code']); |
|
| 427 | + $this->assertEquals('OK', $result['result']['result_code']); |
|
| 428 | 428 | $this->assertEquals('ref-phpunit-2', $result['ref_ext']); |
| 429 | 429 | |
| 430 | 430 | |
@@ -249,8 +249,7 @@ discard block |
||
| 249 | 249 | print __METHOD__." call method ".$WS_METHOD."\n"; |
| 250 | 250 | try { |
| 251 | 251 | $result = $this->soapclient->call($WS_METHOD,$parameters,$this->ns,''); |
| 252 | - } |
|
| 253 | - catch(SoapFault $exception) |
|
| 252 | + } catch(SoapFault $exception) |
|
| 254 | 253 | { |
| 255 | 254 | echo $exception; |
| 256 | 255 | $result=0; |
@@ -307,8 +306,7 @@ discard block |
||
| 307 | 306 | print __METHOD__." call method ".$WS_METHOD."\n"; |
| 308 | 307 | try { |
| 309 | 308 | $result = $this->soapclient->call($WS_METHOD,$parameters,$this->ns,''); |
| 310 | - } |
|
| 311 | - catch(SoapFault $exception) |
|
| 309 | + } catch(SoapFault $exception) |
|
| 312 | 310 | { |
| 313 | 311 | echo $exception; |
| 314 | 312 | $result=0; |
@@ -407,8 +405,7 @@ discard block |
||
| 407 | 405 | print __METHOD__." call method ".$WS_METHOD."\n"; |
| 408 | 406 | try { |
| 409 | 407 | $result = $this->soapclient->call($WS_METHOD,$parameters,$this->ns,''); |
| 410 | - } |
|
| 411 | - catch(SoapFault $exception) |
|
| 408 | + } catch(SoapFault $exception) |
|
| 412 | 409 | { |
| 413 | 410 | echo $exception; |
| 414 | 411 | $result=0; |
@@ -59,9 +59,9 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | function __construct() |
| 61 | 61 | { |
| 62 | - parent::__construct(); |
|
| 62 | + parent::__construct(); |
|
| 63 | 63 | |
| 64 | - //$this->sharedFixture |
|
| 64 | + //$this->sharedFixture |
|
| 65 | 65 | global $conf,$user,$langs,$db; |
| 66 | 66 | $this->savconf=$conf; |
| 67 | 67 | $this->savuser=$user; |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | * End phpunit tests |
| 111 | 111 | * |
| 112 | 112 | * @return void |
| 113 | - */ |
|
| 113 | + */ |
|
| 114 | 114 | protected function tearDown() |
| 115 | 115 | { |
| 116 | 116 | print __METHOD__."\n"; |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * \remarks To run this script as CLI: phpunit filename.php |
| 24 | 24 | */ |
| 25 | 25 | |
| 26 | -global $conf,$user,$langs,$db; |
|
| 26 | +global $conf, $user, $langs, $db; |
|
| 27 | 27 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
| 28 | 28 | //require_once 'PHPUnit/Autoload.php'; |
| 29 | 29 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | $user->fetch(1); |
| 35 | 35 | $user->getrights(); |
| 36 | 36 | } |
| 37 | -$conf->global->MAIN_DISABLE_ALL_MAILS=1; |
|
| 37 | +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
|
| 38 | 38 | |
| 39 | 39 | |
| 40 | 40 | /** |
@@ -62,11 +62,11 @@ discard block |
||
| 62 | 62 | parent::__construct(); |
| 63 | 63 | |
| 64 | 64 | //$this->sharedFixture |
| 65 | - global $conf,$user,$langs,$db; |
|
| 66 | - $this->savconf=$conf; |
|
| 67 | - $this->savuser=$user; |
|
| 68 | - $this->savlangs=$langs; |
|
| 69 | - $this->savdb=$db; |
|
| 65 | + global $conf, $user, $langs, $db; |
|
| 66 | + $this->savconf = $conf; |
|
| 67 | + $this->savuser = $user; |
|
| 68 | + $this->savlangs = $langs; |
|
| 69 | + $this->savdb = $db; |
|
| 70 | 70 | |
| 71 | 71 | print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
| 72 | 72 | //print " - db ".$db->db; |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | // Static methods |
| 77 | 77 | public static function setUpBeforeClass() |
| 78 | 78 | { |
| 79 | - global $conf,$user,$langs,$db; |
|
| 79 | + global $conf, $user, $langs, $db; |
|
| 80 | 80 | $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
| 81 | 81 | |
| 82 | 82 | print __METHOD__."\n"; |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | // tear down after class |
| 86 | 86 | public static function tearDownAfterClass() |
| 87 | 87 | { |
| 88 | - global $conf,$user,$langs,$db; |
|
| 88 | + global $conf, $user, $langs, $db; |
|
| 89 | 89 | $db->rollback(); |
| 90 | 90 | |
| 91 | 91 | print __METHOD__."\n"; |
@@ -98,11 +98,11 @@ discard block |
||
| 98 | 98 | */ |
| 99 | 99 | protected function setUp() |
| 100 | 100 | { |
| 101 | - global $conf,$user,$langs,$db; |
|
| 102 | - $conf=$this->savconf; |
|
| 103 | - $user=$this->savuser; |
|
| 104 | - $langs=$this->savlangs; |
|
| 105 | - $db=$this->savdb; |
|
| 101 | + global $conf, $user, $langs, $db; |
|
| 102 | + $conf = $this->savconf; |
|
| 103 | + $user = $this->savuser; |
|
| 104 | + $langs = $this->savlangs; |
|
| 105 | + $db = $this->savdb; |
|
| 106 | 106 | |
| 107 | 107 | print __METHOD__."\n"; |
| 108 | 108 | } |
@@ -124,13 +124,13 @@ discard block |
||
| 124 | 124 | */ |
| 125 | 125 | public function testCalculateDateLimReglement() |
| 126 | 126 | { |
| 127 | - global $conf,$user,$langs,$db; |
|
| 128 | - $conf=$this->savconf; |
|
| 129 | - $user=$this->savuser; |
|
| 130 | - $langs=$this->savlangs; |
|
| 131 | - $db=$this->savdb; |
|
| 127 | + global $conf, $user, $langs, $db; |
|
| 128 | + $conf = $this->savconf; |
|
| 129 | + $user = $this->savuser; |
|
| 130 | + $langs = $this->savlangs; |
|
| 131 | + $db = $this->savdb; |
|
| 132 | 132 | |
| 133 | - $localobject=new Facture($this->savdb); |
|
| 133 | + $localobject = new Facture($this->savdb); |
|
| 134 | 134 | $localobject->fetch(1); |
| 135 | 135 | $localobject->date = dol_mktime(12, 0, 0, 1, 1, 2010); |
| 136 | 136 | |
@@ -59,9 +59,9 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | function __construct() |
| 61 | 61 | { |
| 62 | - parent::__construct(); |
|
| 62 | + parent::__construct(); |
|
| 63 | 63 | |
| 64 | - //$this->sharedFixture |
|
| 64 | + //$this->sharedFixture |
|
| 65 | 65 | global $conf,$user,$langs,$db; |
| 66 | 66 | $this->savconf=$conf; |
| 67 | 67 | $this->savuser=$user; |
@@ -152,18 +152,18 @@ discard block |
||
| 152 | 152 | */ |
| 153 | 153 | public function testEnableModule() |
| 154 | 154 | { |
| 155 | - global $conf, $db, $langs, $user; |
|
| 156 | - |
|
| 157 | - require_once dirname(__FILE__).'/../../htdocs/core/modules/modExpenseReport.class.php'; |
|
| 158 | - print "Enable module modExpenseReport"; |
|
| 159 | - $moduledescriptor=new modExpenseReport($db); |
|
| 160 | - $moduledescriptor->init(); |
|
| 161 | - $conf->setValues($db); |
|
| 162 | - |
|
| 163 | - require_once dirname(__FILE__).'/../../htdocs/core/modules/modApi.class.php'; |
|
| 164 | - print "Enable module modAPI"; |
|
| 165 | - $moduledescriptor=new modApi($db); |
|
| 166 | - $moduledescriptor->init(); |
|
| 167 | - $conf->setValues($db); |
|
| 155 | + global $conf, $db, $langs, $user; |
|
| 156 | + |
|
| 157 | + require_once dirname(__FILE__).'/../../htdocs/core/modules/modExpenseReport.class.php'; |
|
| 158 | + print "Enable module modExpenseReport"; |
|
| 159 | + $moduledescriptor=new modExpenseReport($db); |
|
| 160 | + $moduledescriptor->init(); |
|
| 161 | + $conf->setValues($db); |
|
| 162 | + |
|
| 163 | + require_once dirname(__FILE__).'/../../htdocs/core/modules/modApi.class.php'; |
|
| 164 | + print "Enable module modAPI"; |
|
| 165 | + $moduledescriptor=new modApi($db); |
|
| 166 | + $moduledescriptor->init(); |
|
| 167 | + $conf->setValues($db); |
|
| 168 | 168 | } |
| 169 | 169 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * \remarks To run this script as CLI: phpunit filename.php |
| 24 | 24 | */ |
| 25 | 25 | |
| 26 | -global $conf,$user,$langs,$db; |
|
| 26 | +global $conf, $user, $langs, $db; |
|
| 27 | 27 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
| 28 | 28 | //require_once 'PHPUnit/Autoload.php'; |
| 29 | 29 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | $user->fetch(1); |
| 35 | 35 | $user->getrights(); |
| 36 | 36 | } |
| 37 | -$conf->global->MAIN_DISABLE_ALL_MAILS=1; |
|
| 37 | +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
|
| 38 | 38 | |
| 39 | 39 | |
| 40 | 40 | /** |
@@ -62,11 +62,11 @@ discard block |
||
| 62 | 62 | parent::__construct(); |
| 63 | 63 | |
| 64 | 64 | //$this->sharedFixture |
| 65 | - global $conf,$user,$langs,$db; |
|
| 66 | - $this->savconf=$conf; |
|
| 67 | - $this->savuser=$user; |
|
| 68 | - $this->savlangs=$langs; |
|
| 69 | - $this->savdb=$db; |
|
| 65 | + global $conf, $user, $langs, $db; |
|
| 66 | + $this->savconf = $conf; |
|
| 67 | + $this->savuser = $user; |
|
| 68 | + $this->savlangs = $langs; |
|
| 69 | + $this->savdb = $db; |
|
| 70 | 70 | |
| 71 | 71 | print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
| 72 | 72 | //print " - db ".$db->db; |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | // Static methods |
| 77 | 77 | public static function setUpBeforeClass() |
| 78 | 78 | { |
| 79 | - global $conf,$user,$langs,$db; |
|
| 79 | + global $conf, $user, $langs, $db; |
|
| 80 | 80 | $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
| 81 | 81 | |
| 82 | 82 | print __METHOD__."\n"; |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | // tear down after class |
| 86 | 86 | public static function tearDownAfterClass() |
| 87 | 87 | { |
| 88 | - global $conf,$user,$langs,$db; |
|
| 88 | + global $conf, $user, $langs, $db; |
|
| 89 | 89 | $db->rollback(); |
| 90 | 90 | |
| 91 | 91 | print __METHOD__."\n"; |
@@ -98,11 +98,11 @@ discard block |
||
| 98 | 98 | */ |
| 99 | 99 | protected function setUp() |
| 100 | 100 | { |
| 101 | - global $conf,$user,$langs,$db; |
|
| 102 | - $conf=$this->savconf; |
|
| 103 | - $user=$this->savuser; |
|
| 104 | - $langs=$this->savlangs; |
|
| 105 | - $db=$this->savdb; |
|
| 101 | + global $conf, $user, $langs, $db; |
|
| 102 | + $conf = $this->savconf; |
|
| 103 | + $user = $this->savuser; |
|
| 104 | + $langs = $this->savlangs; |
|
| 105 | + $db = $this->savdb; |
|
| 106 | 106 | |
| 107 | 107 | print __METHOD__."\n"; |
| 108 | 108 | } |
@@ -123,24 +123,24 @@ discard block |
||
| 123 | 123 | */ |
| 124 | 124 | public function testVersionCompare() |
| 125 | 125 | { |
| 126 | - global $conf,$user,$langs,$db; |
|
| 127 | - $conf=$this->savconf; |
|
| 128 | - $user=$this->savuser; |
|
| 129 | - $langs=$this->savlangs; |
|
| 130 | - $db=$this->savdb; |
|
| 126 | + global $conf, $user, $langs, $db; |
|
| 127 | + $conf = $this->savconf; |
|
| 128 | + $user = $this->savuser; |
|
| 129 | + $langs = $this->savlangs; |
|
| 130 | + $db = $this->savdb; |
|
| 131 | 131 | |
| 132 | - $result=versioncompare(array(3,1,-4),array(3,1,1)); |
|
| 132 | + $result = versioncompare(array(3, 1, -4), array(3, 1, 1)); |
|
| 133 | 133 | print __METHOD__." result=".$result."\n"; |
| 134 | - $this->assertEquals(-3,$result); |
|
| 135 | - $result=versioncompare(array(3,1,0),array(3,1,1)); |
|
| 134 | + $this->assertEquals(-3, $result); |
|
| 135 | + $result = versioncompare(array(3, 1, 0), array(3, 1, 1)); |
|
| 136 | 136 | print __METHOD__." result=".$result."\n"; |
| 137 | - $this->assertEquals(-3,$result); |
|
| 138 | - $result=versioncompare(array(3,1,0),array(3,2,0)); |
|
| 137 | + $this->assertEquals(-3, $result); |
|
| 138 | + $result = versioncompare(array(3, 1, 0), array(3, 2, 0)); |
|
| 139 | 139 | print __METHOD__." result=".$result."\n"; |
| 140 | - $this->assertEquals(-2,$result); |
|
| 141 | - $result=versioncompare(array(3,1,0),array(3,1,0)); |
|
| 140 | + $this->assertEquals(-2, $result); |
|
| 141 | + $result = versioncompare(array(3, 1, 0), array(3, 1, 0)); |
|
| 142 | 142 | print __METHOD__." result=".$result."\n"; |
| 143 | - $this->assertEquals(0,$result); |
|
| 143 | + $this->assertEquals(0, $result); |
|
| 144 | 144 | |
| 145 | 145 | return $result; |
| 146 | 146 | } |
@@ -156,13 +156,13 @@ discard block |
||
| 156 | 156 | |
| 157 | 157 | require_once dirname(__FILE__).'/../../htdocs/core/modules/modExpenseReport.class.php'; |
| 158 | 158 | print "Enable module modExpenseReport"; |
| 159 | - $moduledescriptor=new modExpenseReport($db); |
|
| 159 | + $moduledescriptor = new modExpenseReport($db); |
|
| 160 | 160 | $moduledescriptor->init(); |
| 161 | 161 | $conf->setValues($db); |
| 162 | 162 | |
| 163 | 163 | require_once dirname(__FILE__).'/../../htdocs/core/modules/modApi.class.php'; |
| 164 | 164 | print "Enable module modAPI"; |
| 165 | - $moduledescriptor=new modApi($db); |
|
| 165 | + $moduledescriptor = new modApi($db); |
|
| 166 | 166 | $moduledescriptor->init(); |
| 167 | 167 | $conf->setValues($db); |
| 168 | 168 | } |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | function __construct() |
| 61 | 61 | { |
| 62 | - parent::__construct(); |
|
| 62 | + parent::__construct(); |
|
| 63 | 63 | |
| 64 | 64 | //$this->sharedFixture |
| 65 | 65 | global $conf,$user,$langs,$db; |
@@ -184,18 +184,18 @@ discard block |
||
| 184 | 184 | */ |
| 185 | 185 | public function testAccountingAccountUpdate($localobject) |
| 186 | 186 | { |
| 187 | - global $conf,$user,$langs,$db; |
|
| 188 | - $conf=$this->savconf; |
|
| 189 | - $user=$this->savuser; |
|
| 190 | - $langs=$this->savlangs; |
|
| 191 | - $db=$this->savdb; |
|
| 192 | - |
|
| 193 | - $localobject->label='New label'; |
|
| 194 | - $result=$localobject->update($user); |
|
| 195 | - |
|
| 196 | - $this->assertLessThan($result, 0); |
|
| 197 | - print __METHOD__." id=".$id." result=".$result."\n"; |
|
| 198 | - return $localobject->id; |
|
| 187 | + global $conf,$user,$langs,$db; |
|
| 188 | + $conf=$this->savconf; |
|
| 189 | + $user=$this->savuser; |
|
| 190 | + $langs=$this->savlangs; |
|
| 191 | + $db=$this->savdb; |
|
| 192 | + |
|
| 193 | + $localobject->label='New label'; |
|
| 194 | + $result=$localobject->update($user); |
|
| 195 | + |
|
| 196 | + $this->assertLessThan($result, 0); |
|
| 197 | + print __METHOD__." id=".$id." result=".$result."\n"; |
|
| 198 | + return $localobject->id; |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | /** |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * \remarks To run this script as CLI: phpunit filename.php |
| 24 | 24 | */ |
| 25 | 25 | |
| 26 | -global $conf,$user,$langs,$db; |
|
| 26 | +global $conf, $user, $langs, $db; |
|
| 27 | 27 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
| 28 | 28 | //require_once 'PHPUnit/Autoload.php'; |
| 29 | 29 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | $user->fetch(1); |
| 35 | 35 | $user->getrights(); |
| 36 | 36 | } |
| 37 | -$conf->global->MAIN_DISABLE_ALL_MAILS=1; |
|
| 37 | +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
|
| 38 | 38 | |
| 39 | 39 | |
| 40 | 40 | /** |
@@ -62,11 +62,11 @@ discard block |
||
| 62 | 62 | parent::__construct(); |
| 63 | 63 | |
| 64 | 64 | //$this->sharedFixture |
| 65 | - global $conf,$user,$langs,$db; |
|
| 66 | - $this->savconf=$conf; |
|
| 67 | - $this->savuser=$user; |
|
| 68 | - $this->savlangs=$langs; |
|
| 69 | - $this->savdb=$db; |
|
| 65 | + global $conf, $user, $langs, $db; |
|
| 66 | + $this->savconf = $conf; |
|
| 67 | + $this->savuser = $user; |
|
| 68 | + $this->savlangs = $langs; |
|
| 69 | + $this->savdb = $db; |
|
| 70 | 70 | |
| 71 | 71 | print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
| 72 | 72 | //print " - db ".$db->db; |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | // Static methods |
| 77 | 77 | public static function setUpBeforeClass() |
| 78 | 78 | { |
| 79 | - global $conf,$user,$langs,$db; |
|
| 79 | + global $conf, $user, $langs, $db; |
|
| 80 | 80 | $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
| 81 | 81 | |
| 82 | 82 | if (empty($conf->accounting->enabled)) { print __METHOD__." module accouting must be enabled.\n"; die(); } |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | // tear down after class |
| 88 | 88 | public static function tearDownAfterClass() |
| 89 | 89 | { |
| 90 | - global $conf,$user,$langs,$db; |
|
| 90 | + global $conf, $user, $langs, $db; |
|
| 91 | 91 | $db->rollback(); |
| 92 | 92 | |
| 93 | 93 | print __METHOD__."\n"; |
@@ -100,11 +100,11 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | protected function setUp() |
| 102 | 102 | { |
| 103 | - global $conf,$user,$langs,$db; |
|
| 104 | - $conf=$this->savconf; |
|
| 105 | - $user=$this->savuser; |
|
| 106 | - $langs=$this->savlangs; |
|
| 107 | - $db=$this->savdb; |
|
| 103 | + global $conf, $user, $langs, $db; |
|
| 104 | + $conf = $this->savconf; |
|
| 105 | + $user = $this->savuser; |
|
| 106 | + $langs = $this->savlangs; |
|
| 107 | + $db = $this->savdb; |
|
| 108 | 108 | |
| 109 | 109 | print __METHOD__."\n"; |
| 110 | 110 | //print $db->getVersion()."\n"; |
@@ -127,13 +127,13 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | public function testAccountingAccountCreate() |
| 129 | 129 | { |
| 130 | - global $conf,$user,$langs,$db; |
|
| 131 | - $conf=$this->savconf; |
|
| 132 | - $user=$this->savuser; |
|
| 133 | - $langs=$this->savlangs; |
|
| 134 | - $db=$this->savdb; |
|
| 130 | + global $conf, $user, $langs, $db; |
|
| 131 | + $conf = $this->savconf; |
|
| 132 | + $user = $this->savuser; |
|
| 133 | + $langs = $this->savlangs; |
|
| 134 | + $db = $this->savdb; |
|
| 135 | 135 | |
| 136 | - $localobject=new AccountingAccount($this->savdb); |
|
| 136 | + $localobject = new AccountingAccount($this->savdb); |
|
| 137 | 137 | $localobject->fk_pcg_version = 'PCG99-ABREGE'; |
| 138 | 138 | $localobject->account_category = 0; |
| 139 | 139 | $localobject->pcg_type = 'XXXXX'; |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | $localobject->account_parent = 0; |
| 142 | 142 | $localobject->label = 'Account specimen'; |
| 143 | 143 | $localobject->active = 0; |
| 144 | - $result=$localobject->create($user); |
|
| 144 | + $result = $localobject->create($user); |
|
| 145 | 145 | |
| 146 | 146 | $this->assertLessThan($result, 0); |
| 147 | 147 | print __METHOD__." result=".$result."\n"; |
@@ -159,14 +159,14 @@ discard block |
||
| 159 | 159 | */ |
| 160 | 160 | public function testAccountingAccountFetch($id) |
| 161 | 161 | { |
| 162 | - global $conf,$user,$langs,$db; |
|
| 163 | - $conf=$this->savconf; |
|
| 164 | - $user=$this->savuser; |
|
| 165 | - $langs=$this->savlangs; |
|
| 166 | - $db=$this->savdb; |
|
| 162 | + global $conf, $user, $langs, $db; |
|
| 163 | + $conf = $this->savconf; |
|
| 164 | + $user = $this->savuser; |
|
| 165 | + $langs = $this->savlangs; |
|
| 166 | + $db = $this->savdb; |
|
| 167 | 167 | |
| 168 | - $localobject=new AccountingAccount($this->savdb); |
|
| 169 | - $result=$localobject->fetch($id); |
|
| 168 | + $localobject = new AccountingAccount($this->savdb); |
|
| 169 | + $result = $localobject->fetch($id); |
|
| 170 | 170 | |
| 171 | 171 | $this->assertLessThan($result, 0); |
| 172 | 172 | print __METHOD__." id=".$id." result=".$result."\n"; |
@@ -184,14 +184,14 @@ discard block |
||
| 184 | 184 | */ |
| 185 | 185 | public function testAccountingAccountUpdate($localobject) |
| 186 | 186 | { |
| 187 | - global $conf,$user,$langs,$db; |
|
| 188 | - $conf=$this->savconf; |
|
| 189 | - $user=$this->savuser; |
|
| 190 | - $langs=$this->savlangs; |
|
| 191 | - $db=$this->savdb; |
|
| 187 | + global $conf, $user, $langs, $db; |
|
| 188 | + $conf = $this->savconf; |
|
| 189 | + $user = $this->savuser; |
|
| 190 | + $langs = $this->savlangs; |
|
| 191 | + $db = $this->savdb; |
|
| 192 | 192 | |
| 193 | - $localobject->label='New label'; |
|
| 194 | - $result=$localobject->update($user); |
|
| 193 | + $localobject->label = 'New label'; |
|
| 194 | + $result = $localobject->update($user); |
|
| 195 | 195 | |
| 196 | 196 | $this->assertLessThan($result, 0); |
| 197 | 197 | print __METHOD__." id=".$id." result=".$result."\n"; |
@@ -209,15 +209,15 @@ discard block |
||
| 209 | 209 | */ |
| 210 | 210 | public function testAccountingAccountDelete($id) |
| 211 | 211 | { |
| 212 | - global $conf,$user,$langs,$db; |
|
| 213 | - $conf=$this->savconf; |
|
| 214 | - $user=$this->savuser; |
|
| 215 | - $langs=$this->savlangs; |
|
| 216 | - $db=$this->savdb; |
|
| 217 | - |
|
| 218 | - $localobject=new AccountingAccount($this->savdb); |
|
| 219 | - $result=$localobject->fetch($id); |
|
| 220 | - $result=$localobject->delete($user); |
|
| 212 | + global $conf, $user, $langs, $db; |
|
| 213 | + $conf = $this->savconf; |
|
| 214 | + $user = $this->savuser; |
|
| 215 | + $langs = $this->savlangs; |
|
| 216 | + $db = $this->savdb; |
|
| 217 | + |
|
| 218 | + $localobject = new AccountingAccount($this->savdb); |
|
| 219 | + $result = $localobject->fetch($id); |
|
| 220 | + $result = $localobject->delete($user); |
|
| 221 | 221 | |
| 222 | 222 | print __METHOD__." id=".$id." result=".$result."\n"; |
| 223 | 223 | $this->assertLessThan($result, 0); |
@@ -31,9 +31,9 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | if (empty($user->id)) |
| 33 | 33 | { |
| 34 | - print "Load permissions for admin user nb 1\n"; |
|
| 35 | - $user->fetch(1); |
|
| 36 | - $user->getrights(); |
|
| 34 | + print "Load permissions for admin user nb 1\n"; |
|
| 35 | + $user->fetch(1); |
|
| 36 | + $user->getrights(); |
|
| 37 | 37 | } |
| 38 | 38 | $conf->global->MAIN_DISABLE_ALL_MAILS=1; |
| 39 | 39 | |
@@ -47,75 +47,75 @@ discard block |
||
| 47 | 47 | */ |
| 48 | 48 | class FactureTestRounding extends PHPUnit_Framework_TestCase |
| 49 | 49 | { |
| 50 | - protected $savconf; |
|
| 51 | - protected $savuser; |
|
| 52 | - protected $savlangs; |
|
| 53 | - protected $savdb; |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * Constructor |
|
| 57 | - * We save global variables into local variables |
|
| 58 | - * |
|
| 59 | - * @return FactureTest |
|
| 60 | - */ |
|
| 61 | - function __construct() |
|
| 62 | - { |
|
| 63 | - parent::__construct(); |
|
| 64 | - |
|
| 65 | - //$this->sharedFixture |
|
| 66 | - global $conf,$user,$langs,$db; |
|
| 67 | - $this->savconf=$conf; |
|
| 68 | - $this->savuser=$user; |
|
| 69 | - $this->savlangs=$langs; |
|
| 70 | - $this->savdb=$db; |
|
| 71 | - |
|
| 72 | - print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
|
| 73 | - //print " - db ".$db->db; |
|
| 74 | - print "\n"; |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - // Static methods |
|
| 78 | - public static function setUpBeforeClass() |
|
| 50 | + protected $savconf; |
|
| 51 | + protected $savuser; |
|
| 52 | + protected $savlangs; |
|
| 53 | + protected $savdb; |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * Constructor |
|
| 57 | + * We save global variables into local variables |
|
| 58 | + * |
|
| 59 | + * @return FactureTest |
|
| 60 | + */ |
|
| 61 | + function __construct() |
|
| 79 | 62 | { |
| 80 | - global $conf,$user,$langs,$db; |
|
| 81 | - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
| 63 | + parent::__construct(); |
|
| 82 | 64 | |
| 83 | - print __METHOD__."\n"; |
|
| 65 | + //$this->sharedFixture |
|
| 66 | + global $conf,$user,$langs,$db; |
|
| 67 | + $this->savconf=$conf; |
|
| 68 | + $this->savuser=$user; |
|
| 69 | + $this->savlangs=$langs; |
|
| 70 | + $this->savdb=$db; |
|
| 71 | + |
|
| 72 | + print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
|
| 73 | + //print " - db ".$db->db; |
|
| 74 | + print "\n"; |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + // Static methods |
|
| 78 | + public static function setUpBeforeClass() |
|
| 79 | + { |
|
| 80 | + global $conf,$user,$langs,$db; |
|
| 81 | + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
| 82 | + |
|
| 83 | + print __METHOD__."\n"; |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | // tear down after class |
| 87 | 87 | public static function tearDownAfterClass() |
| 88 | 88 | { |
| 89 | - global $conf,$user,$langs,$db; |
|
| 90 | - $db->rollback(); |
|
| 89 | + global $conf,$user,$langs,$db; |
|
| 90 | + $db->rollback(); |
|
| 91 | 91 | |
| 92 | - print __METHOD__."\n"; |
|
| 92 | + print __METHOD__."\n"; |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - /** |
|
| 96 | - * Init phpunit tests |
|
| 97 | - * |
|
| 98 | - * @return void |
|
| 99 | - */ |
|
| 100 | - protected function setUp() |
|
| 95 | + /** |
|
| 96 | + * Init phpunit tests |
|
| 97 | + * |
|
| 98 | + * @return void |
|
| 99 | + */ |
|
| 100 | + protected function setUp() |
|
| 101 | 101 | { |
| 102 | - global $conf,$user,$langs,$db; |
|
| 103 | - $conf=$this->savconf; |
|
| 104 | - $user=$this->savuser; |
|
| 105 | - $langs=$this->savlangs; |
|
| 106 | - $db=$this->savdb; |
|
| 102 | + global $conf,$user,$langs,$db; |
|
| 103 | + $conf=$this->savconf; |
|
| 104 | + $user=$this->savuser; |
|
| 105 | + $langs=$this->savlangs; |
|
| 106 | + $db=$this->savdb; |
|
| 107 | 107 | |
| 108 | - print __METHOD__."\n"; |
|
| 108 | + print __METHOD__."\n"; |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - /** |
|
| 112 | - * End phpunit tests |
|
| 113 | - * |
|
| 114 | - * @return void |
|
| 115 | - */ |
|
| 116 | - protected function tearDown() |
|
| 111 | + /** |
|
| 112 | + * End phpunit tests |
|
| 113 | + * |
|
| 114 | + * @return void |
|
| 115 | + */ |
|
| 116 | + protected function tearDown() |
|
| 117 | 117 | { |
| 118 | - print __METHOD__."\n"; |
|
| 118 | + print __METHOD__."\n"; |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | $langs=$this->savlangs; |
| 135 | 135 | $db=$this->savdb; |
| 136 | 136 | |
| 137 | - $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=0; |
|
| 137 | + $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=0; |
|
| 138 | 138 | |
| 139 | 139 | $localobject=new Facture($this->savdb); |
| 140 | 140 | $localobject->initAsSpecimen(); |
@@ -211,35 +211,35 @@ discard block |
||
| 211 | 211 | */ |
| 212 | 212 | public function testFactureAddLine1() |
| 213 | 213 | { |
| 214 | - global $conf,$user,$langs,$db; |
|
| 215 | - $conf=$this->savconf; |
|
| 216 | - $user=$this->savuser; |
|
| 217 | - $langs=$this->savlangs; |
|
| 218 | - $db=$this->savdb; |
|
| 219 | - |
|
| 220 | - // With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 0 |
|
| 221 | - $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=0; |
|
| 222 | - |
|
| 223 | - $localobject1a=new Facture($this->savdb); |
|
| 224 | - $localobject1a->initAsSpecimen('nolines'); |
|
| 225 | - $facid=$localobject1a->create($user); |
|
| 226 | - $localobject1a->addline('Line 1', 6.36, 15, 21); // This include update_price |
|
| 227 | - print __METHOD__." id=".$facid." total_ttc=".$localobject1a->total_ttc."\n"; |
|
| 228 | - $this->assertEquals(95.40, $localobject1a->total_ht); |
|
| 229 | - $this->assertEquals(20.03, $localobject1a->total_tva); |
|
| 230 | - $this->assertEquals(115.43, $localobject1a->total_ttc); |
|
| 231 | - |
|
| 232 | - // With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 1 |
|
| 233 | - $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=1; |
|
| 234 | - |
|
| 235 | - $localobject1b=new Facture($this->savdb); |
|
| 236 | - $localobject1b->initAsSpecimen('nolines'); |
|
| 237 | - $facid=$localobject1b->create($user); |
|
| 238 | - $localobject1b->addline('Line 1', 6.36, 15, 21); // This include update_price |
|
| 239 | - print __METHOD__." id=".$facid." total_ttc=".$localobject1b->total_ttc."\n"; |
|
| 240 | - $this->assertEquals(95.40, $localobject1b->total_ht, 'testFactureAddLine1 total_ht'); |
|
| 241 | - $this->assertEquals(20.03, $localobject1b->total_tva, 'testFactureAddLine1 total_tva'); |
|
| 242 | - $this->assertEquals(115.43, $localobject1b->total_ttc, 'testFactureAddLine1 total_ttc'); |
|
| 214 | + global $conf,$user,$langs,$db; |
|
| 215 | + $conf=$this->savconf; |
|
| 216 | + $user=$this->savuser; |
|
| 217 | + $langs=$this->savlangs; |
|
| 218 | + $db=$this->savdb; |
|
| 219 | + |
|
| 220 | + // With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 0 |
|
| 221 | + $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=0; |
|
| 222 | + |
|
| 223 | + $localobject1a=new Facture($this->savdb); |
|
| 224 | + $localobject1a->initAsSpecimen('nolines'); |
|
| 225 | + $facid=$localobject1a->create($user); |
|
| 226 | + $localobject1a->addline('Line 1', 6.36, 15, 21); // This include update_price |
|
| 227 | + print __METHOD__." id=".$facid." total_ttc=".$localobject1a->total_ttc."\n"; |
|
| 228 | + $this->assertEquals(95.40, $localobject1a->total_ht); |
|
| 229 | + $this->assertEquals(20.03, $localobject1a->total_tva); |
|
| 230 | + $this->assertEquals(115.43, $localobject1a->total_ttc); |
|
| 231 | + |
|
| 232 | + // With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 1 |
|
| 233 | + $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=1; |
|
| 234 | + |
|
| 235 | + $localobject1b=new Facture($this->savdb); |
|
| 236 | + $localobject1b->initAsSpecimen('nolines'); |
|
| 237 | + $facid=$localobject1b->create($user); |
|
| 238 | + $localobject1b->addline('Line 1', 6.36, 15, 21); // This include update_price |
|
| 239 | + print __METHOD__." id=".$facid." total_ttc=".$localobject1b->total_ttc."\n"; |
|
| 240 | + $this->assertEquals(95.40, $localobject1b->total_ht, 'testFactureAddLine1 total_ht'); |
|
| 241 | + $this->assertEquals(20.03, $localobject1b->total_tva, 'testFactureAddLine1 total_tva'); |
|
| 242 | + $this->assertEquals(115.43, $localobject1b->total_ttc, 'testFactureAddLine1 total_ttc'); |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | /** |
@@ -252,39 +252,39 @@ discard block |
||
| 252 | 252 | */ |
| 253 | 253 | public function testFactureAddLine2() |
| 254 | 254 | { |
| 255 | - global $conf,$user,$langs,$db; |
|
| 256 | - $conf=$this->savconf; |
|
| 257 | - $user=$this->savuser; |
|
| 258 | - $langs=$this->savlangs; |
|
| 259 | - $db=$this->savdb; |
|
| 260 | - |
|
| 261 | - // With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 0 |
|
| 262 | - $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=0; |
|
| 263 | - |
|
| 264 | - $localobject2=new Facture($this->savdb); |
|
| 265 | - $localobject2->initAsSpecimen('nolines'); |
|
| 266 | - $facid=$localobject2->create($user); |
|
| 267 | - $localobject2->addline('Line 1', 6.36, 5, 21); |
|
| 268 | - $localobject2->addline('Line 2', 6.36, 5, 21); |
|
| 269 | - $localobject2->addline('Line 3', 6.36, 5, 21); |
|
| 270 | - print __METHOD__." id=".$facid." total_ttc=".$localobject2->total_ttc."\n"; |
|
| 271 | - $this->assertEquals(95.40, $localobject2->total_ht); |
|
| 272 | - $this->assertEquals(20.04, $localobject2->total_tva); |
|
| 273 | - $this->assertEquals(115.44, $localobject2->total_ttc); |
|
| 274 | - |
|
| 275 | - // With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 1 |
|
| 276 | - $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=1; |
|
| 277 | - |
|
| 278 | - $localobject2=new Facture($this->savdb); |
|
| 279 | - $localobject2->initAsSpecimen('nolines'); |
|
| 280 | - $facid=$localobject2->create($user); |
|
| 281 | - $localobject2->addline('Line 1', 6.36, 5, 21); |
|
| 282 | - $localobject2->addline('Line 2', 6.36, 5, 21); |
|
| 283 | - $localobject2->addline('Line 3', 6.36, 5, 21); |
|
| 284 | - print __METHOD__." id=".$facid." total_ttc=".$localobject2->total_ttc."\n"; |
|
| 285 | - $this->assertEquals(95.40, $localobject2->total_ht); |
|
| 286 | - $this->assertEquals(20.03, $localobject2->total_tva); |
|
| 287 | - $this->assertEquals(115.43, $localobject2->total_ttc); |
|
| 255 | + global $conf,$user,$langs,$db; |
|
| 256 | + $conf=$this->savconf; |
|
| 257 | + $user=$this->savuser; |
|
| 258 | + $langs=$this->savlangs; |
|
| 259 | + $db=$this->savdb; |
|
| 260 | + |
|
| 261 | + // With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 0 |
|
| 262 | + $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=0; |
|
| 263 | + |
|
| 264 | + $localobject2=new Facture($this->savdb); |
|
| 265 | + $localobject2->initAsSpecimen('nolines'); |
|
| 266 | + $facid=$localobject2->create($user); |
|
| 267 | + $localobject2->addline('Line 1', 6.36, 5, 21); |
|
| 268 | + $localobject2->addline('Line 2', 6.36, 5, 21); |
|
| 269 | + $localobject2->addline('Line 3', 6.36, 5, 21); |
|
| 270 | + print __METHOD__." id=".$facid." total_ttc=".$localobject2->total_ttc."\n"; |
|
| 271 | + $this->assertEquals(95.40, $localobject2->total_ht); |
|
| 272 | + $this->assertEquals(20.04, $localobject2->total_tva); |
|
| 273 | + $this->assertEquals(115.44, $localobject2->total_ttc); |
|
| 274 | + |
|
| 275 | + // With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 1 |
|
| 276 | + $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=1; |
|
| 277 | + |
|
| 278 | + $localobject2=new Facture($this->savdb); |
|
| 279 | + $localobject2->initAsSpecimen('nolines'); |
|
| 280 | + $facid=$localobject2->create($user); |
|
| 281 | + $localobject2->addline('Line 1', 6.36, 5, 21); |
|
| 282 | + $localobject2->addline('Line 2', 6.36, 5, 21); |
|
| 283 | + $localobject2->addline('Line 3', 6.36, 5, 21); |
|
| 284 | + print __METHOD__." id=".$facid." total_ttc=".$localobject2->total_ttc."\n"; |
|
| 285 | + $this->assertEquals(95.40, $localobject2->total_ht); |
|
| 286 | + $this->assertEquals(20.03, $localobject2->total_tva); |
|
| 287 | + $this->assertEquals(115.43, $localobject2->total_ttc); |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | /** |
@@ -297,42 +297,42 @@ discard block |
||
| 297 | 297 | */ |
| 298 | 298 | public function testFactureAddLine3() |
| 299 | 299 | { |
| 300 | - global $conf,$user,$langs,$db; |
|
| 301 | - $conf=$this->savconf; |
|
| 302 | - $user=$this->savuser; |
|
| 303 | - $langs=$this->savlangs; |
|
| 304 | - $db=$this->savdb; |
|
| 305 | - |
|
| 306 | - // With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 0 |
|
| 307 | - $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=0; |
|
| 308 | - |
|
| 309 | - $localobject3=new Facture($this->savdb); |
|
| 310 | - $localobject3->initAsSpecimen('nolines'); |
|
| 311 | - $facid=$localobject3->create($user); |
|
| 312 | - $localobject3->addline('Line 1', 6.36, 3, 21); |
|
| 313 | - $localobject3->addline('Line 2', 6.36, 3, 21); |
|
| 314 | - $localobject3->addline('Line 3', 6.36, 3, 21); |
|
| 315 | - $localobject3->addline('Line 4', 6.36, 3, 21); |
|
| 316 | - $localobject3->addline('Line 5', 6.36, 3, 21); |
|
| 317 | - print __METHOD__." id=".$facid." total_ttc=".$localobject3->total_ttc."\n"; |
|
| 318 | - $this->assertEquals(95.40, $localobject3->total_ht); |
|
| 319 | - $this->assertEquals(20.05, $localobject3->total_tva); |
|
| 320 | - $this->assertEquals(115.45, $localobject3->total_ttc); |
|
| 321 | - |
|
| 322 | - // With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 1 |
|
| 323 | - $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=1; |
|
| 324 | - |
|
| 325 | - $localobject3=new Facture($this->savdb); |
|
| 326 | - $localobject3->initAsSpecimen('nolines'); |
|
| 327 | - $facid=$localobject3->create($user); |
|
| 328 | - $localobject3->addline('Line 1', 6.36, 3, 21); |
|
| 329 | - $localobject3->addline('Line 2', 6.36, 3, 21); |
|
| 330 | - $localobject3->addline('Line 3', 6.36, 3, 21); |
|
| 331 | - $localobject3->addline('Line 4', 6.36, 3, 21); |
|
| 332 | - $localobject3->addline('Line 5', 6.36, 3, 21); |
|
| 333 | - print __METHOD__." id=".$facid." total_ttc=".$localobject3->total_ttc."\n"; |
|
| 334 | - $this->assertEquals(95.40, $localobject3->total_ht); |
|
| 335 | - $this->assertEquals(20.03, $localobject3->total_tva); |
|
| 336 | - $this->assertEquals(115.43, $localobject3->total_ttc); |
|
| 300 | + global $conf,$user,$langs,$db; |
|
| 301 | + $conf=$this->savconf; |
|
| 302 | + $user=$this->savuser; |
|
| 303 | + $langs=$this->savlangs; |
|
| 304 | + $db=$this->savdb; |
|
| 305 | + |
|
| 306 | + // With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 0 |
|
| 307 | + $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=0; |
|
| 308 | + |
|
| 309 | + $localobject3=new Facture($this->savdb); |
|
| 310 | + $localobject3->initAsSpecimen('nolines'); |
|
| 311 | + $facid=$localobject3->create($user); |
|
| 312 | + $localobject3->addline('Line 1', 6.36, 3, 21); |
|
| 313 | + $localobject3->addline('Line 2', 6.36, 3, 21); |
|
| 314 | + $localobject3->addline('Line 3', 6.36, 3, 21); |
|
| 315 | + $localobject3->addline('Line 4', 6.36, 3, 21); |
|
| 316 | + $localobject3->addline('Line 5', 6.36, 3, 21); |
|
| 317 | + print __METHOD__." id=".$facid." total_ttc=".$localobject3->total_ttc."\n"; |
|
| 318 | + $this->assertEquals(95.40, $localobject3->total_ht); |
|
| 319 | + $this->assertEquals(20.05, $localobject3->total_tva); |
|
| 320 | + $this->assertEquals(115.45, $localobject3->total_ttc); |
|
| 321 | + |
|
| 322 | + // With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 1 |
|
| 323 | + $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=1; |
|
| 324 | + |
|
| 325 | + $localobject3=new Facture($this->savdb); |
|
| 326 | + $localobject3->initAsSpecimen('nolines'); |
|
| 327 | + $facid=$localobject3->create($user); |
|
| 328 | + $localobject3->addline('Line 1', 6.36, 3, 21); |
|
| 329 | + $localobject3->addline('Line 2', 6.36, 3, 21); |
|
| 330 | + $localobject3->addline('Line 3', 6.36, 3, 21); |
|
| 331 | + $localobject3->addline('Line 4', 6.36, 3, 21); |
|
| 332 | + $localobject3->addline('Line 5', 6.36, 3, 21); |
|
| 333 | + print __METHOD__." id=".$facid." total_ttc=".$localobject3->total_ttc."\n"; |
|
| 334 | + $this->assertEquals(95.40, $localobject3->total_ht); |
|
| 335 | + $this->assertEquals(20.03, $localobject3->total_tva); |
|
| 336 | + $this->assertEquals(115.43, $localobject3->total_ttc); |
|
| 337 | 337 | } |
| 338 | 338 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * \remarks To run this script as CLI: phpunit filename.php |
| 24 | 24 | */ |
| 25 | 25 | |
| 26 | -global $conf,$user,$langs,$db; |
|
| 26 | +global $conf, $user, $langs, $db; |
|
| 27 | 27 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
| 28 | 28 | //require_once 'PHPUnit/Autoload.php'; |
| 29 | 29 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | $user->fetch(1); |
| 36 | 36 | $user->getrights(); |
| 37 | 37 | } |
| 38 | -$conf->global->MAIN_DISABLE_ALL_MAILS=1; |
|
| 38 | +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
|
| 39 | 39 | |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -63,11 +63,11 @@ discard block |
||
| 63 | 63 | parent::__construct(); |
| 64 | 64 | |
| 65 | 65 | //$this->sharedFixture |
| 66 | - global $conf,$user,$langs,$db; |
|
| 67 | - $this->savconf=$conf; |
|
| 68 | - $this->savuser=$user; |
|
| 69 | - $this->savlangs=$langs; |
|
| 70 | - $this->savdb=$db; |
|
| 66 | + global $conf, $user, $langs, $db; |
|
| 67 | + $this->savconf = $conf; |
|
| 68 | + $this->savuser = $user; |
|
| 69 | + $this->savlangs = $langs; |
|
| 70 | + $this->savdb = $db; |
|
| 71 | 71 | |
| 72 | 72 | print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
| 73 | 73 | //print " - db ".$db->db; |
@@ -77,8 +77,8 @@ discard block |
||
| 77 | 77 | // Static methods |
| 78 | 78 | public static function setUpBeforeClass() |
| 79 | 79 | { |
| 80 | - global $conf,$user,$langs,$db; |
|
| 81 | - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
| 80 | + global $conf, $user, $langs, $db; |
|
| 81 | + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
| 82 | 82 | |
| 83 | 83 | print __METHOD__."\n"; |
| 84 | 84 | } |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | // tear down after class |
| 87 | 87 | public static function tearDownAfterClass() |
| 88 | 88 | { |
| 89 | - global $conf,$user,$langs,$db; |
|
| 89 | + global $conf, $user, $langs, $db; |
|
| 90 | 90 | $db->rollback(); |
| 91 | 91 | |
| 92 | 92 | print __METHOD__."\n"; |
@@ -99,11 +99,11 @@ discard block |
||
| 99 | 99 | */ |
| 100 | 100 | protected function setUp() |
| 101 | 101 | { |
| 102 | - global $conf,$user,$langs,$db; |
|
| 103 | - $conf=$this->savconf; |
|
| 104 | - $user=$this->savuser; |
|
| 105 | - $langs=$this->savlangs; |
|
| 106 | - $db=$this->savdb; |
|
| 102 | + global $conf, $user, $langs, $db; |
|
| 103 | + $conf = $this->savconf; |
|
| 104 | + $user = $this->savuser; |
|
| 105 | + $langs = $this->savlangs; |
|
| 106 | + $db = $this->savdb; |
|
| 107 | 107 | |
| 108 | 108 | print __METHOD__."\n"; |
| 109 | 109 | } |
@@ -128,29 +128,29 @@ discard block |
||
| 128 | 128 | */ |
| 129 | 129 | public function testFactureRoundingCreate1() |
| 130 | 130 | { |
| 131 | - global $conf,$user,$langs,$db; |
|
| 132 | - $conf=$this->savconf; |
|
| 133 | - $user=$this->savuser; |
|
| 134 | - $langs=$this->savlangs; |
|
| 135 | - $db=$this->savdb; |
|
| 131 | + global $conf, $user, $langs, $db; |
|
| 132 | + $conf = $this->savconf; |
|
| 133 | + $user = $this->savuser; |
|
| 134 | + $langs = $this->savlangs; |
|
| 135 | + $db = $this->savdb; |
|
| 136 | 136 | |
| 137 | - $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=0; |
|
| 137 | + $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 0; |
|
| 138 | 138 | |
| 139 | - $localobject=new Facture($this->savdb); |
|
| 139 | + $localobject = new Facture($this->savdb); |
|
| 140 | 140 | $localobject->initAsSpecimen(); |
| 141 | - $localobject->lines=array(); |
|
| 141 | + $localobject->lines = array(); |
|
| 142 | 142 | unset($localobject->total_ht); |
| 143 | 143 | unset($localobject->total_ttc); |
| 144 | 144 | unset($localobject->total_tva); |
| 145 | - $result=$localobject->create($user); |
|
| 145 | + $result = $localobject->create($user); |
|
| 146 | 146 | |
| 147 | 147 | // Add two lines |
| 148 | - for ($i=0; $i<2; $i++) |
|
| 148 | + for ($i = 0; $i < 2; $i++) |
|
| 149 | 149 | { |
| 150 | 150 | $localobject->addline('Description '.$i, 1.24, 1, 10); |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - $newlocalobject=new Facture($this->savdb); |
|
| 153 | + $newlocalobject = new Facture($this->savdb); |
|
| 154 | 154 | $newlocalobject->fetch($result); |
| 155 | 155 | //var_dump($newlocalobject); |
| 156 | 156 | |
@@ -171,29 +171,29 @@ discard block |
||
| 171 | 171 | */ |
| 172 | 172 | public function testFactureRoundingCreate2() |
| 173 | 173 | { |
| 174 | - global $conf,$user,$langs,$db; |
|
| 175 | - $conf=$this->savconf; |
|
| 176 | - $user=$this->savuser; |
|
| 177 | - $langs=$this->savlangs; |
|
| 178 | - $db=$this->savdb; |
|
| 174 | + global $conf, $user, $langs, $db; |
|
| 175 | + $conf = $this->savconf; |
|
| 176 | + $user = $this->savuser; |
|
| 177 | + $langs = $this->savlangs; |
|
| 178 | + $db = $this->savdb; |
|
| 179 | 179 | |
| 180 | - $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=0; |
|
| 180 | + $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 0; |
|
| 181 | 181 | |
| 182 | - $localobject=new Facture($this->savdb); |
|
| 182 | + $localobject = new Facture($this->savdb); |
|
| 183 | 183 | $localobject->initAsSpecimen(); |
| 184 | - $localobject->lines=array(); |
|
| 184 | + $localobject->lines = array(); |
|
| 185 | 185 | unset($localobject->total_ht); |
| 186 | 186 | unset($localobject->total_ttc); |
| 187 | 187 | unset($localobject->total_vat); |
| 188 | - $result=$localobject->create($user); |
|
| 188 | + $result = $localobject->create($user); |
|
| 189 | 189 | |
| 190 | 190 | // Add two lines |
| 191 | - for ($i=0; $i<2; $i++) |
|
| 191 | + for ($i = 0; $i < 2; $i++) |
|
| 192 | 192 | { |
| 193 | 193 | $localobject->addline('Description '.$i, 1.24, 1, 10); |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | - $newlocalobject=new Facture($this->savdb); |
|
| 196 | + $newlocalobject = new Facture($this->savdb); |
|
| 197 | 197 | $newlocalobject->fetch($result); |
| 198 | 198 | //var_dump($newlocalobject); |
| 199 | 199 | |
@@ -211,31 +211,31 @@ discard block |
||
| 211 | 211 | */ |
| 212 | 212 | public function testFactureAddLine1() |
| 213 | 213 | { |
| 214 | - global $conf,$user,$langs,$db; |
|
| 215 | - $conf=$this->savconf; |
|
| 216 | - $user=$this->savuser; |
|
| 217 | - $langs=$this->savlangs; |
|
| 218 | - $db=$this->savdb; |
|
| 214 | + global $conf, $user, $langs, $db; |
|
| 215 | + $conf = $this->savconf; |
|
| 216 | + $user = $this->savuser; |
|
| 217 | + $langs = $this->savlangs; |
|
| 218 | + $db = $this->savdb; |
|
| 219 | 219 | |
| 220 | 220 | // With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 0 |
| 221 | - $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=0; |
|
| 221 | + $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 0; |
|
| 222 | 222 | |
| 223 | - $localobject1a=new Facture($this->savdb); |
|
| 223 | + $localobject1a = new Facture($this->savdb); |
|
| 224 | 224 | $localobject1a->initAsSpecimen('nolines'); |
| 225 | - $facid=$localobject1a->create($user); |
|
| 226 | - $localobject1a->addline('Line 1', 6.36, 15, 21); // This include update_price |
|
| 225 | + $facid = $localobject1a->create($user); |
|
| 226 | + $localobject1a->addline('Line 1', 6.36, 15, 21); // This include update_price |
|
| 227 | 227 | print __METHOD__." id=".$facid." total_ttc=".$localobject1a->total_ttc."\n"; |
| 228 | 228 | $this->assertEquals(95.40, $localobject1a->total_ht); |
| 229 | 229 | $this->assertEquals(20.03, $localobject1a->total_tva); |
| 230 | 230 | $this->assertEquals(115.43, $localobject1a->total_ttc); |
| 231 | 231 | |
| 232 | 232 | // With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 1 |
| 233 | - $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=1; |
|
| 233 | + $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 1; |
|
| 234 | 234 | |
| 235 | - $localobject1b=new Facture($this->savdb); |
|
| 235 | + $localobject1b = new Facture($this->savdb); |
|
| 236 | 236 | $localobject1b->initAsSpecimen('nolines'); |
| 237 | - $facid=$localobject1b->create($user); |
|
| 238 | - $localobject1b->addline('Line 1', 6.36, 15, 21); // This include update_price |
|
| 237 | + $facid = $localobject1b->create($user); |
|
| 238 | + $localobject1b->addline('Line 1', 6.36, 15, 21); // This include update_price |
|
| 239 | 239 | print __METHOD__." id=".$facid." total_ttc=".$localobject1b->total_ttc."\n"; |
| 240 | 240 | $this->assertEquals(95.40, $localobject1b->total_ht, 'testFactureAddLine1 total_ht'); |
| 241 | 241 | $this->assertEquals(20.03, $localobject1b->total_tva, 'testFactureAddLine1 total_tva'); |
@@ -252,18 +252,18 @@ discard block |
||
| 252 | 252 | */ |
| 253 | 253 | public function testFactureAddLine2() |
| 254 | 254 | { |
| 255 | - global $conf,$user,$langs,$db; |
|
| 256 | - $conf=$this->savconf; |
|
| 257 | - $user=$this->savuser; |
|
| 258 | - $langs=$this->savlangs; |
|
| 259 | - $db=$this->savdb; |
|
| 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 | 261 | // With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 0 |
| 262 | - $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=0; |
|
| 262 | + $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 0; |
|
| 263 | 263 | |
| 264 | - $localobject2=new Facture($this->savdb); |
|
| 264 | + $localobject2 = new Facture($this->savdb); |
|
| 265 | 265 | $localobject2->initAsSpecimen('nolines'); |
| 266 | - $facid=$localobject2->create($user); |
|
| 266 | + $facid = $localobject2->create($user); |
|
| 267 | 267 | $localobject2->addline('Line 1', 6.36, 5, 21); |
| 268 | 268 | $localobject2->addline('Line 2', 6.36, 5, 21); |
| 269 | 269 | $localobject2->addline('Line 3', 6.36, 5, 21); |
@@ -273,11 +273,11 @@ discard block |
||
| 273 | 273 | $this->assertEquals(115.44, $localobject2->total_ttc); |
| 274 | 274 | |
| 275 | 275 | // With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 1 |
| 276 | - $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=1; |
|
| 276 | + $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 1; |
|
| 277 | 277 | |
| 278 | - $localobject2=new Facture($this->savdb); |
|
| 278 | + $localobject2 = new Facture($this->savdb); |
|
| 279 | 279 | $localobject2->initAsSpecimen('nolines'); |
| 280 | - $facid=$localobject2->create($user); |
|
| 280 | + $facid = $localobject2->create($user); |
|
| 281 | 281 | $localobject2->addline('Line 1', 6.36, 5, 21); |
| 282 | 282 | $localobject2->addline('Line 2', 6.36, 5, 21); |
| 283 | 283 | $localobject2->addline('Line 3', 6.36, 5, 21); |
@@ -297,18 +297,18 @@ discard block |
||
| 297 | 297 | */ |
| 298 | 298 | public function testFactureAddLine3() |
| 299 | 299 | { |
| 300 | - global $conf,$user,$langs,$db; |
|
| 301 | - $conf=$this->savconf; |
|
| 302 | - $user=$this->savuser; |
|
| 303 | - $langs=$this->savlangs; |
|
| 304 | - $db=$this->savdb; |
|
| 300 | + global $conf, $user, $langs, $db; |
|
| 301 | + $conf = $this->savconf; |
|
| 302 | + $user = $this->savuser; |
|
| 303 | + $langs = $this->savlangs; |
|
| 304 | + $db = $this->savdb; |
|
| 305 | 305 | |
| 306 | 306 | // With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 0 |
| 307 | - $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=0; |
|
| 307 | + $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 0; |
|
| 308 | 308 | |
| 309 | - $localobject3=new Facture($this->savdb); |
|
| 309 | + $localobject3 = new Facture($this->savdb); |
|
| 310 | 310 | $localobject3->initAsSpecimen('nolines'); |
| 311 | - $facid=$localobject3->create($user); |
|
| 311 | + $facid = $localobject3->create($user); |
|
| 312 | 312 | $localobject3->addline('Line 1', 6.36, 3, 21); |
| 313 | 313 | $localobject3->addline('Line 2', 6.36, 3, 21); |
| 314 | 314 | $localobject3->addline('Line 3', 6.36, 3, 21); |
@@ -320,11 +320,11 @@ discard block |
||
| 320 | 320 | $this->assertEquals(115.45, $localobject3->total_ttc); |
| 321 | 321 | |
| 322 | 322 | // With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 1 |
| 323 | - $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=1; |
|
| 323 | + $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 1; |
|
| 324 | 324 | |
| 325 | - $localobject3=new Facture($this->savdb); |
|
| 325 | + $localobject3 = new Facture($this->savdb); |
|
| 326 | 326 | $localobject3->initAsSpecimen('nolines'); |
| 327 | - $facid=$localobject3->create($user); |
|
| 327 | + $facid = $localobject3->create($user); |
|
| 328 | 328 | $localobject3->addline('Line 1', 6.36, 3, 21); |
| 329 | 329 | $localobject3->addline('Line 2', 6.36, 3, 21); |
| 330 | 330 | $localobject3->addline('Line 3', 6.36, 3, 21); |
@@ -49,74 +49,74 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | class ImportTest extends PHPUnit_Framework_TestCase |
| 51 | 51 | { |
| 52 | - protected $savconf; |
|
| 53 | - protected $savuser; |
|
| 54 | - protected $savlangs; |
|
| 55 | - protected $savdb; |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * Constructor |
|
| 59 | - * We save global variables into local variables |
|
| 60 | - * |
|
| 61 | - * @return ImportTest |
|
| 62 | - */ |
|
| 63 | - function __construct() |
|
| 64 | - { |
|
| 65 | - parent::__construct(); |
|
| 66 | - |
|
| 67 | - //$this->sharedFixture |
|
| 68 | - global $conf,$user,$langs,$db; |
|
| 69 | - $this->savconf=$conf; |
|
| 70 | - $this->savuser=$user; |
|
| 71 | - $this->savlangs=$langs; |
|
| 72 | - $this->savdb=$db; |
|
| 73 | - |
|
| 74 | - print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
|
| 75 | - //print " - db ".$db->db; |
|
| 76 | - print "\n"; |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - // Static methods |
|
| 80 | - public static function setUpBeforeClass() |
|
| 52 | + protected $savconf; |
|
| 53 | + protected $savuser; |
|
| 54 | + protected $savlangs; |
|
| 55 | + protected $savdb; |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * Constructor |
|
| 59 | + * We save global variables into local variables |
|
| 60 | + * |
|
| 61 | + * @return ImportTest |
|
| 62 | + */ |
|
| 63 | + function __construct() |
|
| 64 | + { |
|
| 65 | + parent::__construct(); |
|
| 66 | + |
|
| 67 | + //$this->sharedFixture |
|
| 68 | + global $conf,$user,$langs,$db; |
|
| 69 | + $this->savconf=$conf; |
|
| 70 | + $this->savuser=$user; |
|
| 71 | + $this->savlangs=$langs; |
|
| 72 | + $this->savdb=$db; |
|
| 73 | + |
|
| 74 | + print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
|
| 75 | + //print " - db ".$db->db; |
|
| 76 | + print "\n"; |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + // Static methods |
|
| 80 | + public static function setUpBeforeClass() |
|
| 81 | 81 | { |
| 82 | - global $conf,$user,$langs,$db; |
|
| 83 | - //$db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
| 82 | + global $conf,$user,$langs,$db; |
|
| 83 | + //$db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
| 84 | 84 | |
| 85 | - print __METHOD__."\n"; |
|
| 85 | + print __METHOD__."\n"; |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | // tear down after class |
| 89 | 89 | public static function tearDownAfterClass() |
| 90 | 90 | { |
| 91 | - global $conf,$user,$langs,$db; |
|
| 92 | - //$db->rollback(); |
|
| 91 | + global $conf,$user,$langs,$db; |
|
| 92 | + //$db->rollback(); |
|
| 93 | 93 | |
| 94 | - print __METHOD__."\n"; |
|
| 94 | + print __METHOD__."\n"; |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - /** |
|
| 98 | - * Init phpunit tests |
|
| 99 | - * |
|
| 100 | - * @return void |
|
| 101 | - */ |
|
| 97 | + /** |
|
| 98 | + * Init phpunit tests |
|
| 99 | + * |
|
| 100 | + * @return void |
|
| 101 | + */ |
|
| 102 | 102 | protected function setUp() |
| 103 | 103 | { |
| 104 | - global $conf,$user,$langs,$db; |
|
| 105 | - $conf=$this->savconf; |
|
| 106 | - $user=$this->savuser; |
|
| 107 | - $langs=$this->savlangs; |
|
| 108 | - $db=$this->savdb; |
|
| 104 | + global $conf,$user,$langs,$db; |
|
| 105 | + $conf=$this->savconf; |
|
| 106 | + $user=$this->savuser; |
|
| 107 | + $langs=$this->savlangs; |
|
| 108 | + $db=$this->savdb; |
|
| 109 | 109 | |
| 110 | - print __METHOD__."\n"; |
|
| 110 | + print __METHOD__."\n"; |
|
| 111 | 111 | } |
| 112 | - /** |
|
| 113 | - * End phpunit tests |
|
| 114 | - * |
|
| 115 | - * @return void |
|
| 116 | - */ |
|
| 112 | + /** |
|
| 113 | + * End phpunit tests |
|
| 114 | + * |
|
| 115 | + * @return void |
|
| 116 | + */ |
|
| 117 | 117 | protected function tearDown() |
| 118 | 118 | { |
| 119 | - print __METHOD__."\n"; |
|
| 119 | + print __METHOD__."\n"; |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | |
@@ -134,6 +134,6 @@ discard block |
||
| 134 | 134 | // according to option |
| 135 | 135 | |
| 136 | 136 | |
| 137 | - return true; |
|
| 137 | + return true; |
|
| 138 | 138 | } |
| 139 | 139 | } |
@@ -23,21 +23,21 @@ discard block |
||
| 23 | 23 | * \remarks To run this script as CLI: phpunit filename.php |
| 24 | 24 | */ |
| 25 | 25 | |
| 26 | -global $conf,$user,$langs,$db; |
|
| 26 | +global $conf, $user, $langs, $db; |
|
| 27 | 27 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
| 28 | 28 | //require_once 'PHPUnit/Autoload.php'; |
| 29 | 29 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
| 30 | 30 | |
| 31 | -if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); |
|
| 32 | -if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); |
|
| 33 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
| 34 | -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); |
|
| 35 | -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); |
|
| 36 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); |
|
| 37 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show |
|
| 38 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php |
|
| 39 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
| 40 | -if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) |
|
| 31 | +if (!defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); |
|
| 32 | +if (!defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); |
|
| 33 | +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); |
|
| 34 | +if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); |
|
| 35 | +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); |
|
| 36 | +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); |
|
| 37 | +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no menu to show |
|
| 38 | +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php |
|
| 39 | +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); |
|
| 40 | +if (!defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) |
|
| 41 | 41 | |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -65,11 +65,11 @@ discard block |
||
| 65 | 65 | parent::__construct(); |
| 66 | 66 | |
| 67 | 67 | //$this->sharedFixture |
| 68 | - global $conf,$user,$langs,$db; |
|
| 69 | - $this->savconf=$conf; |
|
| 70 | - $this->savuser=$user; |
|
| 71 | - $this->savlangs=$langs; |
|
| 72 | - $this->savdb=$db; |
|
| 68 | + global $conf, $user, $langs, $db; |
|
| 69 | + $this->savconf = $conf; |
|
| 70 | + $this->savuser = $user; |
|
| 71 | + $this->savlangs = $langs; |
|
| 72 | + $this->savdb = $db; |
|
| 73 | 73 | |
| 74 | 74 | print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
| 75 | 75 | //print " - db ".$db->db; |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | // Static methods |
| 80 | 80 | public static function setUpBeforeClass() |
| 81 | 81 | { |
| 82 | - global $conf,$user,$langs,$db; |
|
| 82 | + global $conf, $user, $langs, $db; |
|
| 83 | 83 | //$db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
| 84 | 84 | |
| 85 | 85 | print __METHOD__."\n"; |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | // tear down after class |
| 89 | 89 | public static function tearDownAfterClass() |
| 90 | 90 | { |
| 91 | - global $conf,$user,$langs,$db; |
|
| 91 | + global $conf, $user, $langs, $db; |
|
| 92 | 92 | //$db->rollback(); |
| 93 | 93 | |
| 94 | 94 | print __METHOD__."\n"; |
@@ -101,11 +101,11 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | protected function setUp() |
| 103 | 103 | { |
| 104 | - global $conf,$user,$langs,$db; |
|
| 105 | - $conf=$this->savconf; |
|
| 106 | - $user=$this->savuser; |
|
| 107 | - $langs=$this->savlangs; |
|
| 108 | - $db=$this->savdb; |
|
| 104 | + global $conf, $user, $langs, $db; |
|
| 105 | + $conf = $this->savconf; |
|
| 106 | + $user = $this->savuser; |
|
| 107 | + $langs = $this->savlangs; |
|
| 108 | + $db = $this->savdb; |
|
| 109 | 109 | |
| 110 | 110 | print __METHOD__."\n"; |
| 111 | 111 | } |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | public function testImportSample1() |
| 129 | 129 | { |
| 130 | - $file=dirname(__FILE__).'/Example_import_company_1.csv'; |
|
| 130 | + $file = dirname(__FILE__).'/Example_import_company_1.csv'; |
|
| 131 | 131 | |
| 132 | 132 | // TODO |
| 133 | 133 | // Run import on file and check the record with field "auto" are filled |
@@ -28,16 +28,39 @@ |
||
| 28 | 28 | //require_once 'PHPUnit/Autoload.php'; |
| 29 | 29 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
| 30 | 30 | |
| 31 | -if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); |
|
| 32 | -if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); |
|
| 33 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
| 34 | -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); |
|
| 35 | -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); |
|
| 36 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); |
|
| 37 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show |
|
| 38 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php |
|
| 39 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
| 40 | -if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) |
|
| 31 | +if (! defined('NOREQUIREUSER')) { |
|
| 32 | + define('NOREQUIREUSER','1'); |
|
| 33 | +} |
|
| 34 | +if (! defined('NOREQUIREDB')) { |
|
| 35 | + define('NOREQUIREDB','1'); |
|
| 36 | +} |
|
| 37 | +if (! defined('NOREQUIRESOC')) { |
|
| 38 | + define('NOREQUIRESOC','1'); |
|
| 39 | +} |
|
| 40 | +if (! defined('NOREQUIRETRAN')) { |
|
| 41 | + define('NOREQUIRETRAN','1'); |
|
| 42 | +} |
|
| 43 | +if (! defined('NOCSRFCHECK')) { |
|
| 44 | + define('NOCSRFCHECK','1'); |
|
| 45 | +} |
|
| 46 | +if (! defined('NOTOKENRENEWAL')) { |
|
| 47 | + define('NOTOKENRENEWAL','1'); |
|
| 48 | +} |
|
| 49 | +if (! defined('NOREQUIREMENU')) { |
|
| 50 | + define('NOREQUIREMENU','1'); |
|
| 51 | +} |
|
| 52 | +// If there is no menu to show |
|
| 53 | +if (! defined('NOREQUIREHTML')) { |
|
| 54 | + define('NOREQUIREHTML','1'); |
|
| 55 | +} |
|
| 56 | +// If we don't need to load the html.form.class.php |
|
| 57 | +if (! defined('NOREQUIREAJAX')) { |
|
| 58 | + define('NOREQUIREAJAX','1'); |
|
| 59 | +} |
|
| 60 | +if (! defined("NOLOGIN")) { |
|
| 61 | + define("NOLOGIN",'1'); |
|
| 62 | +} |
|
| 63 | +// If this page is public (can be called outside logged session) |
|
| 41 | 64 | |
| 42 | 65 | |
| 43 | 66 | /** |