@@ -89,9 +89,9 @@ discard block |
||
| 89 | 89 | */ |
| 90 | 90 | function __construct() |
| 91 | 91 | { |
| 92 | - parent::__construct(); |
|
| 92 | + parent::__construct(); |
|
| 93 | 93 | |
| 94 | - //$this->sharedFixture |
|
| 94 | + //$this->sharedFixture |
|
| 95 | 95 | global $conf,$user,$langs,$db; |
| 96 | 96 | $this->savconf=$conf; |
| 97 | 97 | $this->savuser=$user; |
@@ -235,10 +235,10 @@ discard block |
||
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | /** |
| 238 | - * testFactureFournisseurBuild |
|
| 239 | - * |
|
| 240 | - * @return int |
|
| 241 | - */ |
|
| 238 | + * testFactureFournisseurBuild |
|
| 239 | + * |
|
| 240 | + * @return int |
|
| 241 | + */ |
|
| 242 | 242 | public function testFactureFournisseurBuild() |
| 243 | 243 | { |
| 244 | 244 | global $conf,$user,$langs,$db; |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * \remarks To run this script as CLI: phpunit filename.php |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | -global $conf,$user,$langs,$db; |
|
| 27 | +global $conf, $user, $langs, $db; |
|
| 28 | 28 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
| 29 | 29 | //require_once 'PHPUnit/Autoload.php'; |
| 30 | 30 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | $user->fetch(1); |
| 65 | 65 | $user->getrights(); |
| 66 | 66 | } |
| 67 | -$conf->global->MAIN_DISABLE_ALL_MAILS=1; |
|
| 67 | +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
|
| 68 | 68 | |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -92,11 +92,11 @@ discard block |
||
| 92 | 92 | parent::__construct(); |
| 93 | 93 | |
| 94 | 94 | //$this->sharedFixture |
| 95 | - global $conf,$user,$langs,$db; |
|
| 96 | - $this->savconf=$conf; |
|
| 97 | - $this->savuser=$user; |
|
| 98 | - $this->savlangs=$langs; |
|
| 99 | - $this->savdb=$db; |
|
| 95 | + global $conf, $user, $langs, $db; |
|
| 96 | + $this->savconf = $conf; |
|
| 97 | + $this->savuser = $user; |
|
| 98 | + $this->savlangs = $langs; |
|
| 99 | + $this->savdb = $db; |
|
| 100 | 100 | |
| 101 | 101 | print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
| 102 | 102 | //print " - db ".$db->db; |
@@ -106,15 +106,15 @@ discard block |
||
| 106 | 106 | // Static methods |
| 107 | 107 | public static function setUpBeforeClass() |
| 108 | 108 | { |
| 109 | - global $conf,$user,$langs,$db; |
|
| 109 | + global $conf, $user, $langs, $db; |
|
| 110 | 110 | |
| 111 | - if (! $conf->facture->enabled) { print __METHOD__." invoice module not enabled\n"; die(); } |
|
| 112 | - if (! $conf->commande->enabled) { print __METHOD__." order module not enabled\n"; die(); } |
|
| 113 | - if (! $conf->propal->enabled) { print __METHOD__." propal module not enabled\n"; die(); } |
|
| 114 | - if (! $conf->projet->enabled) { print __METHOD__." project module not enabled\n"; die(); } |
|
| 115 | - if (! $conf->expedition->enabled) { print __METHOD__." shipment module not enabled\n"; die(); } |
|
| 116 | - if (! $conf->ficheinter->enabled) { print __METHOD__." intervention module not enabled\n"; die(); } |
|
| 117 | - if (! $conf->expensereport->enabled) { print __METHOD__." expensereport module not enabled\n"; die(); } |
|
| 111 | + if (!$conf->facture->enabled) { print __METHOD__." invoice module not enabled\n"; die(); } |
|
| 112 | + if (!$conf->commande->enabled) { print __METHOD__." order module not enabled\n"; die(); } |
|
| 113 | + if (!$conf->propal->enabled) { print __METHOD__." propal module not enabled\n"; die(); } |
|
| 114 | + if (!$conf->projet->enabled) { print __METHOD__." project module not enabled\n"; die(); } |
|
| 115 | + if (!$conf->expedition->enabled) { print __METHOD__." shipment module not enabled\n"; die(); } |
|
| 116 | + if (!$conf->ficheinter->enabled) { print __METHOD__." intervention module not enabled\n"; die(); } |
|
| 117 | + if (!$conf->expensereport->enabled) { print __METHOD__." expensereport module not enabled\n"; die(); } |
|
| 118 | 118 | |
| 119 | 119 | $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
| 120 | 120 | |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | // tear down after class |
| 125 | 125 | public static function tearDownAfterClass() |
| 126 | 126 | { |
| 127 | - global $conf,$user,$langs,$db; |
|
| 127 | + global $conf, $user, $langs, $db; |
|
| 128 | 128 | $db->rollback(); |
| 129 | 129 | |
| 130 | 130 | print __METHOD__."\n"; |
@@ -137,11 +137,11 @@ discard block |
||
| 137 | 137 | */ |
| 138 | 138 | protected function setUp() |
| 139 | 139 | { |
| 140 | - global $conf,$user,$langs,$db; |
|
| 141 | - $conf=$this->savconf; |
|
| 142 | - $user=$this->savuser; |
|
| 143 | - $langs=$this->savlangs; |
|
| 144 | - $db=$this->savdb; |
|
| 140 | + global $conf, $user, $langs, $db; |
|
| 141 | + $conf = $this->savconf; |
|
| 142 | + $user = $this->savuser; |
|
| 143 | + $langs = $this->savlangs; |
|
| 144 | + $db = $this->savdb; |
|
| 145 | 145 | |
| 146 | 146 | print __METHOD__."\n"; |
| 147 | 147 | } |
@@ -162,71 +162,71 @@ discard block |
||
| 162 | 162 | */ |
| 163 | 163 | public function testFactureBuild() |
| 164 | 164 | { |
| 165 | - global $conf,$user,$langs,$db; |
|
| 166 | - $conf=$this->savconf; |
|
| 167 | - $user=$this->savuser; |
|
| 168 | - $langs=$this->savlangs; |
|
| 169 | - $db=$this->savdb; |
|
| 165 | + global $conf, $user, $langs, $db; |
|
| 166 | + $conf = $this->savconf; |
|
| 167 | + $user = $this->savuser; |
|
| 168 | + $langs = $this->savlangs; |
|
| 169 | + $db = $this->savdb; |
|
| 170 | 170 | |
| 171 | - $conf->facture->dir_output.='/temp'; |
|
| 171 | + $conf->facture->dir_output .= '/temp'; |
|
| 172 | 172 | |
| 173 | - $localobjectcom=new Commande($this->savdb); |
|
| 173 | + $localobjectcom = new Commande($this->savdb); |
|
| 174 | 174 | $localobjectcom->initAsSpecimen(); |
| 175 | 175 | |
| 176 | - $localobject=new Facture($this->savdb); |
|
| 176 | + $localobject = new Facture($this->savdb); |
|
| 177 | 177 | $localobject->createFromOrder($localobjectcom, $user); |
| 178 | - $localobject->date_lim_reglement = dol_now() + 3600 * 24 *30; |
|
| 178 | + $localobject->date_lim_reglement = dol_now() + 3600 * 24 * 30; |
|
| 179 | 179 | |
| 180 | 180 | // Crabe (english) |
| 181 | - $localobject->modelpdf='crabe'; |
|
| 181 | + $localobject->modelpdf = 'crabe'; |
|
| 182 | 182 | $result = $localobject->generateDocument($localobject->modelpdf, $langs); |
| 183 | 183 | $this->assertLessThan($result, 0); |
| 184 | 184 | print __METHOD__." result=".$result."\n"; |
| 185 | 185 | |
| 186 | 186 | // Crabe (japanese) |
| 187 | - $newlangs1=new Translate("",$conf); |
|
| 187 | + $newlangs1 = new Translate("", $conf); |
|
| 188 | 188 | $newlangs1->setDefaultLang('ja_JP'); |
| 189 | - $localobject->modelpdf='crabe'; |
|
| 189 | + $localobject->modelpdf = 'crabe'; |
|
| 190 | 190 | $result = $localobject->generateDocument($localobject->modelpdf, $newlangs1); |
| 191 | 191 | $this->assertLessThan($result, 0); |
| 192 | 192 | print __METHOD__." result=".$result."\n"; |
| 193 | 193 | |
| 194 | 194 | // Crabe (saudiarabia) |
| 195 | - $newlangs2a=new Translate("",$conf); |
|
| 195 | + $newlangs2a = new Translate("", $conf); |
|
| 196 | 196 | $newlangs2a->setDefaultLang('sa_SA'); |
| 197 | - $localobject->modelpdf='crabe'; |
|
| 197 | + $localobject->modelpdf = 'crabe'; |
|
| 198 | 198 | $result = $localobject->generateDocument($localobject->modelpdf, $newlangs2a); |
| 199 | 199 | $this->assertLessThan($result, 0); |
| 200 | 200 | print __METHOD__." result=".$result."\n"; |
| 201 | 201 | |
| 202 | 202 | // Crabe (english_saudiarabia) |
| 203 | - $newlangs2b=new Translate("",$conf); |
|
| 203 | + $newlangs2b = new Translate("", $conf); |
|
| 204 | 204 | $newlangs2b->setDefaultLang('en_SA'); |
| 205 | - $localobject->modelpdf='crabe'; |
|
| 205 | + $localobject->modelpdf = 'crabe'; |
|
| 206 | 206 | $result = $localobject->generateDocument($localobject->modelpdf, $newlangs2b); |
| 207 | 207 | $this->assertLessThan($result, 0); |
| 208 | 208 | print __METHOD__." result=".$result."\n"; |
| 209 | 209 | |
| 210 | 210 | // Crabe (greek) |
| 211 | - $newlangs3=new Translate("",$conf); |
|
| 211 | + $newlangs3 = new Translate("", $conf); |
|
| 212 | 212 | $newlangs3->setDefaultLang('el_GR'); |
| 213 | - $localobject->modelpdf='crabe'; |
|
| 213 | + $localobject->modelpdf = 'crabe'; |
|
| 214 | 214 | $result = $localobject->generateDocument($localobject->modelpdf, $newlangs3); |
| 215 | 215 | $this->assertLessThan($result, 0); |
| 216 | 216 | print __METHOD__." result=".$result."\n"; |
| 217 | 217 | |
| 218 | 218 | // Crabe (chinese) |
| 219 | - $newlangs4=new Translate("",$conf); |
|
| 219 | + $newlangs4 = new Translate("", $conf); |
|
| 220 | 220 | $newlangs4->setDefaultLang('zh_CN'); |
| 221 | - $localobject->modelpdf='crabe'; |
|
| 221 | + $localobject->modelpdf = 'crabe'; |
|
| 222 | 222 | $result = $localobject->generateDocument($localobject->modelpdf, $newlangs4); |
| 223 | 223 | $this->assertLessThan($result, 0); |
| 224 | 224 | print __METHOD__." result=".$result."\n"; |
| 225 | 225 | |
| 226 | 226 | // Crabe (russian) |
| 227 | - $newlangs5=new Translate("",$conf); |
|
| 227 | + $newlangs5 = new Translate("", $conf); |
|
| 228 | 228 | $newlangs5->setDefaultLang('ru_RU'); |
| 229 | - $localobject->modelpdf='crabe'; |
|
| 229 | + $localobject->modelpdf = 'crabe'; |
|
| 230 | 230 | $result = $localobject->generateDocument($localobject->modelpdf, $newlangs5); |
| 231 | 231 | $this->assertLessThan($result, 0); |
| 232 | 232 | print __METHOD__." result=".$result."\n"; |
@@ -241,18 +241,18 @@ discard block |
||
| 241 | 241 | */ |
| 242 | 242 | public function testFactureFournisseurBuild() |
| 243 | 243 | { |
| 244 | - global $conf,$user,$langs,$db; |
|
| 245 | - $conf=$this->savconf; |
|
| 246 | - $user=$this->savuser; |
|
| 247 | - $langs=$this->savlangs; |
|
| 248 | - $db=$this->savdb; |
|
| 249 | - |
|
| 250 | - $conf->fournisseur->facture->dir_output.='/temp'; |
|
| 251 | - $localobject=new FactureFournisseur($this->savdb); |
|
| 244 | + global $conf, $user, $langs, $db; |
|
| 245 | + $conf = $this->savconf; |
|
| 246 | + $user = $this->savuser; |
|
| 247 | + $langs = $this->savlangs; |
|
| 248 | + $db = $this->savdb; |
|
| 249 | + |
|
| 250 | + $conf->fournisseur->facture->dir_output .= '/temp'; |
|
| 251 | + $localobject = new FactureFournisseur($this->savdb); |
|
| 252 | 252 | $localobject->initAsSpecimen(); |
| 253 | 253 | |
| 254 | 254 | // Canelle |
| 255 | - $localobject->modelpdf='canelle'; |
|
| 255 | + $localobject->modelpdf = 'canelle'; |
|
| 256 | 256 | $result = $localobject->generateDocument($localobject->modelpdf, $langs); |
| 257 | 257 | |
| 258 | 258 | $this->assertLessThan($result, 0); |
@@ -268,18 +268,18 @@ discard block |
||
| 268 | 268 | */ |
| 269 | 269 | public function testCommandeBuild() |
| 270 | 270 | { |
| 271 | - global $conf,$user,$langs,$db; |
|
| 272 | - $conf=$this->savconf; |
|
| 273 | - $user=$this->savuser; |
|
| 274 | - $langs=$this->savlangs; |
|
| 275 | - $db=$this->savdb; |
|
| 276 | - |
|
| 277 | - $conf->commande->dir_output.='/temp'; |
|
| 278 | - $localobject=new Commande($this->savdb); |
|
| 271 | + global $conf, $user, $langs, $db; |
|
| 272 | + $conf = $this->savconf; |
|
| 273 | + $user = $this->savuser; |
|
| 274 | + $langs = $this->savlangs; |
|
| 275 | + $db = $this->savdb; |
|
| 276 | + |
|
| 277 | + $conf->commande->dir_output .= '/temp'; |
|
| 278 | + $localobject = new Commande($this->savdb); |
|
| 279 | 279 | $localobject->initAsSpecimen(); |
| 280 | 280 | |
| 281 | 281 | // Einstein |
| 282 | - $localobject->modelpdf='einstein'; |
|
| 282 | + $localobject->modelpdf = 'einstein'; |
|
| 283 | 283 | $result = $localobject->generateDocument($localobject->modelpdf, $langs); |
| 284 | 284 | |
| 285 | 285 | $this->assertLessThan($result, 0); |
@@ -296,19 +296,19 @@ discard block |
||
| 296 | 296 | */ |
| 297 | 297 | public function testCommandeFournisseurBuild() |
| 298 | 298 | { |
| 299 | - global $conf,$user,$langs,$db; |
|
| 300 | - $conf=$this->savconf; |
|
| 301 | - $user=$this->savuser; |
|
| 302 | - $langs=$this->savlangs; |
|
| 303 | - $db=$this->savdb; |
|
| 304 | - |
|
| 305 | - $conf->fournisseur->commande->dir_output.='/temp'; |
|
| 306 | - $localobject=new CommandeFournisseur($this->savdb); |
|
| 299 | + global $conf, $user, $langs, $db; |
|
| 300 | + $conf = $this->savconf; |
|
| 301 | + $user = $this->savuser; |
|
| 302 | + $langs = $this->savlangs; |
|
| 303 | + $db = $this->savdb; |
|
| 304 | + |
|
| 305 | + $conf->fournisseur->commande->dir_output .= '/temp'; |
|
| 306 | + $localobject = new CommandeFournisseur($this->savdb); |
|
| 307 | 307 | $localobject->initAsSpecimen(); |
| 308 | 308 | |
| 309 | 309 | // Muscadet |
| 310 | - $localobject->modelpdf='muscadet'; |
|
| 311 | - $result= $localobject->generateDocument($localobject->modelpdf, $langs); |
|
| 310 | + $localobject->modelpdf = 'muscadet'; |
|
| 311 | + $result = $localobject->generateDocument($localobject->modelpdf, $langs); |
|
| 312 | 312 | |
| 313 | 313 | $this->assertLessThan($result, 0); |
| 314 | 314 | print __METHOD__." result=".$result."\n"; |
@@ -323,18 +323,18 @@ discard block |
||
| 323 | 323 | */ |
| 324 | 324 | public function testPropalBuild() |
| 325 | 325 | { |
| 326 | - global $conf,$user,$langs,$db; |
|
| 327 | - $conf=$this->savconf; |
|
| 328 | - $user=$this->savuser; |
|
| 329 | - $langs=$this->savlangs; |
|
| 330 | - $db=$this->savdb; |
|
| 331 | - |
|
| 332 | - $conf->propal->dir_output.='/temp'; |
|
| 333 | - $localobject=new Propal($this->savdb); |
|
| 326 | + global $conf, $user, $langs, $db; |
|
| 327 | + $conf = $this->savconf; |
|
| 328 | + $user = $this->savuser; |
|
| 329 | + $langs = $this->savlangs; |
|
| 330 | + $db = $this->savdb; |
|
| 331 | + |
|
| 332 | + $conf->propal->dir_output .= '/temp'; |
|
| 333 | + $localobject = new Propal($this->savdb); |
|
| 334 | 334 | $localobject->initAsSpecimen(); |
| 335 | 335 | |
| 336 | 336 | // Azur |
| 337 | - $localobject->modelpdf='azur'; |
|
| 337 | + $localobject->modelpdf = 'azur'; |
|
| 338 | 338 | $result = $localobject->generateDocument($localobject->modelpdf, $langs); |
| 339 | 339 | |
| 340 | 340 | $this->assertLessThan($result, 0); |
@@ -350,17 +350,17 @@ discard block |
||
| 350 | 350 | */ |
| 351 | 351 | public function testProjectBuild() |
| 352 | 352 | { |
| 353 | - global $conf,$user,$langs,$db; |
|
| 354 | - $conf=$this->savconf; |
|
| 355 | - $user=$this->savuser; |
|
| 356 | - $langs=$this->savlangs; |
|
| 357 | - $db=$this->savdb; |
|
| 358 | - $conf->projet->dir_output.='/temp'; |
|
| 359 | - $localobject=new Project($this->savdb); |
|
| 353 | + global $conf, $user, $langs, $db; |
|
| 354 | + $conf = $this->savconf; |
|
| 355 | + $user = $this->savuser; |
|
| 356 | + $langs = $this->savlangs; |
|
| 357 | + $db = $this->savdb; |
|
| 358 | + $conf->projet->dir_output .= '/temp'; |
|
| 359 | + $localobject = new Project($this->savdb); |
|
| 360 | 360 | $localobject->initAsSpecimen(); |
| 361 | 361 | |
| 362 | 362 | // Baleine |
| 363 | - $localobject->modelpdf='baleine'; |
|
| 363 | + $localobject->modelpdf = 'baleine'; |
|
| 364 | 364 | $result = $localobject->generateDocument($localobject->modelpdf, $langs); |
| 365 | 365 | |
| 366 | 366 | $this->assertLessThan($result, 0); |
@@ -376,19 +376,19 @@ discard block |
||
| 376 | 376 | */ |
| 377 | 377 | public function testFichinterBuild() |
| 378 | 378 | { |
| 379 | - global $conf,$user,$langs,$db; |
|
| 380 | - $conf=$this->savconf; |
|
| 381 | - $user=$this->savuser; |
|
| 382 | - $langs=$this->savlangs; |
|
| 383 | - $db=$this->savdb; |
|
| 384 | - |
|
| 385 | - $conf->ficheinter->dir_output.='/temp'; |
|
| 386 | - $localobject=new Fichinter($this->savdb); |
|
| 379 | + global $conf, $user, $langs, $db; |
|
| 380 | + $conf = $this->savconf; |
|
| 381 | + $user = $this->savuser; |
|
| 382 | + $langs = $this->savlangs; |
|
| 383 | + $db = $this->savdb; |
|
| 384 | + |
|
| 385 | + $conf->ficheinter->dir_output .= '/temp'; |
|
| 386 | + $localobject = new Fichinter($this->savdb); |
|
| 387 | 387 | $localobject->initAsSpecimen(); |
| 388 | 388 | |
| 389 | 389 | // Soleil |
| 390 | - $localobject->modelpdf='soleil'; |
|
| 391 | - $result=fichinter_create($db, $localobject, $localobject->modelpdf, $langs); |
|
| 390 | + $localobject->modelpdf = 'soleil'; |
|
| 391 | + $result = fichinter_create($db, $localobject, $localobject->modelpdf, $langs); |
|
| 392 | 392 | |
| 393 | 393 | $this->assertLessThan($result, 0); |
| 394 | 394 | print __METHOD__." result=".$result."\n"; |
@@ -403,26 +403,26 @@ discard block |
||
| 403 | 403 | */ |
| 404 | 404 | public function testExpeditionBuild() |
| 405 | 405 | { |
| 406 | - global $conf,$user,$langs,$db; |
|
| 407 | - $conf=$this->savconf; |
|
| 408 | - $user=$this->savuser; |
|
| 409 | - $langs=$this->savlangs; |
|
| 410 | - $db=$this->savdb; |
|
| 411 | - |
|
| 412 | - $conf->expedition->dir_output.='/temp'; |
|
| 413 | - $localobject=new Expedition($this->savdb); |
|
| 406 | + global $conf, $user, $langs, $db; |
|
| 407 | + $conf = $this->savconf; |
|
| 408 | + $user = $this->savuser; |
|
| 409 | + $langs = $this->savlangs; |
|
| 410 | + $db = $this->savdb; |
|
| 411 | + |
|
| 412 | + $conf->expedition->dir_output .= '/temp'; |
|
| 413 | + $localobject = new Expedition($this->savdb); |
|
| 414 | 414 | $localobject->initAsSpecimen(); |
| 415 | 415 | |
| 416 | 416 | // Merou |
| 417 | - $localobject->modelpdf='merou'; |
|
| 418 | - $result= $localobject->generateDocument($localobject->modelpdf, $langs); |
|
| 417 | + $localobject->modelpdf = 'merou'; |
|
| 418 | + $result = $localobject->generateDocument($localobject->modelpdf, $langs); |
|
| 419 | 419 | |
| 420 | 420 | $this->assertLessThan($result, 0); |
| 421 | 421 | print __METHOD__." result=".$result."\n"; |
| 422 | 422 | |
| 423 | 423 | // Rouget |
| 424 | - $localobject->modelpdf='rouget'; |
|
| 425 | - $result= $localobject->generateDocument($localobject->modelpdf, $langs); |
|
| 424 | + $localobject->modelpdf = 'rouget'; |
|
| 425 | + $result = $localobject->generateDocument($localobject->modelpdf, $langs); |
|
| 426 | 426 | |
| 427 | 427 | $this->assertLessThan($result, 0); |
| 428 | 428 | print __METHOD__." result=".$result."\n"; |
@@ -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,74 +47,74 @@ discard block |
||
| 47 | 47 | */ |
| 48 | 48 | class FichinterTest 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 | - 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 ContratTest |
|
| 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 | - */ |
|
| 95 | + /** |
|
| 96 | + * Init phpunit tests |
|
| 97 | + * |
|
| 98 | + * @return void |
|
| 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 | - print __METHOD__."\n"; |
|
| 108 | + print __METHOD__."\n"; |
|
| 109 | 109 | } |
| 110 | - /** |
|
| 111 | - * End phpunit tests |
|
| 112 | - * |
|
| 113 | - * @return void |
|
| 114 | - */ |
|
| 110 | + /** |
|
| 111 | + * End phpunit tests |
|
| 112 | + * |
|
| 113 | + * @return void |
|
| 114 | + */ |
|
| 115 | 115 | protected function tearDown() |
| 116 | 116 | { |
| 117 | - print __METHOD__."\n"; |
|
| 117 | + print __METHOD__."\n"; |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | /** |
@@ -124,20 +124,20 @@ discard block |
||
| 124 | 124 | */ |
| 125 | 125 | public function testFichinterCreate() |
| 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 Fichinter($this->savdb); |
|
| 134 | - $localobject->initAsSpecimen(); |
|
| 135 | - $result=$localobject->create($user); |
|
| 133 | + $localobject=new Fichinter($this->savdb); |
|
| 134 | + $localobject->initAsSpecimen(); |
|
| 135 | + $result=$localobject->create($user); |
|
| 136 | 136 | |
| 137 | - print __METHOD__." result=".$result."\n"; |
|
| 138 | - $this->assertLessThan($result, 0); |
|
| 137 | + print __METHOD__." result=".$result."\n"; |
|
| 138 | + $this->assertLessThan($result, 0); |
|
| 139 | 139 | |
| 140 | - return $result; |
|
| 140 | + return $result; |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /** |
@@ -151,19 +151,19 @@ discard block |
||
| 151 | 151 | */ |
| 152 | 152 | public function testFichinterFetch($id) |
| 153 | 153 | { |
| 154 | - global $conf,$user,$langs,$db; |
|
| 155 | - $conf=$this->savconf; |
|
| 156 | - $user=$this->savuser; |
|
| 157 | - $langs=$this->savlangs; |
|
| 158 | - $db=$this->savdb; |
|
| 154 | + global $conf,$user,$langs,$db; |
|
| 155 | + $conf=$this->savconf; |
|
| 156 | + $user=$this->savuser; |
|
| 157 | + $langs=$this->savlangs; |
|
| 158 | + $db=$this->savdb; |
|
| 159 | 159 | |
| 160 | - $localobject=new Fichinter($this->savdb); |
|
| 161 | - $result=$localobject->fetch($id); |
|
| 160 | + $localobject=new Fichinter($this->savdb); |
|
| 161 | + $result=$localobject->fetch($id); |
|
| 162 | 162 | |
| 163 | - print __METHOD__." id=".$id." result=".$result."\n"; |
|
| 164 | - $this->assertLessThan($result, 0); |
|
| 163 | + print __METHOD__." id=".$id." result=".$result."\n"; |
|
| 164 | + $this->assertLessThan($result, 0); |
|
| 165 | 165 | |
| 166 | - return $localobject; |
|
| 166 | + return $localobject; |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | /** |
@@ -177,20 +177,20 @@ discard block |
||
| 177 | 177 | */ |
| 178 | 178 | public function testFichinterValid($localobject) |
| 179 | 179 | { |
| 180 | - global $conf,$user,$langs,$db; |
|
| 181 | - $conf=$this->savconf; |
|
| 182 | - $user=$this->savuser; |
|
| 183 | - $langs=$this->savlangs; |
|
| 184 | - $db=$this->savdb; |
|
| 180 | + global $conf,$user,$langs,$db; |
|
| 181 | + $conf=$this->savconf; |
|
| 182 | + $user=$this->savuser; |
|
| 183 | + $langs=$this->savlangs; |
|
| 184 | + $db=$this->savdb; |
|
| 185 | 185 | |
| 186 | - $result=$localobject->setValid($user); |
|
| 187 | - print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
| 186 | + $result=$localobject->setValid($user); |
|
| 187 | + print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
| 188 | 188 | |
| 189 | - $this->assertLessThan($result, 0); |
|
| 190 | - return $localobject; |
|
| 189 | + $this->assertLessThan($result, 0); |
|
| 190 | + return $localobject; |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - /** |
|
| 193 | + /** |
|
| 194 | 194 | * testFichinterValid |
| 195 | 195 | * |
| 196 | 196 | * @param Object $localobject Object intervention |
@@ -230,18 +230,18 @@ discard block |
||
| 230 | 230 | */ |
| 231 | 231 | public function testFichinterDelete($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 Fichinter($this->savdb); |
|
| 240 | - $result=$localobject->fetch($id); |
|
| 241 | - $result=$localobject->delete($user); |
|
| 242 | - |
|
| 243 | - print __METHOD__." id=".$id." result=".$result."\n"; |
|
| 244 | - $this->assertLessThan($result, 0); |
|
| 245 | - return $result; |
|
| 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 Fichinter($this->savdb); |
|
| 240 | + $result=$localobject->fetch($id); |
|
| 241 | + $result=$localobject->delete($user); |
|
| 242 | + |
|
| 243 | + print __METHOD__." id=".$id." result=".$result."\n"; |
|
| 244 | + $this->assertLessThan($result, 0); |
|
| 245 | + return $result; |
|
| 246 | 246 | } |
| 247 | 247 | } |
@@ -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,15 +124,15 @@ discard block |
||
| 124 | 124 | */ |
| 125 | 125 | public function testFichinterCreate() |
| 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 Fichinter($this->savdb); |
|
| 133 | + $localobject = new Fichinter($this->savdb); |
|
| 134 | 134 | $localobject->initAsSpecimen(); |
| 135 | - $result=$localobject->create($user); |
|
| 135 | + $result = $localobject->create($user); |
|
| 136 | 136 | |
| 137 | 137 | print __METHOD__." result=".$result."\n"; |
| 138 | 138 | $this->assertLessThan($result, 0); |
@@ -151,14 +151,14 @@ discard block |
||
| 151 | 151 | */ |
| 152 | 152 | public function testFichinterFetch($id) |
| 153 | 153 | { |
| 154 | - global $conf,$user,$langs,$db; |
|
| 155 | - $conf=$this->savconf; |
|
| 156 | - $user=$this->savuser; |
|
| 157 | - $langs=$this->savlangs; |
|
| 158 | - $db=$this->savdb; |
|
| 154 | + global $conf, $user, $langs, $db; |
|
| 155 | + $conf = $this->savconf; |
|
| 156 | + $user = $this->savuser; |
|
| 157 | + $langs = $this->savlangs; |
|
| 158 | + $db = $this->savdb; |
|
| 159 | 159 | |
| 160 | - $localobject=new Fichinter($this->savdb); |
|
| 161 | - $result=$localobject->fetch($id); |
|
| 160 | + $localobject = new Fichinter($this->savdb); |
|
| 161 | + $result = $localobject->fetch($id); |
|
| 162 | 162 | |
| 163 | 163 | print __METHOD__." id=".$id." result=".$result."\n"; |
| 164 | 164 | $this->assertLessThan($result, 0); |
@@ -177,13 +177,13 @@ discard block |
||
| 177 | 177 | */ |
| 178 | 178 | public function testFichinterValid($localobject) |
| 179 | 179 | { |
| 180 | - global $conf,$user,$langs,$db; |
|
| 181 | - $conf=$this->savconf; |
|
| 182 | - $user=$this->savuser; |
|
| 183 | - $langs=$this->savlangs; |
|
| 184 | - $db=$this->savdb; |
|
| 180 | + global $conf, $user, $langs, $db; |
|
| 181 | + $conf = $this->savconf; |
|
| 182 | + $user = $this->savuser; |
|
| 183 | + $langs = $this->savlangs; |
|
| 184 | + $db = $this->savdb; |
|
| 185 | 185 | |
| 186 | - $result=$localobject->setValid($user); |
|
| 186 | + $result = $localobject->setValid($user); |
|
| 187 | 187 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
| 188 | 188 | |
| 189 | 189 | $this->assertLessThan($result, 0); |
@@ -201,11 +201,11 @@ discard block |
||
| 201 | 201 | */ |
| 202 | 202 | public function testFichinterOther($localobject) |
| 203 | 203 | { |
| 204 | - global $conf,$user,$langs,$db; |
|
| 205 | - $conf=$this->savconf; |
|
| 206 | - $user=$this->savuser; |
|
| 207 | - $langs=$this->savlangs; |
|
| 208 | - $db=$this->savdb; |
|
| 204 | + global $conf, $user, $langs, $db; |
|
| 205 | + $conf = $this->savconf; |
|
| 206 | + $user = $this->savuser; |
|
| 207 | + $langs = $this->savlangs; |
|
| 208 | + $db = $this->savdb; |
|
| 209 | 209 | |
| 210 | 210 | /*$result=$localobject->setstatus(0); |
| 211 | 211 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
@@ -230,15 +230,15 @@ discard block |
||
| 230 | 230 | */ |
| 231 | 231 | public function testFichinterDelete($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 Fichinter($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 Fichinter($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); |
@@ -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 DiscountTest 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 DiscountTest |
|
| 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 DiscountTest |
|
| 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() |
|
| 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 | - print __METHOD__."\n"; |
|
| 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 | - */ |
|
| 95 | + /** |
|
| 96 | + * Init phpunit tests |
|
| 97 | + * |
|
| 98 | + * @return void |
|
| 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; |
|
| 107 | - |
|
| 108 | - print __METHOD__."\n"; |
|
| 109 | - //print $db->getVersion()."\n"; |
|
| 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 | + //print $db->getVersion()."\n"; |
|
| 110 | 110 | } |
| 111 | - /** |
|
| 112 | - * End phpunit tests |
|
| 113 | - * |
|
| 114 | - * @return void |
|
| 115 | - */ |
|
| 111 | + /** |
|
| 112 | + * End phpunit tests |
|
| 113 | + * |
|
| 114 | + * @return void |
|
| 115 | + */ |
|
| 116 | 116 | protected function tearDown() |
| 117 | 117 | { |
| 118 | - print __METHOD__."\n"; |
|
| 118 | + print __METHOD__."\n"; |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | /** |
@@ -125,19 +125,19 @@ discard block |
||
| 125 | 125 | */ |
| 126 | 126 | public function testDiscountCreate() |
| 127 | 127 | { |
| 128 | - global $conf,$user,$langs,$db; |
|
| 129 | - $conf=$this->savconf; |
|
| 130 | - $user=$this->savuser; |
|
| 131 | - $langs=$this->savlangs; |
|
| 132 | - $db=$this->savdb; |
|
| 133 | - |
|
| 134 | - $localobject=new DiscountAbsolute($this->savdb); |
|
| 135 | - $localobject->initAsSpecimen(); |
|
| 136 | - $result=$localobject->create($user); |
|
| 137 | - |
|
| 138 | - $this->assertLessThan($result, 0); |
|
| 139 | - print __METHOD__." result=".$result."\n"; |
|
| 140 | - return $result; |
|
| 128 | + global $conf,$user,$langs,$db; |
|
| 129 | + $conf=$this->savconf; |
|
| 130 | + $user=$this->savuser; |
|
| 131 | + $langs=$this->savlangs; |
|
| 132 | + $db=$this->savdb; |
|
| 133 | + |
|
| 134 | + $localobject=new DiscountAbsolute($this->savdb); |
|
| 135 | + $localobject->initAsSpecimen(); |
|
| 136 | + $result=$localobject->create($user); |
|
| 137 | + |
|
| 138 | + $this->assertLessThan($result, 0); |
|
| 139 | + print __METHOD__." result=".$result."\n"; |
|
| 140 | + return $result; |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /** |
@@ -151,18 +151,18 @@ discard block |
||
| 151 | 151 | */ |
| 152 | 152 | public function testDiscountFetch($id) |
| 153 | 153 | { |
| 154 | - global $conf,$user,$langs,$db; |
|
| 155 | - $conf=$this->savconf; |
|
| 156 | - $user=$this->savuser; |
|
| 157 | - $langs=$this->savlangs; |
|
| 158 | - $db=$this->savdb; |
|
| 159 | - |
|
| 160 | - $localobject=new DiscountAbsolute($this->savdb); |
|
| 161 | - $result=$localobject->fetch($id); |
|
| 162 | - |
|
| 163 | - $this->assertLessThan($result, 0); |
|
| 164 | - print __METHOD__." id=".$id." result=".$result."\n"; |
|
| 165 | - return $id; |
|
| 154 | + global $conf,$user,$langs,$db; |
|
| 155 | + $conf=$this->savconf; |
|
| 156 | + $user=$this->savuser; |
|
| 157 | + $langs=$this->savlangs; |
|
| 158 | + $db=$this->savdb; |
|
| 159 | + |
|
| 160 | + $localobject=new DiscountAbsolute($this->savdb); |
|
| 161 | + $result=$localobject->fetch($id); |
|
| 162 | + |
|
| 163 | + $this->assertLessThan($result, 0); |
|
| 164 | + print __METHOD__." id=".$id." result=".$result."\n"; |
|
| 165 | + return $id; |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | /** |
@@ -176,18 +176,18 @@ discard block |
||
| 176 | 176 | */ |
| 177 | 177 | public function testDiscountDelete($id) |
| 178 | 178 | { |
| 179 | - global $conf,$user,$langs,$db; |
|
| 180 | - $conf=$this->savconf; |
|
| 181 | - $user=$this->savuser; |
|
| 182 | - $langs=$this->savlangs; |
|
| 183 | - $db=$this->savdb; |
|
| 184 | - |
|
| 185 | - $localobject=new DiscountAbsolute($this->savdb); |
|
| 186 | - $result=$localobject->fetch($id); |
|
| 187 | - $result=$localobject->delete($user); |
|
| 188 | - |
|
| 189 | - print __METHOD__." id=".$id." result=".$result."\n"; |
|
| 190 | - $this->assertLessThan($result, 0); |
|
| 191 | - return $result; |
|
| 179 | + global $conf,$user,$langs,$db; |
|
| 180 | + $conf=$this->savconf; |
|
| 181 | + $user=$this->savuser; |
|
| 182 | + $langs=$this->savlangs; |
|
| 183 | + $db=$this->savdb; |
|
| 184 | + |
|
| 185 | + $localobject=new DiscountAbsolute($this->savdb); |
|
| 186 | + $result=$localobject->fetch($id); |
|
| 187 | + $result=$localobject->delete($user); |
|
| 188 | + |
|
| 189 | + print __METHOD__." id=".$id." result=".$result."\n"; |
|
| 190 | + $this->assertLessThan($result, 0); |
|
| 191 | + return $result; |
|
| 192 | 192 | } |
| 193 | 193 | } |
@@ -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 | //print $db->getVersion()."\n"; |
@@ -125,15 +125,15 @@ discard block |
||
| 125 | 125 | */ |
| 126 | 126 | public function testDiscountCreate() |
| 127 | 127 | { |
| 128 | - global $conf,$user,$langs,$db; |
|
| 129 | - $conf=$this->savconf; |
|
| 130 | - $user=$this->savuser; |
|
| 131 | - $langs=$this->savlangs; |
|
| 132 | - $db=$this->savdb; |
|
| 128 | + global $conf, $user, $langs, $db; |
|
| 129 | + $conf = $this->savconf; |
|
| 130 | + $user = $this->savuser; |
|
| 131 | + $langs = $this->savlangs; |
|
| 132 | + $db = $this->savdb; |
|
| 133 | 133 | |
| 134 | - $localobject=new DiscountAbsolute($this->savdb); |
|
| 134 | + $localobject = new DiscountAbsolute($this->savdb); |
|
| 135 | 135 | $localobject->initAsSpecimen(); |
| 136 | - $result=$localobject->create($user); |
|
| 136 | + $result = $localobject->create($user); |
|
| 137 | 137 | |
| 138 | 138 | $this->assertLessThan($result, 0); |
| 139 | 139 | print __METHOD__." result=".$result."\n"; |
@@ -151,14 +151,14 @@ discard block |
||
| 151 | 151 | */ |
| 152 | 152 | public function testDiscountFetch($id) |
| 153 | 153 | { |
| 154 | - global $conf,$user,$langs,$db; |
|
| 155 | - $conf=$this->savconf; |
|
| 156 | - $user=$this->savuser; |
|
| 157 | - $langs=$this->savlangs; |
|
| 158 | - $db=$this->savdb; |
|
| 154 | + global $conf, $user, $langs, $db; |
|
| 155 | + $conf = $this->savconf; |
|
| 156 | + $user = $this->savuser; |
|
| 157 | + $langs = $this->savlangs; |
|
| 158 | + $db = $this->savdb; |
|
| 159 | 159 | |
| 160 | - $localobject=new DiscountAbsolute($this->savdb); |
|
| 161 | - $result=$localobject->fetch($id); |
|
| 160 | + $localobject = new DiscountAbsolute($this->savdb); |
|
| 161 | + $result = $localobject->fetch($id); |
|
| 162 | 162 | |
| 163 | 163 | $this->assertLessThan($result, 0); |
| 164 | 164 | print __METHOD__." id=".$id." result=".$result."\n"; |
@@ -176,15 +176,15 @@ discard block |
||
| 176 | 176 | */ |
| 177 | 177 | public function testDiscountDelete($id) |
| 178 | 178 | { |
| 179 | - global $conf,$user,$langs,$db; |
|
| 180 | - $conf=$this->savconf; |
|
| 181 | - $user=$this->savuser; |
|
| 182 | - $langs=$this->savlangs; |
|
| 183 | - $db=$this->savdb; |
|
| 184 | - |
|
| 185 | - $localobject=new DiscountAbsolute($this->savdb); |
|
| 186 | - $result=$localobject->fetch($id); |
|
| 187 | - $result=$localobject->delete($user); |
|
| 179 | + global $conf, $user, $langs, $db; |
|
| 180 | + $conf = $this->savconf; |
|
| 181 | + $user = $this->savuser; |
|
| 182 | + $langs = $this->savlangs; |
|
| 183 | + $db = $this->savdb; |
|
| 184 | + |
|
| 185 | + $localobject = new DiscountAbsolute($this->savdb); |
|
| 186 | + $result = $localobject->fetch($id); |
|
| 187 | + $result = $localobject->delete($user); |
|
| 188 | 188 | |
| 189 | 189 | print __METHOD__." id=".$id." result=".$result."\n"; |
| 190 | 190 | $this->assertLessThan($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; |
@@ -284,19 +284,19 @@ discard block |
||
| 284 | 284 | */ |
| 285 | 285 | public function testUserAddPermission($id) |
| 286 | 286 | { |
| 287 | - global $conf,$user,$langs,$db; |
|
| 288 | - $conf=$this->savconf; |
|
| 289 | - $user=$this->savuser; |
|
| 290 | - $langs=$this->savlangs; |
|
| 291 | - $db=$this->savdb; |
|
| 292 | - |
|
| 293 | - $localobject=new User($this->savdb); |
|
| 294 | - $result=$localobject->fetch(1); // Other tests use the user id 1 |
|
| 295 | - $result=$localobject->addrights(0, 'supplier_proposal'); |
|
| 296 | - |
|
| 297 | - print __METHOD__." id=".$id." result=".$result."\n"; |
|
| 298 | - $this->assertLessThan($result, 0); |
|
| 299 | - return $result; |
|
| 287 | + global $conf,$user,$langs,$db; |
|
| 288 | + $conf=$this->savconf; |
|
| 289 | + $user=$this->savuser; |
|
| 290 | + $langs=$this->savlangs; |
|
| 291 | + $db=$this->savdb; |
|
| 292 | + |
|
| 293 | + $localobject=new User($this->savdb); |
|
| 294 | + $result=$localobject->fetch(1); // Other tests use the user id 1 |
|
| 295 | + $result=$localobject->addrights(0, 'supplier_proposal'); |
|
| 296 | + |
|
| 297 | + print __METHOD__." id=".$id." result=".$result."\n"; |
|
| 298 | + $this->assertLessThan($result, 0); |
|
| 299 | + return $result; |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | |
@@ -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,11 +76,11 @@ 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 | |
| 81 | - if (! empty($conf->global->MAIN_MODULE_LDAP)) { print "\n".__METHOD__." module LDAP must be disabled.\n"; die(); } |
|
| 81 | + if (!empty($conf->global->MAIN_MODULE_LDAP)) { print "\n".__METHOD__." module LDAP must be disabled.\n"; die(); } |
|
| 82 | 82 | |
| 83 | - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
| 83 | + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
| 84 | 84 | |
| 85 | 85 | print __METHOD__."\n"; |
| 86 | 86 | } |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | // tear down after class |
| 89 | 89 | public static function tearDownAfterClass() |
| 90 | 90 | { |
| 91 | - global $conf,$user,$langs,$db; |
|
| 91 | + global $conf, $user, $langs, $db; |
|
| 92 | 92 | $db->rollback(); |
| 93 | 93 | |
| 94 | 94 | print __METHOD__."\n"; |
@@ -101,11 +101,11 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | protected function setUp() |
| 103 | 103 | { |
| 104 | - global $conf,$user,$langs,$db; |
|
| 105 | - $conf=$this->savconf; |
|
| 106 | - $user=$this->savuser; |
|
| 107 | - $langs=$this->savlangs; |
|
| 108 | - $db=$this->savdb; |
|
| 104 | + global $conf, $user, $langs, $db; |
|
| 105 | + $conf = $this->savconf; |
|
| 106 | + $user = $this->savuser; |
|
| 107 | + $langs = $this->savlangs; |
|
| 108 | + $db = $this->savdb; |
|
| 109 | 109 | |
| 110 | 110 | print __METHOD__."\n"; |
| 111 | 111 | } |
@@ -127,15 +127,15 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | public function testUserCreate() |
| 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 User($this->savdb); |
|
| 136 | + $localobject = new User($this->savdb); |
|
| 137 | 137 | $localobject->initAsSpecimen(); |
| 138 | - $result=$localobject->create($user); |
|
| 138 | + $result = $localobject->create($user); |
|
| 139 | 139 | |
| 140 | 140 | $this->assertLessThan($result, 0); |
| 141 | 141 | print __METHOD__." result=".$result."\n"; |
@@ -152,14 +152,14 @@ discard block |
||
| 152 | 152 | */ |
| 153 | 153 | public function testUserFetch($id) |
| 154 | 154 | { |
| 155 | - global $conf,$user,$langs,$db; |
|
| 156 | - $conf=$this->savconf; |
|
| 157 | - $user=$this->savuser; |
|
| 158 | - $langs=$this->savlangs; |
|
| 159 | - $db=$this->savdb; |
|
| 155 | + global $conf, $user, $langs, $db; |
|
| 156 | + $conf = $this->savconf; |
|
| 157 | + $user = $this->savuser; |
|
| 158 | + $langs = $this->savlangs; |
|
| 159 | + $db = $this->savdb; |
|
| 160 | 160 | |
| 161 | - $localobject=new User($this->savdb); |
|
| 162 | - $result=$localobject->fetch($id); |
|
| 161 | + $localobject = new User($this->savdb); |
|
| 162 | + $result = $localobject->fetch($id); |
|
| 163 | 163 | |
| 164 | 164 | $this->assertLessThan($result, 0); |
| 165 | 165 | print __METHOD__." id=".$id." result=".$result."\n"; |
@@ -176,23 +176,23 @@ discard block |
||
| 176 | 176 | */ |
| 177 | 177 | public function testUserUpdate($localobject) |
| 178 | 178 | { |
| 179 | - global $conf,$user,$langs,$db; |
|
| 180 | - $conf=$this->savconf; |
|
| 181 | - $user=$this->savuser; |
|
| 182 | - $langs=$this->savlangs; |
|
| 183 | - $db=$this->savdb; |
|
| 179 | + global $conf, $user, $langs, $db; |
|
| 180 | + $conf = $this->savconf; |
|
| 181 | + $user = $this->savuser; |
|
| 182 | + $langs = $this->savlangs; |
|
| 183 | + $db = $this->savdb; |
|
| 184 | 184 | |
| 185 | 185 | $this->changeProperties($localobject); |
| 186 | - $result=$localobject->update($user); |
|
| 186 | + $result = $localobject->update($user); |
|
| 187 | 187 | |
| 188 | 188 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
| 189 | 189 | $this->assertLessThan($result, 0); |
| 190 | 190 | |
| 191 | 191 | // Test everything are still same than specimen |
| 192 | - $newlocalobject=new User($this->savdb); |
|
| 192 | + $newlocalobject = new User($this->savdb); |
|
| 193 | 193 | $newlocalobject->initAsSpecimen(); |
| 194 | 194 | $this->changeProperties($newlocalobject); |
| 195 | - $this->assertEquals($this->objCompare($localobject,$newlocalobject,true,array('id','socid','societe_id','ref','pass','pass_indatabase','pass_indatabase_crypted','datec','datem','datelastlogin','datepreviouslogin')), array()); // Actual, Expected |
|
| 195 | + $this->assertEquals($this->objCompare($localobject, $newlocalobject, true, array('id', 'socid', 'societe_id', 'ref', 'pass', 'pass_indatabase', 'pass_indatabase_crypted', 'datec', 'datem', 'datelastlogin', 'datepreviouslogin')), array()); // Actual, Expected |
|
| 196 | 196 | |
| 197 | 197 | return $localobject; |
| 198 | 198 | } |
@@ -207,13 +207,13 @@ discard block |
||
| 207 | 207 | */ |
| 208 | 208 | public function testUserDisable($localobject) |
| 209 | 209 | { |
| 210 | - global $conf,$user,$langs,$db; |
|
| 211 | - $conf=$this->savconf; |
|
| 212 | - $user=$this->savuser; |
|
| 213 | - $langs=$this->savlangs; |
|
| 214 | - $db=$this->savdb; |
|
| 210 | + global $conf, $user, $langs, $db; |
|
| 211 | + $conf = $this->savconf; |
|
| 212 | + $user = $this->savuser; |
|
| 213 | + $langs = $this->savlangs; |
|
| 214 | + $db = $this->savdb; |
|
| 215 | 215 | |
| 216 | - $result=$localobject->setstatus(0); |
|
| 216 | + $result = $localobject->setstatus(0); |
|
| 217 | 217 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
| 218 | 218 | |
| 219 | 219 | $this->assertLessThan($result, 0); |
@@ -231,11 +231,11 @@ discard block |
||
| 231 | 231 | */ |
| 232 | 232 | public function testUserOther($localobject) |
| 233 | 233 | { |
| 234 | - global $conf,$user,$langs,$db; |
|
| 235 | - $conf=$this->savconf; |
|
| 236 | - $user=$this->savuser; |
|
| 237 | - $langs=$this->savlangs; |
|
| 238 | - $db=$this->savdb; |
|
| 234 | + global $conf, $user, $langs, $db; |
|
| 235 | + $conf = $this->savconf; |
|
| 236 | + $user = $this->savuser; |
|
| 237 | + $langs = $this->savlangs; |
|
| 238 | + $db = $this->savdb; |
|
| 239 | 239 | |
| 240 | 240 | /*$result=$localobject->setstatus(0); |
| 241 | 241 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
@@ -259,15 +259,15 @@ discard block |
||
| 259 | 259 | */ |
| 260 | 260 | public function testUserDelete($id) |
| 261 | 261 | { |
| 262 | - global $conf,$user,$langs,$db; |
|
| 263 | - $conf=$this->savconf; |
|
| 264 | - $user=$this->savuser; |
|
| 265 | - $langs=$this->savlangs; |
|
| 266 | - $db=$this->savdb; |
|
| 262 | + global $conf, $user, $langs, $db; |
|
| 263 | + $conf = $this->savconf; |
|
| 264 | + $user = $this->savuser; |
|
| 265 | + $langs = $this->savlangs; |
|
| 266 | + $db = $this->savdb; |
|
| 267 | 267 | |
| 268 | - $localobject=new User($this->savdb); |
|
| 269 | - $result=$localobject->fetch($id); |
|
| 270 | - $result=$localobject->delete($id); |
|
| 268 | + $localobject = new User($this->savdb); |
|
| 269 | + $result = $localobject->fetch($id); |
|
| 270 | + $result = $localobject->delete($id); |
|
| 271 | 271 | |
| 272 | 272 | print __METHOD__." id=".$id." result=".$result."\n"; |
| 273 | 273 | $this->assertLessThan($result, 0); |
@@ -284,15 +284,15 @@ discard block |
||
| 284 | 284 | */ |
| 285 | 285 | public function testUserAddPermission($id) |
| 286 | 286 | { |
| 287 | - global $conf,$user,$langs,$db; |
|
| 288 | - $conf=$this->savconf; |
|
| 289 | - $user=$this->savuser; |
|
| 290 | - $langs=$this->savlangs; |
|
| 291 | - $db=$this->savdb; |
|
| 287 | + global $conf, $user, $langs, $db; |
|
| 288 | + $conf = $this->savconf; |
|
| 289 | + $user = $this->savuser; |
|
| 290 | + $langs = $this->savlangs; |
|
| 291 | + $db = $this->savdb; |
|
| 292 | 292 | |
| 293 | - $localobject=new User($this->savdb); |
|
| 294 | - $result=$localobject->fetch(1); // Other tests use the user id 1 |
|
| 295 | - $result=$localobject->addrights(0, 'supplier_proposal'); |
|
| 293 | + $localobject = new User($this->savdb); |
|
| 294 | + $result = $localobject->fetch(1); // Other tests use the user id 1 |
|
| 295 | + $result = $localobject->addrights(0, 'supplier_proposal'); |
|
| 296 | 296 | |
| 297 | 297 | print __METHOD__." id=".$id." result=".$result."\n"; |
| 298 | 298 | $this->assertLessThan($result, 0); |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | */ |
| 310 | 310 | public function changeProperties(&$localobject) |
| 311 | 311 | { |
| 312 | - $localobject->note='New note after update'; |
|
| 312 | + $localobject->note = 'New note after update'; |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | /** |
@@ -321,24 +321,24 @@ discard block |
||
| 321 | 321 | * @param array $fieldstoignorearray Array of fields to ignore in diff |
| 322 | 322 | * @return array Array with differences |
| 323 | 323 | */ |
| 324 | - public function objCompare($oA,$oB,$ignoretype=true,$fieldstoignorearray=array('id')) |
|
| 324 | + public function objCompare($oA, $oB, $ignoretype = true, $fieldstoignorearray = array('id')) |
|
| 325 | 325 | { |
| 326 | - $retAr=array(); |
|
| 326 | + $retAr = array(); |
|
| 327 | 327 | |
| 328 | 328 | if (get_class($oA) !== get_class($oB)) { |
| 329 | - $retAr[]="Supplied objects are not of same class."; |
|
| 329 | + $retAr[] = "Supplied objects are not of same class."; |
|
| 330 | 330 | } else { |
| 331 | - $oVarsA=get_object_vars($oA); |
|
| 332 | - $oVarsB=get_object_vars($oB); |
|
| 333 | - $aKeys=array_keys($oVarsA); |
|
| 334 | - foreach($aKeys as $sKey) { |
|
| 335 | - if (in_array($sKey,$fieldstoignorearray)) |
|
| 331 | + $oVarsA = get_object_vars($oA); |
|
| 332 | + $oVarsB = get_object_vars($oB); |
|
| 333 | + $aKeys = array_keys($oVarsA); |
|
| 334 | + foreach ($aKeys as $sKey) { |
|
| 335 | + if (in_array($sKey, $fieldstoignorearray)) |
|
| 336 | 336 | continue; |
| 337 | - if (! $ignoretype && $oVarsA[$sKey] !== $oVarsB[$sKey]) { |
|
| 338 | - $retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey])?get_class($oVarsA[$sKey]):$oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey])?get_class($oVarsB[$sKey]):$oVarsB[$sKey]); |
|
| 337 | + if (!$ignoretype && $oVarsA[$sKey] !== $oVarsB[$sKey]) { |
|
| 338 | + $retAr[] = $sKey.' : '.(is_object($oVarsA[$sKey]) ?get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ?get_class($oVarsB[$sKey]) : $oVarsB[$sKey]); |
|
| 339 | 339 | } |
| 340 | 340 | if ($ignoretype && $oVarsA[$sKey] != $oVarsB[$sKey]) { |
| 341 | - $retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey])?get_class($oVarsA[$sKey]):$oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey])?get_class($oVarsB[$sKey]):$oVarsB[$sKey]); |
|
| 341 | + $retAr[] = $sKey.' : '.(is_object($oVarsA[$sKey]) ?get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ?get_class($oVarsB[$sKey]) : $oVarsB[$sKey]); |
|
| 342 | 342 | } |
| 343 | 343 | } |
| 344 | 344 | } |
@@ -332,8 +332,9 @@ |
||
| 332 | 332 | $oVarsB=get_object_vars($oB); |
| 333 | 333 | $aKeys=array_keys($oVarsA); |
| 334 | 334 | foreach($aKeys as $sKey) { |
| 335 | - if (in_array($sKey,$fieldstoignorearray)) |
|
| 336 | - continue; |
|
| 335 | + if (in_array($sKey,$fieldstoignorearray)) { |
|
| 336 | + continue; |
|
| 337 | + } |
|
| 337 | 338 | if (! $ignoretype && $oVarsA[$sKey] !== $oVarsB[$sKey]) { |
| 338 | 339 | $retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey])?get_class($oVarsA[$sKey]):$oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey])?get_class($oVarsB[$sKey]):$oVarsB[$sKey]); |
| 339 | 340 | } |
@@ -34,9 +34,9 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | if (empty($user->id)) |
| 36 | 36 | { |
| 37 | - print "Load permissions for admin user nb 1\n"; |
|
| 38 | - $user->fetch(1); |
|
| 39 | - $user->getrights(); |
|
| 37 | + print "Load permissions for admin user nb 1\n"; |
|
| 38 | + $user->fetch(1); |
|
| 39 | + $user->getrights(); |
|
| 40 | 40 | } |
| 41 | 41 | $conf->global->MAIN_DISABLE_ALL_MAILS=1; |
| 42 | 42 | |
@@ -50,74 +50,74 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | class PdfDocTest extends PHPUnit_Framework_TestCase |
| 52 | 52 | { |
| 53 | - protected $savconf; |
|
| 54 | - protected $savuser; |
|
| 55 | - protected $savlangs; |
|
| 56 | - protected $savdb; |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * Constructor |
|
| 60 | - * We save global variables into local variables |
|
| 61 | - * |
|
| 62 | - * @return PdfDocTest |
|
| 63 | - */ |
|
| 64 | - function __construct() |
|
| 65 | - { |
|
| 66 | - parent::__construct(); |
|
| 67 | - |
|
| 68 | - //$this->sharedFixture |
|
| 69 | - global $conf,$user,$langs,$db; |
|
| 70 | - $this->savconf=$conf; |
|
| 71 | - $this->savuser=$user; |
|
| 72 | - $this->savlangs=$langs; |
|
| 73 | - $this->savdb=$db; |
|
| 74 | - |
|
| 75 | - print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
|
| 76 | - //print " - db ".$db->db; |
|
| 77 | - print "\n"; |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - // Static methods |
|
| 81 | - public static function setUpBeforeClass() |
|
| 53 | + protected $savconf; |
|
| 54 | + protected $savuser; |
|
| 55 | + protected $savlangs; |
|
| 56 | + protected $savdb; |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * Constructor |
|
| 60 | + * We save global variables into local variables |
|
| 61 | + * |
|
| 62 | + * @return PdfDocTest |
|
| 63 | + */ |
|
| 64 | + function __construct() |
|
| 65 | + { |
|
| 66 | + parent::__construct(); |
|
| 67 | + |
|
| 68 | + //$this->sharedFixture |
|
| 69 | + global $conf,$user,$langs,$db; |
|
| 70 | + $this->savconf=$conf; |
|
| 71 | + $this->savuser=$user; |
|
| 72 | + $this->savlangs=$langs; |
|
| 73 | + $this->savdb=$db; |
|
| 74 | + |
|
| 75 | + print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
|
| 76 | + //print " - db ".$db->db; |
|
| 77 | + print "\n"; |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + // Static methods |
|
| 81 | + public static function setUpBeforeClass() |
|
| 82 | 82 | { |
| 83 | - global $conf,$user,$langs,$db; |
|
| 84 | - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
| 83 | + global $conf,$user,$langs,$db; |
|
| 84 | + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
| 85 | 85 | |
| 86 | - print __METHOD__."\n"; |
|
| 86 | + print __METHOD__."\n"; |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | // tear down after class |
| 90 | 90 | public static function tearDownAfterClass() |
| 91 | 91 | { |
| 92 | - global $conf,$user,$langs,$db; |
|
| 93 | - $db->rollback(); |
|
| 92 | + global $conf,$user,$langs,$db; |
|
| 93 | + $db->rollback(); |
|
| 94 | 94 | |
| 95 | - print __METHOD__."\n"; |
|
| 95 | + print __METHOD__."\n"; |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - /** |
|
| 99 | - * Init phpunit tests |
|
| 100 | - * |
|
| 101 | - * @return void |
|
| 102 | - */ |
|
| 98 | + /** |
|
| 99 | + * Init phpunit tests |
|
| 100 | + * |
|
| 101 | + * @return void |
|
| 102 | + */ |
|
| 103 | 103 | protected function setUp() |
| 104 | 104 | { |
| 105 | - global $conf,$user,$langs,$db; |
|
| 106 | - $conf=$this->savconf; |
|
| 107 | - $user=$this->savuser; |
|
| 108 | - $langs=$this->savlangs; |
|
| 109 | - $db=$this->savdb; |
|
| 105 | + global $conf,$user,$langs,$db; |
|
| 106 | + $conf=$this->savconf; |
|
| 107 | + $user=$this->savuser; |
|
| 108 | + $langs=$this->savlangs; |
|
| 109 | + $db=$this->savdb; |
|
| 110 | 110 | |
| 111 | - print __METHOD__."\n"; |
|
| 111 | + print __METHOD__."\n"; |
|
| 112 | 112 | } |
| 113 | - /** |
|
| 114 | - * End phpunit tests |
|
| 115 | - * |
|
| 116 | - * @return void |
|
| 117 | - */ |
|
| 113 | + /** |
|
| 114 | + * End phpunit tests |
|
| 115 | + * |
|
| 116 | + * @return void |
|
| 117 | + */ |
|
| 118 | 118 | protected function tearDown() |
| 119 | 119 | { |
| 120 | - print __METHOD__."\n"; |
|
| 120 | + print __METHOD__."\n"; |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | /** |
@@ -127,48 +127,48 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | public function testPdfDocGetLineDesc() |
| 129 | 129 | { |
| 130 | - global $conf,$user,$langs,$db; |
|
| 131 | - $conf=$this->savconf; |
|
| 132 | - $user=$this->savuser; |
|
| 133 | - $langs=$this->savlangs; |
|
| 134 | - $db=$this->savdb; |
|
| 135 | - |
|
| 136 | - $localproduct=new Product($this->savdb); |
|
| 137 | - $localproduct->fetch(0,'PIDRESS'); |
|
| 138 | - $product_id=$localproduct->id; |
|
| 139 | - if ($product_id <= 0) { print "\n".__METHOD__." A product with ref PIDRESS must exists into database"; die(); } |
|
| 140 | - |
|
| 141 | - $localobject=new Facture($this->savdb); |
|
| 142 | - $localobject->initAsSpecimen(); |
|
| 143 | - $localobject->lines=array(); |
|
| 144 | - $localobject->lines[0]=new FactureLigne($this->savdb); |
|
| 145 | - $localobject->lines[0]->fk_product=$product_id; |
|
| 146 | - $localobject->lines[0]->label='Label 1'; |
|
| 147 | - $localobject->lines[0]->desc="This is a description with a é accent\n(Country of origin: France)"; |
|
| 148 | - |
|
| 149 | - $result=pdf_getlinedesc($localobject,0,$langs); |
|
| 150 | - print __METHOD__." result=".$result."\n"; |
|
| 151 | - $this->assertEquals($result,"PIDRESS - Label 1<br>This is a description with a é accent<br>(Country of origin: France)"); |
|
| 152 | - |
|
| 153 | - $result=doc_getlinedesc($localobject->lines[0],$langs); |
|
| 154 | - print __METHOD__." result=".$result."\n"; |
|
| 155 | - $this->assertEquals($result,"PIDRESS - Label 1\nThis is a description with a é accent\n(Country of origin: France)"); |
|
| 130 | + global $conf,$user,$langs,$db; |
|
| 131 | + $conf=$this->savconf; |
|
| 132 | + $user=$this->savuser; |
|
| 133 | + $langs=$this->savlangs; |
|
| 134 | + $db=$this->savdb; |
|
| 135 | + |
|
| 136 | + $localproduct=new Product($this->savdb); |
|
| 137 | + $localproduct->fetch(0,'PIDRESS'); |
|
| 138 | + $product_id=$localproduct->id; |
|
| 139 | + if ($product_id <= 0) { print "\n".__METHOD__." A product with ref PIDRESS must exists into database"; die(); } |
|
| 140 | + |
|
| 141 | + $localobject=new Facture($this->savdb); |
|
| 142 | + $localobject->initAsSpecimen(); |
|
| 143 | + $localobject->lines=array(); |
|
| 144 | + $localobject->lines[0]=new FactureLigne($this->savdb); |
|
| 145 | + $localobject->lines[0]->fk_product=$product_id; |
|
| 146 | + $localobject->lines[0]->label='Label 1'; |
|
| 147 | + $localobject->lines[0]->desc="This is a description with a é accent\n(Country of origin: France)"; |
|
| 148 | + |
|
| 149 | + $result=pdf_getlinedesc($localobject,0,$langs); |
|
| 150 | + print __METHOD__." result=".$result."\n"; |
|
| 151 | + $this->assertEquals($result,"PIDRESS - Label 1<br>This is a description with a é accent<br>(Country of origin: France)"); |
|
| 152 | + |
|
| 153 | + $result=doc_getlinedesc($localobject->lines[0],$langs); |
|
| 154 | + print __METHOD__." result=".$result."\n"; |
|
| 155 | + $this->assertEquals($result,"PIDRESS - Label 1\nThis is a description with a é accent\n(Country of origin: France)"); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | /** |
| 159 | - * testPdfGetHeightForLogo |
|
| 160 | - * |
|
| 161 | - * @return void |
|
| 162 | - */ |
|
| 159 | + * testPdfGetHeightForLogo |
|
| 160 | + * |
|
| 161 | + * @return void |
|
| 162 | + */ |
|
| 163 | 163 | public function testPdfGetHeightForLogo() |
| 164 | 164 | { |
| 165 | 165 | $file=dirname(__FILE__).'/img250x50.jpg'; |
| 166 | 166 | $result=pdf_getHeightForLogo($file); |
| 167 | 167 | print __METHOD__." result=".$result."\n"; |
| 168 | - $this->assertEquals($result,22); |
|
| 168 | + $this->assertEquals($result,22); |
|
| 169 | 169 | $file=dirname(__FILE__).'/img250x20.png'; |
| 170 | 170 | $result=pdf_getHeightForLogo($file); |
| 171 | 171 | print __METHOD__." result=".$result."\n"; |
| 172 | - $this->assertEquals($result,10.4); |
|
| 172 | + $this->assertEquals($result,10.4); |
|
| 173 | 173 | } |
| 174 | 174 | } |
@@ -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'; |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | $user->fetch(1); |
| 39 | 39 | $user->getrights(); |
| 40 | 40 | } |
| 41 | -$conf->global->MAIN_DISABLE_ALL_MAILS=1; |
|
| 41 | +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
|
| 42 | 42 | |
| 43 | 43 | |
| 44 | 44 | /** |
@@ -66,11 +66,11 @@ discard block |
||
| 66 | 66 | parent::__construct(); |
| 67 | 67 | |
| 68 | 68 | //$this->sharedFixture |
| 69 | - global $conf,$user,$langs,$db; |
|
| 70 | - $this->savconf=$conf; |
|
| 71 | - $this->savuser=$user; |
|
| 72 | - $this->savlangs=$langs; |
|
| 73 | - $this->savdb=$db; |
|
| 69 | + global $conf, $user, $langs, $db; |
|
| 70 | + $this->savconf = $conf; |
|
| 71 | + $this->savuser = $user; |
|
| 72 | + $this->savlangs = $langs; |
|
| 73 | + $this->savdb = $db; |
|
| 74 | 74 | |
| 75 | 75 | print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
| 76 | 76 | //print " - db ".$db->db; |
@@ -80,8 +80,8 @@ discard block |
||
| 80 | 80 | // Static methods |
| 81 | 81 | public static function setUpBeforeClass() |
| 82 | 82 | { |
| 83 | - global $conf,$user,$langs,$db; |
|
| 84 | - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
| 83 | + global $conf, $user, $langs, $db; |
|
| 84 | + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
| 85 | 85 | |
| 86 | 86 | print __METHOD__."\n"; |
| 87 | 87 | } |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | // tear down after class |
| 90 | 90 | public static function tearDownAfterClass() |
| 91 | 91 | { |
| 92 | - global $conf,$user,$langs,$db; |
|
| 92 | + global $conf, $user, $langs, $db; |
|
| 93 | 93 | $db->rollback(); |
| 94 | 94 | |
| 95 | 95 | print __METHOD__."\n"; |
@@ -102,11 +102,11 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | protected function setUp() |
| 104 | 104 | { |
| 105 | - global $conf,$user,$langs,$db; |
|
| 106 | - $conf=$this->savconf; |
|
| 107 | - $user=$this->savuser; |
|
| 108 | - $langs=$this->savlangs; |
|
| 109 | - $db=$this->savdb; |
|
| 105 | + global $conf, $user, $langs, $db; |
|
| 106 | + $conf = $this->savconf; |
|
| 107 | + $user = $this->savuser; |
|
| 108 | + $langs = $this->savlangs; |
|
| 109 | + $db = $this->savdb; |
|
| 110 | 110 | |
| 111 | 111 | print __METHOD__."\n"; |
| 112 | 112 | } |
@@ -127,32 +127,32 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | public function testPdfDocGetLineDesc() |
| 129 | 129 | { |
| 130 | - global $conf,$user,$langs,$db; |
|
| 131 | - $conf=$this->savconf; |
|
| 132 | - $user=$this->savuser; |
|
| 133 | - $langs=$this->savlangs; |
|
| 134 | - $db=$this->savdb; |
|
| 135 | - |
|
| 136 | - $localproduct=new Product($this->savdb); |
|
| 137 | - $localproduct->fetch(0,'PIDRESS'); |
|
| 138 | - $product_id=$localproduct->id; |
|
| 130 | + global $conf, $user, $langs, $db; |
|
| 131 | + $conf = $this->savconf; |
|
| 132 | + $user = $this->savuser; |
|
| 133 | + $langs = $this->savlangs; |
|
| 134 | + $db = $this->savdb; |
|
| 135 | + |
|
| 136 | + $localproduct = new Product($this->savdb); |
|
| 137 | + $localproduct->fetch(0, 'PIDRESS'); |
|
| 138 | + $product_id = $localproduct->id; |
|
| 139 | 139 | if ($product_id <= 0) { print "\n".__METHOD__." A product with ref PIDRESS must exists into database"; die(); } |
| 140 | 140 | |
| 141 | - $localobject=new Facture($this->savdb); |
|
| 141 | + $localobject = new Facture($this->savdb); |
|
| 142 | 142 | $localobject->initAsSpecimen(); |
| 143 | - $localobject->lines=array(); |
|
| 144 | - $localobject->lines[0]=new FactureLigne($this->savdb); |
|
| 145 | - $localobject->lines[0]->fk_product=$product_id; |
|
| 146 | - $localobject->lines[0]->label='Label 1'; |
|
| 147 | - $localobject->lines[0]->desc="This is a description with a é accent\n(Country of origin: France)"; |
|
| 143 | + $localobject->lines = array(); |
|
| 144 | + $localobject->lines[0] = new FactureLigne($this->savdb); |
|
| 145 | + $localobject->lines[0]->fk_product = $product_id; |
|
| 146 | + $localobject->lines[0]->label = 'Label 1'; |
|
| 147 | + $localobject->lines[0]->desc = "This is a description with a é accent\n(Country of origin: France)"; |
|
| 148 | 148 | |
| 149 | - $result=pdf_getlinedesc($localobject,0,$langs); |
|
| 149 | + $result = pdf_getlinedesc($localobject, 0, $langs); |
|
| 150 | 150 | print __METHOD__." result=".$result."\n"; |
| 151 | - $this->assertEquals($result,"PIDRESS - Label 1<br>This is a description with a é accent<br>(Country of origin: France)"); |
|
| 151 | + $this->assertEquals($result, "PIDRESS - Label 1<br>This is a description with a é accent<br>(Country of origin: France)"); |
|
| 152 | 152 | |
| 153 | - $result=doc_getlinedesc($localobject->lines[0],$langs); |
|
| 153 | + $result = doc_getlinedesc($localobject->lines[0], $langs); |
|
| 154 | 154 | print __METHOD__." result=".$result."\n"; |
| 155 | - $this->assertEquals($result,"PIDRESS - Label 1\nThis is a description with a é accent\n(Country of origin: France)"); |
|
| 155 | + $this->assertEquals($result, "PIDRESS - Label 1\nThis is a description with a é accent\n(Country of origin: France)"); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | /** |
@@ -162,13 +162,13 @@ discard block |
||
| 162 | 162 | */ |
| 163 | 163 | public function testPdfGetHeightForLogo() |
| 164 | 164 | { |
| 165 | - $file=dirname(__FILE__).'/img250x50.jpg'; |
|
| 166 | - $result=pdf_getHeightForLogo($file); |
|
| 165 | + $file = dirname(__FILE__).'/img250x50.jpg'; |
|
| 166 | + $result = pdf_getHeightForLogo($file); |
|
| 167 | 167 | print __METHOD__." result=".$result."\n"; |
| 168 | - $this->assertEquals($result,22); |
|
| 169 | - $file=dirname(__FILE__).'/img250x20.png'; |
|
| 170 | - $result=pdf_getHeightForLogo($file); |
|
| 168 | + $this->assertEquals($result, 22); |
|
| 169 | + $file = dirname(__FILE__).'/img250x20.png'; |
|
| 170 | + $result = pdf_getHeightForLogo($file); |
|
| 171 | 171 | print __METHOD__." result=".$result."\n"; |
| 172 | - $this->assertEquals($result,10.4); |
|
| 172 | + $this->assertEquals($result, 10.4); |
|
| 173 | 173 | } |
| 174 | 174 | } |
@@ -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 LoanTest 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 LoanTest |
|
| 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 LoanTest |
|
| 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() |
|
| 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 | - print __METHOD__."\n"; |
|
| 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 | - */ |
|
| 95 | + /** |
|
| 96 | + * Init phpunit tests |
|
| 97 | + * |
|
| 98 | + * @return void |
|
| 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; |
|
| 107 | - |
|
| 108 | - print __METHOD__."\n"; |
|
| 109 | - //print $db->getVersion()."\n"; |
|
| 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 | + //print $db->getVersion()."\n"; |
|
| 110 | 110 | } |
| 111 | - /** |
|
| 112 | - * End phpunit tests |
|
| 113 | - * |
|
| 114 | - * @return void |
|
| 115 | - */ |
|
| 111 | + /** |
|
| 112 | + * End phpunit tests |
|
| 113 | + * |
|
| 114 | + * @return void |
|
| 115 | + */ |
|
| 116 | 116 | protected function tearDown() |
| 117 | 117 | { |
| 118 | - print __METHOD__."\n"; |
|
| 118 | + print __METHOD__."\n"; |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | /** |
@@ -125,19 +125,19 @@ discard block |
||
| 125 | 125 | */ |
| 126 | 126 | public function testLoanCreate() |
| 127 | 127 | { |
| 128 | - global $conf,$user,$langs,$db; |
|
| 129 | - $conf=$this->savconf; |
|
| 130 | - $user=$this->savuser; |
|
| 131 | - $langs=$this->savlangs; |
|
| 132 | - $db=$this->savdb; |
|
| 133 | - |
|
| 134 | - $localobject=new Loan($this->savdb); |
|
| 135 | - $localobject->initAsSpecimen(); |
|
| 136 | - $result=$localobject->create($user); |
|
| 137 | - |
|
| 138 | - $this->assertLessThan($result, 0); |
|
| 139 | - print __METHOD__." result=".$result."\n"; |
|
| 140 | - return $result; |
|
| 128 | + global $conf,$user,$langs,$db; |
|
| 129 | + $conf=$this->savconf; |
|
| 130 | + $user=$this->savuser; |
|
| 131 | + $langs=$this->savlangs; |
|
| 132 | + $db=$this->savdb; |
|
| 133 | + |
|
| 134 | + $localobject=new Loan($this->savdb); |
|
| 135 | + $localobject->initAsSpecimen(); |
|
| 136 | + $result=$localobject->create($user); |
|
| 137 | + |
|
| 138 | + $this->assertLessThan($result, 0); |
|
| 139 | + print __METHOD__." result=".$result."\n"; |
|
| 140 | + return $result; |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /** |
@@ -151,21 +151,21 @@ discard block |
||
| 151 | 151 | */ |
| 152 | 152 | public function testLoanFetch($id) |
| 153 | 153 | { |
| 154 | - global $conf,$user,$langs,$db; |
|
| 155 | - $conf=$this->savconf; |
|
| 156 | - $user=$this->savuser; |
|
| 157 | - $langs=$this->savlangs; |
|
| 158 | - $db=$this->savdb; |
|
| 159 | - |
|
| 160 | - $localobject=new Loan($this->savdb); |
|
| 161 | - $result=$localobject->fetch($id); |
|
| 162 | - |
|
| 163 | - $this->assertLessThan($result, 0); |
|
| 164 | - print __METHOD__." id=".$id." result=".$result."\n"; |
|
| 165 | - return $localobject; |
|
| 154 | + global $conf,$user,$langs,$db; |
|
| 155 | + $conf=$this->savconf; |
|
| 156 | + $user=$this->savuser; |
|
| 157 | + $langs=$this->savlangs; |
|
| 158 | + $db=$this->savdb; |
|
| 159 | + |
|
| 160 | + $localobject=new Loan($this->savdb); |
|
| 161 | + $result=$localobject->fetch($id); |
|
| 162 | + |
|
| 163 | + $this->assertLessThan($result, 0); |
|
| 164 | + print __METHOD__." id=".$id." result=".$result."\n"; |
|
| 165 | + return $localobject; |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - /** |
|
| 168 | + /** |
|
| 169 | 169 | * testLoanOther |
| 170 | 170 | * |
| 171 | 171 | * @param Loan $localobject Loan |
@@ -184,8 +184,8 @@ discard block |
||
| 184 | 184 | |
| 185 | 185 | $result=$localobject->set_paid($user); |
| 186 | 186 | |
| 187 | - print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
| 188 | - $this->assertLessThan($result, 0); |
|
| 187 | + print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
| 188 | + $this->assertLessThan($result, 0); |
|
| 189 | 189 | return $localobject->id; |
| 190 | 190 | } |
| 191 | 191 | |
@@ -200,18 +200,18 @@ discard block |
||
| 200 | 200 | */ |
| 201 | 201 | public function testLoanDelete($id) |
| 202 | 202 | { |
| 203 | - global $conf,$user,$langs,$db; |
|
| 204 | - $conf=$this->savconf; |
|
| 205 | - $user=$this->savuser; |
|
| 206 | - $langs=$this->savlangs; |
|
| 207 | - $db=$this->savdb; |
|
| 208 | - |
|
| 209 | - $localobject=new Loan($this->savdb); |
|
| 210 | - $result=$localobject->fetch($id); |
|
| 211 | - $result=$localobject->delete($user); |
|
| 212 | - |
|
| 213 | - print __METHOD__." id=".$id." result=".$result."\n"; |
|
| 214 | - $this->assertLessThan($result, 0); |
|
| 215 | - return $result; |
|
| 203 | + global $conf,$user,$langs,$db; |
|
| 204 | + $conf=$this->savconf; |
|
| 205 | + $user=$this->savuser; |
|
| 206 | + $langs=$this->savlangs; |
|
| 207 | + $db=$this->savdb; |
|
| 208 | + |
|
| 209 | + $localobject=new Loan($this->savdb); |
|
| 210 | + $result=$localobject->fetch($id); |
|
| 211 | + $result=$localobject->delete($user); |
|
| 212 | + |
|
| 213 | + print __METHOD__." id=".$id." result=".$result."\n"; |
|
| 214 | + $this->assertLessThan($result, 0); |
|
| 215 | + return $result; |
|
| 216 | 216 | } |
| 217 | 217 | } |
@@ -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 | //print $db->getVersion()."\n"; |
@@ -125,15 +125,15 @@ discard block |
||
| 125 | 125 | */ |
| 126 | 126 | public function testLoanCreate() |
| 127 | 127 | { |
| 128 | - global $conf,$user,$langs,$db; |
|
| 129 | - $conf=$this->savconf; |
|
| 130 | - $user=$this->savuser; |
|
| 131 | - $langs=$this->savlangs; |
|
| 132 | - $db=$this->savdb; |
|
| 128 | + global $conf, $user, $langs, $db; |
|
| 129 | + $conf = $this->savconf; |
|
| 130 | + $user = $this->savuser; |
|
| 131 | + $langs = $this->savlangs; |
|
| 132 | + $db = $this->savdb; |
|
| 133 | 133 | |
| 134 | - $localobject=new Loan($this->savdb); |
|
| 134 | + $localobject = new Loan($this->savdb); |
|
| 135 | 135 | $localobject->initAsSpecimen(); |
| 136 | - $result=$localobject->create($user); |
|
| 136 | + $result = $localobject->create($user); |
|
| 137 | 137 | |
| 138 | 138 | $this->assertLessThan($result, 0); |
| 139 | 139 | print __METHOD__." result=".$result."\n"; |
@@ -151,14 +151,14 @@ discard block |
||
| 151 | 151 | */ |
| 152 | 152 | public function testLoanFetch($id) |
| 153 | 153 | { |
| 154 | - global $conf,$user,$langs,$db; |
|
| 155 | - $conf=$this->savconf; |
|
| 156 | - $user=$this->savuser; |
|
| 157 | - $langs=$this->savlangs; |
|
| 158 | - $db=$this->savdb; |
|
| 154 | + global $conf, $user, $langs, $db; |
|
| 155 | + $conf = $this->savconf; |
|
| 156 | + $user = $this->savuser; |
|
| 157 | + $langs = $this->savlangs; |
|
| 158 | + $db = $this->savdb; |
|
| 159 | 159 | |
| 160 | - $localobject=new Loan($this->savdb); |
|
| 161 | - $result=$localobject->fetch($id); |
|
| 160 | + $localobject = new Loan($this->savdb); |
|
| 161 | + $result = $localobject->fetch($id); |
|
| 162 | 162 | |
| 163 | 163 | $this->assertLessThan($result, 0); |
| 164 | 164 | print __METHOD__." id=".$id." result=".$result."\n"; |
@@ -176,13 +176,13 @@ discard block |
||
| 176 | 176 | */ |
| 177 | 177 | public function testLoanOther($localobject) |
| 178 | 178 | { |
| 179 | - global $conf,$user,$langs,$db; |
|
| 180 | - $conf=$this->savconf; |
|
| 181 | - $user=$this->savuser; |
|
| 182 | - $langs=$this->savlangs; |
|
| 183 | - $db=$this->savdb; |
|
| 179 | + global $conf, $user, $langs, $db; |
|
| 180 | + $conf = $this->savconf; |
|
| 181 | + $user = $this->savuser; |
|
| 182 | + $langs = $this->savlangs; |
|
| 183 | + $db = $this->savdb; |
|
| 184 | 184 | |
| 185 | - $result=$localobject->set_paid($user); |
|
| 185 | + $result = $localobject->set_paid($user); |
|
| 186 | 186 | |
| 187 | 187 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
| 188 | 188 | $this->assertLessThan($result, 0); |
@@ -200,15 +200,15 @@ discard block |
||
| 200 | 200 | */ |
| 201 | 201 | public function testLoanDelete($id) |
| 202 | 202 | { |
| 203 | - global $conf,$user,$langs,$db; |
|
| 204 | - $conf=$this->savconf; |
|
| 205 | - $user=$this->savuser; |
|
| 206 | - $langs=$this->savlangs; |
|
| 207 | - $db=$this->savdb; |
|
| 208 | - |
|
| 209 | - $localobject=new Loan($this->savdb); |
|
| 210 | - $result=$localobject->fetch($id); |
|
| 211 | - $result=$localobject->delete($user); |
|
| 203 | + global $conf, $user, $langs, $db; |
|
| 204 | + $conf = $this->savconf; |
|
| 205 | + $user = $this->savuser; |
|
| 206 | + $langs = $this->savlangs; |
|
| 207 | + $db = $this->savdb; |
|
| 208 | + |
|
| 209 | + $localobject = new Loan($this->savdb); |
|
| 210 | + $result = $localobject->fetch($id); |
|
| 211 | + $result = $localobject->delete($user); |
|
| 212 | 212 | |
| 213 | 213 | print __METHOD__." id=".$id." result=".$result."\n"; |
| 214 | 214 | $this->assertLessThan($result, 0); |
@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | function __construct() |
| 63 | 63 | { |
| 64 | - parent::__construct(); |
|
| 64 | + parent::__construct(); |
|
| 65 | 65 | |
| 66 | - //$this->sharedFixture |
|
| 66 | + //$this->sharedFixture |
|
| 67 | 67 | global $conf,$user,$langs,$db; |
| 68 | 68 | $this->savconf=$conf; |
| 69 | 69 | $this->savuser=$user; |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | $result=$localobject->update_note($localobject->note,'_private'); |
| 271 | 271 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
| 272 | 272 | $this->assertLessThan($result, 0); |
| 273 | - $result=$localobject->update_note($localobject->note,'_public'); |
|
| 273 | + $result=$localobject->update_note($localobject->note,'_public'); |
|
| 274 | 274 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
| 275 | 275 | $this->assertLessThan($result, 0); |
| 276 | 276 | |
@@ -338,15 +338,15 @@ discard block |
||
| 338 | 338 | return $localobject; |
| 339 | 339 | } |
| 340 | 340 | |
| 341 | - /** |
|
| 342 | - * testAdherentSetUserId |
|
| 343 | - * |
|
| 344 | - * @param Adherent $localobject Member instance |
|
| 345 | - * @return Adherent |
|
| 346 | - * |
|
| 347 | - * @depends testAdherentMakeSubstitution |
|
| 348 | - * The depends says test is run only if previous is ok |
|
| 349 | - */ |
|
| 341 | + /** |
|
| 342 | + * testAdherentSetUserId |
|
| 343 | + * |
|
| 344 | + * @param Adherent $localobject Member instance |
|
| 345 | + * @return Adherent |
|
| 346 | + * |
|
| 347 | + * @depends testAdherentMakeSubstitution |
|
| 348 | + * The depends says test is run only if previous is ok |
|
| 349 | + */ |
|
| 350 | 350 | public function testAdherentSetUserId(Adherent $localobject) |
| 351 | 351 | { |
| 352 | 352 | global $conf,$user,$langs,$db; |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * \remarks To run this script as CLI: phpunit filename.php |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | -global $conf,$user,$langs,$db; |
|
| 27 | +global $conf, $user, $langs, $db; |
|
| 28 | 28 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
| 29 | 29 | //require_once 'PHPUnit/Autoload.php'; |
| 30 | 30 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | $user->fetch(1); |
| 37 | 37 | $user->getrights(); |
| 38 | 38 | } |
| 39 | -$conf->global->MAIN_DISABLE_ALL_MAILS=1; |
|
| 39 | +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
|
| 40 | 40 | |
| 41 | 41 | |
| 42 | 42 | /** |
@@ -64,11 +64,11 @@ discard block |
||
| 64 | 64 | parent::__construct(); |
| 65 | 65 | |
| 66 | 66 | //$this->sharedFixture |
| 67 | - global $conf,$user,$langs,$db; |
|
| 68 | - $this->savconf=$conf; |
|
| 69 | - $this->savuser=$user; |
|
| 70 | - $this->savlangs=$langs; |
|
| 71 | - $this->savdb=$db; |
|
| 67 | + global $conf, $user, $langs, $db; |
|
| 68 | + $this->savconf = $conf; |
|
| 69 | + $this->savuser = $user; |
|
| 70 | + $this->savlangs = $langs; |
|
| 71 | + $this->savdb = $db; |
|
| 72 | 72 | |
| 73 | 73 | print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
| 74 | 74 | //print " - db ".$db->db; |
@@ -78,15 +78,15 @@ discard block |
||
| 78 | 78 | // Static methods |
| 79 | 79 | public static function setUpBeforeClass() |
| 80 | 80 | { |
| 81 | - global $conf,$user,$langs,$db; |
|
| 81 | + global $conf, $user, $langs, $db; |
|
| 82 | 82 | $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
| 83 | 83 | |
| 84 | - if (! empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)) { |
|
| 84 | + if (!empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)) { |
|
| 85 | 85 | print "\n".__METHOD__." Company must be setup to have name-firstname in order 'Firstname Lastname'\n"; |
| 86 | 86 | die(); |
| 87 | 87 | } |
| 88 | - if (! empty($conf->global->MAIN_MODULE_LDAP)) { print "\n".__METHOD__." module LDAP must be disabled.\n"; die(); } |
|
| 89 | - if (! empty($conf->global->MAIN_MODULE_MAILMANSPIP)) { print "\n".__METHOD__." module MailmanSpip must be disabled.\n"; die(); } |
|
| 88 | + if (!empty($conf->global->MAIN_MODULE_LDAP)) { print "\n".__METHOD__." module LDAP must be disabled.\n"; die(); } |
|
| 89 | + if (!empty($conf->global->MAIN_MODULE_MAILMANSPIP)) { print "\n".__METHOD__." module MailmanSpip must be disabled.\n"; die(); } |
|
| 90 | 90 | |
| 91 | 91 | print __METHOD__."\n"; |
| 92 | 92 | } |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | // tear down after class |
| 95 | 95 | public static function tearDownAfterClass() |
| 96 | 96 | { |
| 97 | - global $conf,$user,$langs,$db; |
|
| 97 | + global $conf, $user, $langs, $db; |
|
| 98 | 98 | $db->rollback(); |
| 99 | 99 | |
| 100 | 100 | print __METHOD__."\n"; |
@@ -107,11 +107,11 @@ discard block |
||
| 107 | 107 | */ |
| 108 | 108 | protected function setUp() |
| 109 | 109 | { |
| 110 | - global $conf,$user,$langs,$db; |
|
| 111 | - $conf=$this->savconf; |
|
| 112 | - $user=$this->savuser; |
|
| 113 | - $langs=$this->savlangs; |
|
| 114 | - $db=$this->savdb; |
|
| 110 | + global $conf, $user, $langs, $db; |
|
| 111 | + $conf = $this->savconf; |
|
| 112 | + $user = $this->savuser; |
|
| 113 | + $langs = $this->savlangs; |
|
| 114 | + $db = $this->savdb; |
|
| 115 | 115 | |
| 116 | 116 | print __METHOD__."\n"; |
| 117 | 117 | } |
@@ -132,18 +132,18 @@ discard block |
||
| 132 | 132 | */ |
| 133 | 133 | public function testAdherentTypeCreate() |
| 134 | 134 | { |
| 135 | - global $conf,$user,$langs,$db; |
|
| 136 | - $conf=$this->savconf; |
|
| 137 | - $user=$this->savuser; |
|
| 138 | - $langs=$this->savlangs; |
|
| 139 | - $db=$this->savdb; |
|
| 140 | - |
|
| 141 | - $localobject=new AdherentType($this->savdb); |
|
| 142 | - $localobject->statut=1; |
|
| 143 | - $localobject->label='Adherent type test'; |
|
| 144 | - $localobject->subscription=1; |
|
| 145 | - $localobject->vote=1; |
|
| 146 | - $result=$localobject->create($user); |
|
| 135 | + global $conf, $user, $langs, $db; |
|
| 136 | + $conf = $this->savconf; |
|
| 137 | + $user = $this->savuser; |
|
| 138 | + $langs = $this->savlangs; |
|
| 139 | + $db = $this->savdb; |
|
| 140 | + |
|
| 141 | + $localobject = new AdherentType($this->savdb); |
|
| 142 | + $localobject->statut = 1; |
|
| 143 | + $localobject->label = 'Adherent type test'; |
|
| 144 | + $localobject->subscription = 1; |
|
| 145 | + $localobject->vote = 1; |
|
| 146 | + $result = $localobject->create($user); |
|
| 147 | 147 | print __METHOD__." result=".$result."\n"; |
| 148 | 148 | $this->assertLessThan($result, 0); |
| 149 | 149 | |
@@ -161,16 +161,16 @@ discard block |
||
| 161 | 161 | */ |
| 162 | 162 | public function testAdherentCreate($fk_adherent_type) |
| 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 Adherent($this->savdb); |
|
| 170 | + $localobject = new Adherent($this->savdb); |
|
| 171 | 171 | $localobject->initAsSpecimen(); |
| 172 | - $localobject->typeid=$fk_adherent_type; |
|
| 173 | - $result=$localobject->create($user); |
|
| 172 | + $localobject->typeid = $fk_adherent_type; |
|
| 173 | + $result = $localobject->create($user); |
|
| 174 | 174 | print __METHOD__." result=".$result."\n"; |
| 175 | 175 | $this->assertLessThan($result, 0); |
| 176 | 176 | |
@@ -188,14 +188,14 @@ discard block |
||
| 188 | 188 | */ |
| 189 | 189 | public function testAdherentFetch($id) |
| 190 | 190 | { |
| 191 | - global $conf,$user,$langs,$db; |
|
| 192 | - $conf=$this->savconf; |
|
| 193 | - $user=$this->savuser; |
|
| 194 | - $langs=$this->savlangs; |
|
| 195 | - $db=$this->savdb; |
|
| 196 | - |
|
| 197 | - $localobject=new Adherent($this->savdb); |
|
| 198 | - $result=$localobject->fetch($id); |
|
| 191 | + global $conf, $user, $langs, $db; |
|
| 192 | + $conf = $this->savconf; |
|
| 193 | + $user = $this->savuser; |
|
| 194 | + $langs = $this->savlangs; |
|
| 195 | + $db = $this->savdb; |
|
| 196 | + |
|
| 197 | + $localobject = new Adherent($this->savdb); |
|
| 198 | + $result = $localobject->fetch($id); |
|
| 199 | 199 | print __METHOD__." id=".$id." result=".$result."\n"; |
| 200 | 200 | $this->assertLessThan($result, 0); |
| 201 | 201 | return $localobject; |
@@ -212,11 +212,11 @@ discard block |
||
| 212 | 212 | */ |
| 213 | 213 | public function testAdherentFetchLogin(Adherent $localobject) |
| 214 | 214 | { |
| 215 | - global $conf,$user,$langs,$db; |
|
| 216 | - $conf=$this->savconf; |
|
| 217 | - $user=$this->savuser; |
|
| 218 | - $langs=$this->savlangs; |
|
| 219 | - $db=$this->savdb; |
|
| 215 | + global $conf, $user, $langs, $db; |
|
| 216 | + $conf = $this->savconf; |
|
| 217 | + $user = $this->savuser; |
|
| 218 | + $langs = $this->savlangs; |
|
| 219 | + $db = $this->savdb; |
|
| 220 | 220 | |
| 221 | 221 | $newobject = new Adherent($this->savdb); |
| 222 | 222 | $result = $newobject->fetch_login($localobject->login); |
@@ -237,45 +237,45 @@ discard block |
||
| 237 | 237 | */ |
| 238 | 238 | public function testAdherentUpdate(Adherent $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 | $timestamp = dol_now(); |
| 247 | 247 | |
| 248 | 248 | $localobject->civility_id = 0; |
| 249 | - $localobject->login='newlogin'; |
|
| 250 | - $localobject->societe='New company'; |
|
| 251 | - $localobject->note='New note after update'; |
|
| 249 | + $localobject->login = 'newlogin'; |
|
| 250 | + $localobject->societe = 'New company'; |
|
| 251 | + $localobject->note = 'New note after update'; |
|
| 252 | 252 | //$localobject->note_public='New note public after update'; |
| 253 | - $localobject->lastname='New name'; |
|
| 254 | - $localobject->firstname='New firstname'; |
|
| 255 | - $localobject->gender='man'; |
|
| 256 | - $localobject->address='New address'; |
|
| 257 | - $localobject->zip='New zip'; |
|
| 258 | - $localobject->town='New town'; |
|
| 259 | - $localobject->country_id=2; |
|
| 260 | - $localobject->statut=0; |
|
| 261 | - $localobject->morphy=0; |
|
| 262 | - $localobject->phone='New tel pro'; |
|
| 263 | - $localobject->phone_perso='New tel perso'; |
|
| 264 | - $localobject->phone_mobile='New tel mobile'; |
|
| 265 | - $localobject->email='[email protected]'; |
|
| 266 | - $localobject->birth=$timestamp; |
|
| 267 | - $result=$localobject->update($user); |
|
| 253 | + $localobject->lastname = 'New name'; |
|
| 254 | + $localobject->firstname = 'New firstname'; |
|
| 255 | + $localobject->gender = 'man'; |
|
| 256 | + $localobject->address = 'New address'; |
|
| 257 | + $localobject->zip = 'New zip'; |
|
| 258 | + $localobject->town = 'New town'; |
|
| 259 | + $localobject->country_id = 2; |
|
| 260 | + $localobject->statut = 0; |
|
| 261 | + $localobject->morphy = 0; |
|
| 262 | + $localobject->phone = 'New tel pro'; |
|
| 263 | + $localobject->phone_perso = 'New tel perso'; |
|
| 264 | + $localobject->phone_mobile = 'New tel mobile'; |
|
| 265 | + $localobject->email = '[email protected]'; |
|
| 266 | + $localobject->birth = $timestamp; |
|
| 267 | + $result = $localobject->update($user); |
|
| 268 | 268 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
| 269 | 269 | $this->assertLessThan($result, 0); |
| 270 | - $result=$localobject->update_note($localobject->note,'_private'); |
|
| 270 | + $result = $localobject->update_note($localobject->note, '_private'); |
|
| 271 | 271 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
| 272 | 272 | $this->assertLessThan($result, 0); |
| 273 | - $result=$localobject->update_note($localobject->note,'_public'); |
|
| 273 | + $result = $localobject->update_note($localobject->note, '_public'); |
|
| 274 | 274 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
| 275 | 275 | $this->assertLessThan($result, 0); |
| 276 | 276 | |
| 277 | - $newobject=new Adherent($this->savdb); |
|
| 278 | - $result=$newobject->fetch($localobject->id); |
|
| 277 | + $newobject = new Adherent($this->savdb); |
|
| 278 | + $result = $newobject->fetch($localobject->id); |
|
| 279 | 279 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
| 280 | 280 | $this->assertLessThan($result, 0); |
| 281 | 281 | |
@@ -315,20 +315,20 @@ discard block |
||
| 315 | 315 | */ |
| 316 | 316 | public function testAdherentMakeSubstitution(Adherent $localobject) |
| 317 | 317 | { |
| 318 | - global $conf,$user,$langs,$db; |
|
| 319 | - $conf=$this->savconf; |
|
| 320 | - $user=$this->savuser; |
|
| 321 | - $langs=$this->savlangs; |
|
| 322 | - $db=$this->savdb; |
|
| 318 | + global $conf, $user, $langs, $db; |
|
| 319 | + $conf = $this->savconf; |
|
| 320 | + $user = $this->savuser; |
|
| 321 | + $langs = $this->savlangs; |
|
| 322 | + $db = $this->savdb; |
|
| 323 | 323 | |
| 324 | - $conf->global->MAIN_FIRSTNAME_NAME_POSITION = 0; // Force setup for firstname+lastname |
|
| 324 | + $conf->global->MAIN_FIRSTNAME_NAME_POSITION = 0; // Force setup for firstname+lastname |
|
| 325 | 325 | |
| 326 | 326 | $template = '__CIVILITY__,__FIRSTNAME__,__LASTNAME__,__FULLNAME__,__COMPANY__,'. |
| 327 | 327 | '__ADDRESS__,__ZIP__,__TOWN__,__COUNTRY__,__EMAIL__,__BIRTH__,__PHOTO__,__LOGIN__'; |
| 328 | 328 | |
| 329 | 329 | // If option to store clear password has been set, we get 'dolibspec' into PASSWORD field. |
| 330 | 330 | $expected = ',New firstname,New name,New firstname New name,'. |
| 331 | - 'New company,New address,New zip,New town,Belgium,[email protected],'.dol_print_date($localobject->birth,'day').',,'. |
|
| 331 | + 'New company,New address,New zip,New town,Belgium,[email protected],'.dol_print_date($localobject->birth, 'day').',,'. |
|
| 332 | 332 | 'newlogin'; |
| 333 | 333 | |
| 334 | 334 | $result = $localobject->makeSubstitution($template); |
@@ -349,11 +349,11 @@ discard block |
||
| 349 | 349 | */ |
| 350 | 350 | public function testAdherentSetUserId(Adherent $localobject) |
| 351 | 351 | { |
| 352 | - global $conf,$user,$langs,$db; |
|
| 353 | - $conf=$this->savconf; |
|
| 354 | - $user=$this->savuser; |
|
| 355 | - $langs=$this->savlangs; |
|
| 356 | - $db=$this->savdb; |
|
| 352 | + global $conf, $user, $langs, $db; |
|
| 353 | + $conf = $this->savconf; |
|
| 354 | + $user = $this->savuser; |
|
| 355 | + $langs = $this->savlangs; |
|
| 356 | + $db = $this->savdb; |
|
| 357 | 357 | |
| 358 | 358 | //We associate member with user |
| 359 | 359 | $result = $localobject->setUserId($user->id); |
@@ -391,11 +391,11 @@ discard block |
||
| 391 | 391 | */ |
| 392 | 392 | public function testAdherentSetThirdPartyId(Adherent $localobject) |
| 393 | 393 | { |
| 394 | - global $conf,$user,$langs,$db; |
|
| 395 | - $conf=$this->savconf; |
|
| 396 | - $user=$this->savuser; |
|
| 397 | - $langs=$this->savlangs; |
|
| 398 | - $db=$this->savdb; |
|
| 394 | + global $conf, $user, $langs, $db; |
|
| 395 | + $conf = $this->savconf; |
|
| 396 | + $user = $this->savuser; |
|
| 397 | + $langs = $this->savlangs; |
|
| 398 | + $db = $this->savdb; |
|
| 399 | 399 | |
| 400 | 400 | //Create a Third Party |
| 401 | 401 | $thirdparty = new Societe($db); |
@@ -423,7 +423,7 @@ discard block |
||
| 423 | 423 | $this->assertNull($localobject->fk_soc); |
| 424 | 424 | |
| 425 | 425 | //Now we remove the third party |
| 426 | - $result = $thirdparty->delete($thirdparty->id,$user); |
|
| 426 | + $result = $thirdparty->delete($thirdparty->id, $user); |
|
| 427 | 427 | $this->assertEquals($result, 1); |
| 428 | 428 | |
| 429 | 429 | return $localobject; |
@@ -440,13 +440,13 @@ discard block |
||
| 440 | 440 | */ |
| 441 | 441 | public function testAdherentValidate(Adherent $localobject) |
| 442 | 442 | { |
| 443 | - global $conf,$user,$langs,$db; |
|
| 444 | - $conf=$this->savconf; |
|
| 445 | - $user=$this->savuser; |
|
| 446 | - $langs=$this->savlangs; |
|
| 447 | - $db=$this->savdb; |
|
| 443 | + global $conf, $user, $langs, $db; |
|
| 444 | + $conf = $this->savconf; |
|
| 445 | + $user = $this->savuser; |
|
| 446 | + $langs = $this->savlangs; |
|
| 447 | + $db = $this->savdb; |
|
| 448 | 448 | |
| 449 | - $result=$localobject->validate($user); |
|
| 449 | + $result = $localobject->validate($user); |
|
| 450 | 450 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
| 451 | 451 | $this->assertLessThan($result, 0); |
| 452 | 452 | |
@@ -464,11 +464,11 @@ discard block |
||
| 464 | 464 | */ |
| 465 | 465 | public function testAdherentOther(Adherent $localobject) |
| 466 | 466 | { |
| 467 | - global $conf,$user,$langs,$db; |
|
| 468 | - $conf=$this->savconf; |
|
| 469 | - $user=$this->savuser; |
|
| 470 | - $langs=$this->savlangs; |
|
| 471 | - $db=$this->savdb; |
|
| 467 | + global $conf, $user, $langs, $db; |
|
| 468 | + $conf = $this->savconf; |
|
| 469 | + $user = $this->savuser; |
|
| 470 | + $langs = $this->savlangs; |
|
| 471 | + $db = $this->savdb; |
|
| 472 | 472 | |
| 473 | 473 | /*$result=$localobject->setstatus(0); |
| 474 | 474 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
@@ -493,11 +493,11 @@ discard block |
||
| 493 | 493 | */ |
| 494 | 494 | public function testAdherentResiliate(Adherent $localobject) |
| 495 | 495 | { |
| 496 | - global $conf,$user,$langs,$db; |
|
| 497 | - $conf=$this->savconf; |
|
| 498 | - $user=$this->savuser; |
|
| 499 | - $langs=$this->savlangs; |
|
| 500 | - $db=$this->savdb; |
|
| 496 | + global $conf, $user, $langs, $db; |
|
| 497 | + $conf = $this->savconf; |
|
| 498 | + $user = $this->savuser; |
|
| 499 | + $langs = $this->savlangs; |
|
| 500 | + $db = $this->savdb; |
|
| 501 | 501 | |
| 502 | 502 | //Let's resilie un adherent |
| 503 | 503 | $result = $localobject->resiliate($user); |
@@ -530,13 +530,13 @@ discard block |
||
| 530 | 530 | */ |
| 531 | 531 | public function testAdherentDelete($localobject) |
| 532 | 532 | { |
| 533 | - global $conf,$user,$langs,$db; |
|
| 534 | - $conf=$this->savconf; |
|
| 535 | - $user=$this->savuser; |
|
| 536 | - $langs=$this->savlangs; |
|
| 537 | - $db=$this->savdb; |
|
| 533 | + global $conf, $user, $langs, $db; |
|
| 534 | + $conf = $this->savconf; |
|
| 535 | + $user = $this->savuser; |
|
| 536 | + $langs = $this->savlangs; |
|
| 537 | + $db = $this->savdb; |
|
| 538 | 538 | |
| 539 | - $result=$localobject->delete($localobject->id, $user); |
|
| 539 | + $result = $localobject->delete($localobject->id, $user); |
|
| 540 | 540 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
| 541 | 541 | $this->assertLessThan($result, 0); |
| 542 | 542 | |
@@ -555,15 +555,15 @@ discard block |
||
| 555 | 555 | */ |
| 556 | 556 | public function testAdherentTypeDelete($localobject) |
| 557 | 557 | { |
| 558 | - global $conf,$user,$langs,$db; |
|
| 559 | - $conf=$this->savconf; |
|
| 560 | - $user=$this->savuser; |
|
| 561 | - $langs=$this->savlangs; |
|
| 562 | - $db=$this->savdb; |
|
| 563 | - |
|
| 564 | - $localobjectat=new AdherentType($this->savdb); |
|
| 565 | - $result=$localobjectat->fetch($localobject->typeid); |
|
| 566 | - $result=$localobjectat->delete(); |
|
| 558 | + global $conf, $user, $langs, $db; |
|
| 559 | + $conf = $this->savconf; |
|
| 560 | + $user = $this->savuser; |
|
| 561 | + $langs = $this->savlangs; |
|
| 562 | + $db = $this->savdb; |
|
| 563 | + |
|
| 564 | + $localobjectat = new AdherentType($this->savdb); |
|
| 565 | + $result = $localobjectat->fetch($localobject->typeid); |
|
| 566 | + $result = $localobjectat->delete(); |
|
| 567 | 567 | print __METHOD__." result=".$result."\n"; |
| 568 | 568 | $this->assertLessThan($result, 0); |
| 569 | 569 | |
@@ -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; |
@@ -178,18 +178,18 @@ discard block |
||
| 178 | 178 | */ |
| 179 | 179 | public function testCommandeUpdate($localobject) |
| 180 | 180 | { |
| 181 | - global $conf,$user,$langs,$db; |
|
| 182 | - $conf=$this->savconf; |
|
| 183 | - $user=$this->savuser; |
|
| 184 | - $langs=$this->savlangs; |
|
| 185 | - $db=$this->savdb; |
|
| 186 | - |
|
| 187 | - $localobject->note_private='New note private after update'; |
|
| 188 | - $result=$localobject->update($user); |
|
| 189 | - |
|
| 190 | - $this->assertLessThan($result, 0); |
|
| 191 | - print __METHOD__." id=".$id." result=".$result."\n"; |
|
| 192 | - return $localobject; |
|
| 181 | + global $conf,$user,$langs,$db; |
|
| 182 | + $conf=$this->savconf; |
|
| 183 | + $user=$this->savuser; |
|
| 184 | + $langs=$this->savlangs; |
|
| 185 | + $db=$this->savdb; |
|
| 186 | + |
|
| 187 | + $localobject->note_private='New note private after update'; |
|
| 188 | + $result=$localobject->update($user); |
|
| 189 | + |
|
| 190 | + $this->assertLessThan($result, 0); |
|
| 191 | + print __METHOD__." id=".$id." result=".$result."\n"; |
|
| 192 | + return $localobject; |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | /** |
@@ -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->commande->enabled)) { print __METHOD__." module customer order 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,15 +127,15 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | public function testCommandeCreate() |
| 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 Commande($this->savdb); |
|
| 136 | + $localobject = new Commande($this->savdb); |
|
| 137 | 137 | $localobject->initAsSpecimen(); |
| 138 | - $result=$localobject->create($user); |
|
| 138 | + $result = $localobject->create($user); |
|
| 139 | 139 | |
| 140 | 140 | $this->assertLessThan($result, 0); |
| 141 | 141 | print __METHOD__." result=".$result."\n"; |
@@ -153,14 +153,14 @@ discard block |
||
| 153 | 153 | */ |
| 154 | 154 | public function testCommandeFetch($id) |
| 155 | 155 | { |
| 156 | - global $conf,$user,$langs,$db; |
|
| 157 | - $conf=$this->savconf; |
|
| 158 | - $user=$this->savuser; |
|
| 159 | - $langs=$this->savlangs; |
|
| 160 | - $db=$this->savdb; |
|
| 156 | + global $conf, $user, $langs, $db; |
|
| 157 | + $conf = $this->savconf; |
|
| 158 | + $user = $this->savuser; |
|
| 159 | + $langs = $this->savlangs; |
|
| 160 | + $db = $this->savdb; |
|
| 161 | 161 | |
| 162 | - $localobject=new Commande($this->savdb); |
|
| 163 | - $result=$localobject->fetch($id); |
|
| 162 | + $localobject = new Commande($this->savdb); |
|
| 163 | + $result = $localobject->fetch($id); |
|
| 164 | 164 | |
| 165 | 165 | $this->assertLessThan($result, 0); |
| 166 | 166 | print __METHOD__." id=".$id." result=".$result."\n"; |
@@ -178,14 +178,14 @@ discard block |
||
| 178 | 178 | */ |
| 179 | 179 | public function testCommandeUpdate($localobject) |
| 180 | 180 | { |
| 181 | - global $conf,$user,$langs,$db; |
|
| 182 | - $conf=$this->savconf; |
|
| 183 | - $user=$this->savuser; |
|
| 184 | - $langs=$this->savlangs; |
|
| 185 | - $db=$this->savdb; |
|
| 181 | + global $conf, $user, $langs, $db; |
|
| 182 | + $conf = $this->savconf; |
|
| 183 | + $user = $this->savuser; |
|
| 184 | + $langs = $this->savlangs; |
|
| 185 | + $db = $this->savdb; |
|
| 186 | 186 | |
| 187 | - $localobject->note_private='New note private after update'; |
|
| 188 | - $result=$localobject->update($user); |
|
| 187 | + $localobject->note_private = 'New note private after update'; |
|
| 188 | + $result = $localobject->update($user); |
|
| 189 | 189 | |
| 190 | 190 | $this->assertLessThan($result, 0); |
| 191 | 191 | print __METHOD__." id=".$id." result=".$result."\n"; |
@@ -203,13 +203,13 @@ discard block |
||
| 203 | 203 | */ |
| 204 | 204 | public function testCommandeValid($localobject) |
| 205 | 205 | { |
| 206 | - global $conf,$user,$langs,$db; |
|
| 207 | - $conf=$this->savconf; |
|
| 208 | - $user=$this->savuser; |
|
| 209 | - $langs=$this->savlangs; |
|
| 210 | - $db=$this->savdb; |
|
| 206 | + global $conf, $user, $langs, $db; |
|
| 207 | + $conf = $this->savconf; |
|
| 208 | + $user = $this->savuser; |
|
| 209 | + $langs = $this->savlangs; |
|
| 210 | + $db = $this->savdb; |
|
| 211 | 211 | |
| 212 | - $result=$localobject->valid($user); |
|
| 212 | + $result = $localobject->valid($user); |
|
| 213 | 213 | |
| 214 | 214 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
| 215 | 215 | $this->assertLessThan($result, 0); |
@@ -227,13 +227,13 @@ discard block |
||
| 227 | 227 | */ |
| 228 | 228 | public function testCommandeCancel($localobject) |
| 229 | 229 | { |
| 230 | - global $conf,$user,$langs,$db; |
|
| 231 | - $conf=$this->savconf; |
|
| 232 | - $user=$this->savuser; |
|
| 233 | - $langs=$this->savlangs; |
|
| 234 | - $db=$this->savdb; |
|
| 230 | + global $conf, $user, $langs, $db; |
|
| 231 | + $conf = $this->savconf; |
|
| 232 | + $user = $this->savuser; |
|
| 233 | + $langs = $this->savlangs; |
|
| 234 | + $db = $this->savdb; |
|
| 235 | 235 | |
| 236 | - $result=$localobject->cancel(); |
|
| 236 | + $result = $localobject->cancel(); |
|
| 237 | 237 | |
| 238 | 238 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
| 239 | 239 | $this->assertLessThan($result, 0); |
@@ -251,11 +251,11 @@ discard block |
||
| 251 | 251 | */ |
| 252 | 252 | public function testCommandeOther($localobject) |
| 253 | 253 | { |
| 254 | - global $conf,$user,$langs,$db; |
|
| 255 | - $conf=$this->savconf; |
|
| 256 | - $user=$this->savuser; |
|
| 257 | - $langs=$this->savlangs; |
|
| 258 | - $db=$this->savdb; |
|
| 254 | + global $conf, $user, $langs, $db; |
|
| 255 | + $conf = $this->savconf; |
|
| 256 | + $user = $this->savuser; |
|
| 257 | + $langs = $this->savlangs; |
|
| 258 | + $db = $this->savdb; |
|
| 259 | 259 | |
| 260 | 260 | /*$result=$localobject->setstatus(0); |
| 261 | 261 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
@@ -280,15 +280,15 @@ discard block |
||
| 280 | 280 | */ |
| 281 | 281 | public function testCommandeDelete($id) |
| 282 | 282 | { |
| 283 | - global $conf,$user,$langs,$db; |
|
| 284 | - $conf=$this->savconf; |
|
| 285 | - $user=$this->savuser; |
|
| 286 | - $langs=$this->savlangs; |
|
| 287 | - $db=$this->savdb; |
|
| 288 | - |
|
| 289 | - $localobject=new Commande($this->savdb); |
|
| 290 | - $result=$localobject->fetch($id); |
|
| 291 | - $result=$localobject->delete($user); |
|
| 283 | + global $conf, $user, $langs, $db; |
|
| 284 | + $conf = $this->savconf; |
|
| 285 | + $user = $this->savuser; |
|
| 286 | + $langs = $this->savlangs; |
|
| 287 | + $db = $this->savdb; |
|
| 288 | + |
|
| 289 | + $localobject = new Commande($this->savdb); |
|
| 290 | + $result = $localobject->fetch($id); |
|
| 291 | + $result = $localobject->delete($user); |
|
| 292 | 292 | |
| 293 | 293 | print __METHOD__." id=".$id." result=".$result."\n"; |
| 294 | 294 | $this->assertLessThan($result, 0); |
@@ -60,9 +60,9 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | function __construct() |
| 62 | 62 | { |
| 63 | - parent::__construct(); |
|
| 63 | + parent::__construct(); |
|
| 64 | 64 | |
| 65 | - //$this->sharedFixture |
|
| 65 | + //$this->sharedFixture |
|
| 66 | 66 | global $conf,$user,$langs,$db; |
| 67 | 67 | $this->savconf=$conf; |
| 68 | 68 | $this->savuser=$user; |
@@ -225,22 +225,22 @@ discard block |
||
| 225 | 225 | unset($localobject->array_options['options_reseller']); |
| 226 | 226 | |
| 227 | 227 | $arraywithdiff = $this->objCompare( |
| 228 | - $localobject, |
|
| 229 | - $newlocalobject, |
|
| 230 | - true, |
|
| 231 | - array( |
|
| 232 | - 'newref','oldref','id','lines','client','thirdparty','brouillon','user_author','date_creation','date_validation','datem','date_modification', |
|
| 233 | - 'ref','statut','paye','specimen','ref','actiontypecode','actionmsg2','actionmsg','mode_reglement','cond_reglement', |
|
| 234 | - 'cond_reglement_doc','situation_cycle_ref','situation_counter','situation_final','multicurrency_total_ht','multicurrency_total_tva', |
|
| 235 | - 'multicurrency_total_ttc','fk_multicurrency','multicurrency_code','multicurrency_tx' |
|
| 236 | - ) |
|
| 237 | - ); |
|
| 228 | + $localobject, |
|
| 229 | + $newlocalobject, |
|
| 230 | + true, |
|
| 231 | + array( |
|
| 232 | + 'newref','oldref','id','lines','client','thirdparty','brouillon','user_author','date_creation','date_validation','datem','date_modification', |
|
| 233 | + 'ref','statut','paye','specimen','ref','actiontypecode','actionmsg2','actionmsg','mode_reglement','cond_reglement', |
|
| 234 | + 'cond_reglement_doc','situation_cycle_ref','situation_counter','situation_final','multicurrency_total_ht','multicurrency_total_tva', |
|
| 235 | + 'multicurrency_total_ttc','fk_multicurrency','multicurrency_code','multicurrency_tx' |
|
| 236 | + ) |
|
| 237 | + ); |
|
| 238 | 238 | $this->assertEquals($arraywithdiff, array()); // Actual, Expected |
| 239 | 239 | |
| 240 | 240 | return $localobject; |
| 241 | 241 | } |
| 242 | 242 | |
| 243 | - /** |
|
| 243 | + /** |
|
| 244 | 244 | * testFactureOther |
| 245 | 245 | * |
| 246 | 246 | * @param Object $localobject Invoice |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | |
| 269 | 269 | $result=$localobject->demande_prelevement($user); |
| 270 | 270 | print __METHOD__." result=".$result."\n"; |
| 271 | - $this->assertLessThan($result, 0); |
|
| 271 | + $this->assertLessThan($result, 0); |
|
| 272 | 272 | |
| 273 | 273 | return $localobject->id; |
| 274 | 274 | } |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | $result=$localobject2->initAsSpecimen(); |
| 303 | 303 | $result=$localobject2->create($user); |
| 304 | 304 | $result=$localobject2->validate($user); |
| 305 | - print 'Invoice $localobject ref = '.$localobject->ref."\n"; |
|
| 305 | + print 'Invoice $localobject ref = '.$localobject->ref."\n"; |
|
| 306 | 306 | print 'Invoice $localobject2 created with ref = '.$localobject2->ref."\n"; |
| 307 | 307 | |
| 308 | 308 | $conf->global->INVOICE_CAN_NEVER_BE_REMOVED = 1; |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * \remarks To run this script as CLI: phpunit filename.php |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | -global $conf,$user,$langs,$db; |
|
| 27 | +global $conf, $user, $langs, $db; |
|
| 28 | 28 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
| 29 | 29 | //require_once 'PHPUnit/Autoload.php'; |
| 30 | 30 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | $user->fetch(1); |
| 36 | 36 | $user->getrights(); |
| 37 | 37 | } |
| 38 | -$conf->global->MAIN_DISABLE_ALL_MAILS=1; |
|
| 38 | +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
|
| 39 | 39 | |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -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,10 +77,10 @@ discard block |
||
| 77 | 77 | // Static methods |
| 78 | 78 | public static function setUpBeforeClass() |
| 79 | 79 | { |
| 80 | - global $conf,$user,$langs,$db; |
|
| 80 | + global $conf, $user, $langs, $db; |
|
| 81 | 81 | |
| 82 | 82 | if (empty($conf->facture->enabled)) { print __METHOD__." module customer invoice must be enabled.\n"; die(); } |
| 83 | - if (! empty($conf->ecotaxdeee->enabled)) { print __METHOD__." ecotaxdeee module must not be enabled.\n"; die(); } |
|
| 83 | + if (!empty($conf->ecotaxdeee->enabled)) { print __METHOD__." ecotaxdeee module must not be enabled.\n"; die(); } |
|
| 84 | 84 | |
| 85 | 85 | $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
| 86 | 86 | |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | // tear down after class |
| 91 | 91 | public static function tearDownAfterClass() |
| 92 | 92 | { |
| 93 | - global $conf,$user,$langs,$db; |
|
| 93 | + global $conf, $user, $langs, $db; |
|
| 94 | 94 | $db->rollback(); |
| 95 | 95 | |
| 96 | 96 | print __METHOD__."\n"; |
@@ -103,11 +103,11 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | protected function setUp() |
| 105 | 105 | { |
| 106 | - global $conf,$user,$langs,$db; |
|
| 107 | - $conf=$this->savconf; |
|
| 108 | - $user=$this->savuser; |
|
| 109 | - $langs=$this->savlangs; |
|
| 110 | - $db=$this->savdb; |
|
| 106 | + global $conf, $user, $langs, $db; |
|
| 107 | + $conf = $this->savconf; |
|
| 108 | + $user = $this->savuser; |
|
| 109 | + $langs = $this->savlangs; |
|
| 110 | + $db = $this->savdb; |
|
| 111 | 111 | |
| 112 | 112 | print __METHOD__."\n"; |
| 113 | 113 | } |
@@ -129,15 +129,15 @@ discard block |
||
| 129 | 129 | */ |
| 130 | 130 | public function testFactureCreate() |
| 131 | 131 | { |
| 132 | - global $conf,$user,$langs,$db; |
|
| 133 | - $conf=$this->savconf; |
|
| 134 | - $user=$this->savuser; |
|
| 135 | - $langs=$this->savlangs; |
|
| 136 | - $db=$this->savdb; |
|
| 132 | + global $conf, $user, $langs, $db; |
|
| 133 | + $conf = $this->savconf; |
|
| 134 | + $user = $this->savuser; |
|
| 135 | + $langs = $this->savlangs; |
|
| 136 | + $db = $this->savdb; |
|
| 137 | 137 | |
| 138 | - $localobject=new Facture($this->savdb); |
|
| 138 | + $localobject = new Facture($this->savdb); |
|
| 139 | 139 | $localobject->initAsSpecimen(); |
| 140 | - $result=$localobject->create($user); |
|
| 140 | + $result = $localobject->create($user); |
|
| 141 | 141 | $this->assertLessThan($result, 0); |
| 142 | 142 | print __METHOD__." result=".$result."\n"; |
| 143 | 143 | return $result; |
@@ -154,14 +154,14 @@ discard block |
||
| 154 | 154 | */ |
| 155 | 155 | public function testFactureFetch($id) |
| 156 | 156 | { |
| 157 | - global $conf,$user,$langs,$db; |
|
| 158 | - $conf=$this->savconf; |
|
| 159 | - $user=$this->savuser; |
|
| 160 | - $langs=$this->savlangs; |
|
| 161 | - $db=$this->savdb; |
|
| 157 | + global $conf, $user, $langs, $db; |
|
| 158 | + $conf = $this->savconf; |
|
| 159 | + $user = $this->savuser; |
|
| 160 | + $langs = $this->savlangs; |
|
| 161 | + $db = $this->savdb; |
|
| 162 | 162 | |
| 163 | - $localobject=new Facture($this->savdb); |
|
| 164 | - $result=$localobject->fetch($id); |
|
| 163 | + $localobject = new Facture($this->savdb); |
|
| 164 | + $result = $localobject->fetch($id); |
|
| 165 | 165 | |
| 166 | 166 | $this->assertLessThan($result, 0); |
| 167 | 167 | print __METHOD__." id=".$id." result=".$result."\n"; |
@@ -179,14 +179,14 @@ discard block |
||
| 179 | 179 | */ |
| 180 | 180 | public function testFactureUpdate($localobject) |
| 181 | 181 | { |
| 182 | - global $conf,$user,$langs,$db; |
|
| 183 | - $conf=$this->savconf; |
|
| 184 | - $user=$this->savuser; |
|
| 185 | - $langs=$this->savlangs; |
|
| 186 | - $db=$this->savdb; |
|
| 182 | + global $conf, $user, $langs, $db; |
|
| 183 | + $conf = $this->savconf; |
|
| 184 | + $user = $this->savuser; |
|
| 185 | + $langs = $this->savlangs; |
|
| 186 | + $db = $this->savdb; |
|
| 187 | 187 | |
| 188 | 188 | $this->changeProperties($localobject); |
| 189 | - $result=$localobject->update($user); |
|
| 189 | + $result = $localobject->update($user); |
|
| 190 | 190 | |
| 191 | 191 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
| 192 | 192 | $this->assertLessThan($result, 0); |
@@ -204,19 +204,19 @@ discard block |
||
| 204 | 204 | */ |
| 205 | 205 | public function testFactureValid($localobject) |
| 206 | 206 | { |
| 207 | - global $conf,$user,$langs,$db; |
|
| 208 | - $conf=$this->savconf; |
|
| 209 | - $user=$this->savuser; |
|
| 210 | - $langs=$this->savlangs; |
|
| 211 | - $db=$this->savdb; |
|
| 207 | + global $conf, $user, $langs, $db; |
|
| 208 | + $conf = $this->savconf; |
|
| 209 | + $user = $this->savuser; |
|
| 210 | + $langs = $this->savlangs; |
|
| 211 | + $db = $this->savdb; |
|
| 212 | 212 | |
| 213 | - $result=$localobject->validate($user); |
|
| 213 | + $result = $localobject->validate($user); |
|
| 214 | 214 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
| 215 | 215 | |
| 216 | 216 | $this->assertLessThan($result, 0); |
| 217 | 217 | |
| 218 | 218 | // Test everything are still same than specimen |
| 219 | - $newlocalobject=new Facture($this->savdb); |
|
| 219 | + $newlocalobject = new Facture($this->savdb); |
|
| 220 | 220 | $newlocalobject->initAsSpecimen(); |
| 221 | 221 | $this->changeProperties($newlocalobject); |
| 222 | 222 | |
@@ -229,13 +229,13 @@ discard block |
||
| 229 | 229 | $newlocalobject, |
| 230 | 230 | true, |
| 231 | 231 | array( |
| 232 | - 'newref','oldref','id','lines','client','thirdparty','brouillon','user_author','date_creation','date_validation','datem','date_modification', |
|
| 233 | - 'ref','statut','paye','specimen','ref','actiontypecode','actionmsg2','actionmsg','mode_reglement','cond_reglement', |
|
| 234 | - 'cond_reglement_doc','situation_cycle_ref','situation_counter','situation_final','multicurrency_total_ht','multicurrency_total_tva', |
|
| 235 | - 'multicurrency_total_ttc','fk_multicurrency','multicurrency_code','multicurrency_tx' |
|
| 232 | + 'newref', 'oldref', 'id', 'lines', 'client', 'thirdparty', 'brouillon', 'user_author', 'date_creation', 'date_validation', 'datem', 'date_modification', |
|
| 233 | + 'ref', 'statut', 'paye', 'specimen', 'ref', 'actiontypecode', 'actionmsg2', 'actionmsg', 'mode_reglement', 'cond_reglement', |
|
| 234 | + 'cond_reglement_doc', 'situation_cycle_ref', 'situation_counter', 'situation_final', 'multicurrency_total_ht', 'multicurrency_total_tva', |
|
| 235 | + 'multicurrency_total_ttc', 'fk_multicurrency', 'multicurrency_code', 'multicurrency_tx' |
|
| 236 | 236 | ) |
| 237 | 237 | ); |
| 238 | - $this->assertEquals($arraywithdiff, array()); // Actual, Expected |
|
| 238 | + $this->assertEquals($arraywithdiff, array()); // Actual, Expected |
|
| 239 | 239 | |
| 240 | 240 | return $localobject; |
| 241 | 241 | } |
@@ -251,11 +251,11 @@ discard block |
||
| 251 | 251 | */ |
| 252 | 252 | public function testFactureOther($localobject) |
| 253 | 253 | { |
| 254 | - global $conf,$user,$langs,$db; |
|
| 255 | - $conf=$this->savconf; |
|
| 256 | - $user=$this->savuser; |
|
| 257 | - $langs=$this->savlangs; |
|
| 258 | - $db=$this->savdb; |
|
| 254 | + global $conf, $user, $langs, $db; |
|
| 255 | + $conf = $this->savconf; |
|
| 256 | + $user = $this->savuser; |
|
| 257 | + $langs = $this->savlangs; |
|
| 258 | + $db = $this->savdb; |
|
| 259 | 259 | |
| 260 | 260 | /*$result=$localobject->setstatus(0); |
| 261 | 261 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | print __METHOD__." localobject->date_creation=".$localobject->date_creation."\n"; |
| 267 | 267 | $this->assertNotEquals($localobject->date_creation, ''); |
| 268 | 268 | |
| 269 | - $result=$localobject->demande_prelevement($user); |
|
| 269 | + $result = $localobject->demande_prelevement($user); |
|
| 270 | 270 | print __METHOD__." result=".$result."\n"; |
| 271 | 271 | $this->assertLessThan($result, 0); |
| 272 | 272 | |
@@ -284,44 +284,44 @@ discard block |
||
| 284 | 284 | */ |
| 285 | 285 | public function testFactureDelete($id) |
| 286 | 286 | { |
| 287 | - global $conf,$user,$langs,$db; |
|
| 288 | - $conf=$this->savconf; |
|
| 289 | - $user=$this->savuser; |
|
| 290 | - $langs=$this->savlangs; |
|
| 291 | - $db=$this->savdb; |
|
| 287 | + global $conf, $user, $langs, $db; |
|
| 288 | + $conf = $this->savconf; |
|
| 289 | + $user = $this->savuser; |
|
| 290 | + $langs = $this->savlangs; |
|
| 291 | + $db = $this->savdb; |
|
| 292 | 292 | |
| 293 | 293 | // Force default setup |
| 294 | 294 | unset($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED); |
| 295 | 295 | unset($conf->global->INVOICE_CAN_NEVER_BE_REMOVED); |
| 296 | 296 | |
| 297 | - $localobject=new Facture($this->savdb); |
|
| 298 | - $result=$localobject->fetch($id); |
|
| 297 | + $localobject = new Facture($this->savdb); |
|
| 298 | + $result = $localobject->fetch($id); |
|
| 299 | 299 | |
| 300 | 300 | // Create another invoice and validate it after $localobject |
| 301 | - $localobject2=new Facture($this->savdb); |
|
| 302 | - $result=$localobject2->initAsSpecimen(); |
|
| 303 | - $result=$localobject2->create($user); |
|
| 304 | - $result=$localobject2->validate($user); |
|
| 301 | + $localobject2 = new Facture($this->savdb); |
|
| 302 | + $result = $localobject2->initAsSpecimen(); |
|
| 303 | + $result = $localobject2->create($user); |
|
| 304 | + $result = $localobject2->validate($user); |
|
| 305 | 305 | print 'Invoice $localobject ref = '.$localobject->ref."\n"; |
| 306 | 306 | print 'Invoice $localobject2 created with ref = '.$localobject2->ref."\n"; |
| 307 | 307 | |
| 308 | 308 | $conf->global->INVOICE_CAN_NEVER_BE_REMOVED = 1; |
| 309 | 309 | |
| 310 | - $result=$localobject2->delete($user); // Deletion is KO, option INVOICE_CAN_NEVER_BE_REMOVED is on |
|
| 310 | + $result = $localobject2->delete($user); // Deletion is KO, option INVOICE_CAN_NEVER_BE_REMOVED is on |
|
| 311 | 311 | print __METHOD__." id=".$localobject2->id." ref=".$localobject2->ref." result=".$result."\n"; |
| 312 | 312 | $this->assertEquals(0, $result, 'Deletion should fail, option INVOICE_CAN_NEVER_BE_REMOVED is on'); |
| 313 | 313 | |
| 314 | 314 | unset($conf->global->INVOICE_CAN_NEVER_BE_REMOVED); |
| 315 | 315 | |
| 316 | - $result=$localobject->delete($user); // Deletion is KO, it is not last invoice |
|
| 316 | + $result = $localobject->delete($user); // Deletion is KO, it is not last invoice |
|
| 317 | 317 | print __METHOD__." id=".$localobject->id." ref=".$localobject->ref." result=".$result."\n"; |
| 318 | 318 | $this->assertEquals(0, $result, 'Deletion should fail, it is not last invoice'); |
| 319 | 319 | |
| 320 | - $result=$localobject2->delete($user); // Deletion is OK, it is last invoice |
|
| 320 | + $result = $localobject2->delete($user); // Deletion is OK, it is last invoice |
|
| 321 | 321 | print __METHOD__." id=".$localobject2->id." ref=".$localobject2->ref." result=".$result."\n"; |
| 322 | 322 | $this->assertGreaterThan(0, $result, 'Deletion should work, it is last invoice'); |
| 323 | 323 | |
| 324 | - $result=$localobject->delete($user); // Deletion is KO, it is not last invoice |
|
| 324 | + $result = $localobject->delete($user); // Deletion is KO, it is not last invoice |
|
| 325 | 325 | print __METHOD__." id=".$localobject->id." ref=".$localobject->ref." result=".$result."\n"; |
| 326 | 326 | $this->assertGreaterThan(0, $result, 'Deletion should work, it is again last invoice'); |
| 327 | 327 | |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | */ |
| 337 | 337 | public function changeProperties(&$localobject) |
| 338 | 338 | { |
| 339 | - $localobject->note_private='New note'; |
|
| 339 | + $localobject->note_private = 'New note'; |
|
| 340 | 340 | //$localobject->note='New note after update'; |
| 341 | 341 | } |
| 342 | 342 | |
@@ -349,29 +349,29 @@ discard block |
||
| 349 | 349 | * @param array $fieldstoignorearray Array of fields to ignore in diff |
| 350 | 350 | * @return array Array with differences |
| 351 | 351 | */ |
| 352 | - public function objCompare($oA,$oB,$ignoretype=true,$fieldstoignorearray=array('id')) |
|
| 352 | + public function objCompare($oA, $oB, $ignoretype = true, $fieldstoignorearray = array('id')) |
|
| 353 | 353 | { |
| 354 | - $retAr=array(); |
|
| 354 | + $retAr = array(); |
|
| 355 | 355 | |
| 356 | 356 | if (get_class($oA) !== get_class($oB)) |
| 357 | 357 | { |
| 358 | - $retAr[]="Supplied objects are not of same class."; |
|
| 358 | + $retAr[] = "Supplied objects are not of same class."; |
|
| 359 | 359 | } |
| 360 | 360 | else |
| 361 | 361 | { |
| 362 | - $oVarsA=get_object_vars($oA); |
|
| 363 | - $oVarsB=get_object_vars($oB); |
|
| 364 | - $aKeys=array_keys($oVarsA); |
|
| 365 | - foreach($aKeys as $sKey) |
|
| 362 | + $oVarsA = get_object_vars($oA); |
|
| 363 | + $oVarsB = get_object_vars($oB); |
|
| 364 | + $aKeys = array_keys($oVarsA); |
|
| 365 | + foreach ($aKeys as $sKey) |
|
| 366 | 366 | { |
| 367 | - if (in_array($sKey,$fieldstoignorearray)) continue; |
|
| 368 | - if (! $ignoretype && $oVarsA[$sKey] !== $oVarsB[$sKey]) |
|
| 367 | + if (in_array($sKey, $fieldstoignorearray)) continue; |
|
| 368 | + if (!$ignoretype && $oVarsA[$sKey] !== $oVarsB[$sKey]) |
|
| 369 | 369 | { |
| 370 | - $retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey])?get_class($oVarsA[$sKey]):$oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey])?get_class($oVarsB[$sKey]):$oVarsB[$sKey]); |
|
| 370 | + $retAr[] = $sKey.' : '.(is_object($oVarsA[$sKey]) ?get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ?get_class($oVarsB[$sKey]) : $oVarsB[$sKey]); |
|
| 371 | 371 | } |
| 372 | 372 | if ($ignoretype && $oVarsA[$sKey] != $oVarsB[$sKey]) |
| 373 | 373 | { |
| 374 | - $retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey])?get_class($oVarsA[$sKey]):$oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey])?get_class($oVarsB[$sKey]):$oVarsB[$sKey]); |
|
| 374 | + $retAr[] = $sKey.' : '.(is_object($oVarsA[$sKey]) ?get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ?get_class($oVarsB[$sKey]) : $oVarsB[$sKey]); |
|
| 375 | 375 | } |
| 376 | 376 | } |
| 377 | 377 | } |
@@ -356,15 +356,16 @@ |
||
| 356 | 356 | if (get_class($oA) !== get_class($oB)) |
| 357 | 357 | { |
| 358 | 358 | $retAr[]="Supplied objects are not of same class."; |
| 359 | - } |
|
| 360 | - else |
|
| 359 | + } else |
|
| 361 | 360 | { |
| 362 | 361 | $oVarsA=get_object_vars($oA); |
| 363 | 362 | $oVarsB=get_object_vars($oB); |
| 364 | 363 | $aKeys=array_keys($oVarsA); |
| 365 | 364 | foreach($aKeys as $sKey) |
| 366 | 365 | { |
| 367 | - if (in_array($sKey,$fieldstoignorearray)) continue; |
|
| 366 | + if (in_array($sKey,$fieldstoignorearray)) { |
|
| 367 | + continue; |
|
| 368 | + } |
|
| 368 | 369 | if (! $ignoretype && $oVarsA[$sKey] !== $oVarsB[$sKey]) |
| 369 | 370 | { |
| 370 | 371 | $retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey])?get_class($oVarsA[$sKey]):$oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey])?get_class($oVarsB[$sKey]):$oVarsB[$sKey]); |