@@ -32,12 +32,12 @@ discard block |
||
32 | 32 | // Test if batch mode |
33 | 33 | if (substr($sapi_type, 0, 3) == 'cgi') { |
34 | 34 | echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; |
35 | - exit(-1); |
|
35 | + exit(-1); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | if (! isset($argv[1]) || ! $argv[1]) { |
39 | 39 | print "Usage: ".$script_file." now\n"; |
40 | - exit(-1); |
|
40 | + exit(-1); |
|
41 | 41 | } |
42 | 42 | $now=$argv[1]; |
43 | 43 | |
@@ -72,60 +72,60 @@ discard block |
||
72 | 72 | $resql = $db->query($sql); |
73 | 73 | if ($resql) |
74 | 74 | { |
75 | - $num = $db->num_rows($resql); |
|
76 | - $i = 0; |
|
77 | - |
|
78 | - $ldap=new Ldap(); |
|
79 | - $result=$ldap->connect_bind(); |
|
80 | - |
|
81 | - if ($result > 0) |
|
82 | - { |
|
83 | - while ($i < $num) |
|
84 | - { |
|
85 | - $ldap->error=""; |
|
86 | - |
|
87 | - $obj = $db->fetch_object($resql); |
|
88 | - |
|
89 | - $membertype = new AdherentType($db); |
|
90 | - $membertype->id = $obj->rowid; |
|
91 | - $membertype->fetch($membertype->id); |
|
92 | - |
|
93 | - print $langs->trans("UpdateMemberType")." rowid=".$membertype->id." ".$membertype-label; |
|
94 | - |
|
95 | - $oldobject=$membertype; |
|
96 | - |
|
97 | - $oldinfo=$membertype->_load_ldap_info(); |
|
98 | - $olddn=$membertype->_load_ldap_dn($oldinfo); |
|
99 | - |
|
100 | - $info=$membertype->_load_ldap_info(); |
|
101 | - $dn=$membertype->_load_ldap_dn($info); |
|
102 | - |
|
103 | - $result=$ldap->add($dn,$info,$user); // Wil fail if already exists |
|
104 | - $result=$ldap->update($dn,$info,$user,$olddn); |
|
105 | - if ($result > 0) |
|
106 | - { |
|
107 | - print " - ".$langs->trans("OK"); |
|
108 | - } |
|
109 | - else |
|
110 | - { |
|
111 | - $error++; |
|
112 | - print " - ".$langs->trans("KO").' - '.$ldap->error; |
|
113 | - } |
|
114 | - print "\n"; |
|
115 | - |
|
116 | - $i++; |
|
117 | - } |
|
118 | - |
|
119 | - $ldap->unbind(); |
|
120 | - $ldap->close(); |
|
121 | - } |
|
122 | - else { |
|
123 | - print $ldap->error; |
|
124 | - } |
|
75 | + $num = $db->num_rows($resql); |
|
76 | + $i = 0; |
|
77 | + |
|
78 | + $ldap=new Ldap(); |
|
79 | + $result=$ldap->connect_bind(); |
|
80 | + |
|
81 | + if ($result > 0) |
|
82 | + { |
|
83 | + while ($i < $num) |
|
84 | + { |
|
85 | + $ldap->error=""; |
|
86 | + |
|
87 | + $obj = $db->fetch_object($resql); |
|
88 | + |
|
89 | + $membertype = new AdherentType($db); |
|
90 | + $membertype->id = $obj->rowid; |
|
91 | + $membertype->fetch($membertype->id); |
|
92 | + |
|
93 | + print $langs->trans("UpdateMemberType")." rowid=".$membertype->id." ".$membertype-label; |
|
94 | + |
|
95 | + $oldobject=$membertype; |
|
96 | + |
|
97 | + $oldinfo=$membertype->_load_ldap_info(); |
|
98 | + $olddn=$membertype->_load_ldap_dn($oldinfo); |
|
99 | + |
|
100 | + $info=$membertype->_load_ldap_info(); |
|
101 | + $dn=$membertype->_load_ldap_dn($info); |
|
102 | + |
|
103 | + $result=$ldap->add($dn,$info,$user); // Wil fail if already exists |
|
104 | + $result=$ldap->update($dn,$info,$user,$olddn); |
|
105 | + if ($result > 0) |
|
106 | + { |
|
107 | + print " - ".$langs->trans("OK"); |
|
108 | + } |
|
109 | + else |
|
110 | + { |
|
111 | + $error++; |
|
112 | + print " - ".$langs->trans("KO").' - '.$ldap->error; |
|
113 | + } |
|
114 | + print "\n"; |
|
115 | + |
|
116 | + $i++; |
|
117 | + } |
|
118 | + |
|
119 | + $ldap->unbind(); |
|
120 | + $ldap->close(); |
|
121 | + } |
|
122 | + else { |
|
123 | + print $ldap->error; |
|
124 | + } |
|
125 | 125 | } |
126 | 126 | else |
127 | 127 | { |
128 | - dol_print_error($db); |
|
128 | + dol_print_error($db); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | exit($error); |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | // Test if batch mode |
34 | 34 | if (substr($sapi_type, 0, 3) == 'cgi') { |
35 | 35 | echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; |
36 | - exit(-1); |
|
36 | + exit(-1); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | require_once $path."../../htdocs/master.inc.php"; |
@@ -60,10 +60,10 @@ discard block |
||
60 | 60 | |
61 | 61 | // List of fields to get from LDAP |
62 | 62 | $required_fields = array( |
63 | - $conf->global->LDAP_KEY_MEMBERS_TYPES, |
|
64 | - $conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME, |
|
65 | - $conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION, |
|
66 | - $conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS |
|
63 | + $conf->global->LDAP_KEY_MEMBERS_TYPES, |
|
64 | + $conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME, |
|
65 | + $conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION, |
|
66 | + $conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS |
|
67 | 67 | ); |
68 | 68 | |
69 | 69 | // Remove from required_fields all entries not configured in LDAP (empty) and duplicated |
@@ -71,17 +71,17 @@ discard block |
||
71 | 71 | |
72 | 72 | |
73 | 73 | if (! isset($argv[1])) { |
74 | - //print "Usage: $script_file (nocommitiferror|commitiferror) [id_group]\n"; |
|
75 | - print "Usage: $script_file (nocommitiferror|commitiferror) [--server=ldapserverhost] [--excludeuser=user1,user2...] [-y]\n"; |
|
76 | - exit(-1); |
|
74 | + //print "Usage: $script_file (nocommitiferror|commitiferror) [id_group]\n"; |
|
75 | + print "Usage: $script_file (nocommitiferror|commitiferror) [--server=ldapserverhost] [--excludeuser=user1,user2...] [-y]\n"; |
|
76 | + exit(-1); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | foreach($argv as $key => $val) |
80 | 80 | { |
81 | - if ($val == 'commitiferror') $forcecommit=1; |
|
82 | - if (preg_match('/--server=([^\s]+)$/',$val,$reg)) $conf->global->LDAP_SERVER_HOST=$reg[1]; |
|
83 | - if (preg_match('/--excludeuser=([^\s]+)$/',$val,$reg)) $excludeuser=explode(',',$reg[1]); |
|
84 | - if (preg_match('/-y$/',$val,$reg)) $confirmed=1; |
|
81 | + if ($val == 'commitiferror') $forcecommit=1; |
|
82 | + if (preg_match('/--server=([^\s]+)$/',$val,$reg)) $conf->global->LDAP_SERVER_HOST=$reg[1]; |
|
83 | + if (preg_match('/--excludeuser=([^\s]+)$/',$val,$reg)) $excludeuser=explode(',',$reg[1]); |
|
84 | + if (preg_match('/-y$/',$val,$reg)) $confirmed=1; |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | print "Mails sending disabled (useless in batch mode)\n"; |
@@ -107,14 +107,14 @@ discard block |
||
107 | 107 | |
108 | 108 | if (! $confirmed) |
109 | 109 | { |
110 | - print "Hit Enter to continue or CTRL+C to stop...\n"; |
|
111 | - $input = trim(fgets(STDIN)); |
|
110 | + print "Hit Enter to continue or CTRL+C to stop...\n"; |
|
111 | + $input = trim(fgets(STDIN)); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | if (empty($conf->global->LDAP_MEMBER_TYPE_DN)) |
115 | 115 | { |
116 | - print $langs->trans("Error").': '.$langs->trans("LDAP setup for members types not defined inside Dolibarr"); |
|
117 | - exit(-1); |
|
116 | + print $langs->trans("Error").': '.$langs->trans("LDAP setup for members types not defined inside Dolibarr"); |
|
117 | + exit(-1); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | |
@@ -122,84 +122,84 @@ discard block |
||
122 | 122 | $result = $ldap->connect_bind(); |
123 | 123 | if ($result >= 0) |
124 | 124 | { |
125 | - $justthese=array(); |
|
126 | - |
|
127 | - |
|
128 | - // We disable synchro Dolibarr-LDAP |
|
129 | - $conf->global->LDAP_MEMBER_TYPE_ACTIVE=0; |
|
130 | - |
|
131 | - $ldaprecords = $ldap->getRecords('*',$conf->global->LDAP_MEMBER_TYPE_DN, $conf->global->LDAP_KEY_MEMBERS_TYPES, $required_fields, 0, array($conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS)); |
|
132 | - if (is_array($ldaprecords)) |
|
133 | - { |
|
134 | - $db->begin(); |
|
135 | - |
|
136 | - // Warning $ldapuser has a key in lowercase |
|
137 | - foreach ($ldaprecords as $key => $ldapgroup) |
|
138 | - { |
|
139 | - $membertype = new AdherentType($db); |
|
140 | - $membertype->fetch('', $ldapgroup[$conf->global->LDAP_KEY_MEMBERS_TYPES]); |
|
141 | - $membertype->label = $ldapgroup[$conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME]; |
|
142 | - $membertype->description = $ldapgroup[$conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION]; |
|
143 | - $membertype->entity = $conf->entity; |
|
144 | - |
|
145 | - //print_r($ldapgroup); |
|
146 | - |
|
147 | - if ($membertype->id > 0) { // Member type update |
|
148 | - print $langs->transnoentities("MemberTypeUpdate").' # '.$key.': name='.$membertype->label; |
|
149 | - $res=$membertype->update($user); |
|
150 | - |
|
151 | - if ($res > 0) |
|
152 | - { |
|
153 | - print ' --> Updated member type id='.$membertype->id.' name='.$membertype->label; |
|
154 | - } |
|
155 | - else |
|
156 | - { |
|
157 | - $error++; |
|
158 | - print ' --> '.$res.' '.$membertype->error; |
|
159 | - } |
|
160 | - print "\n"; |
|
161 | - } else { // Member type creation |
|
162 | - print $langs->transnoentities("MemberTypeCreate").' # '.$key.': name='.$membertype->label; |
|
163 | - $res=$membertype->create($user); |
|
164 | - |
|
165 | - if ($res > 0) |
|
166 | - { |
|
167 | - print ' --> Created member type id='.$membertype->id.' name='.$membertype->label; |
|
168 | - } |
|
169 | - else |
|
170 | - { |
|
171 | - $error++; |
|
172 | - print ' --> '.$res.' '.$membertype->error; |
|
173 | - } |
|
174 | - print "\n"; |
|
175 | - } |
|
176 | - |
|
177 | - //print_r($membertype); |
|
178 | - } |
|
179 | - |
|
180 | - if (! $error || $forcecommit) |
|
181 | - { |
|
182 | - if (! $error) print $langs->transnoentities("NoErrorCommitIsDone")."\n"; |
|
183 | - else print $langs->transnoentities("ErrorButCommitIsDone")."\n"; |
|
184 | - $db->commit(); |
|
185 | - } |
|
186 | - else |
|
187 | - { |
|
188 | - print $langs->transnoentities("ErrorSomeErrorWereFoundRollbackIsDone",$error)."\n"; |
|
189 | - $db->rollback(); |
|
190 | - } |
|
191 | - print "\n"; |
|
192 | - } |
|
193 | - else |
|
194 | - { |
|
195 | - dol_print_error('',$ldap->error); |
|
196 | - $error++; |
|
197 | - } |
|
125 | + $justthese=array(); |
|
126 | + |
|
127 | + |
|
128 | + // We disable synchro Dolibarr-LDAP |
|
129 | + $conf->global->LDAP_MEMBER_TYPE_ACTIVE=0; |
|
130 | + |
|
131 | + $ldaprecords = $ldap->getRecords('*',$conf->global->LDAP_MEMBER_TYPE_DN, $conf->global->LDAP_KEY_MEMBERS_TYPES, $required_fields, 0, array($conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS)); |
|
132 | + if (is_array($ldaprecords)) |
|
133 | + { |
|
134 | + $db->begin(); |
|
135 | + |
|
136 | + // Warning $ldapuser has a key in lowercase |
|
137 | + foreach ($ldaprecords as $key => $ldapgroup) |
|
138 | + { |
|
139 | + $membertype = new AdherentType($db); |
|
140 | + $membertype->fetch('', $ldapgroup[$conf->global->LDAP_KEY_MEMBERS_TYPES]); |
|
141 | + $membertype->label = $ldapgroup[$conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME]; |
|
142 | + $membertype->description = $ldapgroup[$conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION]; |
|
143 | + $membertype->entity = $conf->entity; |
|
144 | + |
|
145 | + //print_r($ldapgroup); |
|
146 | + |
|
147 | + if ($membertype->id > 0) { // Member type update |
|
148 | + print $langs->transnoentities("MemberTypeUpdate").' # '.$key.': name='.$membertype->label; |
|
149 | + $res=$membertype->update($user); |
|
150 | + |
|
151 | + if ($res > 0) |
|
152 | + { |
|
153 | + print ' --> Updated member type id='.$membertype->id.' name='.$membertype->label; |
|
154 | + } |
|
155 | + else |
|
156 | + { |
|
157 | + $error++; |
|
158 | + print ' --> '.$res.' '.$membertype->error; |
|
159 | + } |
|
160 | + print "\n"; |
|
161 | + } else { // Member type creation |
|
162 | + print $langs->transnoentities("MemberTypeCreate").' # '.$key.': name='.$membertype->label; |
|
163 | + $res=$membertype->create($user); |
|
164 | + |
|
165 | + if ($res > 0) |
|
166 | + { |
|
167 | + print ' --> Created member type id='.$membertype->id.' name='.$membertype->label; |
|
168 | + } |
|
169 | + else |
|
170 | + { |
|
171 | + $error++; |
|
172 | + print ' --> '.$res.' '.$membertype->error; |
|
173 | + } |
|
174 | + print "\n"; |
|
175 | + } |
|
176 | + |
|
177 | + //print_r($membertype); |
|
178 | + } |
|
179 | + |
|
180 | + if (! $error || $forcecommit) |
|
181 | + { |
|
182 | + if (! $error) print $langs->transnoentities("NoErrorCommitIsDone")."\n"; |
|
183 | + else print $langs->transnoentities("ErrorButCommitIsDone")."\n"; |
|
184 | + $db->commit(); |
|
185 | + } |
|
186 | + else |
|
187 | + { |
|
188 | + print $langs->transnoentities("ErrorSomeErrorWereFoundRollbackIsDone",$error)."\n"; |
|
189 | + $db->rollback(); |
|
190 | + } |
|
191 | + print "\n"; |
|
192 | + } |
|
193 | + else |
|
194 | + { |
|
195 | + dol_print_error('',$ldap->error); |
|
196 | + $error++; |
|
197 | + } |
|
198 | 198 | } |
199 | 199 | else |
200 | 200 | { |
201 | - dol_print_error('',$ldap->error); |
|
202 | - $error++; |
|
201 | + dol_print_error('',$ldap->error); |
|
202 | + $error++; |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | |
@@ -214,6 +214,6 @@ discard block |
||
214 | 214 | */ |
215 | 215 | function dolValidElementType($element) |
216 | 216 | { |
217 | - return (trim($element) != ''); |
|
217 | + return (trim($element) != ''); |
|
218 | 218 | } |
219 | 219 |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | // Test if batch mode |
31 | 31 | if (substr($sapi_type, 0, 3) == 'cgi') { |
32 | 32 | echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; |
33 | - exit(-1); |
|
33 | + exit(-1); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | @set_time_limit(0); // No timeout for this script |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | |
59 | 59 | if (! isset($argv[1]) || $argv[1] != 'product') { |
60 | 60 | print "Usage: $script_file product\n"; |
61 | - exit(-1); |
|
61 | + exit(-1); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | print '--- start'."\n"; |
@@ -66,24 +66,24 @@ discard block |
||
66 | 66 | // Case to migrate products path |
67 | 67 | if ($argv[1] == 'product') |
68 | 68 | { |
69 | - $product = new Product($db); |
|
70 | - |
|
71 | - $sql = "SELECT rowid as pid from ".MAIN_DB_PREFIX."product"; // Get list of all products |
|
72 | - $resql = $db->query($sql); |
|
73 | - if ($resql) |
|
74 | - { |
|
75 | - while ($obj = $db->fetch_object($resql)) |
|
76 | - { |
|
77 | - $product->fetch($obj->pid); |
|
78 | - print " migrating product id=".$product->id." ref=".$product->ref."\n"; |
|
79 | - migrate_product_photospath($product); |
|
80 | - } |
|
81 | - } |
|
82 | - else |
|
83 | - { |
|
84 | - print "\n sql error ".$sql; |
|
85 | - exit; |
|
86 | - } |
|
69 | + $product = new Product($db); |
|
70 | + |
|
71 | + $sql = "SELECT rowid as pid from ".MAIN_DB_PREFIX."product"; // Get list of all products |
|
72 | + $resql = $db->query($sql); |
|
73 | + if ($resql) |
|
74 | + { |
|
75 | + while ($obj = $db->fetch_object($resql)) |
|
76 | + { |
|
77 | + $product->fetch($obj->pid); |
|
78 | + print " migrating product id=".$product->id." ref=".$product->ref."\n"; |
|
79 | + migrate_product_photospath($product); |
|
80 | + } |
|
81 | + } |
|
82 | + else |
|
83 | + { |
|
84 | + print "\n sql error ".$sql; |
|
85 | + exit; |
|
86 | + } |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | |
@@ -101,47 +101,47 @@ discard block |
||
101 | 101 | */ |
102 | 102 | function migrate_product_photospath($product) |
103 | 103 | { |
104 | - global $conf; |
|
104 | + global $conf; |
|
105 | 105 | |
106 | - $dir = $conf->product->multidir_output[$product->entity]; |
|
107 | - $conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO = 1; |
|
108 | - $origin = $dir .'/'. get_exdir($product->id,2,0,0,$product,'product') . $product->id ."/photos"; |
|
109 | - $destin = $dir.'/'.dol_sanitizeFileName($product->ref); |
|
106 | + $dir = $conf->product->multidir_output[$product->entity]; |
|
107 | + $conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO = 1; |
|
108 | + $origin = $dir .'/'. get_exdir($product->id,2,0,0,$product,'product') . $product->id ."/photos"; |
|
109 | + $destin = $dir.'/'.dol_sanitizeFileName($product->ref); |
|
110 | 110 | |
111 | - $error = 0; |
|
111 | + $error = 0; |
|
112 | 112 | |
113 | - $origin_osencoded=dol_osencode($origin); |
|
114 | - $destin_osencoded=dol_osencode($destin); |
|
115 | - dol_mkdir($destin); |
|
113 | + $origin_osencoded=dol_osencode($origin); |
|
114 | + $destin_osencoded=dol_osencode($destin); |
|
115 | + dol_mkdir($destin); |
|
116 | 116 | |
117 | - if (dol_is_dir($origin)) |
|
118 | - { |
|
119 | - $handle=opendir($origin_osencoded); |
|
117 | + if (dol_is_dir($origin)) |
|
118 | + { |
|
119 | + $handle=opendir($origin_osencoded); |
|
120 | 120 | if (is_resource($handle)) |
121 | 121 | { |
122 | - while (($file = readdir($handle)) !== false) |
|
123 | - { |
|
124 | - if ($file != '.' && $file != '..' && is_dir($origin_osencoded.'/'.$file)) |
|
125 | - { |
|
126 | - $thumbs = opendir($origin_osencoded.'/'.$file); |
|
127 | - if (is_resource($thumbs)) |
|
128 | - { |
|
129 | - dol_mkdir($destin.'/'.$file); |
|
130 | - while (($thumb = readdir($thumbs)) !== false) |
|
131 | - { |
|
132 | - dol_move($origin.'/'.$file.'/'.$thumb, $destin.'/'.$file.'/'.$thumb); |
|
133 | - } |
|
122 | + while (($file = readdir($handle)) !== false) |
|
123 | + { |
|
124 | + if ($file != '.' && $file != '..' && is_dir($origin_osencoded.'/'.$file)) |
|
125 | + { |
|
126 | + $thumbs = opendir($origin_osencoded.'/'.$file); |
|
127 | + if (is_resource($thumbs)) |
|
128 | + { |
|
129 | + dol_mkdir($destin.'/'.$file); |
|
130 | + while (($thumb = readdir($thumbs)) !== false) |
|
131 | + { |
|
132 | + dol_move($origin.'/'.$file.'/'.$thumb, $destin.'/'.$file.'/'.$thumb); |
|
133 | + } |
|
134 | 134 | // dol_delete_dir($origin.'/'.$file); |
135 | - } |
|
136 | - } |
|
137 | - else |
|
138 | - { |
|
139 | - if (dol_is_file($origin.'/'.$file) ) |
|
140 | - { |
|
141 | - dol_move($origin.'/'.$file, $destin.'/'.$file); |
|
142 | - } |
|
143 | - } |
|
144 | - } |
|
135 | + } |
|
136 | + } |
|
137 | + else |
|
138 | + { |
|
139 | + if (dol_is_file($origin.'/'.$file) ) |
|
140 | + { |
|
141 | + dol_move($origin.'/'.$file, $destin.'/'.$file); |
|
142 | + } |
|
143 | + } |
|
144 | + } |
|
145 | 145 | } |
146 | - } |
|
146 | + } |
|
147 | 147 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | // Test if batch mode |
31 | 31 | if (substr($sapi_type, 0, 3) == 'cgi') { |
32 | 32 | echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; |
33 | - exit(-1); |
|
33 | + exit(-1); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | @set_time_limit(0); // No timeout for this script |
@@ -69,13 +69,13 @@ discard block |
||
69 | 69 | $subdir=$argv[1]; |
70 | 70 | if (empty($dir) || empty($subdir)) |
71 | 71 | { |
72 | - dol_print_error('', 'dir not defined'); |
|
73 | - exit(1); |
|
72 | + dol_print_error('', 'dir not defined'); |
|
73 | + exit(1); |
|
74 | 74 | } |
75 | 75 | if (! dol_is_dir($dir.'/'.$subdir)) |
76 | 76 | { |
77 | - print 'Directory '.$dir.'/'.$subdir.' not found.'."\n"; |
|
78 | - exit(2); |
|
77 | + print 'Directory '.$dir.'/'.$subdir.' not found.'."\n"; |
|
78 | + exit(2); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | $filearray=dol_dir_list($dir.'/'.$subdir,"directories",0,'','temp$'); |
@@ -84,22 +84,22 @@ discard block |
||
84 | 84 | |
85 | 85 | foreach($filearray as $keyf => $valf) |
86 | 86 | { |
87 | - $ref=basename($valf['name']); |
|
88 | - $filearrayimg=dol_dir_list($valf['fullname'],"files",0,'(\.gif|\.png|\.jpg|\.jpeg|\.bmp)$','(\.meta|_preview.*\.png)$'); |
|
89 | - foreach($filearrayimg as $keyi => $vali) |
|
90 | - { |
|
91 | - print 'Process image for ref '.$ref.' : '.$vali['name']."\n"; |
|
92 | - |
|
93 | - // Create small thumbs for image |
|
94 | - // Used on logon for example |
|
95 | - $imgThumbSmall = vignette($vali['fullname'], $maxwidthsmall, $maxheightsmall, '_small', 50, "thumbs"); |
|
96 | - if (preg_match('/Error/', $imgThumbSmall)) print $imgThumbSmall."\n"; |
|
97 | - |
|
98 | - // Create mini thumbs for image (Ratio is near 16/9) |
|
99 | - // Used on menu or for setup page for example |
|
100 | - $imgThumbMini = vignette($vali['fullname'], $maxwidthmini, $maxheightmini, '_mini', 50, "thumbs"); |
|
101 | - if (preg_match('/Error/', $imgThumbMini)) print $imgThumbMini."\n"; |
|
102 | - } |
|
87 | + $ref=basename($valf['name']); |
|
88 | + $filearrayimg=dol_dir_list($valf['fullname'],"files",0,'(\.gif|\.png|\.jpg|\.jpeg|\.bmp)$','(\.meta|_preview.*\.png)$'); |
|
89 | + foreach($filearrayimg as $keyi => $vali) |
|
90 | + { |
|
91 | + print 'Process image for ref '.$ref.' : '.$vali['name']."\n"; |
|
92 | + |
|
93 | + // Create small thumbs for image |
|
94 | + // Used on logon for example |
|
95 | + $imgThumbSmall = vignette($vali['fullname'], $maxwidthsmall, $maxheightsmall, '_small', 50, "thumbs"); |
|
96 | + if (preg_match('/Error/', $imgThumbSmall)) print $imgThumbSmall."\n"; |
|
97 | + |
|
98 | + // Create mini thumbs for image (Ratio is near 16/9) |
|
99 | + // Used on menu or for setup page for example |
|
100 | + $imgThumbMini = vignette($vali['fullname'], $maxwidthmini, $maxheightmini, '_mini', 50, "thumbs"); |
|
101 | + if (preg_match('/Error/', $imgThumbMini)) print $imgThumbMini."\n"; |
|
102 | + } |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | $db->close(); // Close $db database opened handler |
@@ -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 | } |
@@ -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 | /** |
@@ -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 | } |
@@ -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"; |
@@ -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 | } |