@@ -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 | /** |
@@ -62,9 +62,9 @@ discard block |
||
62 | 62 | */ |
63 | 63 | function __construct() |
64 | 64 | { |
65 | - parent::__construct(); |
|
65 | + parent::__construct(); |
|
66 | 66 | |
67 | - //$this->sharedFixture |
|
67 | + //$this->sharedFixture |
|
68 | 68 | global $conf,$user,$langs,$db; |
69 | 69 | $this->savconf=$conf; |
70 | 70 | $this->savuser=$user; |
@@ -94,11 +94,11 @@ discard block |
||
94 | 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 | 104 | global $conf,$user,$langs,$db; |
@@ -109,11 +109,11 @@ discard block |
||
109 | 109 | |
110 | 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 | 119 | print __METHOD__."\n"; |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | |
136 | 136 | // Do a test with an array starting with 0 |
137 | 137 | $arraytotest=array(0=>array('key'=>1,'value'=>'PRODREF','label'=>'Product ref with é and special chars \\ \' "')); |
138 | - $arrayencodedexpected='[{"key":1,"value":"PRODREF","label":"Product ref with \u00e9 and special chars \\\\ \' \""}]'; |
|
138 | + $arrayencodedexpected='[{"key":1,"value":"PRODREF","label":"Product ref with \u00e9 and special chars \\\\ \' \""}]'; |
|
139 | 139 | |
140 | 140 | $encoded=json_encode($arraytotest); |
141 | 141 | $this->assertEquals($arrayencodedexpected,$encoded); |
@@ -147,9 +147,9 @@ discard block |
||
147 | 147 | $decoded=dol_json_decode($encoded,true); |
148 | 148 | $this->assertEquals($arraytotest,$decoded,'test for dol_json_xxx'); |
149 | 149 | |
150 | - // Same test but array start with 2 instead of 0 |
|
150 | + // Same test but array start with 2 instead of 0 |
|
151 | 151 | $arraytotest=array(2=>array('key'=>1,'value'=>'PRODREF','label'=>'Product ref with é and special chars \\ \' "')); |
152 | - $arrayencodedexpected='{"2":{"key":1,"value":"PRODREF","label":"Product ref with \u00e9 and special chars \\\\ \' \""}}'; |
|
152 | + $arrayencodedexpected='{"2":{"key":1,"value":"PRODREF","label":"Product ref with \u00e9 and special chars \\\\ \' \""}}'; |
|
153 | 153 | |
154 | 154 | $encoded=json_encode($arraytotest); |
155 | 155 | $this->assertEquals($arrayencodedexpected,$encoded); |
@@ -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,47 +127,47 @@ discard block |
||
127 | 127 | public function testJsonEncode() |
128 | 128 | { |
129 | 129 | //$this->sharedFixture |
130 | - global $conf,$user,$langs,$db; |
|
131 | - $this->savconf=$conf; |
|
132 | - $this->savuser=$user; |
|
133 | - $this->savlangs=$langs; |
|
134 | - $this->savdb=$db; |
|
130 | + global $conf, $user, $langs, $db; |
|
131 | + $this->savconf = $conf; |
|
132 | + $this->savuser = $user; |
|
133 | + $this->savlangs = $langs; |
|
134 | + $this->savdb = $db; |
|
135 | 135 | |
136 | 136 | // Do a test with an array starting with 0 |
137 | - $arraytotest=array(0=>array('key'=>1,'value'=>'PRODREF','label'=>'Product ref with é and special chars \\ \' "')); |
|
138 | - $arrayencodedexpected='[{"key":1,"value":"PRODREF","label":"Product ref with \u00e9 and special chars \\\\ \' \""}]'; |
|
137 | + $arraytotest = array(0=>array('key'=>1, 'value'=>'PRODREF', 'label'=>'Product ref with é and special chars \\ \' "')); |
|
138 | + $arrayencodedexpected = '[{"key":1,"value":"PRODREF","label":"Product ref with \u00e9 and special chars \\\\ \' \""}]'; |
|
139 | 139 | |
140 | - $encoded=json_encode($arraytotest); |
|
141 | - $this->assertEquals($arrayencodedexpected,$encoded); |
|
142 | - $decoded=json_decode($encoded,true); |
|
143 | - $this->assertEquals($arraytotest,$decoded,'test for json_xxx'); |
|
140 | + $encoded = json_encode($arraytotest); |
|
141 | + $this->assertEquals($arrayencodedexpected, $encoded); |
|
142 | + $decoded = json_decode($encoded, true); |
|
143 | + $this->assertEquals($arraytotest, $decoded, 'test for json_xxx'); |
|
144 | 144 | |
145 | - $encoded=dol_json_encode($arraytotest); |
|
146 | - $this->assertEquals($arrayencodedexpected,$encoded); |
|
147 | - $decoded=dol_json_decode($encoded,true); |
|
148 | - $this->assertEquals($arraytotest,$decoded,'test for dol_json_xxx'); |
|
145 | + $encoded = dol_json_encode($arraytotest); |
|
146 | + $this->assertEquals($arrayencodedexpected, $encoded); |
|
147 | + $decoded = dol_json_decode($encoded, true); |
|
148 | + $this->assertEquals($arraytotest, $decoded, 'test for dol_json_xxx'); |
|
149 | 149 | |
150 | 150 | // Same test but array start with 2 instead of 0 |
151 | - $arraytotest=array(2=>array('key'=>1,'value'=>'PRODREF','label'=>'Product ref with é and special chars \\ \' "')); |
|
152 | - $arrayencodedexpected='{"2":{"key":1,"value":"PRODREF","label":"Product ref with \u00e9 and special chars \\\\ \' \""}}'; |
|
151 | + $arraytotest = array(2=>array('key'=>1, 'value'=>'PRODREF', 'label'=>'Product ref with é and special chars \\ \' "')); |
|
152 | + $arrayencodedexpected = '{"2":{"key":1,"value":"PRODREF","label":"Product ref with \u00e9 and special chars \\\\ \' \""}}'; |
|
153 | 153 | |
154 | - $encoded=json_encode($arraytotest); |
|
155 | - $this->assertEquals($arrayencodedexpected,$encoded); |
|
156 | - $decoded=json_decode($encoded,true); |
|
157 | - $this->assertEquals($arraytotest,$decoded,'test for json_xxx'); |
|
154 | + $encoded = json_encode($arraytotest); |
|
155 | + $this->assertEquals($arrayencodedexpected, $encoded); |
|
156 | + $decoded = json_decode($encoded, true); |
|
157 | + $this->assertEquals($arraytotest, $decoded, 'test for json_xxx'); |
|
158 | 158 | |
159 | - $encoded=dol_json_encode($arraytotest); |
|
160 | - $this->assertEquals($arrayencodedexpected,$encoded); |
|
161 | - $decoded=dol_json_decode($encoded,true); |
|
162 | - $this->assertEquals($arraytotest,$decoded,'test for dol_json_xxx'); |
|
159 | + $encoded = dol_json_encode($arraytotest); |
|
160 | + $this->assertEquals($arrayencodedexpected, $encoded); |
|
161 | + $decoded = dol_json_decode($encoded, true); |
|
162 | + $this->assertEquals($arraytotest, $decoded, 'test for dol_json_xxx'); |
|
163 | 163 | |
164 | 164 | // Test with object |
165 | - $now=gmmktime(12,0,0,1,1,1970); |
|
166 | - $objecttotest=new stdClass(); |
|
167 | - $objecttotest->property1='abc'; |
|
168 | - $objecttotest->property2=1234; |
|
169 | - $objecttotest->property3=$now; |
|
170 | - $encoded=dol_json_encode($objecttotest); |
|
171 | - $this->assertEquals('{"property1":"abc","property2":1234,"property3":43200}',$encoded); |
|
165 | + $now = gmmktime(12, 0, 0, 1, 1, 1970); |
|
166 | + $objecttotest = new stdClass(); |
|
167 | + $objecttotest->property1 = 'abc'; |
|
168 | + $objecttotest->property2 = 1234; |
|
169 | + $objecttotest->property3 = $now; |
|
170 | + $encoded = dol_json_encode($objecttotest); |
|
171 | + $this->assertEquals('{"property1":"abc","property2":1234,"property3":43200}', $encoded); |
|
172 | 172 | } |
173 | 173 | } |
@@ -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 | /** |
@@ -31,9 +31,9 @@ discard block |
||
31 | 31 | require_once dirname(__FILE__).'/../../htdocs/ticket/class/ticket.class.php'; |
32 | 32 | |
33 | 33 | if (empty($user->id)) { |
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,366 +47,366 @@ discard block |
||
47 | 47 | */ |
48 | 48 | class TicketTest 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 ContratTest |
|
60 | - */ |
|
61 | - public 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() |
|
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 | - } |
|
85 | - |
|
86 | - // tear down after class |
|
87 | - public static function tearDownAfterClass() |
|
88 | - { |
|
89 | - global $conf,$user,$langs,$db; |
|
90 | - $db->rollback(); |
|
91 | - |
|
92 | - print __METHOD__."\n"; |
|
93 | - } |
|
94 | - |
|
95 | - /** |
|
96 | - * Init phpunit tests |
|
97 | - * |
|
98 | - * @return void |
|
99 | - */ |
|
100 | - protected function setUp() |
|
101 | - { |
|
102 | - global $conf,$user,$langs,$db; |
|
103 | - $conf=$this->savconf; |
|
104 | - $user=$this->savuser; |
|
105 | - $langs=$this->savlangs; |
|
106 | - $db=$this->savdb; |
|
107 | - |
|
108 | - print __METHOD__."\n"; |
|
109 | - } |
|
110 | - /** |
|
111 | - * End phpunit tests |
|
112 | - * |
|
113 | - * @return void |
|
114 | - */ |
|
115 | - protected function tearDown() |
|
116 | - { |
|
117 | - print __METHOD__."\n"; |
|
118 | - } |
|
119 | - |
|
120 | - /** |
|
121 | - * testTicketCreate |
|
122 | - * |
|
123 | - * @return int |
|
124 | - */ |
|
125 | - public function testTicketCreate() |
|
126 | - { |
|
127 | - global $conf,$user,$langs,$db; |
|
128 | - $conf=$this->savconf; |
|
129 | - $user=$this->savuser; |
|
130 | - $langs=$this->savlangs; |
|
131 | - $db=$this->savdb; |
|
132 | - |
|
133 | - // Try to create one with bad values |
|
134 | - $localobject=new Ticket($this->savdb); |
|
135 | - $localobject->initAsSpecimen(); |
|
136 | - $localobject->ref = ''; |
|
137 | - $result=$localobject->create($user); |
|
138 | - |
|
139 | - print __METHOD__." result=".$result."\n"; |
|
140 | - $this->assertEquals(-3, $result, $localobject->error.join(',', $localobject->errors)); |
|
141 | - |
|
142 | - // Try to create one with correct values |
|
143 | - $localobject=new Ticket($this->savdb); |
|
144 | - $localobject->initAsSpecimen(); |
|
145 | - $result=$localobject->create($user); |
|
146 | - |
|
147 | - print __METHOD__." result=".$result."\n"; |
|
148 | - $this->assertGreaterThan(0, $result, $localobject->error.join(',', $localobject->errors)); |
|
149 | - |
|
150 | - return $result; |
|
151 | - } |
|
152 | - |
|
153 | - /** |
|
154 | - * testTicketFetch |
|
155 | - * |
|
156 | - * @param int $id Id of ticket |
|
157 | - * @return int |
|
158 | - * |
|
159 | - * @depends testTicketCreate |
|
160 | - * The depends says test is run only if previous is ok |
|
161 | - */ |
|
162 | - public function testTicketFetch($id) |
|
163 | - { |
|
164 | - global $conf,$user,$langs,$db; |
|
165 | - $conf=$this->savconf; |
|
166 | - $user=$this->savuser; |
|
167 | - $langs=$this->savlangs; |
|
168 | - $db=$this->savdb; |
|
169 | - |
|
170 | - $localobject=new Ticket($this->savdb); |
|
171 | - $result=$localobject->fetch($id); |
|
172 | - |
|
173 | - print __METHOD__." id=".$id." result=".$result."\n"; |
|
174 | - $this->assertGreaterThan(0, $result); |
|
175 | - |
|
176 | - return $localobject; |
|
177 | - } |
|
178 | - |
|
179 | - /** |
|
180 | - * testTicketmarkAsRead |
|
181 | - * |
|
182 | - * @param Ticket $localobject Ticket |
|
183 | - * @return int |
|
184 | - * |
|
185 | - * @depends testTicketFetch |
|
186 | - * The depends says test is run only if previous is ok |
|
187 | - */ |
|
188 | - public function testTicketmarkAsRead($localobject) |
|
189 | - { |
|
190 | - global $conf,$user,$langs,$db; |
|
191 | - $conf=$this->savconf; |
|
192 | - $user=$this->savuser; |
|
193 | - $langs=$this->savlangs; |
|
194 | - $db=$this->savdb; |
|
195 | - |
|
196 | - $result=$localobject->markAsRead($user); |
|
197 | - print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
198 | - |
|
199 | - $this->assertGreaterThan(0, $result); |
|
200 | - return $localobject; |
|
201 | - } |
|
202 | - |
|
203 | - /** |
|
204 | - * testTicketsetProject |
|
205 | - * |
|
206 | - * @param Ticket $localobject Ticket |
|
207 | - * @return int |
|
208 | - * |
|
209 | - * @depends testTicketFetch |
|
210 | - * The depends says test is run only if previous is ok |
|
211 | - */ |
|
212 | - public function testTicketsetProject($localobject) |
|
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 | - $project_id = 1; |
|
221 | - |
|
222 | - $result=$localobject->setProject($project_id); |
|
223 | - print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
224 | - |
|
225 | - $this->assertGreaterThan(0, $result); |
|
226 | - return $localobject; |
|
227 | - } |
|
228 | - |
|
229 | - /** |
|
230 | - * testTicketsetContract |
|
231 | - * |
|
232 | - * @param Ticket $localobject Ticket |
|
233 | - * @return int |
|
234 | - * |
|
235 | - * @depends testTicketFetch |
|
236 | - * The depends says test is run only if previous is ok |
|
237 | - */ |
|
238 | - public function testTicketsetContract($localobject) |
|
239 | - { |
|
240 | - global $conf,$user,$langs,$db; |
|
241 | - $conf=$this->savconf; |
|
242 | - $user=$this->savuser; |
|
243 | - $langs=$this->savlangs; |
|
244 | - $db=$this->savdb; |
|
245 | - |
|
246 | - $contract_id = 1; |
|
247 | - |
|
248 | - $result=$localobject->setContract($contract_id); |
|
249 | - print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
250 | - |
|
251 | - $this->assertGreaterThan(0, $result); |
|
252 | - return $localobject; |
|
253 | - } |
|
254 | - |
|
255 | - /** |
|
256 | - * testTicketsetProgression |
|
257 | - * |
|
258 | - * @param Ticket $localobject Ticket |
|
259 | - * @return int |
|
260 | - * |
|
261 | - * @depends testTicketFetch |
|
262 | - * The depends says test is run only if previous is ok |
|
263 | - */ |
|
264 | - public function testTicketsetProgression($localobject) |
|
265 | - { |
|
266 | - global $conf,$user,$langs,$db; |
|
267 | - $conf=$this->savconf; |
|
268 | - $user=$this->savuser; |
|
269 | - $langs=$this->savlangs; |
|
270 | - $db=$this->savdb; |
|
271 | - |
|
272 | - $percent = 80; |
|
273 | - |
|
274 | - $result=$localobject->setProgression($percent); |
|
275 | - print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
276 | - |
|
277 | - $this->assertGreaterThan(0, $result); |
|
278 | - return $localobject; |
|
279 | - } |
|
280 | - |
|
281 | - /** |
|
282 | - * testTicketassignUser |
|
283 | - * |
|
284 | - * @param Ticket $localobject Ticket |
|
285 | - * @return int |
|
286 | - * |
|
287 | - * @depends testTicketFetch |
|
288 | - * The depends says test is run only if previous is ok |
|
289 | - */ |
|
290 | - public function testTicketassignUser($localobject) |
|
291 | - { |
|
292 | - global $conf,$user,$langs,$db; |
|
293 | - $conf=$this->savconf; |
|
294 | - $user=$this->savuser; |
|
295 | - $langs=$this->savlangs; |
|
296 | - $db=$this->savdb; |
|
297 | - |
|
298 | - $user_id_to_assign = 1; |
|
299 | - |
|
300 | - $result=$localobject->assignUser($user, $user_id_to_assign); |
|
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 ContratTest |
|
60 | + */ |
|
61 | + public 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() |
|
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 | + } |
|
85 | + |
|
86 | + // tear down after class |
|
87 | + public static function tearDownAfterClass() |
|
88 | + { |
|
89 | + global $conf,$user,$langs,$db; |
|
90 | + $db->rollback(); |
|
91 | + |
|
92 | + print __METHOD__."\n"; |
|
93 | + } |
|
94 | + |
|
95 | + /** |
|
96 | + * Init phpunit tests |
|
97 | + * |
|
98 | + * @return void |
|
99 | + */ |
|
100 | + protected function setUp() |
|
101 | + { |
|
102 | + global $conf,$user,$langs,$db; |
|
103 | + $conf=$this->savconf; |
|
104 | + $user=$this->savuser; |
|
105 | + $langs=$this->savlangs; |
|
106 | + $db=$this->savdb; |
|
107 | + |
|
108 | + print __METHOD__."\n"; |
|
109 | + } |
|
110 | + /** |
|
111 | + * End phpunit tests |
|
112 | + * |
|
113 | + * @return void |
|
114 | + */ |
|
115 | + protected function tearDown() |
|
116 | + { |
|
117 | + print __METHOD__."\n"; |
|
118 | + } |
|
119 | + |
|
120 | + /** |
|
121 | + * testTicketCreate |
|
122 | + * |
|
123 | + * @return int |
|
124 | + */ |
|
125 | + public function testTicketCreate() |
|
126 | + { |
|
127 | + global $conf,$user,$langs,$db; |
|
128 | + $conf=$this->savconf; |
|
129 | + $user=$this->savuser; |
|
130 | + $langs=$this->savlangs; |
|
131 | + $db=$this->savdb; |
|
132 | + |
|
133 | + // Try to create one with bad values |
|
134 | + $localobject=new Ticket($this->savdb); |
|
135 | + $localobject->initAsSpecimen(); |
|
136 | + $localobject->ref = ''; |
|
137 | + $result=$localobject->create($user); |
|
138 | + |
|
139 | + print __METHOD__." result=".$result."\n"; |
|
140 | + $this->assertEquals(-3, $result, $localobject->error.join(',', $localobject->errors)); |
|
141 | + |
|
142 | + // Try to create one with correct values |
|
143 | + $localobject=new Ticket($this->savdb); |
|
144 | + $localobject->initAsSpecimen(); |
|
145 | + $result=$localobject->create($user); |
|
146 | + |
|
147 | + print __METHOD__." result=".$result."\n"; |
|
148 | + $this->assertGreaterThan(0, $result, $localobject->error.join(',', $localobject->errors)); |
|
149 | + |
|
150 | + return $result; |
|
151 | + } |
|
152 | + |
|
153 | + /** |
|
154 | + * testTicketFetch |
|
155 | + * |
|
156 | + * @param int $id Id of ticket |
|
157 | + * @return int |
|
158 | + * |
|
159 | + * @depends testTicketCreate |
|
160 | + * The depends says test is run only if previous is ok |
|
161 | + */ |
|
162 | + public function testTicketFetch($id) |
|
163 | + { |
|
164 | + global $conf,$user,$langs,$db; |
|
165 | + $conf=$this->savconf; |
|
166 | + $user=$this->savuser; |
|
167 | + $langs=$this->savlangs; |
|
168 | + $db=$this->savdb; |
|
169 | + |
|
170 | + $localobject=new Ticket($this->savdb); |
|
171 | + $result=$localobject->fetch($id); |
|
172 | + |
|
173 | + print __METHOD__." id=".$id." result=".$result."\n"; |
|
174 | + $this->assertGreaterThan(0, $result); |
|
175 | + |
|
176 | + return $localobject; |
|
177 | + } |
|
178 | + |
|
179 | + /** |
|
180 | + * testTicketmarkAsRead |
|
181 | + * |
|
182 | + * @param Ticket $localobject Ticket |
|
183 | + * @return int |
|
184 | + * |
|
185 | + * @depends testTicketFetch |
|
186 | + * The depends says test is run only if previous is ok |
|
187 | + */ |
|
188 | + public function testTicketmarkAsRead($localobject) |
|
189 | + { |
|
190 | + global $conf,$user,$langs,$db; |
|
191 | + $conf=$this->savconf; |
|
192 | + $user=$this->savuser; |
|
193 | + $langs=$this->savlangs; |
|
194 | + $db=$this->savdb; |
|
195 | + |
|
196 | + $result=$localobject->markAsRead($user); |
|
197 | + print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
198 | + |
|
199 | + $this->assertGreaterThan(0, $result); |
|
200 | + return $localobject; |
|
201 | + } |
|
202 | + |
|
203 | + /** |
|
204 | + * testTicketsetProject |
|
205 | + * |
|
206 | + * @param Ticket $localobject Ticket |
|
207 | + * @return int |
|
208 | + * |
|
209 | + * @depends testTicketFetch |
|
210 | + * The depends says test is run only if previous is ok |
|
211 | + */ |
|
212 | + public function testTicketsetProject($localobject) |
|
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 | + $project_id = 1; |
|
221 | + |
|
222 | + $result=$localobject->setProject($project_id); |
|
223 | + print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
224 | + |
|
225 | + $this->assertGreaterThan(0, $result); |
|
226 | + return $localobject; |
|
227 | + } |
|
228 | + |
|
229 | + /** |
|
230 | + * testTicketsetContract |
|
231 | + * |
|
232 | + * @param Ticket $localobject Ticket |
|
233 | + * @return int |
|
234 | + * |
|
235 | + * @depends testTicketFetch |
|
236 | + * The depends says test is run only if previous is ok |
|
237 | + */ |
|
238 | + public function testTicketsetContract($localobject) |
|
239 | + { |
|
240 | + global $conf,$user,$langs,$db; |
|
241 | + $conf=$this->savconf; |
|
242 | + $user=$this->savuser; |
|
243 | + $langs=$this->savlangs; |
|
244 | + $db=$this->savdb; |
|
245 | + |
|
246 | + $contract_id = 1; |
|
247 | + |
|
248 | + $result=$localobject->setContract($contract_id); |
|
249 | + print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
250 | + |
|
251 | + $this->assertGreaterThan(0, $result); |
|
252 | + return $localobject; |
|
253 | + } |
|
254 | + |
|
255 | + /** |
|
256 | + * testTicketsetProgression |
|
257 | + * |
|
258 | + * @param Ticket $localobject Ticket |
|
259 | + * @return int |
|
260 | + * |
|
261 | + * @depends testTicketFetch |
|
262 | + * The depends says test is run only if previous is ok |
|
263 | + */ |
|
264 | + public function testTicketsetProgression($localobject) |
|
265 | + { |
|
266 | + global $conf,$user,$langs,$db; |
|
267 | + $conf=$this->savconf; |
|
268 | + $user=$this->savuser; |
|
269 | + $langs=$this->savlangs; |
|
270 | + $db=$this->savdb; |
|
271 | + |
|
272 | + $percent = 80; |
|
273 | + |
|
274 | + $result=$localobject->setProgression($percent); |
|
275 | + print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
276 | + |
|
277 | + $this->assertGreaterThan(0, $result); |
|
278 | + return $localobject; |
|
279 | + } |
|
280 | + |
|
281 | + /** |
|
282 | + * testTicketassignUser |
|
283 | + * |
|
284 | + * @param Ticket $localobject Ticket |
|
285 | + * @return int |
|
286 | + * |
|
287 | + * @depends testTicketFetch |
|
288 | + * The depends says test is run only if previous is ok |
|
289 | + */ |
|
290 | + public function testTicketassignUser($localobject) |
|
291 | + { |
|
292 | + global $conf,$user,$langs,$db; |
|
293 | + $conf=$this->savconf; |
|
294 | + $user=$this->savuser; |
|
295 | + $langs=$this->savlangs; |
|
296 | + $db=$this->savdb; |
|
297 | + |
|
298 | + $user_id_to_assign = 1; |
|
299 | + |
|
300 | + $result=$localobject->assignUser($user, $user_id_to_assign); |
|
301 | 301 | ; |
302 | - print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
303 | - |
|
304 | - $this->assertGreaterThan(0, $result); |
|
305 | - return $localobject; |
|
306 | - } |
|
307 | - |
|
308 | - /** |
|
309 | - * testTicketassignUserOther |
|
310 | - * |
|
311 | - * @param Ticket $localobject Ticket |
|
312 | - * @return int |
|
313 | - * |
|
314 | - * @depends testTicketFetch |
|
315 | - * The depends says test is run only if previous is ok |
|
316 | - */ |
|
317 | - public function testTicketassignUserOther($localobject) |
|
318 | - { |
|
319 | - global $conf,$user,$langs,$db; |
|
320 | - $conf=$this->savconf; |
|
321 | - $user=$this->savuser; |
|
322 | - $langs=$this->savlangs; |
|
323 | - $db=$this->savdb; |
|
324 | - |
|
325 | - $user_id_to_assign = 2; |
|
326 | - |
|
327 | - $result=$localobject->assignUser($user, $user_id_to_assign); |
|
328 | - ; |
|
329 | - print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
330 | - |
|
331 | - $this->assertGreaterThan(0, $result); |
|
332 | - return $localobject; |
|
333 | - } |
|
334 | - |
|
335 | - /** |
|
336 | - * testTicketcreateTicketLog |
|
337 | - * |
|
338 | - * @param Ticket $localobject Ticket |
|
339 | - * @return int |
|
340 | - * |
|
341 | - * @depends testTicketFetch |
|
342 | - * The depends says test is run only if previous is ok |
|
343 | - */ |
|
344 | - public function testTicketcreateTicketLog($localobject) |
|
345 | - { |
|
346 | - global $conf,$user,$langs,$db; |
|
347 | - $conf=$this->savconf; |
|
348 | - $user=$this->savuser; |
|
349 | - $langs=$this->savlangs; |
|
350 | - $db=$this->savdb; |
|
351 | - |
|
352 | - |
|
353 | - $message = 'Test ticket log'; |
|
354 | - $noemail = 1; |
|
355 | - $result=$localobject->createTicketLog($user, $message, $noemail); |
|
356 | - print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
357 | - |
|
358 | - $this->assertGreaterThan(0, $result); |
|
359 | - return $localobject; |
|
360 | - } |
|
361 | - |
|
362 | - /** |
|
363 | - * testTicketclose |
|
364 | - * |
|
365 | - * @param Ticket $localobject Ticket |
|
366 | - * @return int |
|
367 | - * |
|
368 | - * @depends testTicketFetch |
|
369 | - * The depends says test is run only if previous is ok |
|
370 | - */ |
|
371 | - public function testTicketclose($localobject) |
|
372 | - { |
|
373 | - global $conf,$user,$langs,$db; |
|
374 | - $conf=$this->savconf; |
|
375 | - $user=$this->savuser; |
|
376 | - $langs=$this->savlangs; |
|
377 | - $db=$this->savdb; |
|
378 | - |
|
379 | - $result=$localobject->close(); |
|
380 | - print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
381 | - |
|
382 | - $this->assertGreaterThan(0, $result); |
|
383 | - return $localobject->id; |
|
384 | - } |
|
385 | - |
|
386 | - |
|
387 | - /** |
|
388 | - * testTicketDelete |
|
389 | - * |
|
390 | - * @param int $id Id of ticket |
|
391 | - * @return int |
|
392 | - * |
|
393 | - * @depends testTicketclose |
|
394 | - * The depends says test is run only if previous is ok |
|
395 | - */ |
|
396 | - public function testTicketDelete($id) |
|
397 | - { |
|
398 | - global $conf,$user,$langs,$db; |
|
399 | - $conf=$this->savconf; |
|
400 | - $user=$this->savuser; |
|
401 | - $langs=$this->savlangs; |
|
402 | - $db=$this->savdb; |
|
403 | - |
|
404 | - $localobject=new Ticket($this->savdb); |
|
405 | - $result=$localobject->fetch($id); |
|
406 | - $result=$localobject->delete($user); |
|
407 | - |
|
408 | - print __METHOD__." id=".$id." result=".$result."\n"; |
|
409 | - $this->assertGreaterThan(0, $result); |
|
410 | - return $result; |
|
411 | - } |
|
302 | + print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
303 | + |
|
304 | + $this->assertGreaterThan(0, $result); |
|
305 | + return $localobject; |
|
306 | + } |
|
307 | + |
|
308 | + /** |
|
309 | + * testTicketassignUserOther |
|
310 | + * |
|
311 | + * @param Ticket $localobject Ticket |
|
312 | + * @return int |
|
313 | + * |
|
314 | + * @depends testTicketFetch |
|
315 | + * The depends says test is run only if previous is ok |
|
316 | + */ |
|
317 | + public function testTicketassignUserOther($localobject) |
|
318 | + { |
|
319 | + global $conf,$user,$langs,$db; |
|
320 | + $conf=$this->savconf; |
|
321 | + $user=$this->savuser; |
|
322 | + $langs=$this->savlangs; |
|
323 | + $db=$this->savdb; |
|
324 | + |
|
325 | + $user_id_to_assign = 2; |
|
326 | + |
|
327 | + $result=$localobject->assignUser($user, $user_id_to_assign); |
|
328 | + ; |
|
329 | + print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
330 | + |
|
331 | + $this->assertGreaterThan(0, $result); |
|
332 | + return $localobject; |
|
333 | + } |
|
334 | + |
|
335 | + /** |
|
336 | + * testTicketcreateTicketLog |
|
337 | + * |
|
338 | + * @param Ticket $localobject Ticket |
|
339 | + * @return int |
|
340 | + * |
|
341 | + * @depends testTicketFetch |
|
342 | + * The depends says test is run only if previous is ok |
|
343 | + */ |
|
344 | + public function testTicketcreateTicketLog($localobject) |
|
345 | + { |
|
346 | + global $conf,$user,$langs,$db; |
|
347 | + $conf=$this->savconf; |
|
348 | + $user=$this->savuser; |
|
349 | + $langs=$this->savlangs; |
|
350 | + $db=$this->savdb; |
|
351 | + |
|
352 | + |
|
353 | + $message = 'Test ticket log'; |
|
354 | + $noemail = 1; |
|
355 | + $result=$localobject->createTicketLog($user, $message, $noemail); |
|
356 | + print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
357 | + |
|
358 | + $this->assertGreaterThan(0, $result); |
|
359 | + return $localobject; |
|
360 | + } |
|
361 | + |
|
362 | + /** |
|
363 | + * testTicketclose |
|
364 | + * |
|
365 | + * @param Ticket $localobject Ticket |
|
366 | + * @return int |
|
367 | + * |
|
368 | + * @depends testTicketFetch |
|
369 | + * The depends says test is run only if previous is ok |
|
370 | + */ |
|
371 | + public function testTicketclose($localobject) |
|
372 | + { |
|
373 | + global $conf,$user,$langs,$db; |
|
374 | + $conf=$this->savconf; |
|
375 | + $user=$this->savuser; |
|
376 | + $langs=$this->savlangs; |
|
377 | + $db=$this->savdb; |
|
378 | + |
|
379 | + $result=$localobject->close(); |
|
380 | + print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
381 | + |
|
382 | + $this->assertGreaterThan(0, $result); |
|
383 | + return $localobject->id; |
|
384 | + } |
|
385 | + |
|
386 | + |
|
387 | + /** |
|
388 | + * testTicketDelete |
|
389 | + * |
|
390 | + * @param int $id Id of ticket |
|
391 | + * @return int |
|
392 | + * |
|
393 | + * @depends testTicketclose |
|
394 | + * The depends says test is run only if previous is ok |
|
395 | + */ |
|
396 | + public function testTicketDelete($id) |
|
397 | + { |
|
398 | + global $conf,$user,$langs,$db; |
|
399 | + $conf=$this->savconf; |
|
400 | + $user=$this->savuser; |
|
401 | + $langs=$this->savlangs; |
|
402 | + $db=$this->savdb; |
|
403 | + |
|
404 | + $localobject=new Ticket($this->savdb); |
|
405 | + $result=$localobject->fetch($id); |
|
406 | + $result=$localobject->delete($user); |
|
407 | + |
|
408 | + print __METHOD__." id=".$id." result=".$result."\n"; |
|
409 | + $this->assertGreaterThan(0, $result); |
|
410 | + return $result; |
|
411 | + } |
|
412 | 412 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * \remarks To run this script as CLI: phpunit filename.php |
24 | 24 | */ |
25 | 25 | |
26 | -global $conf,$user,$langs,$db; |
|
26 | +global $conf, $user, $langs, $db; |
|
27 | 27 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
28 | 28 | //require_once 'PHPUnit/Autoload.php'; |
29 | 29 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | $user->fetch(1); |
36 | 36 | $user->getrights(); |
37 | 37 | } |
38 | -$conf->global->MAIN_DISABLE_ALL_MAILS=1; |
|
38 | +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
|
39 | 39 | |
40 | 40 | |
41 | 41 | /** |
@@ -63,11 +63,11 @@ discard block |
||
63 | 63 | parent::__construct(); |
64 | 64 | |
65 | 65 | //$this->sharedFixture |
66 | - global $conf,$user,$langs,$db; |
|
67 | - $this->savconf=$conf; |
|
68 | - $this->savuser=$user; |
|
69 | - $this->savlangs=$langs; |
|
70 | - $this->savdb=$db; |
|
66 | + global $conf, $user, $langs, $db; |
|
67 | + $this->savconf = $conf; |
|
68 | + $this->savuser = $user; |
|
69 | + $this->savlangs = $langs; |
|
70 | + $this->savdb = $db; |
|
71 | 71 | |
72 | 72 | print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
73 | 73 | //print " - db ".$db->db; |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | // Static methods |
78 | 78 | public static function setUpBeforeClass() |
79 | 79 | { |
80 | - global $conf,$user,$langs,$db; |
|
81 | - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
80 | + global $conf, $user, $langs, $db; |
|
81 | + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
82 | 82 | |
83 | 83 | print __METHOD__."\n"; |
84 | 84 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | // tear down after class |
87 | 87 | public static function tearDownAfterClass() |
88 | 88 | { |
89 | - global $conf,$user,$langs,$db; |
|
89 | + global $conf, $user, $langs, $db; |
|
90 | 90 | $db->rollback(); |
91 | 91 | |
92 | 92 | print __METHOD__."\n"; |
@@ -99,11 +99,11 @@ discard block |
||
99 | 99 | */ |
100 | 100 | protected function setUp() |
101 | 101 | { |
102 | - global $conf,$user,$langs,$db; |
|
103 | - $conf=$this->savconf; |
|
104 | - $user=$this->savuser; |
|
105 | - $langs=$this->savlangs; |
|
106 | - $db=$this->savdb; |
|
102 | + global $conf, $user, $langs, $db; |
|
103 | + $conf = $this->savconf; |
|
104 | + $user = $this->savuser; |
|
105 | + $langs = $this->savlangs; |
|
106 | + $db = $this->savdb; |
|
107 | 107 | |
108 | 108 | print __METHOD__."\n"; |
109 | 109 | } |
@@ -124,25 +124,25 @@ discard block |
||
124 | 124 | */ |
125 | 125 | public function testTicketCreate() |
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 | 133 | // Try to create one with bad values |
134 | - $localobject=new Ticket($this->savdb); |
|
134 | + $localobject = new Ticket($this->savdb); |
|
135 | 135 | $localobject->initAsSpecimen(); |
136 | 136 | $localobject->ref = ''; |
137 | - $result=$localobject->create($user); |
|
137 | + $result = $localobject->create($user); |
|
138 | 138 | |
139 | 139 | print __METHOD__." result=".$result."\n"; |
140 | 140 | $this->assertEquals(-3, $result, $localobject->error.join(',', $localobject->errors)); |
141 | 141 | |
142 | 142 | // Try to create one with correct values |
143 | - $localobject=new Ticket($this->savdb); |
|
143 | + $localobject = new Ticket($this->savdb); |
|
144 | 144 | $localobject->initAsSpecimen(); |
145 | - $result=$localobject->create($user); |
|
145 | + $result = $localobject->create($user); |
|
146 | 146 | |
147 | 147 | print __METHOD__." result=".$result."\n"; |
148 | 148 | $this->assertGreaterThan(0, $result, $localobject->error.join(',', $localobject->errors)); |
@@ -161,14 +161,14 @@ discard block |
||
161 | 161 | */ |
162 | 162 | public function testTicketFetch($id) |
163 | 163 | { |
164 | - global $conf,$user,$langs,$db; |
|
165 | - $conf=$this->savconf; |
|
166 | - $user=$this->savuser; |
|
167 | - $langs=$this->savlangs; |
|
168 | - $db=$this->savdb; |
|
164 | + global $conf, $user, $langs, $db; |
|
165 | + $conf = $this->savconf; |
|
166 | + $user = $this->savuser; |
|
167 | + $langs = $this->savlangs; |
|
168 | + $db = $this->savdb; |
|
169 | 169 | |
170 | - $localobject=new Ticket($this->savdb); |
|
171 | - $result=$localobject->fetch($id); |
|
170 | + $localobject = new Ticket($this->savdb); |
|
171 | + $result = $localobject->fetch($id); |
|
172 | 172 | |
173 | 173 | print __METHOD__." id=".$id." result=".$result."\n"; |
174 | 174 | $this->assertGreaterThan(0, $result); |
@@ -187,13 +187,13 @@ discard block |
||
187 | 187 | */ |
188 | 188 | public function testTicketmarkAsRead($localobject) |
189 | 189 | { |
190 | - global $conf,$user,$langs,$db; |
|
191 | - $conf=$this->savconf; |
|
192 | - $user=$this->savuser; |
|
193 | - $langs=$this->savlangs; |
|
194 | - $db=$this->savdb; |
|
190 | + global $conf, $user, $langs, $db; |
|
191 | + $conf = $this->savconf; |
|
192 | + $user = $this->savuser; |
|
193 | + $langs = $this->savlangs; |
|
194 | + $db = $this->savdb; |
|
195 | 195 | |
196 | - $result=$localobject->markAsRead($user); |
|
196 | + $result = $localobject->markAsRead($user); |
|
197 | 197 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
198 | 198 | |
199 | 199 | $this->assertGreaterThan(0, $result); |
@@ -211,15 +211,15 @@ discard block |
||
211 | 211 | */ |
212 | 212 | public function testTicketsetProject($localobject) |
213 | 213 | { |
214 | - global $conf,$user,$langs,$db; |
|
215 | - $conf=$this->savconf; |
|
216 | - $user=$this->savuser; |
|
217 | - $langs=$this->savlangs; |
|
218 | - $db=$this->savdb; |
|
214 | + global $conf, $user, $langs, $db; |
|
215 | + $conf = $this->savconf; |
|
216 | + $user = $this->savuser; |
|
217 | + $langs = $this->savlangs; |
|
218 | + $db = $this->savdb; |
|
219 | 219 | |
220 | 220 | $project_id = 1; |
221 | 221 | |
222 | - $result=$localobject->setProject($project_id); |
|
222 | + $result = $localobject->setProject($project_id); |
|
223 | 223 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
224 | 224 | |
225 | 225 | $this->assertGreaterThan(0, $result); |
@@ -237,15 +237,15 @@ discard block |
||
237 | 237 | */ |
238 | 238 | public function testTicketsetContract($localobject) |
239 | 239 | { |
240 | - global $conf,$user,$langs,$db; |
|
241 | - $conf=$this->savconf; |
|
242 | - $user=$this->savuser; |
|
243 | - $langs=$this->savlangs; |
|
244 | - $db=$this->savdb; |
|
240 | + global $conf, $user, $langs, $db; |
|
241 | + $conf = $this->savconf; |
|
242 | + $user = $this->savuser; |
|
243 | + $langs = $this->savlangs; |
|
244 | + $db = $this->savdb; |
|
245 | 245 | |
246 | 246 | $contract_id = 1; |
247 | 247 | |
248 | - $result=$localobject->setContract($contract_id); |
|
248 | + $result = $localobject->setContract($contract_id); |
|
249 | 249 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
250 | 250 | |
251 | 251 | $this->assertGreaterThan(0, $result); |
@@ -263,15 +263,15 @@ discard block |
||
263 | 263 | */ |
264 | 264 | public function testTicketsetProgression($localobject) |
265 | 265 | { |
266 | - global $conf,$user,$langs,$db; |
|
267 | - $conf=$this->savconf; |
|
268 | - $user=$this->savuser; |
|
269 | - $langs=$this->savlangs; |
|
270 | - $db=$this->savdb; |
|
266 | + global $conf, $user, $langs, $db; |
|
267 | + $conf = $this->savconf; |
|
268 | + $user = $this->savuser; |
|
269 | + $langs = $this->savlangs; |
|
270 | + $db = $this->savdb; |
|
271 | 271 | |
272 | 272 | $percent = 80; |
273 | 273 | |
274 | - $result=$localobject->setProgression($percent); |
|
274 | + $result = $localobject->setProgression($percent); |
|
275 | 275 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
276 | 276 | |
277 | 277 | $this->assertGreaterThan(0, $result); |
@@ -289,15 +289,15 @@ discard block |
||
289 | 289 | */ |
290 | 290 | public function testTicketassignUser($localobject) |
291 | 291 | { |
292 | - global $conf,$user,$langs,$db; |
|
293 | - $conf=$this->savconf; |
|
294 | - $user=$this->savuser; |
|
295 | - $langs=$this->savlangs; |
|
296 | - $db=$this->savdb; |
|
292 | + global $conf, $user, $langs, $db; |
|
293 | + $conf = $this->savconf; |
|
294 | + $user = $this->savuser; |
|
295 | + $langs = $this->savlangs; |
|
296 | + $db = $this->savdb; |
|
297 | 297 | |
298 | 298 | $user_id_to_assign = 1; |
299 | 299 | |
300 | - $result=$localobject->assignUser($user, $user_id_to_assign); |
|
300 | + $result = $localobject->assignUser($user, $user_id_to_assign); |
|
301 | 301 | ; |
302 | 302 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
303 | 303 | |
@@ -316,15 +316,15 @@ discard block |
||
316 | 316 | */ |
317 | 317 | public function testTicketassignUserOther($localobject) |
318 | 318 | { |
319 | - global $conf,$user,$langs,$db; |
|
320 | - $conf=$this->savconf; |
|
321 | - $user=$this->savuser; |
|
322 | - $langs=$this->savlangs; |
|
323 | - $db=$this->savdb; |
|
319 | + global $conf, $user, $langs, $db; |
|
320 | + $conf = $this->savconf; |
|
321 | + $user = $this->savuser; |
|
322 | + $langs = $this->savlangs; |
|
323 | + $db = $this->savdb; |
|
324 | 324 | |
325 | 325 | $user_id_to_assign = 2; |
326 | 326 | |
327 | - $result=$localobject->assignUser($user, $user_id_to_assign); |
|
327 | + $result = $localobject->assignUser($user, $user_id_to_assign); |
|
328 | 328 | ; |
329 | 329 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
330 | 330 | |
@@ -343,16 +343,16 @@ discard block |
||
343 | 343 | */ |
344 | 344 | public function testTicketcreateTicketLog($localobject) |
345 | 345 | { |
346 | - global $conf,$user,$langs,$db; |
|
347 | - $conf=$this->savconf; |
|
348 | - $user=$this->savuser; |
|
349 | - $langs=$this->savlangs; |
|
350 | - $db=$this->savdb; |
|
346 | + global $conf, $user, $langs, $db; |
|
347 | + $conf = $this->savconf; |
|
348 | + $user = $this->savuser; |
|
349 | + $langs = $this->savlangs; |
|
350 | + $db = $this->savdb; |
|
351 | 351 | |
352 | 352 | |
353 | 353 | $message = 'Test ticket log'; |
354 | 354 | $noemail = 1; |
355 | - $result=$localobject->createTicketLog($user, $message, $noemail); |
|
355 | + $result = $localobject->createTicketLog($user, $message, $noemail); |
|
356 | 356 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
357 | 357 | |
358 | 358 | $this->assertGreaterThan(0, $result); |
@@ -370,13 +370,13 @@ discard block |
||
370 | 370 | */ |
371 | 371 | public function testTicketclose($localobject) |
372 | 372 | { |
373 | - global $conf,$user,$langs,$db; |
|
374 | - $conf=$this->savconf; |
|
375 | - $user=$this->savuser; |
|
376 | - $langs=$this->savlangs; |
|
377 | - $db=$this->savdb; |
|
373 | + global $conf, $user, $langs, $db; |
|
374 | + $conf = $this->savconf; |
|
375 | + $user = $this->savuser; |
|
376 | + $langs = $this->savlangs; |
|
377 | + $db = $this->savdb; |
|
378 | 378 | |
379 | - $result=$localobject->close(); |
|
379 | + $result = $localobject->close(); |
|
380 | 380 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
381 | 381 | |
382 | 382 | $this->assertGreaterThan(0, $result); |
@@ -395,15 +395,15 @@ discard block |
||
395 | 395 | */ |
396 | 396 | public function testTicketDelete($id) |
397 | 397 | { |
398 | - global $conf,$user,$langs,$db; |
|
399 | - $conf=$this->savconf; |
|
400 | - $user=$this->savuser; |
|
401 | - $langs=$this->savlangs; |
|
402 | - $db=$this->savdb; |
|
403 | - |
|
404 | - $localobject=new Ticket($this->savdb); |
|
405 | - $result=$localobject->fetch($id); |
|
406 | - $result=$localobject->delete($user); |
|
398 | + global $conf, $user, $langs, $db; |
|
399 | + $conf = $this->savconf; |
|
400 | + $user = $this->savuser; |
|
401 | + $langs = $this->savlangs; |
|
402 | + $db = $this->savdb; |
|
403 | + |
|
404 | + $localobject = new Ticket($this->savdb); |
|
405 | + $result = $localobject->fetch($id); |
|
406 | + $result = $localobject->delete($user); |
|
407 | 407 | |
408 | 408 | print __METHOD__." id=".$id." result=".$result."\n"; |
409 | 409 | $this->assertGreaterThan(0, $result); |