@@ -59,9 +59,9 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | function __construct() |
| 61 | 61 | { |
| 62 | - parent::__construct(); |
|
| 62 | + parent::__construct(); |
|
| 63 | 63 | |
| 64 | - //$this->sharedFixture |
|
| 64 | + //$this->sharedFixture |
|
| 65 | 65 | global $conf,$user,$langs,$db; |
| 66 | 66 | $this->savconf=$conf; |
| 67 | 67 | $this->savuser=$user; |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | * End phpunit tests |
| 111 | 111 | * |
| 112 | 112 | * @return void |
| 113 | - */ |
|
| 113 | + */ |
|
| 114 | 114 | protected function tearDown() |
| 115 | 115 | { |
| 116 | 116 | print __METHOD__."\n"; |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * \remarks To run this script as CLI: phpunit filename.php |
| 24 | 24 | */ |
| 25 | 25 | |
| 26 | -global $conf,$user,$langs,$db; |
|
| 26 | +global $conf, $user, $langs, $db; |
|
| 27 | 27 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
| 28 | 28 | //require_once 'PHPUnit/Autoload.php'; |
| 29 | 29 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | $user->fetch(1); |
| 35 | 35 | $user->getrights(); |
| 36 | 36 | } |
| 37 | -$conf->global->MAIN_DISABLE_ALL_MAILS=1; |
|
| 37 | +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
|
| 38 | 38 | |
| 39 | 39 | |
| 40 | 40 | /** |
@@ -62,11 +62,11 @@ discard block |
||
| 62 | 62 | parent::__construct(); |
| 63 | 63 | |
| 64 | 64 | //$this->sharedFixture |
| 65 | - global $conf,$user,$langs,$db; |
|
| 66 | - $this->savconf=$conf; |
|
| 67 | - $this->savuser=$user; |
|
| 68 | - $this->savlangs=$langs; |
|
| 69 | - $this->savdb=$db; |
|
| 65 | + global $conf, $user, $langs, $db; |
|
| 66 | + $this->savconf = $conf; |
|
| 67 | + $this->savuser = $user; |
|
| 68 | + $this->savlangs = $langs; |
|
| 69 | + $this->savdb = $db; |
|
| 70 | 70 | |
| 71 | 71 | print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
| 72 | 72 | //print " - db ".$db->db; |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | // Static methods |
| 77 | 77 | public static function setUpBeforeClass() |
| 78 | 78 | { |
| 79 | - global $conf,$user,$langs,$db; |
|
| 79 | + global $conf, $user, $langs, $db; |
|
| 80 | 80 | $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
| 81 | 81 | |
| 82 | 82 | print __METHOD__."\n"; |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | // tear down after class |
| 86 | 86 | public static function tearDownAfterClass() |
| 87 | 87 | { |
| 88 | - global $conf,$user,$langs,$db; |
|
| 88 | + global $conf, $user, $langs, $db; |
|
| 89 | 89 | $db->rollback(); |
| 90 | 90 | |
| 91 | 91 | print __METHOD__."\n"; |
@@ -98,11 +98,11 @@ discard block |
||
| 98 | 98 | */ |
| 99 | 99 | protected function setUp() |
| 100 | 100 | { |
| 101 | - global $conf,$user,$langs,$db; |
|
| 102 | - $conf=$this->savconf; |
|
| 103 | - $user=$this->savuser; |
|
| 104 | - $langs=$this->savlangs; |
|
| 105 | - $db=$this->savdb; |
|
| 101 | + global $conf, $user, $langs, $db; |
|
| 102 | + $conf = $this->savconf; |
|
| 103 | + $user = $this->savuser; |
|
| 104 | + $langs = $this->savlangs; |
|
| 105 | + $db = $this->savdb; |
|
| 106 | 106 | |
| 107 | 107 | print __METHOD__."\n"; |
| 108 | 108 | } |
@@ -124,13 +124,13 @@ discard block |
||
| 124 | 124 | */ |
| 125 | 125 | public function testCalculateDateLimReglement() |
| 126 | 126 | { |
| 127 | - global $conf,$user,$langs,$db; |
|
| 128 | - $conf=$this->savconf; |
|
| 129 | - $user=$this->savuser; |
|
| 130 | - $langs=$this->savlangs; |
|
| 131 | - $db=$this->savdb; |
|
| 127 | + global $conf, $user, $langs, $db; |
|
| 128 | + $conf = $this->savconf; |
|
| 129 | + $user = $this->savuser; |
|
| 130 | + $langs = $this->savlangs; |
|
| 131 | + $db = $this->savdb; |
|
| 132 | 132 | |
| 133 | - $localobject=new Facture($this->savdb); |
|
| 133 | + $localobject = new Facture($this->savdb); |
|
| 134 | 134 | $localobject->fetch(1); |
| 135 | 135 | $localobject->date = dol_mktime(12, 0, 0, 1, 1, 2010); |
| 136 | 136 | |
@@ -59,9 +59,9 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | function __construct() |
| 61 | 61 | { |
| 62 | - parent::__construct(); |
|
| 62 | + parent::__construct(); |
|
| 63 | 63 | |
| 64 | - //$this->sharedFixture |
|
| 64 | + //$this->sharedFixture |
|
| 65 | 65 | global $conf,$user,$langs,$db; |
| 66 | 66 | $this->savconf=$conf; |
| 67 | 67 | $this->savuser=$user; |
@@ -152,18 +152,18 @@ discard block |
||
| 152 | 152 | */ |
| 153 | 153 | public function testEnableModule() |
| 154 | 154 | { |
| 155 | - global $conf, $db, $langs, $user; |
|
| 156 | - |
|
| 157 | - require_once dirname(__FILE__).'/../../htdocs/core/modules/modExpenseReport.class.php'; |
|
| 158 | - print "Enable module modExpenseReport"; |
|
| 159 | - $moduledescriptor=new modExpenseReport($db); |
|
| 160 | - $moduledescriptor->init(); |
|
| 161 | - $conf->setValues($db); |
|
| 162 | - |
|
| 163 | - require_once dirname(__FILE__).'/../../htdocs/core/modules/modApi.class.php'; |
|
| 164 | - print "Enable module modAPI"; |
|
| 165 | - $moduledescriptor=new modApi($db); |
|
| 166 | - $moduledescriptor->init(); |
|
| 167 | - $conf->setValues($db); |
|
| 155 | + global $conf, $db, $langs, $user; |
|
| 156 | + |
|
| 157 | + require_once dirname(__FILE__).'/../../htdocs/core/modules/modExpenseReport.class.php'; |
|
| 158 | + print "Enable module modExpenseReport"; |
|
| 159 | + $moduledescriptor=new modExpenseReport($db); |
|
| 160 | + $moduledescriptor->init(); |
|
| 161 | + $conf->setValues($db); |
|
| 162 | + |
|
| 163 | + require_once dirname(__FILE__).'/../../htdocs/core/modules/modApi.class.php'; |
|
| 164 | + print "Enable module modAPI"; |
|
| 165 | + $moduledescriptor=new modApi($db); |
|
| 166 | + $moduledescriptor->init(); |
|
| 167 | + $conf->setValues($db); |
|
| 168 | 168 | } |
| 169 | 169 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * \remarks To run this script as CLI: phpunit filename.php |
| 24 | 24 | */ |
| 25 | 25 | |
| 26 | -global $conf,$user,$langs,$db; |
|
| 26 | +global $conf, $user, $langs, $db; |
|
| 27 | 27 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
| 28 | 28 | //require_once 'PHPUnit/Autoload.php'; |
| 29 | 29 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | $user->fetch(1); |
| 35 | 35 | $user->getrights(); |
| 36 | 36 | } |
| 37 | -$conf->global->MAIN_DISABLE_ALL_MAILS=1; |
|
| 37 | +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
|
| 38 | 38 | |
| 39 | 39 | |
| 40 | 40 | /** |
@@ -62,11 +62,11 @@ discard block |
||
| 62 | 62 | parent::__construct(); |
| 63 | 63 | |
| 64 | 64 | //$this->sharedFixture |
| 65 | - global $conf,$user,$langs,$db; |
|
| 66 | - $this->savconf=$conf; |
|
| 67 | - $this->savuser=$user; |
|
| 68 | - $this->savlangs=$langs; |
|
| 69 | - $this->savdb=$db; |
|
| 65 | + global $conf, $user, $langs, $db; |
|
| 66 | + $this->savconf = $conf; |
|
| 67 | + $this->savuser = $user; |
|
| 68 | + $this->savlangs = $langs; |
|
| 69 | + $this->savdb = $db; |
|
| 70 | 70 | |
| 71 | 71 | print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
| 72 | 72 | //print " - db ".$db->db; |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | // Static methods |
| 77 | 77 | public static function setUpBeforeClass() |
| 78 | 78 | { |
| 79 | - global $conf,$user,$langs,$db; |
|
| 79 | + global $conf, $user, $langs, $db; |
|
| 80 | 80 | $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
| 81 | 81 | |
| 82 | 82 | print __METHOD__."\n"; |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | // tear down after class |
| 86 | 86 | public static function tearDownAfterClass() |
| 87 | 87 | { |
| 88 | - global $conf,$user,$langs,$db; |
|
| 88 | + global $conf, $user, $langs, $db; |
|
| 89 | 89 | $db->rollback(); |
| 90 | 90 | |
| 91 | 91 | print __METHOD__."\n"; |
@@ -98,11 +98,11 @@ discard block |
||
| 98 | 98 | */ |
| 99 | 99 | protected function setUp() |
| 100 | 100 | { |
| 101 | - global $conf,$user,$langs,$db; |
|
| 102 | - $conf=$this->savconf; |
|
| 103 | - $user=$this->savuser; |
|
| 104 | - $langs=$this->savlangs; |
|
| 105 | - $db=$this->savdb; |
|
| 101 | + global $conf, $user, $langs, $db; |
|
| 102 | + $conf = $this->savconf; |
|
| 103 | + $user = $this->savuser; |
|
| 104 | + $langs = $this->savlangs; |
|
| 105 | + $db = $this->savdb; |
|
| 106 | 106 | |
| 107 | 107 | print __METHOD__."\n"; |
| 108 | 108 | } |
@@ -123,24 +123,24 @@ discard block |
||
| 123 | 123 | */ |
| 124 | 124 | public function testVersionCompare() |
| 125 | 125 | { |
| 126 | - global $conf,$user,$langs,$db; |
|
| 127 | - $conf=$this->savconf; |
|
| 128 | - $user=$this->savuser; |
|
| 129 | - $langs=$this->savlangs; |
|
| 130 | - $db=$this->savdb; |
|
| 126 | + global $conf, $user, $langs, $db; |
|
| 127 | + $conf = $this->savconf; |
|
| 128 | + $user = $this->savuser; |
|
| 129 | + $langs = $this->savlangs; |
|
| 130 | + $db = $this->savdb; |
|
| 131 | 131 | |
| 132 | - $result=versioncompare(array(3,1,-4),array(3,1,1)); |
|
| 132 | + $result = versioncompare(array(3, 1, -4), array(3, 1, 1)); |
|
| 133 | 133 | print __METHOD__." result=".$result."\n"; |
| 134 | - $this->assertEquals(-3,$result); |
|
| 135 | - $result=versioncompare(array(3,1,0),array(3,1,1)); |
|
| 134 | + $this->assertEquals(-3, $result); |
|
| 135 | + $result = versioncompare(array(3, 1, 0), array(3, 1, 1)); |
|
| 136 | 136 | print __METHOD__." result=".$result."\n"; |
| 137 | - $this->assertEquals(-3,$result); |
|
| 138 | - $result=versioncompare(array(3,1,0),array(3,2,0)); |
|
| 137 | + $this->assertEquals(-3, $result); |
|
| 138 | + $result = versioncompare(array(3, 1, 0), array(3, 2, 0)); |
|
| 139 | 139 | print __METHOD__." result=".$result."\n"; |
| 140 | - $this->assertEquals(-2,$result); |
|
| 141 | - $result=versioncompare(array(3,1,0),array(3,1,0)); |
|
| 140 | + $this->assertEquals(-2, $result); |
|
| 141 | + $result = versioncompare(array(3, 1, 0), array(3, 1, 0)); |
|
| 142 | 142 | print __METHOD__." result=".$result."\n"; |
| 143 | - $this->assertEquals(0,$result); |
|
| 143 | + $this->assertEquals(0, $result); |
|
| 144 | 144 | |
| 145 | 145 | return $result; |
| 146 | 146 | } |
@@ -156,13 +156,13 @@ discard block |
||
| 156 | 156 | |
| 157 | 157 | require_once dirname(__FILE__).'/../../htdocs/core/modules/modExpenseReport.class.php'; |
| 158 | 158 | print "Enable module modExpenseReport"; |
| 159 | - $moduledescriptor=new modExpenseReport($db); |
|
| 159 | + $moduledescriptor = new modExpenseReport($db); |
|
| 160 | 160 | $moduledescriptor->init(); |
| 161 | 161 | $conf->setValues($db); |
| 162 | 162 | |
| 163 | 163 | require_once dirname(__FILE__).'/../../htdocs/core/modules/modApi.class.php'; |
| 164 | 164 | print "Enable module modAPI"; |
| 165 | - $moduledescriptor=new modApi($db); |
|
| 165 | + $moduledescriptor = new modApi($db); |
|
| 166 | 166 | $moduledescriptor->init(); |
| 167 | 167 | $conf->setValues($db); |
| 168 | 168 | } |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | function __construct() |
| 61 | 61 | { |
| 62 | - parent::__construct(); |
|
| 62 | + parent::__construct(); |
|
| 63 | 63 | |
| 64 | 64 | //$this->sharedFixture |
| 65 | 65 | global $conf,$user,$langs,$db; |
@@ -184,18 +184,18 @@ discard block |
||
| 184 | 184 | */ |
| 185 | 185 | public function testAccountingAccountUpdate($localobject) |
| 186 | 186 | { |
| 187 | - global $conf,$user,$langs,$db; |
|
| 188 | - $conf=$this->savconf; |
|
| 189 | - $user=$this->savuser; |
|
| 190 | - $langs=$this->savlangs; |
|
| 191 | - $db=$this->savdb; |
|
| 192 | - |
|
| 193 | - $localobject->label='New label'; |
|
| 194 | - $result=$localobject->update($user); |
|
| 195 | - |
|
| 196 | - $this->assertLessThan($result, 0); |
|
| 197 | - print __METHOD__." id=".$id." result=".$result."\n"; |
|
| 198 | - return $localobject->id; |
|
| 187 | + global $conf,$user,$langs,$db; |
|
| 188 | + $conf=$this->savconf; |
|
| 189 | + $user=$this->savuser; |
|
| 190 | + $langs=$this->savlangs; |
|
| 191 | + $db=$this->savdb; |
|
| 192 | + |
|
| 193 | + $localobject->label='New label'; |
|
| 194 | + $result=$localobject->update($user); |
|
| 195 | + |
|
| 196 | + $this->assertLessThan($result, 0); |
|
| 197 | + print __METHOD__." id=".$id." result=".$result."\n"; |
|
| 198 | + return $localobject->id; |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | /** |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * \remarks To run this script as CLI: phpunit filename.php |
| 24 | 24 | */ |
| 25 | 25 | |
| 26 | -global $conf,$user,$langs,$db; |
|
| 26 | +global $conf, $user, $langs, $db; |
|
| 27 | 27 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
| 28 | 28 | //require_once 'PHPUnit/Autoload.php'; |
| 29 | 29 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | $user->fetch(1); |
| 35 | 35 | $user->getrights(); |
| 36 | 36 | } |
| 37 | -$conf->global->MAIN_DISABLE_ALL_MAILS=1; |
|
| 37 | +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
|
| 38 | 38 | |
| 39 | 39 | |
| 40 | 40 | /** |
@@ -62,11 +62,11 @@ discard block |
||
| 62 | 62 | parent::__construct(); |
| 63 | 63 | |
| 64 | 64 | //$this->sharedFixture |
| 65 | - global $conf,$user,$langs,$db; |
|
| 66 | - $this->savconf=$conf; |
|
| 67 | - $this->savuser=$user; |
|
| 68 | - $this->savlangs=$langs; |
|
| 69 | - $this->savdb=$db; |
|
| 65 | + global $conf, $user, $langs, $db; |
|
| 66 | + $this->savconf = $conf; |
|
| 67 | + $this->savuser = $user; |
|
| 68 | + $this->savlangs = $langs; |
|
| 69 | + $this->savdb = $db; |
|
| 70 | 70 | |
| 71 | 71 | print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
| 72 | 72 | //print " - db ".$db->db; |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | // Static methods |
| 77 | 77 | public static function setUpBeforeClass() |
| 78 | 78 | { |
| 79 | - global $conf,$user,$langs,$db; |
|
| 79 | + global $conf, $user, $langs, $db; |
|
| 80 | 80 | $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
| 81 | 81 | |
| 82 | 82 | if (empty($conf->accounting->enabled)) { print __METHOD__." module accouting must be enabled.\n"; die(); } |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | // tear down after class |
| 88 | 88 | public static function tearDownAfterClass() |
| 89 | 89 | { |
| 90 | - global $conf,$user,$langs,$db; |
|
| 90 | + global $conf, $user, $langs, $db; |
|
| 91 | 91 | $db->rollback(); |
| 92 | 92 | |
| 93 | 93 | print __METHOD__."\n"; |
@@ -100,11 +100,11 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | protected function setUp() |
| 102 | 102 | { |
| 103 | - global $conf,$user,$langs,$db; |
|
| 104 | - $conf=$this->savconf; |
|
| 105 | - $user=$this->savuser; |
|
| 106 | - $langs=$this->savlangs; |
|
| 107 | - $db=$this->savdb; |
|
| 103 | + global $conf, $user, $langs, $db; |
|
| 104 | + $conf = $this->savconf; |
|
| 105 | + $user = $this->savuser; |
|
| 106 | + $langs = $this->savlangs; |
|
| 107 | + $db = $this->savdb; |
|
| 108 | 108 | |
| 109 | 109 | print __METHOD__."\n"; |
| 110 | 110 | //print $db->getVersion()."\n"; |
@@ -127,13 +127,13 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | public function testAccountingAccountCreate() |
| 129 | 129 | { |
| 130 | - global $conf,$user,$langs,$db; |
|
| 131 | - $conf=$this->savconf; |
|
| 132 | - $user=$this->savuser; |
|
| 133 | - $langs=$this->savlangs; |
|
| 134 | - $db=$this->savdb; |
|
| 130 | + global $conf, $user, $langs, $db; |
|
| 131 | + $conf = $this->savconf; |
|
| 132 | + $user = $this->savuser; |
|
| 133 | + $langs = $this->savlangs; |
|
| 134 | + $db = $this->savdb; |
|
| 135 | 135 | |
| 136 | - $localobject=new AccountingAccount($this->savdb); |
|
| 136 | + $localobject = new AccountingAccount($this->savdb); |
|
| 137 | 137 | $localobject->fk_pcg_version = 'PCG99-ABREGE'; |
| 138 | 138 | $localobject->account_category = 0; |
| 139 | 139 | $localobject->pcg_type = 'XXXXX'; |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | $localobject->account_parent = 0; |
| 142 | 142 | $localobject->label = 'Account specimen'; |
| 143 | 143 | $localobject->active = 0; |
| 144 | - $result=$localobject->create($user); |
|
| 144 | + $result = $localobject->create($user); |
|
| 145 | 145 | |
| 146 | 146 | $this->assertLessThan($result, 0); |
| 147 | 147 | print __METHOD__." result=".$result."\n"; |
@@ -159,14 +159,14 @@ discard block |
||
| 159 | 159 | */ |
| 160 | 160 | public function testAccountingAccountFetch($id) |
| 161 | 161 | { |
| 162 | - global $conf,$user,$langs,$db; |
|
| 163 | - $conf=$this->savconf; |
|
| 164 | - $user=$this->savuser; |
|
| 165 | - $langs=$this->savlangs; |
|
| 166 | - $db=$this->savdb; |
|
| 162 | + global $conf, $user, $langs, $db; |
|
| 163 | + $conf = $this->savconf; |
|
| 164 | + $user = $this->savuser; |
|
| 165 | + $langs = $this->savlangs; |
|
| 166 | + $db = $this->savdb; |
|
| 167 | 167 | |
| 168 | - $localobject=new AccountingAccount($this->savdb); |
|
| 169 | - $result=$localobject->fetch($id); |
|
| 168 | + $localobject = new AccountingAccount($this->savdb); |
|
| 169 | + $result = $localobject->fetch($id); |
|
| 170 | 170 | |
| 171 | 171 | $this->assertLessThan($result, 0); |
| 172 | 172 | print __METHOD__." id=".$id." result=".$result."\n"; |
@@ -184,14 +184,14 @@ discard block |
||
| 184 | 184 | */ |
| 185 | 185 | public function testAccountingAccountUpdate($localobject) |
| 186 | 186 | { |
| 187 | - global $conf,$user,$langs,$db; |
|
| 188 | - $conf=$this->savconf; |
|
| 189 | - $user=$this->savuser; |
|
| 190 | - $langs=$this->savlangs; |
|
| 191 | - $db=$this->savdb; |
|
| 187 | + global $conf, $user, $langs, $db; |
|
| 188 | + $conf = $this->savconf; |
|
| 189 | + $user = $this->savuser; |
|
| 190 | + $langs = $this->savlangs; |
|
| 191 | + $db = $this->savdb; |
|
| 192 | 192 | |
| 193 | - $localobject->label='New label'; |
|
| 194 | - $result=$localobject->update($user); |
|
| 193 | + $localobject->label = 'New label'; |
|
| 194 | + $result = $localobject->update($user); |
|
| 195 | 195 | |
| 196 | 196 | $this->assertLessThan($result, 0); |
| 197 | 197 | print __METHOD__." id=".$id." result=".$result."\n"; |
@@ -209,15 +209,15 @@ discard block |
||
| 209 | 209 | */ |
| 210 | 210 | public function testAccountingAccountDelete($id) |
| 211 | 211 | { |
| 212 | - global $conf,$user,$langs,$db; |
|
| 213 | - $conf=$this->savconf; |
|
| 214 | - $user=$this->savuser; |
|
| 215 | - $langs=$this->savlangs; |
|
| 216 | - $db=$this->savdb; |
|
| 217 | - |
|
| 218 | - $localobject=new AccountingAccount($this->savdb); |
|
| 219 | - $result=$localobject->fetch($id); |
|
| 220 | - $result=$localobject->delete($user); |
|
| 212 | + global $conf, $user, $langs, $db; |
|
| 213 | + $conf = $this->savconf; |
|
| 214 | + $user = $this->savuser; |
|
| 215 | + $langs = $this->savlangs; |
|
| 216 | + $db = $this->savdb; |
|
| 217 | + |
|
| 218 | + $localobject = new AccountingAccount($this->savdb); |
|
| 219 | + $result = $localobject->fetch($id); |
|
| 220 | + $result = $localobject->delete($user); |
|
| 221 | 221 | |
| 222 | 222 | print __METHOD__." id=".$id." result=".$result."\n"; |
| 223 | 223 | $this->assertLessThan($result, 0); |
@@ -31,9 +31,9 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | if (empty($user->id)) |
| 33 | 33 | { |
| 34 | - print "Load permissions for admin user nb 1\n"; |
|
| 35 | - $user->fetch(1); |
|
| 36 | - $user->getrights(); |
|
| 34 | + print "Load permissions for admin user nb 1\n"; |
|
| 35 | + $user->fetch(1); |
|
| 36 | + $user->getrights(); |
|
| 37 | 37 | } |
| 38 | 38 | $conf->global->MAIN_DISABLE_ALL_MAILS=1; |
| 39 | 39 | |
@@ -47,75 +47,75 @@ discard block |
||
| 47 | 47 | */ |
| 48 | 48 | class FactureTestRounding extends PHPUnit_Framework_TestCase |
| 49 | 49 | { |
| 50 | - protected $savconf; |
|
| 51 | - protected $savuser; |
|
| 52 | - protected $savlangs; |
|
| 53 | - protected $savdb; |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * Constructor |
|
| 57 | - * We save global variables into local variables |
|
| 58 | - * |
|
| 59 | - * @return FactureTest |
|
| 60 | - */ |
|
| 61 | - function __construct() |
|
| 62 | - { |
|
| 63 | - parent::__construct(); |
|
| 64 | - |
|
| 65 | - //$this->sharedFixture |
|
| 66 | - global $conf,$user,$langs,$db; |
|
| 67 | - $this->savconf=$conf; |
|
| 68 | - $this->savuser=$user; |
|
| 69 | - $this->savlangs=$langs; |
|
| 70 | - $this->savdb=$db; |
|
| 71 | - |
|
| 72 | - print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
|
| 73 | - //print " - db ".$db->db; |
|
| 74 | - print "\n"; |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - // Static methods |
|
| 78 | - public static function setUpBeforeClass() |
|
| 50 | + protected $savconf; |
|
| 51 | + protected $savuser; |
|
| 52 | + protected $savlangs; |
|
| 53 | + protected $savdb; |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * Constructor |
|
| 57 | + * We save global variables into local variables |
|
| 58 | + * |
|
| 59 | + * @return FactureTest |
|
| 60 | + */ |
|
| 61 | + function __construct() |
|
| 79 | 62 | { |
| 80 | - global $conf,$user,$langs,$db; |
|
| 81 | - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
| 63 | + parent::__construct(); |
|
| 82 | 64 | |
| 83 | - print __METHOD__."\n"; |
|
| 65 | + //$this->sharedFixture |
|
| 66 | + global $conf,$user,$langs,$db; |
|
| 67 | + $this->savconf=$conf; |
|
| 68 | + $this->savuser=$user; |
|
| 69 | + $this->savlangs=$langs; |
|
| 70 | + $this->savdb=$db; |
|
| 71 | + |
|
| 72 | + print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
|
| 73 | + //print " - db ".$db->db; |
|
| 74 | + print "\n"; |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + // Static methods |
|
| 78 | + public static function setUpBeforeClass() |
|
| 79 | + { |
|
| 80 | + global $conf,$user,$langs,$db; |
|
| 81 | + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
| 82 | + |
|
| 83 | + print __METHOD__."\n"; |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | // tear down after class |
| 87 | 87 | public static function tearDownAfterClass() |
| 88 | 88 | { |
| 89 | - global $conf,$user,$langs,$db; |
|
| 90 | - $db->rollback(); |
|
| 89 | + global $conf,$user,$langs,$db; |
|
| 90 | + $db->rollback(); |
|
| 91 | 91 | |
| 92 | - print __METHOD__."\n"; |
|
| 92 | + print __METHOD__."\n"; |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - /** |
|
| 96 | - * Init phpunit tests |
|
| 97 | - * |
|
| 98 | - * @return void |
|
| 99 | - */ |
|
| 100 | - protected function setUp() |
|
| 95 | + /** |
|
| 96 | + * Init phpunit tests |
|
| 97 | + * |
|
| 98 | + * @return void |
|
| 99 | + */ |
|
| 100 | + protected function setUp() |
|
| 101 | 101 | { |
| 102 | - global $conf,$user,$langs,$db; |
|
| 103 | - $conf=$this->savconf; |
|
| 104 | - $user=$this->savuser; |
|
| 105 | - $langs=$this->savlangs; |
|
| 106 | - $db=$this->savdb; |
|
| 102 | + global $conf,$user,$langs,$db; |
|
| 103 | + $conf=$this->savconf; |
|
| 104 | + $user=$this->savuser; |
|
| 105 | + $langs=$this->savlangs; |
|
| 106 | + $db=$this->savdb; |
|
| 107 | 107 | |
| 108 | - print __METHOD__."\n"; |
|
| 108 | + print __METHOD__."\n"; |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - /** |
|
| 112 | - * End phpunit tests |
|
| 113 | - * |
|
| 114 | - * @return void |
|
| 115 | - */ |
|
| 116 | - protected function tearDown() |
|
| 111 | + /** |
|
| 112 | + * End phpunit tests |
|
| 113 | + * |
|
| 114 | + * @return void |
|
| 115 | + */ |
|
| 116 | + protected function tearDown() |
|
| 117 | 117 | { |
| 118 | - print __METHOD__."\n"; |
|
| 118 | + print __METHOD__."\n"; |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | $langs=$this->savlangs; |
| 135 | 135 | $db=$this->savdb; |
| 136 | 136 | |
| 137 | - $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=0; |
|
| 137 | + $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=0; |
|
| 138 | 138 | |
| 139 | 139 | $localobject=new Facture($this->savdb); |
| 140 | 140 | $localobject->initAsSpecimen(); |
@@ -211,35 +211,35 @@ discard block |
||
| 211 | 211 | */ |
| 212 | 212 | public function testFactureAddLine1() |
| 213 | 213 | { |
| 214 | - global $conf,$user,$langs,$db; |
|
| 215 | - $conf=$this->savconf; |
|
| 216 | - $user=$this->savuser; |
|
| 217 | - $langs=$this->savlangs; |
|
| 218 | - $db=$this->savdb; |
|
| 219 | - |
|
| 220 | - // With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 0 |
|
| 221 | - $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=0; |
|
| 222 | - |
|
| 223 | - $localobject1a=new Facture($this->savdb); |
|
| 224 | - $localobject1a->initAsSpecimen('nolines'); |
|
| 225 | - $facid=$localobject1a->create($user); |
|
| 226 | - $localobject1a->addline('Line 1', 6.36, 15, 21); // This include update_price |
|
| 227 | - print __METHOD__." id=".$facid." total_ttc=".$localobject1a->total_ttc."\n"; |
|
| 228 | - $this->assertEquals(95.40, $localobject1a->total_ht); |
|
| 229 | - $this->assertEquals(20.03, $localobject1a->total_tva); |
|
| 230 | - $this->assertEquals(115.43, $localobject1a->total_ttc); |
|
| 231 | - |
|
| 232 | - // With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 1 |
|
| 233 | - $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=1; |
|
| 234 | - |
|
| 235 | - $localobject1b=new Facture($this->savdb); |
|
| 236 | - $localobject1b->initAsSpecimen('nolines'); |
|
| 237 | - $facid=$localobject1b->create($user); |
|
| 238 | - $localobject1b->addline('Line 1', 6.36, 15, 21); // This include update_price |
|
| 239 | - print __METHOD__." id=".$facid." total_ttc=".$localobject1b->total_ttc."\n"; |
|
| 240 | - $this->assertEquals(95.40, $localobject1b->total_ht, 'testFactureAddLine1 total_ht'); |
|
| 241 | - $this->assertEquals(20.03, $localobject1b->total_tva, 'testFactureAddLine1 total_tva'); |
|
| 242 | - $this->assertEquals(115.43, $localobject1b->total_ttc, 'testFactureAddLine1 total_ttc'); |
|
| 214 | + global $conf,$user,$langs,$db; |
|
| 215 | + $conf=$this->savconf; |
|
| 216 | + $user=$this->savuser; |
|
| 217 | + $langs=$this->savlangs; |
|
| 218 | + $db=$this->savdb; |
|
| 219 | + |
|
| 220 | + // With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 0 |
|
| 221 | + $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=0; |
|
| 222 | + |
|
| 223 | + $localobject1a=new Facture($this->savdb); |
|
| 224 | + $localobject1a->initAsSpecimen('nolines'); |
|
| 225 | + $facid=$localobject1a->create($user); |
|
| 226 | + $localobject1a->addline('Line 1', 6.36, 15, 21); // This include update_price |
|
| 227 | + print __METHOD__." id=".$facid." total_ttc=".$localobject1a->total_ttc."\n"; |
|
| 228 | + $this->assertEquals(95.40, $localobject1a->total_ht); |
|
| 229 | + $this->assertEquals(20.03, $localobject1a->total_tva); |
|
| 230 | + $this->assertEquals(115.43, $localobject1a->total_ttc); |
|
| 231 | + |
|
| 232 | + // With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 1 |
|
| 233 | + $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=1; |
|
| 234 | + |
|
| 235 | + $localobject1b=new Facture($this->savdb); |
|
| 236 | + $localobject1b->initAsSpecimen('nolines'); |
|
| 237 | + $facid=$localobject1b->create($user); |
|
| 238 | + $localobject1b->addline('Line 1', 6.36, 15, 21); // This include update_price |
|
| 239 | + print __METHOD__." id=".$facid." total_ttc=".$localobject1b->total_ttc."\n"; |
|
| 240 | + $this->assertEquals(95.40, $localobject1b->total_ht, 'testFactureAddLine1 total_ht'); |
|
| 241 | + $this->assertEquals(20.03, $localobject1b->total_tva, 'testFactureAddLine1 total_tva'); |
|
| 242 | + $this->assertEquals(115.43, $localobject1b->total_ttc, 'testFactureAddLine1 total_ttc'); |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | /** |
@@ -252,39 +252,39 @@ discard block |
||
| 252 | 252 | */ |
| 253 | 253 | public function testFactureAddLine2() |
| 254 | 254 | { |
| 255 | - global $conf,$user,$langs,$db; |
|
| 256 | - $conf=$this->savconf; |
|
| 257 | - $user=$this->savuser; |
|
| 258 | - $langs=$this->savlangs; |
|
| 259 | - $db=$this->savdb; |
|
| 260 | - |
|
| 261 | - // With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 0 |
|
| 262 | - $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=0; |
|
| 263 | - |
|
| 264 | - $localobject2=new Facture($this->savdb); |
|
| 265 | - $localobject2->initAsSpecimen('nolines'); |
|
| 266 | - $facid=$localobject2->create($user); |
|
| 267 | - $localobject2->addline('Line 1', 6.36, 5, 21); |
|
| 268 | - $localobject2->addline('Line 2', 6.36, 5, 21); |
|
| 269 | - $localobject2->addline('Line 3', 6.36, 5, 21); |
|
| 270 | - print __METHOD__." id=".$facid." total_ttc=".$localobject2->total_ttc."\n"; |
|
| 271 | - $this->assertEquals(95.40, $localobject2->total_ht); |
|
| 272 | - $this->assertEquals(20.04, $localobject2->total_tva); |
|
| 273 | - $this->assertEquals(115.44, $localobject2->total_ttc); |
|
| 274 | - |
|
| 275 | - // With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 1 |
|
| 276 | - $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=1; |
|
| 277 | - |
|
| 278 | - $localobject2=new Facture($this->savdb); |
|
| 279 | - $localobject2->initAsSpecimen('nolines'); |
|
| 280 | - $facid=$localobject2->create($user); |
|
| 281 | - $localobject2->addline('Line 1', 6.36, 5, 21); |
|
| 282 | - $localobject2->addline('Line 2', 6.36, 5, 21); |
|
| 283 | - $localobject2->addline('Line 3', 6.36, 5, 21); |
|
| 284 | - print __METHOD__." id=".$facid." total_ttc=".$localobject2->total_ttc."\n"; |
|
| 285 | - $this->assertEquals(95.40, $localobject2->total_ht); |
|
| 286 | - $this->assertEquals(20.03, $localobject2->total_tva); |
|
| 287 | - $this->assertEquals(115.43, $localobject2->total_ttc); |
|
| 255 | + global $conf,$user,$langs,$db; |
|
| 256 | + $conf=$this->savconf; |
|
| 257 | + $user=$this->savuser; |
|
| 258 | + $langs=$this->savlangs; |
|
| 259 | + $db=$this->savdb; |
|
| 260 | + |
|
| 261 | + // With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 0 |
|
| 262 | + $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=0; |
|
| 263 | + |
|
| 264 | + $localobject2=new Facture($this->savdb); |
|
| 265 | + $localobject2->initAsSpecimen('nolines'); |
|
| 266 | + $facid=$localobject2->create($user); |
|
| 267 | + $localobject2->addline('Line 1', 6.36, 5, 21); |
|
| 268 | + $localobject2->addline('Line 2', 6.36, 5, 21); |
|
| 269 | + $localobject2->addline('Line 3', 6.36, 5, 21); |
|
| 270 | + print __METHOD__." id=".$facid." total_ttc=".$localobject2->total_ttc."\n"; |
|
| 271 | + $this->assertEquals(95.40, $localobject2->total_ht); |
|
| 272 | + $this->assertEquals(20.04, $localobject2->total_tva); |
|
| 273 | + $this->assertEquals(115.44, $localobject2->total_ttc); |
|
| 274 | + |
|
| 275 | + // With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 1 |
|
| 276 | + $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=1; |
|
| 277 | + |
|
| 278 | + $localobject2=new Facture($this->savdb); |
|
| 279 | + $localobject2->initAsSpecimen('nolines'); |
|
| 280 | + $facid=$localobject2->create($user); |
|
| 281 | + $localobject2->addline('Line 1', 6.36, 5, 21); |
|
| 282 | + $localobject2->addline('Line 2', 6.36, 5, 21); |
|
| 283 | + $localobject2->addline('Line 3', 6.36, 5, 21); |
|
| 284 | + print __METHOD__." id=".$facid." total_ttc=".$localobject2->total_ttc."\n"; |
|
| 285 | + $this->assertEquals(95.40, $localobject2->total_ht); |
|
| 286 | + $this->assertEquals(20.03, $localobject2->total_tva); |
|
| 287 | + $this->assertEquals(115.43, $localobject2->total_ttc); |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | /** |
@@ -297,42 +297,42 @@ discard block |
||
| 297 | 297 | */ |
| 298 | 298 | public function testFactureAddLine3() |
| 299 | 299 | { |
| 300 | - global $conf,$user,$langs,$db; |
|
| 301 | - $conf=$this->savconf; |
|
| 302 | - $user=$this->savuser; |
|
| 303 | - $langs=$this->savlangs; |
|
| 304 | - $db=$this->savdb; |
|
| 305 | - |
|
| 306 | - // With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 0 |
|
| 307 | - $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=0; |
|
| 308 | - |
|
| 309 | - $localobject3=new Facture($this->savdb); |
|
| 310 | - $localobject3->initAsSpecimen('nolines'); |
|
| 311 | - $facid=$localobject3->create($user); |
|
| 312 | - $localobject3->addline('Line 1', 6.36, 3, 21); |
|
| 313 | - $localobject3->addline('Line 2', 6.36, 3, 21); |
|
| 314 | - $localobject3->addline('Line 3', 6.36, 3, 21); |
|
| 315 | - $localobject3->addline('Line 4', 6.36, 3, 21); |
|
| 316 | - $localobject3->addline('Line 5', 6.36, 3, 21); |
|
| 317 | - print __METHOD__." id=".$facid." total_ttc=".$localobject3->total_ttc."\n"; |
|
| 318 | - $this->assertEquals(95.40, $localobject3->total_ht); |
|
| 319 | - $this->assertEquals(20.05, $localobject3->total_tva); |
|
| 320 | - $this->assertEquals(115.45, $localobject3->total_ttc); |
|
| 321 | - |
|
| 322 | - // With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 1 |
|
| 323 | - $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=1; |
|
| 324 | - |
|
| 325 | - $localobject3=new Facture($this->savdb); |
|
| 326 | - $localobject3->initAsSpecimen('nolines'); |
|
| 327 | - $facid=$localobject3->create($user); |
|
| 328 | - $localobject3->addline('Line 1', 6.36, 3, 21); |
|
| 329 | - $localobject3->addline('Line 2', 6.36, 3, 21); |
|
| 330 | - $localobject3->addline('Line 3', 6.36, 3, 21); |
|
| 331 | - $localobject3->addline('Line 4', 6.36, 3, 21); |
|
| 332 | - $localobject3->addline('Line 5', 6.36, 3, 21); |
|
| 333 | - print __METHOD__." id=".$facid." total_ttc=".$localobject3->total_ttc."\n"; |
|
| 334 | - $this->assertEquals(95.40, $localobject3->total_ht); |
|
| 335 | - $this->assertEquals(20.03, $localobject3->total_tva); |
|
| 336 | - $this->assertEquals(115.43, $localobject3->total_ttc); |
|
| 300 | + global $conf,$user,$langs,$db; |
|
| 301 | + $conf=$this->savconf; |
|
| 302 | + $user=$this->savuser; |
|
| 303 | + $langs=$this->savlangs; |
|
| 304 | + $db=$this->savdb; |
|
| 305 | + |
|
| 306 | + // With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 0 |
|
| 307 | + $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=0; |
|
| 308 | + |
|
| 309 | + $localobject3=new Facture($this->savdb); |
|
| 310 | + $localobject3->initAsSpecimen('nolines'); |
|
| 311 | + $facid=$localobject3->create($user); |
|
| 312 | + $localobject3->addline('Line 1', 6.36, 3, 21); |
|
| 313 | + $localobject3->addline('Line 2', 6.36, 3, 21); |
|
| 314 | + $localobject3->addline('Line 3', 6.36, 3, 21); |
|
| 315 | + $localobject3->addline('Line 4', 6.36, 3, 21); |
|
| 316 | + $localobject3->addline('Line 5', 6.36, 3, 21); |
|
| 317 | + print __METHOD__." id=".$facid." total_ttc=".$localobject3->total_ttc."\n"; |
|
| 318 | + $this->assertEquals(95.40, $localobject3->total_ht); |
|
| 319 | + $this->assertEquals(20.05, $localobject3->total_tva); |
|
| 320 | + $this->assertEquals(115.45, $localobject3->total_ttc); |
|
| 321 | + |
|
| 322 | + // With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 1 |
|
| 323 | + $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=1; |
|
| 324 | + |
|
| 325 | + $localobject3=new Facture($this->savdb); |
|
| 326 | + $localobject3->initAsSpecimen('nolines'); |
|
| 327 | + $facid=$localobject3->create($user); |
|
| 328 | + $localobject3->addline('Line 1', 6.36, 3, 21); |
|
| 329 | + $localobject3->addline('Line 2', 6.36, 3, 21); |
|
| 330 | + $localobject3->addline('Line 3', 6.36, 3, 21); |
|
| 331 | + $localobject3->addline('Line 4', 6.36, 3, 21); |
|
| 332 | + $localobject3->addline('Line 5', 6.36, 3, 21); |
|
| 333 | + print __METHOD__." id=".$facid." total_ttc=".$localobject3->total_ttc."\n"; |
|
| 334 | + $this->assertEquals(95.40, $localobject3->total_ht); |
|
| 335 | + $this->assertEquals(20.03, $localobject3->total_tva); |
|
| 336 | + $this->assertEquals(115.43, $localobject3->total_ttc); |
|
| 337 | 337 | } |
| 338 | 338 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * \remarks To run this script as CLI: phpunit filename.php |
| 24 | 24 | */ |
| 25 | 25 | |
| 26 | -global $conf,$user,$langs,$db; |
|
| 26 | +global $conf, $user, $langs, $db; |
|
| 27 | 27 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
| 28 | 28 | //require_once 'PHPUnit/Autoload.php'; |
| 29 | 29 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | $user->fetch(1); |
| 36 | 36 | $user->getrights(); |
| 37 | 37 | } |
| 38 | -$conf->global->MAIN_DISABLE_ALL_MAILS=1; |
|
| 38 | +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
|
| 39 | 39 | |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -63,11 +63,11 @@ discard block |
||
| 63 | 63 | parent::__construct(); |
| 64 | 64 | |
| 65 | 65 | //$this->sharedFixture |
| 66 | - global $conf,$user,$langs,$db; |
|
| 67 | - $this->savconf=$conf; |
|
| 68 | - $this->savuser=$user; |
|
| 69 | - $this->savlangs=$langs; |
|
| 70 | - $this->savdb=$db; |
|
| 66 | + global $conf, $user, $langs, $db; |
|
| 67 | + $this->savconf = $conf; |
|
| 68 | + $this->savuser = $user; |
|
| 69 | + $this->savlangs = $langs; |
|
| 70 | + $this->savdb = $db; |
|
| 71 | 71 | |
| 72 | 72 | print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
| 73 | 73 | //print " - db ".$db->db; |
@@ -77,8 +77,8 @@ discard block |
||
| 77 | 77 | // Static methods |
| 78 | 78 | public static function setUpBeforeClass() |
| 79 | 79 | { |
| 80 | - global $conf,$user,$langs,$db; |
|
| 81 | - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
| 80 | + global $conf, $user, $langs, $db; |
|
| 81 | + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
| 82 | 82 | |
| 83 | 83 | print __METHOD__."\n"; |
| 84 | 84 | } |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | // tear down after class |
| 87 | 87 | public static function tearDownAfterClass() |
| 88 | 88 | { |
| 89 | - global $conf,$user,$langs,$db; |
|
| 89 | + global $conf, $user, $langs, $db; |
|
| 90 | 90 | $db->rollback(); |
| 91 | 91 | |
| 92 | 92 | print __METHOD__."\n"; |
@@ -99,11 +99,11 @@ discard block |
||
| 99 | 99 | */ |
| 100 | 100 | protected function setUp() |
| 101 | 101 | { |
| 102 | - global $conf,$user,$langs,$db; |
|
| 103 | - $conf=$this->savconf; |
|
| 104 | - $user=$this->savuser; |
|
| 105 | - $langs=$this->savlangs; |
|
| 106 | - $db=$this->savdb; |
|
| 102 | + global $conf, $user, $langs, $db; |
|
| 103 | + $conf = $this->savconf; |
|
| 104 | + $user = $this->savuser; |
|
| 105 | + $langs = $this->savlangs; |
|
| 106 | + $db = $this->savdb; |
|
| 107 | 107 | |
| 108 | 108 | print __METHOD__."\n"; |
| 109 | 109 | } |
@@ -128,29 +128,29 @@ discard block |
||
| 128 | 128 | */ |
| 129 | 129 | public function testFactureRoundingCreate1() |
| 130 | 130 | { |
| 131 | - global $conf,$user,$langs,$db; |
|
| 132 | - $conf=$this->savconf; |
|
| 133 | - $user=$this->savuser; |
|
| 134 | - $langs=$this->savlangs; |
|
| 135 | - $db=$this->savdb; |
|
| 131 | + global $conf, $user, $langs, $db; |
|
| 132 | + $conf = $this->savconf; |
|
| 133 | + $user = $this->savuser; |
|
| 134 | + $langs = $this->savlangs; |
|
| 135 | + $db = $this->savdb; |
|
| 136 | 136 | |
| 137 | - $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=0; |
|
| 137 | + $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 0; |
|
| 138 | 138 | |
| 139 | - $localobject=new Facture($this->savdb); |
|
| 139 | + $localobject = new Facture($this->savdb); |
|
| 140 | 140 | $localobject->initAsSpecimen(); |
| 141 | - $localobject->lines=array(); |
|
| 141 | + $localobject->lines = array(); |
|
| 142 | 142 | unset($localobject->total_ht); |
| 143 | 143 | unset($localobject->total_ttc); |
| 144 | 144 | unset($localobject->total_tva); |
| 145 | - $result=$localobject->create($user); |
|
| 145 | + $result = $localobject->create($user); |
|
| 146 | 146 | |
| 147 | 147 | // Add two lines |
| 148 | - for ($i=0; $i<2; $i++) |
|
| 148 | + for ($i = 0; $i < 2; $i++) |
|
| 149 | 149 | { |
| 150 | 150 | $localobject->addline('Description '.$i, 1.24, 1, 10); |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - $newlocalobject=new Facture($this->savdb); |
|
| 153 | + $newlocalobject = new Facture($this->savdb); |
|
| 154 | 154 | $newlocalobject->fetch($result); |
| 155 | 155 | //var_dump($newlocalobject); |
| 156 | 156 | |
@@ -171,29 +171,29 @@ discard block |
||
| 171 | 171 | */ |
| 172 | 172 | public function testFactureRoundingCreate2() |
| 173 | 173 | { |
| 174 | - global $conf,$user,$langs,$db; |
|
| 175 | - $conf=$this->savconf; |
|
| 176 | - $user=$this->savuser; |
|
| 177 | - $langs=$this->savlangs; |
|
| 178 | - $db=$this->savdb; |
|
| 174 | + global $conf, $user, $langs, $db; |
|
| 175 | + $conf = $this->savconf; |
|
| 176 | + $user = $this->savuser; |
|
| 177 | + $langs = $this->savlangs; |
|
| 178 | + $db = $this->savdb; |
|
| 179 | 179 | |
| 180 | - $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=0; |
|
| 180 | + $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 0; |
|
| 181 | 181 | |
| 182 | - $localobject=new Facture($this->savdb); |
|
| 182 | + $localobject = new Facture($this->savdb); |
|
| 183 | 183 | $localobject->initAsSpecimen(); |
| 184 | - $localobject->lines=array(); |
|
| 184 | + $localobject->lines = array(); |
|
| 185 | 185 | unset($localobject->total_ht); |
| 186 | 186 | unset($localobject->total_ttc); |
| 187 | 187 | unset($localobject->total_vat); |
| 188 | - $result=$localobject->create($user); |
|
| 188 | + $result = $localobject->create($user); |
|
| 189 | 189 | |
| 190 | 190 | // Add two lines |
| 191 | - for ($i=0; $i<2; $i++) |
|
| 191 | + for ($i = 0; $i < 2; $i++) |
|
| 192 | 192 | { |
| 193 | 193 | $localobject->addline('Description '.$i, 1.24, 1, 10); |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | - $newlocalobject=new Facture($this->savdb); |
|
| 196 | + $newlocalobject = new Facture($this->savdb); |
|
| 197 | 197 | $newlocalobject->fetch($result); |
| 198 | 198 | //var_dump($newlocalobject); |
| 199 | 199 | |
@@ -211,31 +211,31 @@ discard block |
||
| 211 | 211 | */ |
| 212 | 212 | public function testFactureAddLine1() |
| 213 | 213 | { |
| 214 | - global $conf,$user,$langs,$db; |
|
| 215 | - $conf=$this->savconf; |
|
| 216 | - $user=$this->savuser; |
|
| 217 | - $langs=$this->savlangs; |
|
| 218 | - $db=$this->savdb; |
|
| 214 | + global $conf, $user, $langs, $db; |
|
| 215 | + $conf = $this->savconf; |
|
| 216 | + $user = $this->savuser; |
|
| 217 | + $langs = $this->savlangs; |
|
| 218 | + $db = $this->savdb; |
|
| 219 | 219 | |
| 220 | 220 | // With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 0 |
| 221 | - $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=0; |
|
| 221 | + $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 0; |
|
| 222 | 222 | |
| 223 | - $localobject1a=new Facture($this->savdb); |
|
| 223 | + $localobject1a = new Facture($this->savdb); |
|
| 224 | 224 | $localobject1a->initAsSpecimen('nolines'); |
| 225 | - $facid=$localobject1a->create($user); |
|
| 226 | - $localobject1a->addline('Line 1', 6.36, 15, 21); // This include update_price |
|
| 225 | + $facid = $localobject1a->create($user); |
|
| 226 | + $localobject1a->addline('Line 1', 6.36, 15, 21); // This include update_price |
|
| 227 | 227 | print __METHOD__." id=".$facid." total_ttc=".$localobject1a->total_ttc."\n"; |
| 228 | 228 | $this->assertEquals(95.40, $localobject1a->total_ht); |
| 229 | 229 | $this->assertEquals(20.03, $localobject1a->total_tva); |
| 230 | 230 | $this->assertEquals(115.43, $localobject1a->total_ttc); |
| 231 | 231 | |
| 232 | 232 | // With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 1 |
| 233 | - $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=1; |
|
| 233 | + $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 1; |
|
| 234 | 234 | |
| 235 | - $localobject1b=new Facture($this->savdb); |
|
| 235 | + $localobject1b = new Facture($this->savdb); |
|
| 236 | 236 | $localobject1b->initAsSpecimen('nolines'); |
| 237 | - $facid=$localobject1b->create($user); |
|
| 238 | - $localobject1b->addline('Line 1', 6.36, 15, 21); // This include update_price |
|
| 237 | + $facid = $localobject1b->create($user); |
|
| 238 | + $localobject1b->addline('Line 1', 6.36, 15, 21); // This include update_price |
|
| 239 | 239 | print __METHOD__." id=".$facid." total_ttc=".$localobject1b->total_ttc."\n"; |
| 240 | 240 | $this->assertEquals(95.40, $localobject1b->total_ht, 'testFactureAddLine1 total_ht'); |
| 241 | 241 | $this->assertEquals(20.03, $localobject1b->total_tva, 'testFactureAddLine1 total_tva'); |
@@ -252,18 +252,18 @@ discard block |
||
| 252 | 252 | */ |
| 253 | 253 | public function testFactureAddLine2() |
| 254 | 254 | { |
| 255 | - global $conf,$user,$langs,$db; |
|
| 256 | - $conf=$this->savconf; |
|
| 257 | - $user=$this->savuser; |
|
| 258 | - $langs=$this->savlangs; |
|
| 259 | - $db=$this->savdb; |
|
| 255 | + global $conf, $user, $langs, $db; |
|
| 256 | + $conf = $this->savconf; |
|
| 257 | + $user = $this->savuser; |
|
| 258 | + $langs = $this->savlangs; |
|
| 259 | + $db = $this->savdb; |
|
| 260 | 260 | |
| 261 | 261 | // With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 0 |
| 262 | - $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=0; |
|
| 262 | + $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 0; |
|
| 263 | 263 | |
| 264 | - $localobject2=new Facture($this->savdb); |
|
| 264 | + $localobject2 = new Facture($this->savdb); |
|
| 265 | 265 | $localobject2->initAsSpecimen('nolines'); |
| 266 | - $facid=$localobject2->create($user); |
|
| 266 | + $facid = $localobject2->create($user); |
|
| 267 | 267 | $localobject2->addline('Line 1', 6.36, 5, 21); |
| 268 | 268 | $localobject2->addline('Line 2', 6.36, 5, 21); |
| 269 | 269 | $localobject2->addline('Line 3', 6.36, 5, 21); |
@@ -273,11 +273,11 @@ discard block |
||
| 273 | 273 | $this->assertEquals(115.44, $localobject2->total_ttc); |
| 274 | 274 | |
| 275 | 275 | // With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 1 |
| 276 | - $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=1; |
|
| 276 | + $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 1; |
|
| 277 | 277 | |
| 278 | - $localobject2=new Facture($this->savdb); |
|
| 278 | + $localobject2 = new Facture($this->savdb); |
|
| 279 | 279 | $localobject2->initAsSpecimen('nolines'); |
| 280 | - $facid=$localobject2->create($user); |
|
| 280 | + $facid = $localobject2->create($user); |
|
| 281 | 281 | $localobject2->addline('Line 1', 6.36, 5, 21); |
| 282 | 282 | $localobject2->addline('Line 2', 6.36, 5, 21); |
| 283 | 283 | $localobject2->addline('Line 3', 6.36, 5, 21); |
@@ -297,18 +297,18 @@ discard block |
||
| 297 | 297 | */ |
| 298 | 298 | public function testFactureAddLine3() |
| 299 | 299 | { |
| 300 | - global $conf,$user,$langs,$db; |
|
| 301 | - $conf=$this->savconf; |
|
| 302 | - $user=$this->savuser; |
|
| 303 | - $langs=$this->savlangs; |
|
| 304 | - $db=$this->savdb; |
|
| 300 | + global $conf, $user, $langs, $db; |
|
| 301 | + $conf = $this->savconf; |
|
| 302 | + $user = $this->savuser; |
|
| 303 | + $langs = $this->savlangs; |
|
| 304 | + $db = $this->savdb; |
|
| 305 | 305 | |
| 306 | 306 | // With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 0 |
| 307 | - $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=0; |
|
| 307 | + $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 0; |
|
| 308 | 308 | |
| 309 | - $localobject3=new Facture($this->savdb); |
|
| 309 | + $localobject3 = new Facture($this->savdb); |
|
| 310 | 310 | $localobject3->initAsSpecimen('nolines'); |
| 311 | - $facid=$localobject3->create($user); |
|
| 311 | + $facid = $localobject3->create($user); |
|
| 312 | 312 | $localobject3->addline('Line 1', 6.36, 3, 21); |
| 313 | 313 | $localobject3->addline('Line 2', 6.36, 3, 21); |
| 314 | 314 | $localobject3->addline('Line 3', 6.36, 3, 21); |
@@ -320,11 +320,11 @@ discard block |
||
| 320 | 320 | $this->assertEquals(115.45, $localobject3->total_ttc); |
| 321 | 321 | |
| 322 | 322 | // With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 1 |
| 323 | - $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=1; |
|
| 323 | + $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 1; |
|
| 324 | 324 | |
| 325 | - $localobject3=new Facture($this->savdb); |
|
| 325 | + $localobject3 = new Facture($this->savdb); |
|
| 326 | 326 | $localobject3->initAsSpecimen('nolines'); |
| 327 | - $facid=$localobject3->create($user); |
|
| 327 | + $facid = $localobject3->create($user); |
|
| 328 | 328 | $localobject3->addline('Line 1', 6.36, 3, 21); |
| 329 | 329 | $localobject3->addline('Line 2', 6.36, 3, 21); |
| 330 | 330 | $localobject3->addline('Line 3', 6.36, 3, 21); |
@@ -49,74 +49,74 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | class ImportTest extends PHPUnit_Framework_TestCase |
| 51 | 51 | { |
| 52 | - protected $savconf; |
|
| 53 | - protected $savuser; |
|
| 54 | - protected $savlangs; |
|
| 55 | - protected $savdb; |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * Constructor |
|
| 59 | - * We save global variables into local variables |
|
| 60 | - * |
|
| 61 | - * @return ImportTest |
|
| 62 | - */ |
|
| 63 | - function __construct() |
|
| 64 | - { |
|
| 65 | - parent::__construct(); |
|
| 66 | - |
|
| 67 | - //$this->sharedFixture |
|
| 68 | - global $conf,$user,$langs,$db; |
|
| 69 | - $this->savconf=$conf; |
|
| 70 | - $this->savuser=$user; |
|
| 71 | - $this->savlangs=$langs; |
|
| 72 | - $this->savdb=$db; |
|
| 73 | - |
|
| 74 | - print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
|
| 75 | - //print " - db ".$db->db; |
|
| 76 | - print "\n"; |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - // Static methods |
|
| 80 | - public static function setUpBeforeClass() |
|
| 52 | + protected $savconf; |
|
| 53 | + protected $savuser; |
|
| 54 | + protected $savlangs; |
|
| 55 | + protected $savdb; |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * Constructor |
|
| 59 | + * We save global variables into local variables |
|
| 60 | + * |
|
| 61 | + * @return ImportTest |
|
| 62 | + */ |
|
| 63 | + function __construct() |
|
| 64 | + { |
|
| 65 | + parent::__construct(); |
|
| 66 | + |
|
| 67 | + //$this->sharedFixture |
|
| 68 | + global $conf,$user,$langs,$db; |
|
| 69 | + $this->savconf=$conf; |
|
| 70 | + $this->savuser=$user; |
|
| 71 | + $this->savlangs=$langs; |
|
| 72 | + $this->savdb=$db; |
|
| 73 | + |
|
| 74 | + print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
|
| 75 | + //print " - db ".$db->db; |
|
| 76 | + print "\n"; |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + // Static methods |
|
| 80 | + public static function setUpBeforeClass() |
|
| 81 | 81 | { |
| 82 | - global $conf,$user,$langs,$db; |
|
| 83 | - //$db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
| 82 | + global $conf,$user,$langs,$db; |
|
| 83 | + //$db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
| 84 | 84 | |
| 85 | - print __METHOD__."\n"; |
|
| 85 | + print __METHOD__."\n"; |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | // tear down after class |
| 89 | 89 | public static function tearDownAfterClass() |
| 90 | 90 | { |
| 91 | - global $conf,$user,$langs,$db; |
|
| 92 | - //$db->rollback(); |
|
| 91 | + global $conf,$user,$langs,$db; |
|
| 92 | + //$db->rollback(); |
|
| 93 | 93 | |
| 94 | - print __METHOD__."\n"; |
|
| 94 | + print __METHOD__."\n"; |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - /** |
|
| 98 | - * Init phpunit tests |
|
| 99 | - * |
|
| 100 | - * @return void |
|
| 101 | - */ |
|
| 97 | + /** |
|
| 98 | + * Init phpunit tests |
|
| 99 | + * |
|
| 100 | + * @return void |
|
| 101 | + */ |
|
| 102 | 102 | protected function setUp() |
| 103 | 103 | { |
| 104 | - global $conf,$user,$langs,$db; |
|
| 105 | - $conf=$this->savconf; |
|
| 106 | - $user=$this->savuser; |
|
| 107 | - $langs=$this->savlangs; |
|
| 108 | - $db=$this->savdb; |
|
| 104 | + global $conf,$user,$langs,$db; |
|
| 105 | + $conf=$this->savconf; |
|
| 106 | + $user=$this->savuser; |
|
| 107 | + $langs=$this->savlangs; |
|
| 108 | + $db=$this->savdb; |
|
| 109 | 109 | |
| 110 | - print __METHOD__."\n"; |
|
| 110 | + print __METHOD__."\n"; |
|
| 111 | 111 | } |
| 112 | - /** |
|
| 113 | - * End phpunit tests |
|
| 114 | - * |
|
| 115 | - * @return void |
|
| 116 | - */ |
|
| 112 | + /** |
|
| 113 | + * End phpunit tests |
|
| 114 | + * |
|
| 115 | + * @return void |
|
| 116 | + */ |
|
| 117 | 117 | protected function tearDown() |
| 118 | 118 | { |
| 119 | - print __METHOD__."\n"; |
|
| 119 | + print __METHOD__."\n"; |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | |
@@ -134,6 +134,6 @@ discard block |
||
| 134 | 134 | // according to option |
| 135 | 135 | |
| 136 | 136 | |
| 137 | - return true; |
|
| 137 | + return true; |
|
| 138 | 138 | } |
| 139 | 139 | } |
@@ -23,21 +23,21 @@ discard block |
||
| 23 | 23 | * \remarks To run this script as CLI: phpunit filename.php |
| 24 | 24 | */ |
| 25 | 25 | |
| 26 | -global $conf,$user,$langs,$db; |
|
| 26 | +global $conf, $user, $langs, $db; |
|
| 27 | 27 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
| 28 | 28 | //require_once 'PHPUnit/Autoload.php'; |
| 29 | 29 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
| 30 | 30 | |
| 31 | -if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); |
|
| 32 | -if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); |
|
| 33 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
| 34 | -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); |
|
| 35 | -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); |
|
| 36 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); |
|
| 37 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show |
|
| 38 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php |
|
| 39 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
| 40 | -if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) |
|
| 31 | +if (!defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); |
|
| 32 | +if (!defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); |
|
| 33 | +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); |
|
| 34 | +if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); |
|
| 35 | +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); |
|
| 36 | +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); |
|
| 37 | +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no menu to show |
|
| 38 | +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php |
|
| 39 | +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); |
|
| 40 | +if (!defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) |
|
| 41 | 41 | |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -65,11 +65,11 @@ discard block |
||
| 65 | 65 | parent::__construct(); |
| 66 | 66 | |
| 67 | 67 | //$this->sharedFixture |
| 68 | - global $conf,$user,$langs,$db; |
|
| 69 | - $this->savconf=$conf; |
|
| 70 | - $this->savuser=$user; |
|
| 71 | - $this->savlangs=$langs; |
|
| 72 | - $this->savdb=$db; |
|
| 68 | + global $conf, $user, $langs, $db; |
|
| 69 | + $this->savconf = $conf; |
|
| 70 | + $this->savuser = $user; |
|
| 71 | + $this->savlangs = $langs; |
|
| 72 | + $this->savdb = $db; |
|
| 73 | 73 | |
| 74 | 74 | print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
| 75 | 75 | //print " - db ".$db->db; |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | // Static methods |
| 80 | 80 | public static function setUpBeforeClass() |
| 81 | 81 | { |
| 82 | - global $conf,$user,$langs,$db; |
|
| 82 | + global $conf, $user, $langs, $db; |
|
| 83 | 83 | //$db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
| 84 | 84 | |
| 85 | 85 | print __METHOD__."\n"; |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | // tear down after class |
| 89 | 89 | public static function tearDownAfterClass() |
| 90 | 90 | { |
| 91 | - global $conf,$user,$langs,$db; |
|
| 91 | + global $conf, $user, $langs, $db; |
|
| 92 | 92 | //$db->rollback(); |
| 93 | 93 | |
| 94 | 94 | print __METHOD__."\n"; |
@@ -101,11 +101,11 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | protected function setUp() |
| 103 | 103 | { |
| 104 | - global $conf,$user,$langs,$db; |
|
| 105 | - $conf=$this->savconf; |
|
| 106 | - $user=$this->savuser; |
|
| 107 | - $langs=$this->savlangs; |
|
| 108 | - $db=$this->savdb; |
|
| 104 | + global $conf, $user, $langs, $db; |
|
| 105 | + $conf = $this->savconf; |
|
| 106 | + $user = $this->savuser; |
|
| 107 | + $langs = $this->savlangs; |
|
| 108 | + $db = $this->savdb; |
|
| 109 | 109 | |
| 110 | 110 | print __METHOD__."\n"; |
| 111 | 111 | } |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | public function testImportSample1() |
| 129 | 129 | { |
| 130 | - $file=dirname(__FILE__).'/Example_import_company_1.csv'; |
|
| 130 | + $file = dirname(__FILE__).'/Example_import_company_1.csv'; |
|
| 131 | 131 | |
| 132 | 132 | // TODO |
| 133 | 133 | // Run import on file and check the record with field "auto" are filled |
@@ -28,16 +28,39 @@ |
||
| 28 | 28 | //require_once 'PHPUnit/Autoload.php'; |
| 29 | 29 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
| 30 | 30 | |
| 31 | -if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); |
|
| 32 | -if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); |
|
| 33 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
| 34 | -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); |
|
| 35 | -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); |
|
| 36 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); |
|
| 37 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show |
|
| 38 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php |
|
| 39 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
| 40 | -if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) |
|
| 31 | +if (! defined('NOREQUIREUSER')) { |
|
| 32 | + define('NOREQUIREUSER','1'); |
|
| 33 | +} |
|
| 34 | +if (! defined('NOREQUIREDB')) { |
|
| 35 | + define('NOREQUIREDB','1'); |
|
| 36 | +} |
|
| 37 | +if (! defined('NOREQUIRESOC')) { |
|
| 38 | + define('NOREQUIRESOC','1'); |
|
| 39 | +} |
|
| 40 | +if (! defined('NOREQUIRETRAN')) { |
|
| 41 | + define('NOREQUIRETRAN','1'); |
|
| 42 | +} |
|
| 43 | +if (! defined('NOCSRFCHECK')) { |
|
| 44 | + define('NOCSRFCHECK','1'); |
|
| 45 | +} |
|
| 46 | +if (! defined('NOTOKENRENEWAL')) { |
|
| 47 | + define('NOTOKENRENEWAL','1'); |
|
| 48 | +} |
|
| 49 | +if (! defined('NOREQUIREMENU')) { |
|
| 50 | + define('NOREQUIREMENU','1'); |
|
| 51 | +} |
|
| 52 | +// If there is no menu to show |
|
| 53 | +if (! defined('NOREQUIREHTML')) { |
|
| 54 | + define('NOREQUIREHTML','1'); |
|
| 55 | +} |
|
| 56 | +// If we don't need to load the html.form.class.php |
|
| 57 | +if (! defined('NOREQUIREAJAX')) { |
|
| 58 | + define('NOREQUIREAJAX','1'); |
|
| 59 | +} |
|
| 60 | +if (! defined("NOLOGIN")) { |
|
| 61 | + define("NOLOGIN",'1'); |
|
| 62 | +} |
|
| 63 | +// If this page is public (can be called outside logged session) |
|
| 41 | 64 | |
| 42 | 65 | |
| 43 | 66 | /** |
@@ -62,9 +62,9 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | function __construct() |
| 64 | 64 | { |
| 65 | - parent::__construct(); |
|
| 65 | + parent::__construct(); |
|
| 66 | 66 | |
| 67 | - //$this->sharedFixture |
|
| 67 | + //$this->sharedFixture |
|
| 68 | 68 | global $conf,$user,$langs,$db; |
| 69 | 69 | $this->savconf=$conf; |
| 70 | 70 | $this->savuser=$user; |
@@ -94,11 +94,11 @@ discard block |
||
| 94 | 94 | print __METHOD__."\n"; |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - /** |
|
| 98 | - * Init phpunit tests |
|
| 99 | - * |
|
| 100 | - * @return void |
|
| 101 | - */ |
|
| 97 | + /** |
|
| 98 | + * Init phpunit tests |
|
| 99 | + * |
|
| 100 | + * @return void |
|
| 101 | + */ |
|
| 102 | 102 | protected function setUp() |
| 103 | 103 | { |
| 104 | 104 | global $conf,$user,$langs,$db; |
@@ -109,11 +109,11 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | print __METHOD__."\n"; |
| 111 | 111 | } |
| 112 | - /** |
|
| 113 | - * End phpunit tests |
|
| 114 | - * |
|
| 115 | - * @return void |
|
| 116 | - */ |
|
| 112 | + /** |
|
| 113 | + * End phpunit tests |
|
| 114 | + * |
|
| 115 | + * @return void |
|
| 116 | + */ |
|
| 117 | 117 | protected function tearDown() |
| 118 | 118 | { |
| 119 | 119 | print __METHOD__."\n"; |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | |
| 136 | 136 | // Do a test with an array starting with 0 |
| 137 | 137 | $arraytotest=array(0=>array('key'=>1,'value'=>'PRODREF','label'=>'Product ref with é and special chars \\ \' "')); |
| 138 | - $arrayencodedexpected='[{"key":1,"value":"PRODREF","label":"Product ref with \u00e9 and special chars \\\\ \' \""}]'; |
|
| 138 | + $arrayencodedexpected='[{"key":1,"value":"PRODREF","label":"Product ref with \u00e9 and special chars \\\\ \' \""}]'; |
|
| 139 | 139 | |
| 140 | 140 | $encoded=json_encode($arraytotest); |
| 141 | 141 | $this->assertEquals($arrayencodedexpected,$encoded); |
@@ -147,9 +147,9 @@ discard block |
||
| 147 | 147 | $decoded=dol_json_decode($encoded,true); |
| 148 | 148 | $this->assertEquals($arraytotest,$decoded,'test for dol_json_xxx'); |
| 149 | 149 | |
| 150 | - // Same test but array start with 2 instead of 0 |
|
| 150 | + // Same test but array start with 2 instead of 0 |
|
| 151 | 151 | $arraytotest=array(2=>array('key'=>1,'value'=>'PRODREF','label'=>'Product ref with é and special chars \\ \' "')); |
| 152 | - $arrayencodedexpected='{"2":{"key":1,"value":"PRODREF","label":"Product ref with \u00e9 and special chars \\\\ \' \""}}'; |
|
| 152 | + $arrayencodedexpected='{"2":{"key":1,"value":"PRODREF","label":"Product ref with \u00e9 and special chars \\\\ \' \""}}'; |
|
| 153 | 153 | |
| 154 | 154 | $encoded=json_encode($arraytotest); |
| 155 | 155 | $this->assertEquals($arrayencodedexpected,$encoded); |
@@ -23,21 +23,21 @@ discard block |
||
| 23 | 23 | * \remarks To run this script as CLI: phpunit filename.php |
| 24 | 24 | */ |
| 25 | 25 | |
| 26 | -global $conf,$user,$langs,$db; |
|
| 26 | +global $conf, $user, $langs, $db; |
|
| 27 | 27 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
| 28 | 28 | //require_once 'PHPUnit/Autoload.php'; |
| 29 | 29 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
| 30 | 30 | |
| 31 | -if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); |
|
| 32 | -if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); |
|
| 33 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
| 34 | -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); |
|
| 35 | -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); |
|
| 36 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); |
|
| 37 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show |
|
| 38 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php |
|
| 39 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
| 40 | -if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) |
|
| 31 | +if (!defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); |
|
| 32 | +if (!defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); |
|
| 33 | +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); |
|
| 34 | +if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); |
|
| 35 | +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); |
|
| 36 | +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); |
|
| 37 | +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no menu to show |
|
| 38 | +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php |
|
| 39 | +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); |
|
| 40 | +if (!defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) |
|
| 41 | 41 | |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -65,11 +65,11 @@ discard block |
||
| 65 | 65 | parent::__construct(); |
| 66 | 66 | |
| 67 | 67 | //$this->sharedFixture |
| 68 | - global $conf,$user,$langs,$db; |
|
| 69 | - $this->savconf=$conf; |
|
| 70 | - $this->savuser=$user; |
|
| 71 | - $this->savlangs=$langs; |
|
| 72 | - $this->savdb=$db; |
|
| 68 | + global $conf, $user, $langs, $db; |
|
| 69 | + $this->savconf = $conf; |
|
| 70 | + $this->savuser = $user; |
|
| 71 | + $this->savlangs = $langs; |
|
| 72 | + $this->savdb = $db; |
|
| 73 | 73 | |
| 74 | 74 | print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
| 75 | 75 | //print " - db ".$db->db; |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | // Static methods |
| 80 | 80 | public static function setUpBeforeClass() |
| 81 | 81 | { |
| 82 | - global $conf,$user,$langs,$db; |
|
| 82 | + global $conf, $user, $langs, $db; |
|
| 83 | 83 | //$db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
| 84 | 84 | |
| 85 | 85 | print __METHOD__."\n"; |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | // tear down after class |
| 89 | 89 | public static function tearDownAfterClass() |
| 90 | 90 | { |
| 91 | - global $conf,$user,$langs,$db; |
|
| 91 | + global $conf, $user, $langs, $db; |
|
| 92 | 92 | //$db->rollback(); |
| 93 | 93 | |
| 94 | 94 | print __METHOD__."\n"; |
@@ -101,11 +101,11 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | protected function setUp() |
| 103 | 103 | { |
| 104 | - global $conf,$user,$langs,$db; |
|
| 105 | - $conf=$this->savconf; |
|
| 106 | - $user=$this->savuser; |
|
| 107 | - $langs=$this->savlangs; |
|
| 108 | - $db=$this->savdb; |
|
| 104 | + global $conf, $user, $langs, $db; |
|
| 105 | + $conf = $this->savconf; |
|
| 106 | + $user = $this->savuser; |
|
| 107 | + $langs = $this->savlangs; |
|
| 108 | + $db = $this->savdb; |
|
| 109 | 109 | |
| 110 | 110 | print __METHOD__."\n"; |
| 111 | 111 | } |
@@ -127,47 +127,47 @@ discard block |
||
| 127 | 127 | public function testJsonEncode() |
| 128 | 128 | { |
| 129 | 129 | //$this->sharedFixture |
| 130 | - global $conf,$user,$langs,$db; |
|
| 131 | - $this->savconf=$conf; |
|
| 132 | - $this->savuser=$user; |
|
| 133 | - $this->savlangs=$langs; |
|
| 134 | - $this->savdb=$db; |
|
| 130 | + global $conf, $user, $langs, $db; |
|
| 131 | + $this->savconf = $conf; |
|
| 132 | + $this->savuser = $user; |
|
| 133 | + $this->savlangs = $langs; |
|
| 134 | + $this->savdb = $db; |
|
| 135 | 135 | |
| 136 | 136 | // Do a test with an array starting with 0 |
| 137 | - $arraytotest=array(0=>array('key'=>1,'value'=>'PRODREF','label'=>'Product ref with é and special chars \\ \' "')); |
|
| 138 | - $arrayencodedexpected='[{"key":1,"value":"PRODREF","label":"Product ref with \u00e9 and special chars \\\\ \' \""}]'; |
|
| 137 | + $arraytotest = array(0=>array('key'=>1, 'value'=>'PRODREF', 'label'=>'Product ref with é and special chars \\ \' "')); |
|
| 138 | + $arrayencodedexpected = '[{"key":1,"value":"PRODREF","label":"Product ref with \u00e9 and special chars \\\\ \' \""}]'; |
|
| 139 | 139 | |
| 140 | - $encoded=json_encode($arraytotest); |
|
| 141 | - $this->assertEquals($arrayencodedexpected,$encoded); |
|
| 142 | - $decoded=json_decode($encoded,true); |
|
| 143 | - $this->assertEquals($arraytotest,$decoded,'test for json_xxx'); |
|
| 140 | + $encoded = json_encode($arraytotest); |
|
| 141 | + $this->assertEquals($arrayencodedexpected, $encoded); |
|
| 142 | + $decoded = json_decode($encoded, true); |
|
| 143 | + $this->assertEquals($arraytotest, $decoded, 'test for json_xxx'); |
|
| 144 | 144 | |
| 145 | - $encoded=dol_json_encode($arraytotest); |
|
| 146 | - $this->assertEquals($arrayencodedexpected,$encoded); |
|
| 147 | - $decoded=dol_json_decode($encoded,true); |
|
| 148 | - $this->assertEquals($arraytotest,$decoded,'test for dol_json_xxx'); |
|
| 145 | + $encoded = dol_json_encode($arraytotest); |
|
| 146 | + $this->assertEquals($arrayencodedexpected, $encoded); |
|
| 147 | + $decoded = dol_json_decode($encoded, true); |
|
| 148 | + $this->assertEquals($arraytotest, $decoded, 'test for dol_json_xxx'); |
|
| 149 | 149 | |
| 150 | 150 | // Same test but array start with 2 instead of 0 |
| 151 | - $arraytotest=array(2=>array('key'=>1,'value'=>'PRODREF','label'=>'Product ref with é and special chars \\ \' "')); |
|
| 152 | - $arrayencodedexpected='{"2":{"key":1,"value":"PRODREF","label":"Product ref with \u00e9 and special chars \\\\ \' \""}}'; |
|
| 151 | + $arraytotest = array(2=>array('key'=>1, 'value'=>'PRODREF', 'label'=>'Product ref with é and special chars \\ \' "')); |
|
| 152 | + $arrayencodedexpected = '{"2":{"key":1,"value":"PRODREF","label":"Product ref with \u00e9 and special chars \\\\ \' \""}}'; |
|
| 153 | 153 | |
| 154 | - $encoded=json_encode($arraytotest); |
|
| 155 | - $this->assertEquals($arrayencodedexpected,$encoded); |
|
| 156 | - $decoded=json_decode($encoded,true); |
|
| 157 | - $this->assertEquals($arraytotest,$decoded,'test for json_xxx'); |
|
| 154 | + $encoded = json_encode($arraytotest); |
|
| 155 | + $this->assertEquals($arrayencodedexpected, $encoded); |
|
| 156 | + $decoded = json_decode($encoded, true); |
|
| 157 | + $this->assertEquals($arraytotest, $decoded, 'test for json_xxx'); |
|
| 158 | 158 | |
| 159 | - $encoded=dol_json_encode($arraytotest); |
|
| 160 | - $this->assertEquals($arrayencodedexpected,$encoded); |
|
| 161 | - $decoded=dol_json_decode($encoded,true); |
|
| 162 | - $this->assertEquals($arraytotest,$decoded,'test for dol_json_xxx'); |
|
| 159 | + $encoded = dol_json_encode($arraytotest); |
|
| 160 | + $this->assertEquals($arrayencodedexpected, $encoded); |
|
| 161 | + $decoded = dol_json_decode($encoded, true); |
|
| 162 | + $this->assertEquals($arraytotest, $decoded, 'test for dol_json_xxx'); |
|
| 163 | 163 | |
| 164 | 164 | // Test with object |
| 165 | - $now=gmmktime(12,0,0,1,1,1970); |
|
| 166 | - $objecttotest=new stdClass(); |
|
| 167 | - $objecttotest->property1='abc'; |
|
| 168 | - $objecttotest->property2=1234; |
|
| 169 | - $objecttotest->property3=$now; |
|
| 170 | - $encoded=dol_json_encode($objecttotest); |
|
| 171 | - $this->assertEquals('{"property1":"abc","property2":1234,"property3":43200}',$encoded); |
|
| 165 | + $now = gmmktime(12, 0, 0, 1, 1, 1970); |
|
| 166 | + $objecttotest = new stdClass(); |
|
| 167 | + $objecttotest->property1 = 'abc'; |
|
| 168 | + $objecttotest->property2 = 1234; |
|
| 169 | + $objecttotest->property3 = $now; |
|
| 170 | + $encoded = dol_json_encode($objecttotest); |
|
| 171 | + $this->assertEquals('{"property1":"abc","property2":1234,"property3":43200}', $encoded); |
|
| 172 | 172 | } |
| 173 | 173 | } |
@@ -28,16 +28,39 @@ |
||
| 28 | 28 | //require_once 'PHPUnit/Autoload.php'; |
| 29 | 29 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
| 30 | 30 | |
| 31 | -if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); |
|
| 32 | -if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); |
|
| 33 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
| 34 | -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); |
|
| 35 | -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); |
|
| 36 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); |
|
| 37 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show |
|
| 38 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php |
|
| 39 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
| 40 | -if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) |
|
| 31 | +if (! defined('NOREQUIREUSER')) { |
|
| 32 | + define('NOREQUIREUSER','1'); |
|
| 33 | +} |
|
| 34 | +if (! defined('NOREQUIREDB')) { |
|
| 35 | + define('NOREQUIREDB','1'); |
|
| 36 | +} |
|
| 37 | +if (! defined('NOREQUIRESOC')) { |
|
| 38 | + define('NOREQUIRESOC','1'); |
|
| 39 | +} |
|
| 40 | +if (! defined('NOREQUIRETRAN')) { |
|
| 41 | + define('NOREQUIRETRAN','1'); |
|
| 42 | +} |
|
| 43 | +if (! defined('NOCSRFCHECK')) { |
|
| 44 | + define('NOCSRFCHECK','1'); |
|
| 45 | +} |
|
| 46 | +if (! defined('NOTOKENRENEWAL')) { |
|
| 47 | + define('NOTOKENRENEWAL','1'); |
|
| 48 | +} |
|
| 49 | +if (! defined('NOREQUIREMENU')) { |
|
| 50 | + define('NOREQUIREMENU','1'); |
|
| 51 | +} |
|
| 52 | +// If there is no menu to show |
|
| 53 | +if (! defined('NOREQUIREHTML')) { |
|
| 54 | + define('NOREQUIREHTML','1'); |
|
| 55 | +} |
|
| 56 | +// If we don't need to load the html.form.class.php |
|
| 57 | +if (! defined('NOREQUIREAJAX')) { |
|
| 58 | + define('NOREQUIREAJAX','1'); |
|
| 59 | +} |
|
| 60 | +if (! defined("NOLOGIN")) { |
|
| 61 | + define("NOLOGIN",'1'); |
|
| 62 | +} |
|
| 63 | +// If this page is public (can be called outside logged session) |
|
| 41 | 64 | |
| 42 | 65 | |
| 43 | 66 | /** |
@@ -31,9 +31,9 @@ discard block |
||
| 31 | 31 | require_once dirname(__FILE__).'/../../htdocs/ticket/class/ticket.class.php'; |
| 32 | 32 | |
| 33 | 33 | if (empty($user->id)) { |
| 34 | - print "Load permissions for admin user nb 1\n"; |
|
| 35 | - $user->fetch(1); |
|
| 36 | - $user->getrights(); |
|
| 34 | + print "Load permissions for admin user nb 1\n"; |
|
| 35 | + $user->fetch(1); |
|
| 36 | + $user->getrights(); |
|
| 37 | 37 | } |
| 38 | 38 | $conf->global->MAIN_DISABLE_ALL_MAILS=1; |
| 39 | 39 | |
@@ -47,366 +47,366 @@ discard block |
||
| 47 | 47 | */ |
| 48 | 48 | class TicketTest extends PHPUnit_Framework_TestCase |
| 49 | 49 | { |
| 50 | - protected $savconf; |
|
| 51 | - protected $savuser; |
|
| 52 | - protected $savlangs; |
|
| 53 | - protected $savdb; |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * Constructor |
|
| 57 | - * We save global variables into local variables |
|
| 58 | - * |
|
| 59 | - * @return ContratTest |
|
| 60 | - */ |
|
| 61 | - public function __construct() |
|
| 62 | - { |
|
| 63 | - parent::__construct(); |
|
| 64 | - |
|
| 65 | - //$this->sharedFixture |
|
| 66 | - global $conf,$user,$langs,$db; |
|
| 67 | - $this->savconf=$conf; |
|
| 68 | - $this->savuser=$user; |
|
| 69 | - $this->savlangs=$langs; |
|
| 70 | - $this->savdb=$db; |
|
| 71 | - |
|
| 72 | - print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
|
| 73 | - //print " - db ".$db->db; |
|
| 74 | - print "\n"; |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - // Static methods |
|
| 78 | - public static function setUpBeforeClass() |
|
| 79 | - { |
|
| 80 | - global $conf,$user,$langs,$db; |
|
| 81 | - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
| 82 | - |
|
| 83 | - print __METHOD__."\n"; |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - // tear down after class |
|
| 87 | - public static function tearDownAfterClass() |
|
| 88 | - { |
|
| 89 | - global $conf,$user,$langs,$db; |
|
| 90 | - $db->rollback(); |
|
| 91 | - |
|
| 92 | - print __METHOD__."\n"; |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - /** |
|
| 96 | - * Init phpunit tests |
|
| 97 | - * |
|
| 98 | - * @return void |
|
| 99 | - */ |
|
| 100 | - protected function setUp() |
|
| 101 | - { |
|
| 102 | - global $conf,$user,$langs,$db; |
|
| 103 | - $conf=$this->savconf; |
|
| 104 | - $user=$this->savuser; |
|
| 105 | - $langs=$this->savlangs; |
|
| 106 | - $db=$this->savdb; |
|
| 107 | - |
|
| 108 | - print __METHOD__."\n"; |
|
| 109 | - } |
|
| 110 | - /** |
|
| 111 | - * End phpunit tests |
|
| 112 | - * |
|
| 113 | - * @return void |
|
| 114 | - */ |
|
| 115 | - protected function tearDown() |
|
| 116 | - { |
|
| 117 | - print __METHOD__."\n"; |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - /** |
|
| 121 | - * testTicketCreate |
|
| 122 | - * |
|
| 123 | - * @return int |
|
| 124 | - */ |
|
| 125 | - public function testTicketCreate() |
|
| 126 | - { |
|
| 127 | - global $conf,$user,$langs,$db; |
|
| 128 | - $conf=$this->savconf; |
|
| 129 | - $user=$this->savuser; |
|
| 130 | - $langs=$this->savlangs; |
|
| 131 | - $db=$this->savdb; |
|
| 132 | - |
|
| 133 | - // Try to create one with bad values |
|
| 134 | - $localobject=new Ticket($this->savdb); |
|
| 135 | - $localobject->initAsSpecimen(); |
|
| 136 | - $localobject->ref = ''; |
|
| 137 | - $result=$localobject->create($user); |
|
| 138 | - |
|
| 139 | - print __METHOD__." result=".$result."\n"; |
|
| 140 | - $this->assertEquals(-3, $result, $localobject->error.join(',', $localobject->errors)); |
|
| 141 | - |
|
| 142 | - // Try to create one with correct values |
|
| 143 | - $localobject=new Ticket($this->savdb); |
|
| 144 | - $localobject->initAsSpecimen(); |
|
| 145 | - $result=$localobject->create($user); |
|
| 146 | - |
|
| 147 | - print __METHOD__." result=".$result."\n"; |
|
| 148 | - $this->assertGreaterThan(0, $result, $localobject->error.join(',', $localobject->errors)); |
|
| 149 | - |
|
| 150 | - return $result; |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - /** |
|
| 154 | - * testTicketFetch |
|
| 155 | - * |
|
| 156 | - * @param int $id Id of ticket |
|
| 157 | - * @return int |
|
| 158 | - * |
|
| 159 | - * @depends testTicketCreate |
|
| 160 | - * The depends says test is run only if previous is ok |
|
| 161 | - */ |
|
| 162 | - public function testTicketFetch($id) |
|
| 163 | - { |
|
| 164 | - global $conf,$user,$langs,$db; |
|
| 165 | - $conf=$this->savconf; |
|
| 166 | - $user=$this->savuser; |
|
| 167 | - $langs=$this->savlangs; |
|
| 168 | - $db=$this->savdb; |
|
| 169 | - |
|
| 170 | - $localobject=new Ticket($this->savdb); |
|
| 171 | - $result=$localobject->fetch($id); |
|
| 172 | - |
|
| 173 | - print __METHOD__." id=".$id." result=".$result."\n"; |
|
| 174 | - $this->assertGreaterThan(0, $result); |
|
| 175 | - |
|
| 176 | - return $localobject; |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - /** |
|
| 180 | - * testTicketmarkAsRead |
|
| 181 | - * |
|
| 182 | - * @param Ticket $localobject Ticket |
|
| 183 | - * @return int |
|
| 184 | - * |
|
| 185 | - * @depends testTicketFetch |
|
| 186 | - * The depends says test is run only if previous is ok |
|
| 187 | - */ |
|
| 188 | - public function testTicketmarkAsRead($localobject) |
|
| 189 | - { |
|
| 190 | - global $conf,$user,$langs,$db; |
|
| 191 | - $conf=$this->savconf; |
|
| 192 | - $user=$this->savuser; |
|
| 193 | - $langs=$this->savlangs; |
|
| 194 | - $db=$this->savdb; |
|
| 195 | - |
|
| 196 | - $result=$localobject->markAsRead($user); |
|
| 197 | - print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
| 198 | - |
|
| 199 | - $this->assertGreaterThan(0, $result); |
|
| 200 | - return $localobject; |
|
| 201 | - } |
|
| 202 | - |
|
| 203 | - /** |
|
| 204 | - * testTicketsetProject |
|
| 205 | - * |
|
| 206 | - * @param Ticket $localobject Ticket |
|
| 207 | - * @return int |
|
| 208 | - * |
|
| 209 | - * @depends testTicketFetch |
|
| 210 | - * The depends says test is run only if previous is ok |
|
| 211 | - */ |
|
| 212 | - public function testTicketsetProject($localobject) |
|
| 213 | - { |
|
| 214 | - global $conf,$user,$langs,$db; |
|
| 215 | - $conf=$this->savconf; |
|
| 216 | - $user=$this->savuser; |
|
| 217 | - $langs=$this->savlangs; |
|
| 218 | - $db=$this->savdb; |
|
| 219 | - |
|
| 220 | - $project_id = 1; |
|
| 221 | - |
|
| 222 | - $result=$localobject->setProject($project_id); |
|
| 223 | - print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
| 224 | - |
|
| 225 | - $this->assertGreaterThan(0, $result); |
|
| 226 | - return $localobject; |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - /** |
|
| 230 | - * testTicketsetContract |
|
| 231 | - * |
|
| 232 | - * @param Ticket $localobject Ticket |
|
| 233 | - * @return int |
|
| 234 | - * |
|
| 235 | - * @depends testTicketFetch |
|
| 236 | - * The depends says test is run only if previous is ok |
|
| 237 | - */ |
|
| 238 | - public function testTicketsetContract($localobject) |
|
| 239 | - { |
|
| 240 | - global $conf,$user,$langs,$db; |
|
| 241 | - $conf=$this->savconf; |
|
| 242 | - $user=$this->savuser; |
|
| 243 | - $langs=$this->savlangs; |
|
| 244 | - $db=$this->savdb; |
|
| 245 | - |
|
| 246 | - $contract_id = 1; |
|
| 247 | - |
|
| 248 | - $result=$localobject->setContract($contract_id); |
|
| 249 | - print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
| 250 | - |
|
| 251 | - $this->assertGreaterThan(0, $result); |
|
| 252 | - return $localobject; |
|
| 253 | - } |
|
| 254 | - |
|
| 255 | - /** |
|
| 256 | - * testTicketsetProgression |
|
| 257 | - * |
|
| 258 | - * @param Ticket $localobject Ticket |
|
| 259 | - * @return int |
|
| 260 | - * |
|
| 261 | - * @depends testTicketFetch |
|
| 262 | - * The depends says test is run only if previous is ok |
|
| 263 | - */ |
|
| 264 | - public function testTicketsetProgression($localobject) |
|
| 265 | - { |
|
| 266 | - global $conf,$user,$langs,$db; |
|
| 267 | - $conf=$this->savconf; |
|
| 268 | - $user=$this->savuser; |
|
| 269 | - $langs=$this->savlangs; |
|
| 270 | - $db=$this->savdb; |
|
| 271 | - |
|
| 272 | - $percent = 80; |
|
| 273 | - |
|
| 274 | - $result=$localobject->setProgression($percent); |
|
| 275 | - print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
| 276 | - |
|
| 277 | - $this->assertGreaterThan(0, $result); |
|
| 278 | - return $localobject; |
|
| 279 | - } |
|
| 280 | - |
|
| 281 | - /** |
|
| 282 | - * testTicketassignUser |
|
| 283 | - * |
|
| 284 | - * @param Ticket $localobject Ticket |
|
| 285 | - * @return int |
|
| 286 | - * |
|
| 287 | - * @depends testTicketFetch |
|
| 288 | - * The depends says test is run only if previous is ok |
|
| 289 | - */ |
|
| 290 | - public function testTicketassignUser($localobject) |
|
| 291 | - { |
|
| 292 | - global $conf,$user,$langs,$db; |
|
| 293 | - $conf=$this->savconf; |
|
| 294 | - $user=$this->savuser; |
|
| 295 | - $langs=$this->savlangs; |
|
| 296 | - $db=$this->savdb; |
|
| 297 | - |
|
| 298 | - $user_id_to_assign = 1; |
|
| 299 | - |
|
| 300 | - $result=$localobject->assignUser($user, $user_id_to_assign); |
|
| 50 | + protected $savconf; |
|
| 51 | + protected $savuser; |
|
| 52 | + protected $savlangs; |
|
| 53 | + protected $savdb; |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * Constructor |
|
| 57 | + * We save global variables into local variables |
|
| 58 | + * |
|
| 59 | + * @return ContratTest |
|
| 60 | + */ |
|
| 61 | + public function __construct() |
|
| 62 | + { |
|
| 63 | + parent::__construct(); |
|
| 64 | + |
|
| 65 | + //$this->sharedFixture |
|
| 66 | + global $conf,$user,$langs,$db; |
|
| 67 | + $this->savconf=$conf; |
|
| 68 | + $this->savuser=$user; |
|
| 69 | + $this->savlangs=$langs; |
|
| 70 | + $this->savdb=$db; |
|
| 71 | + |
|
| 72 | + print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
|
| 73 | + //print " - db ".$db->db; |
|
| 74 | + print "\n"; |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + // Static methods |
|
| 78 | + public static function setUpBeforeClass() |
|
| 79 | + { |
|
| 80 | + global $conf,$user,$langs,$db; |
|
| 81 | + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
| 82 | + |
|
| 83 | + print __METHOD__."\n"; |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + // tear down after class |
|
| 87 | + public static function tearDownAfterClass() |
|
| 88 | + { |
|
| 89 | + global $conf,$user,$langs,$db; |
|
| 90 | + $db->rollback(); |
|
| 91 | + |
|
| 92 | + print __METHOD__."\n"; |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + /** |
|
| 96 | + * Init phpunit tests |
|
| 97 | + * |
|
| 98 | + * @return void |
|
| 99 | + */ |
|
| 100 | + protected function setUp() |
|
| 101 | + { |
|
| 102 | + global $conf,$user,$langs,$db; |
|
| 103 | + $conf=$this->savconf; |
|
| 104 | + $user=$this->savuser; |
|
| 105 | + $langs=$this->savlangs; |
|
| 106 | + $db=$this->savdb; |
|
| 107 | + |
|
| 108 | + print __METHOD__."\n"; |
|
| 109 | + } |
|
| 110 | + /** |
|
| 111 | + * End phpunit tests |
|
| 112 | + * |
|
| 113 | + * @return void |
|
| 114 | + */ |
|
| 115 | + protected function tearDown() |
|
| 116 | + { |
|
| 117 | + print __METHOD__."\n"; |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + /** |
|
| 121 | + * testTicketCreate |
|
| 122 | + * |
|
| 123 | + * @return int |
|
| 124 | + */ |
|
| 125 | + public function testTicketCreate() |
|
| 126 | + { |
|
| 127 | + global $conf,$user,$langs,$db; |
|
| 128 | + $conf=$this->savconf; |
|
| 129 | + $user=$this->savuser; |
|
| 130 | + $langs=$this->savlangs; |
|
| 131 | + $db=$this->savdb; |
|
| 132 | + |
|
| 133 | + // Try to create one with bad values |
|
| 134 | + $localobject=new Ticket($this->savdb); |
|
| 135 | + $localobject->initAsSpecimen(); |
|
| 136 | + $localobject->ref = ''; |
|
| 137 | + $result=$localobject->create($user); |
|
| 138 | + |
|
| 139 | + print __METHOD__." result=".$result."\n"; |
|
| 140 | + $this->assertEquals(-3, $result, $localobject->error.join(',', $localobject->errors)); |
|
| 141 | + |
|
| 142 | + // Try to create one with correct values |
|
| 143 | + $localobject=new Ticket($this->savdb); |
|
| 144 | + $localobject->initAsSpecimen(); |
|
| 145 | + $result=$localobject->create($user); |
|
| 146 | + |
|
| 147 | + print __METHOD__." result=".$result."\n"; |
|
| 148 | + $this->assertGreaterThan(0, $result, $localobject->error.join(',', $localobject->errors)); |
|
| 149 | + |
|
| 150 | + return $result; |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + /** |
|
| 154 | + * testTicketFetch |
|
| 155 | + * |
|
| 156 | + * @param int $id Id of ticket |
|
| 157 | + * @return int |
|
| 158 | + * |
|
| 159 | + * @depends testTicketCreate |
|
| 160 | + * The depends says test is run only if previous is ok |
|
| 161 | + */ |
|
| 162 | + public function testTicketFetch($id) |
|
| 163 | + { |
|
| 164 | + global $conf,$user,$langs,$db; |
|
| 165 | + $conf=$this->savconf; |
|
| 166 | + $user=$this->savuser; |
|
| 167 | + $langs=$this->savlangs; |
|
| 168 | + $db=$this->savdb; |
|
| 169 | + |
|
| 170 | + $localobject=new Ticket($this->savdb); |
|
| 171 | + $result=$localobject->fetch($id); |
|
| 172 | + |
|
| 173 | + print __METHOD__." id=".$id." result=".$result."\n"; |
|
| 174 | + $this->assertGreaterThan(0, $result); |
|
| 175 | + |
|
| 176 | + return $localobject; |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + /** |
|
| 180 | + * testTicketmarkAsRead |
|
| 181 | + * |
|
| 182 | + * @param Ticket $localobject Ticket |
|
| 183 | + * @return int |
|
| 184 | + * |
|
| 185 | + * @depends testTicketFetch |
|
| 186 | + * The depends says test is run only if previous is ok |
|
| 187 | + */ |
|
| 188 | + public function testTicketmarkAsRead($localobject) |
|
| 189 | + { |
|
| 190 | + global $conf,$user,$langs,$db; |
|
| 191 | + $conf=$this->savconf; |
|
| 192 | + $user=$this->savuser; |
|
| 193 | + $langs=$this->savlangs; |
|
| 194 | + $db=$this->savdb; |
|
| 195 | + |
|
| 196 | + $result=$localobject->markAsRead($user); |
|
| 197 | + print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
| 198 | + |
|
| 199 | + $this->assertGreaterThan(0, $result); |
|
| 200 | + return $localobject; |
|
| 201 | + } |
|
| 202 | + |
|
| 203 | + /** |
|
| 204 | + * testTicketsetProject |
|
| 205 | + * |
|
| 206 | + * @param Ticket $localobject Ticket |
|
| 207 | + * @return int |
|
| 208 | + * |
|
| 209 | + * @depends testTicketFetch |
|
| 210 | + * The depends says test is run only if previous is ok |
|
| 211 | + */ |
|
| 212 | + public function testTicketsetProject($localobject) |
|
| 213 | + { |
|
| 214 | + global $conf,$user,$langs,$db; |
|
| 215 | + $conf=$this->savconf; |
|
| 216 | + $user=$this->savuser; |
|
| 217 | + $langs=$this->savlangs; |
|
| 218 | + $db=$this->savdb; |
|
| 219 | + |
|
| 220 | + $project_id = 1; |
|
| 221 | + |
|
| 222 | + $result=$localobject->setProject($project_id); |
|
| 223 | + print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
| 224 | + |
|
| 225 | + $this->assertGreaterThan(0, $result); |
|
| 226 | + return $localobject; |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + /** |
|
| 230 | + * testTicketsetContract |
|
| 231 | + * |
|
| 232 | + * @param Ticket $localobject Ticket |
|
| 233 | + * @return int |
|
| 234 | + * |
|
| 235 | + * @depends testTicketFetch |
|
| 236 | + * The depends says test is run only if previous is ok |
|
| 237 | + */ |
|
| 238 | + public function testTicketsetContract($localobject) |
|
| 239 | + { |
|
| 240 | + global $conf,$user,$langs,$db; |
|
| 241 | + $conf=$this->savconf; |
|
| 242 | + $user=$this->savuser; |
|
| 243 | + $langs=$this->savlangs; |
|
| 244 | + $db=$this->savdb; |
|
| 245 | + |
|
| 246 | + $contract_id = 1; |
|
| 247 | + |
|
| 248 | + $result=$localobject->setContract($contract_id); |
|
| 249 | + print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
| 250 | + |
|
| 251 | + $this->assertGreaterThan(0, $result); |
|
| 252 | + return $localobject; |
|
| 253 | + } |
|
| 254 | + |
|
| 255 | + /** |
|
| 256 | + * testTicketsetProgression |
|
| 257 | + * |
|
| 258 | + * @param Ticket $localobject Ticket |
|
| 259 | + * @return int |
|
| 260 | + * |
|
| 261 | + * @depends testTicketFetch |
|
| 262 | + * The depends says test is run only if previous is ok |
|
| 263 | + */ |
|
| 264 | + public function testTicketsetProgression($localobject) |
|
| 265 | + { |
|
| 266 | + global $conf,$user,$langs,$db; |
|
| 267 | + $conf=$this->savconf; |
|
| 268 | + $user=$this->savuser; |
|
| 269 | + $langs=$this->savlangs; |
|
| 270 | + $db=$this->savdb; |
|
| 271 | + |
|
| 272 | + $percent = 80; |
|
| 273 | + |
|
| 274 | + $result=$localobject->setProgression($percent); |
|
| 275 | + print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
| 276 | + |
|
| 277 | + $this->assertGreaterThan(0, $result); |
|
| 278 | + return $localobject; |
|
| 279 | + } |
|
| 280 | + |
|
| 281 | + /** |
|
| 282 | + * testTicketassignUser |
|
| 283 | + * |
|
| 284 | + * @param Ticket $localobject Ticket |
|
| 285 | + * @return int |
|
| 286 | + * |
|
| 287 | + * @depends testTicketFetch |
|
| 288 | + * The depends says test is run only if previous is ok |
|
| 289 | + */ |
|
| 290 | + public function testTicketassignUser($localobject) |
|
| 291 | + { |
|
| 292 | + global $conf,$user,$langs,$db; |
|
| 293 | + $conf=$this->savconf; |
|
| 294 | + $user=$this->savuser; |
|
| 295 | + $langs=$this->savlangs; |
|
| 296 | + $db=$this->savdb; |
|
| 297 | + |
|
| 298 | + $user_id_to_assign = 1; |
|
| 299 | + |
|
| 300 | + $result=$localobject->assignUser($user, $user_id_to_assign); |
|
| 301 | 301 | ; |
| 302 | - print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
| 303 | - |
|
| 304 | - $this->assertGreaterThan(0, $result); |
|
| 305 | - return $localobject; |
|
| 306 | - } |
|
| 307 | - |
|
| 308 | - /** |
|
| 309 | - * testTicketassignUserOther |
|
| 310 | - * |
|
| 311 | - * @param Ticket $localobject Ticket |
|
| 312 | - * @return int |
|
| 313 | - * |
|
| 314 | - * @depends testTicketFetch |
|
| 315 | - * The depends says test is run only if previous is ok |
|
| 316 | - */ |
|
| 317 | - public function testTicketassignUserOther($localobject) |
|
| 318 | - { |
|
| 319 | - global $conf,$user,$langs,$db; |
|
| 320 | - $conf=$this->savconf; |
|
| 321 | - $user=$this->savuser; |
|
| 322 | - $langs=$this->savlangs; |
|
| 323 | - $db=$this->savdb; |
|
| 324 | - |
|
| 325 | - $user_id_to_assign = 2; |
|
| 326 | - |
|
| 327 | - $result=$localobject->assignUser($user, $user_id_to_assign); |
|
| 328 | - ; |
|
| 329 | - print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
| 330 | - |
|
| 331 | - $this->assertGreaterThan(0, $result); |
|
| 332 | - return $localobject; |
|
| 333 | - } |
|
| 334 | - |
|
| 335 | - /** |
|
| 336 | - * testTicketcreateTicketLog |
|
| 337 | - * |
|
| 338 | - * @param Ticket $localobject Ticket |
|
| 339 | - * @return int |
|
| 340 | - * |
|
| 341 | - * @depends testTicketFetch |
|
| 342 | - * The depends says test is run only if previous is ok |
|
| 343 | - */ |
|
| 344 | - public function testTicketcreateTicketLog($localobject) |
|
| 345 | - { |
|
| 346 | - global $conf,$user,$langs,$db; |
|
| 347 | - $conf=$this->savconf; |
|
| 348 | - $user=$this->savuser; |
|
| 349 | - $langs=$this->savlangs; |
|
| 350 | - $db=$this->savdb; |
|
| 351 | - |
|
| 352 | - |
|
| 353 | - $message = 'Test ticket log'; |
|
| 354 | - $noemail = 1; |
|
| 355 | - $result=$localobject->createTicketLog($user, $message, $noemail); |
|
| 356 | - print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
| 357 | - |
|
| 358 | - $this->assertGreaterThan(0, $result); |
|
| 359 | - return $localobject; |
|
| 360 | - } |
|
| 361 | - |
|
| 362 | - /** |
|
| 363 | - * testTicketclose |
|
| 364 | - * |
|
| 365 | - * @param Ticket $localobject Ticket |
|
| 366 | - * @return int |
|
| 367 | - * |
|
| 368 | - * @depends testTicketFetch |
|
| 369 | - * The depends says test is run only if previous is ok |
|
| 370 | - */ |
|
| 371 | - public function testTicketclose($localobject) |
|
| 372 | - { |
|
| 373 | - global $conf,$user,$langs,$db; |
|
| 374 | - $conf=$this->savconf; |
|
| 375 | - $user=$this->savuser; |
|
| 376 | - $langs=$this->savlangs; |
|
| 377 | - $db=$this->savdb; |
|
| 378 | - |
|
| 379 | - $result=$localobject->close(); |
|
| 380 | - print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
| 381 | - |
|
| 382 | - $this->assertGreaterThan(0, $result); |
|
| 383 | - return $localobject->id; |
|
| 384 | - } |
|
| 385 | - |
|
| 386 | - |
|
| 387 | - /** |
|
| 388 | - * testTicketDelete |
|
| 389 | - * |
|
| 390 | - * @param int $id Id of ticket |
|
| 391 | - * @return int |
|
| 392 | - * |
|
| 393 | - * @depends testTicketclose |
|
| 394 | - * The depends says test is run only if previous is ok |
|
| 395 | - */ |
|
| 396 | - public function testTicketDelete($id) |
|
| 397 | - { |
|
| 398 | - global $conf,$user,$langs,$db; |
|
| 399 | - $conf=$this->savconf; |
|
| 400 | - $user=$this->savuser; |
|
| 401 | - $langs=$this->savlangs; |
|
| 402 | - $db=$this->savdb; |
|
| 403 | - |
|
| 404 | - $localobject=new Ticket($this->savdb); |
|
| 405 | - $result=$localobject->fetch($id); |
|
| 406 | - $result=$localobject->delete($user); |
|
| 407 | - |
|
| 408 | - print __METHOD__." id=".$id." result=".$result."\n"; |
|
| 409 | - $this->assertGreaterThan(0, $result); |
|
| 410 | - return $result; |
|
| 411 | - } |
|
| 302 | + print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
| 303 | + |
|
| 304 | + $this->assertGreaterThan(0, $result); |
|
| 305 | + return $localobject; |
|
| 306 | + } |
|
| 307 | + |
|
| 308 | + /** |
|
| 309 | + * testTicketassignUserOther |
|
| 310 | + * |
|
| 311 | + * @param Ticket $localobject Ticket |
|
| 312 | + * @return int |
|
| 313 | + * |
|
| 314 | + * @depends testTicketFetch |
|
| 315 | + * The depends says test is run only if previous is ok |
|
| 316 | + */ |
|
| 317 | + public function testTicketassignUserOther($localobject) |
|
| 318 | + { |
|
| 319 | + global $conf,$user,$langs,$db; |
|
| 320 | + $conf=$this->savconf; |
|
| 321 | + $user=$this->savuser; |
|
| 322 | + $langs=$this->savlangs; |
|
| 323 | + $db=$this->savdb; |
|
| 324 | + |
|
| 325 | + $user_id_to_assign = 2; |
|
| 326 | + |
|
| 327 | + $result=$localobject->assignUser($user, $user_id_to_assign); |
|
| 328 | + ; |
|
| 329 | + print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
| 330 | + |
|
| 331 | + $this->assertGreaterThan(0, $result); |
|
| 332 | + return $localobject; |
|
| 333 | + } |
|
| 334 | + |
|
| 335 | + /** |
|
| 336 | + * testTicketcreateTicketLog |
|
| 337 | + * |
|
| 338 | + * @param Ticket $localobject Ticket |
|
| 339 | + * @return int |
|
| 340 | + * |
|
| 341 | + * @depends testTicketFetch |
|
| 342 | + * The depends says test is run only if previous is ok |
|
| 343 | + */ |
|
| 344 | + public function testTicketcreateTicketLog($localobject) |
|
| 345 | + { |
|
| 346 | + global $conf,$user,$langs,$db; |
|
| 347 | + $conf=$this->savconf; |
|
| 348 | + $user=$this->savuser; |
|
| 349 | + $langs=$this->savlangs; |
|
| 350 | + $db=$this->savdb; |
|
| 351 | + |
|
| 352 | + |
|
| 353 | + $message = 'Test ticket log'; |
|
| 354 | + $noemail = 1; |
|
| 355 | + $result=$localobject->createTicketLog($user, $message, $noemail); |
|
| 356 | + print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
| 357 | + |
|
| 358 | + $this->assertGreaterThan(0, $result); |
|
| 359 | + return $localobject; |
|
| 360 | + } |
|
| 361 | + |
|
| 362 | + /** |
|
| 363 | + * testTicketclose |
|
| 364 | + * |
|
| 365 | + * @param Ticket $localobject Ticket |
|
| 366 | + * @return int |
|
| 367 | + * |
|
| 368 | + * @depends testTicketFetch |
|
| 369 | + * The depends says test is run only if previous is ok |
|
| 370 | + */ |
|
| 371 | + public function testTicketclose($localobject) |
|
| 372 | + { |
|
| 373 | + global $conf,$user,$langs,$db; |
|
| 374 | + $conf=$this->savconf; |
|
| 375 | + $user=$this->savuser; |
|
| 376 | + $langs=$this->savlangs; |
|
| 377 | + $db=$this->savdb; |
|
| 378 | + |
|
| 379 | + $result=$localobject->close(); |
|
| 380 | + print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
| 381 | + |
|
| 382 | + $this->assertGreaterThan(0, $result); |
|
| 383 | + return $localobject->id; |
|
| 384 | + } |
|
| 385 | + |
|
| 386 | + |
|
| 387 | + /** |
|
| 388 | + * testTicketDelete |
|
| 389 | + * |
|
| 390 | + * @param int $id Id of ticket |
|
| 391 | + * @return int |
|
| 392 | + * |
|
| 393 | + * @depends testTicketclose |
|
| 394 | + * The depends says test is run only if previous is ok |
|
| 395 | + */ |
|
| 396 | + public function testTicketDelete($id) |
|
| 397 | + { |
|
| 398 | + global $conf,$user,$langs,$db; |
|
| 399 | + $conf=$this->savconf; |
|
| 400 | + $user=$this->savuser; |
|
| 401 | + $langs=$this->savlangs; |
|
| 402 | + $db=$this->savdb; |
|
| 403 | + |
|
| 404 | + $localobject=new Ticket($this->savdb); |
|
| 405 | + $result=$localobject->fetch($id); |
|
| 406 | + $result=$localobject->delete($user); |
|
| 407 | + |
|
| 408 | + print __METHOD__." id=".$id." result=".$result."\n"; |
|
| 409 | + $this->assertGreaterThan(0, $result); |
|
| 410 | + return $result; |
|
| 411 | + } |
|
| 412 | 412 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * \remarks To run this script as CLI: phpunit filename.php |
| 24 | 24 | */ |
| 25 | 25 | |
| 26 | -global $conf,$user,$langs,$db; |
|
| 26 | +global $conf, $user, $langs, $db; |
|
| 27 | 27 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
| 28 | 28 | //require_once 'PHPUnit/Autoload.php'; |
| 29 | 29 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | $user->fetch(1); |
| 36 | 36 | $user->getrights(); |
| 37 | 37 | } |
| 38 | -$conf->global->MAIN_DISABLE_ALL_MAILS=1; |
|
| 38 | +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
|
| 39 | 39 | |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -63,11 +63,11 @@ discard block |
||
| 63 | 63 | parent::__construct(); |
| 64 | 64 | |
| 65 | 65 | //$this->sharedFixture |
| 66 | - global $conf,$user,$langs,$db; |
|
| 67 | - $this->savconf=$conf; |
|
| 68 | - $this->savuser=$user; |
|
| 69 | - $this->savlangs=$langs; |
|
| 70 | - $this->savdb=$db; |
|
| 66 | + global $conf, $user, $langs, $db; |
|
| 67 | + $this->savconf = $conf; |
|
| 68 | + $this->savuser = $user; |
|
| 69 | + $this->savlangs = $langs; |
|
| 70 | + $this->savdb = $db; |
|
| 71 | 71 | |
| 72 | 72 | print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
| 73 | 73 | //print " - db ".$db->db; |
@@ -77,8 +77,8 @@ discard block |
||
| 77 | 77 | // Static methods |
| 78 | 78 | public static function setUpBeforeClass() |
| 79 | 79 | { |
| 80 | - global $conf,$user,$langs,$db; |
|
| 81 | - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
| 80 | + global $conf, $user, $langs, $db; |
|
| 81 | + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
| 82 | 82 | |
| 83 | 83 | print __METHOD__."\n"; |
| 84 | 84 | } |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | // tear down after class |
| 87 | 87 | public static function tearDownAfterClass() |
| 88 | 88 | { |
| 89 | - global $conf,$user,$langs,$db; |
|
| 89 | + global $conf, $user, $langs, $db; |
|
| 90 | 90 | $db->rollback(); |
| 91 | 91 | |
| 92 | 92 | print __METHOD__."\n"; |
@@ -99,11 +99,11 @@ discard block |
||
| 99 | 99 | */ |
| 100 | 100 | protected function setUp() |
| 101 | 101 | { |
| 102 | - global $conf,$user,$langs,$db; |
|
| 103 | - $conf=$this->savconf; |
|
| 104 | - $user=$this->savuser; |
|
| 105 | - $langs=$this->savlangs; |
|
| 106 | - $db=$this->savdb; |
|
| 102 | + global $conf, $user, $langs, $db; |
|
| 103 | + $conf = $this->savconf; |
|
| 104 | + $user = $this->savuser; |
|
| 105 | + $langs = $this->savlangs; |
|
| 106 | + $db = $this->savdb; |
|
| 107 | 107 | |
| 108 | 108 | print __METHOD__."\n"; |
| 109 | 109 | } |
@@ -124,25 +124,25 @@ discard block |
||
| 124 | 124 | */ |
| 125 | 125 | public function testTicketCreate() |
| 126 | 126 | { |
| 127 | - global $conf,$user,$langs,$db; |
|
| 128 | - $conf=$this->savconf; |
|
| 129 | - $user=$this->savuser; |
|
| 130 | - $langs=$this->savlangs; |
|
| 131 | - $db=$this->savdb; |
|
| 127 | + global $conf, $user, $langs, $db; |
|
| 128 | + $conf = $this->savconf; |
|
| 129 | + $user = $this->savuser; |
|
| 130 | + $langs = $this->savlangs; |
|
| 131 | + $db = $this->savdb; |
|
| 132 | 132 | |
| 133 | 133 | // Try to create one with bad values |
| 134 | - $localobject=new Ticket($this->savdb); |
|
| 134 | + $localobject = new Ticket($this->savdb); |
|
| 135 | 135 | $localobject->initAsSpecimen(); |
| 136 | 136 | $localobject->ref = ''; |
| 137 | - $result=$localobject->create($user); |
|
| 137 | + $result = $localobject->create($user); |
|
| 138 | 138 | |
| 139 | 139 | print __METHOD__." result=".$result."\n"; |
| 140 | 140 | $this->assertEquals(-3, $result, $localobject->error.join(',', $localobject->errors)); |
| 141 | 141 | |
| 142 | 142 | // Try to create one with correct values |
| 143 | - $localobject=new Ticket($this->savdb); |
|
| 143 | + $localobject = new Ticket($this->savdb); |
|
| 144 | 144 | $localobject->initAsSpecimen(); |
| 145 | - $result=$localobject->create($user); |
|
| 145 | + $result = $localobject->create($user); |
|
| 146 | 146 | |
| 147 | 147 | print __METHOD__." result=".$result."\n"; |
| 148 | 148 | $this->assertGreaterThan(0, $result, $localobject->error.join(',', $localobject->errors)); |
@@ -161,14 +161,14 @@ discard block |
||
| 161 | 161 | */ |
| 162 | 162 | public function testTicketFetch($id) |
| 163 | 163 | { |
| 164 | - global $conf,$user,$langs,$db; |
|
| 165 | - $conf=$this->savconf; |
|
| 166 | - $user=$this->savuser; |
|
| 167 | - $langs=$this->savlangs; |
|
| 168 | - $db=$this->savdb; |
|
| 164 | + global $conf, $user, $langs, $db; |
|
| 165 | + $conf = $this->savconf; |
|
| 166 | + $user = $this->savuser; |
|
| 167 | + $langs = $this->savlangs; |
|
| 168 | + $db = $this->savdb; |
|
| 169 | 169 | |
| 170 | - $localobject=new Ticket($this->savdb); |
|
| 171 | - $result=$localobject->fetch($id); |
|
| 170 | + $localobject = new Ticket($this->savdb); |
|
| 171 | + $result = $localobject->fetch($id); |
|
| 172 | 172 | |
| 173 | 173 | print __METHOD__." id=".$id." result=".$result."\n"; |
| 174 | 174 | $this->assertGreaterThan(0, $result); |
@@ -187,13 +187,13 @@ discard block |
||
| 187 | 187 | */ |
| 188 | 188 | public function testTicketmarkAsRead($localobject) |
| 189 | 189 | { |
| 190 | - global $conf,$user,$langs,$db; |
|
| 191 | - $conf=$this->savconf; |
|
| 192 | - $user=$this->savuser; |
|
| 193 | - $langs=$this->savlangs; |
|
| 194 | - $db=$this->savdb; |
|
| 190 | + global $conf, $user, $langs, $db; |
|
| 191 | + $conf = $this->savconf; |
|
| 192 | + $user = $this->savuser; |
|
| 193 | + $langs = $this->savlangs; |
|
| 194 | + $db = $this->savdb; |
|
| 195 | 195 | |
| 196 | - $result=$localobject->markAsRead($user); |
|
| 196 | + $result = $localobject->markAsRead($user); |
|
| 197 | 197 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
| 198 | 198 | |
| 199 | 199 | $this->assertGreaterThan(0, $result); |
@@ -211,15 +211,15 @@ discard block |
||
| 211 | 211 | */ |
| 212 | 212 | public function testTicketsetProject($localobject) |
| 213 | 213 | { |
| 214 | - global $conf,$user,$langs,$db; |
|
| 215 | - $conf=$this->savconf; |
|
| 216 | - $user=$this->savuser; |
|
| 217 | - $langs=$this->savlangs; |
|
| 218 | - $db=$this->savdb; |
|
| 214 | + global $conf, $user, $langs, $db; |
|
| 215 | + $conf = $this->savconf; |
|
| 216 | + $user = $this->savuser; |
|
| 217 | + $langs = $this->savlangs; |
|
| 218 | + $db = $this->savdb; |
|
| 219 | 219 | |
| 220 | 220 | $project_id = 1; |
| 221 | 221 | |
| 222 | - $result=$localobject->setProject($project_id); |
|
| 222 | + $result = $localobject->setProject($project_id); |
|
| 223 | 223 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
| 224 | 224 | |
| 225 | 225 | $this->assertGreaterThan(0, $result); |
@@ -237,15 +237,15 @@ discard block |
||
| 237 | 237 | */ |
| 238 | 238 | public function testTicketsetContract($localobject) |
| 239 | 239 | { |
| 240 | - global $conf,$user,$langs,$db; |
|
| 241 | - $conf=$this->savconf; |
|
| 242 | - $user=$this->savuser; |
|
| 243 | - $langs=$this->savlangs; |
|
| 244 | - $db=$this->savdb; |
|
| 240 | + global $conf, $user, $langs, $db; |
|
| 241 | + $conf = $this->savconf; |
|
| 242 | + $user = $this->savuser; |
|
| 243 | + $langs = $this->savlangs; |
|
| 244 | + $db = $this->savdb; |
|
| 245 | 245 | |
| 246 | 246 | $contract_id = 1; |
| 247 | 247 | |
| 248 | - $result=$localobject->setContract($contract_id); |
|
| 248 | + $result = $localobject->setContract($contract_id); |
|
| 249 | 249 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
| 250 | 250 | |
| 251 | 251 | $this->assertGreaterThan(0, $result); |
@@ -263,15 +263,15 @@ discard block |
||
| 263 | 263 | */ |
| 264 | 264 | public function testTicketsetProgression($localobject) |
| 265 | 265 | { |
| 266 | - global $conf,$user,$langs,$db; |
|
| 267 | - $conf=$this->savconf; |
|
| 268 | - $user=$this->savuser; |
|
| 269 | - $langs=$this->savlangs; |
|
| 270 | - $db=$this->savdb; |
|
| 266 | + global $conf, $user, $langs, $db; |
|
| 267 | + $conf = $this->savconf; |
|
| 268 | + $user = $this->savuser; |
|
| 269 | + $langs = $this->savlangs; |
|
| 270 | + $db = $this->savdb; |
|
| 271 | 271 | |
| 272 | 272 | $percent = 80; |
| 273 | 273 | |
| 274 | - $result=$localobject->setProgression($percent); |
|
| 274 | + $result = $localobject->setProgression($percent); |
|
| 275 | 275 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
| 276 | 276 | |
| 277 | 277 | $this->assertGreaterThan(0, $result); |
@@ -289,15 +289,15 @@ discard block |
||
| 289 | 289 | */ |
| 290 | 290 | public function testTicketassignUser($localobject) |
| 291 | 291 | { |
| 292 | - global $conf,$user,$langs,$db; |
|
| 293 | - $conf=$this->savconf; |
|
| 294 | - $user=$this->savuser; |
|
| 295 | - $langs=$this->savlangs; |
|
| 296 | - $db=$this->savdb; |
|
| 292 | + global $conf, $user, $langs, $db; |
|
| 293 | + $conf = $this->savconf; |
|
| 294 | + $user = $this->savuser; |
|
| 295 | + $langs = $this->savlangs; |
|
| 296 | + $db = $this->savdb; |
|
| 297 | 297 | |
| 298 | 298 | $user_id_to_assign = 1; |
| 299 | 299 | |
| 300 | - $result=$localobject->assignUser($user, $user_id_to_assign); |
|
| 300 | + $result = $localobject->assignUser($user, $user_id_to_assign); |
|
| 301 | 301 | ; |
| 302 | 302 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
| 303 | 303 | |
@@ -316,15 +316,15 @@ discard block |
||
| 316 | 316 | */ |
| 317 | 317 | public function testTicketassignUserOther($localobject) |
| 318 | 318 | { |
| 319 | - global $conf,$user,$langs,$db; |
|
| 320 | - $conf=$this->savconf; |
|
| 321 | - $user=$this->savuser; |
|
| 322 | - $langs=$this->savlangs; |
|
| 323 | - $db=$this->savdb; |
|
| 319 | + global $conf, $user, $langs, $db; |
|
| 320 | + $conf = $this->savconf; |
|
| 321 | + $user = $this->savuser; |
|
| 322 | + $langs = $this->savlangs; |
|
| 323 | + $db = $this->savdb; |
|
| 324 | 324 | |
| 325 | 325 | $user_id_to_assign = 2; |
| 326 | 326 | |
| 327 | - $result=$localobject->assignUser($user, $user_id_to_assign); |
|
| 327 | + $result = $localobject->assignUser($user, $user_id_to_assign); |
|
| 328 | 328 | ; |
| 329 | 329 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
| 330 | 330 | |
@@ -343,16 +343,16 @@ discard block |
||
| 343 | 343 | */ |
| 344 | 344 | public function testTicketcreateTicketLog($localobject) |
| 345 | 345 | { |
| 346 | - global $conf,$user,$langs,$db; |
|
| 347 | - $conf=$this->savconf; |
|
| 348 | - $user=$this->savuser; |
|
| 349 | - $langs=$this->savlangs; |
|
| 350 | - $db=$this->savdb; |
|
| 346 | + global $conf, $user, $langs, $db; |
|
| 347 | + $conf = $this->savconf; |
|
| 348 | + $user = $this->savuser; |
|
| 349 | + $langs = $this->savlangs; |
|
| 350 | + $db = $this->savdb; |
|
| 351 | 351 | |
| 352 | 352 | |
| 353 | 353 | $message = 'Test ticket log'; |
| 354 | 354 | $noemail = 1; |
| 355 | - $result=$localobject->createTicketLog($user, $message, $noemail); |
|
| 355 | + $result = $localobject->createTicketLog($user, $message, $noemail); |
|
| 356 | 356 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
| 357 | 357 | |
| 358 | 358 | $this->assertGreaterThan(0, $result); |
@@ -370,13 +370,13 @@ discard block |
||
| 370 | 370 | */ |
| 371 | 371 | public function testTicketclose($localobject) |
| 372 | 372 | { |
| 373 | - global $conf,$user,$langs,$db; |
|
| 374 | - $conf=$this->savconf; |
|
| 375 | - $user=$this->savuser; |
|
| 376 | - $langs=$this->savlangs; |
|
| 377 | - $db=$this->savdb; |
|
| 373 | + global $conf, $user, $langs, $db; |
|
| 374 | + $conf = $this->savconf; |
|
| 375 | + $user = $this->savuser; |
|
| 376 | + $langs = $this->savlangs; |
|
| 377 | + $db = $this->savdb; |
|
| 378 | 378 | |
| 379 | - $result=$localobject->close(); |
|
| 379 | + $result = $localobject->close(); |
|
| 380 | 380 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
| 381 | 381 | |
| 382 | 382 | $this->assertGreaterThan(0, $result); |
@@ -395,15 +395,15 @@ discard block |
||
| 395 | 395 | */ |
| 396 | 396 | public function testTicketDelete($id) |
| 397 | 397 | { |
| 398 | - global $conf,$user,$langs,$db; |
|
| 399 | - $conf=$this->savconf; |
|
| 400 | - $user=$this->savuser; |
|
| 401 | - $langs=$this->savlangs; |
|
| 402 | - $db=$this->savdb; |
|
| 403 | - |
|
| 404 | - $localobject=new Ticket($this->savdb); |
|
| 405 | - $result=$localobject->fetch($id); |
|
| 406 | - $result=$localobject->delete($user); |
|
| 398 | + global $conf, $user, $langs, $db; |
|
| 399 | + $conf = $this->savconf; |
|
| 400 | + $user = $this->savuser; |
|
| 401 | + $langs = $this->savlangs; |
|
| 402 | + $db = $this->savdb; |
|
| 403 | + |
|
| 404 | + $localobject = new Ticket($this->savdb); |
|
| 405 | + $result = $localobject->fetch($id); |
|
| 406 | + $result = $localobject->delete($user); |
|
| 407 | 407 | |
| 408 | 408 | print __METHOD__." id=".$id." result=".$result."\n"; |
| 409 | 409 | $this->assertGreaterThan(0, $result); |
@@ -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 CompanyBankAccountTest 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 CompanyBankAccountTest |
|
| 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 CompanyBankAccountTest |
|
| 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; |
|
| 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 testCompanyBankAccountCreate() |
| 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 CompanyBankAccount($this->savdb); |
|
| 135 | - $localobject->initAsSpecimen(); |
|
| 136 | - $result=$localobject->create($user); |
|
| 137 | - |
|
| 138 | - print __METHOD__." result=".$result." id=".$localobject->id."\n"; |
|
| 139 | - $this->assertLessThan($result, 0); |
|
| 140 | - return $localobject->id; |
|
| 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 CompanyBankAccount($this->savdb); |
|
| 135 | + $localobject->initAsSpecimen(); |
|
| 136 | + $result=$localobject->create($user); |
|
| 137 | + |
|
| 138 | + print __METHOD__." result=".$result." id=".$localobject->id."\n"; |
|
| 139 | + $this->assertLessThan($result, 0); |
|
| 140 | + return $localobject->id; |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /** |
@@ -151,17 +151,17 @@ discard block |
||
| 151 | 151 | */ |
| 152 | 152 | public function testCompanyBankAccountFetch($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 CompanyBankAccount($this->savdb); |
|
| 161 | - $result=$localobject->fetch($id); |
|
| 162 | - print __METHOD__." id=".$id." result=".$result."\n"; |
|
| 163 | - $this->assertLessThan($result, 0); |
|
| 164 | - 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 CompanyBankAccount($this->savdb); |
|
| 161 | + $result=$localobject->fetch($id); |
|
| 162 | + print __METHOD__." id=".$id." result=".$result."\n"; |
|
| 163 | + $this->assertLessThan($result, 0); |
|
| 164 | + return $localobject; |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | /** |
@@ -197,18 +197,18 @@ discard block |
||
| 197 | 197 | */ |
| 198 | 198 | public function testCompanyBankAccountUpdate($localobject) |
| 199 | 199 | { |
| 200 | - global $conf,$user,$langs,$db; |
|
| 201 | - $conf=$this->savconf; |
|
| 202 | - $user=$this->savuser; |
|
| 203 | - $langs=$this->savlangs; |
|
| 204 | - $db=$this->savdb; |
|
| 205 | - |
|
| 206 | - $localobject->owner='New owner'; |
|
| 207 | - $result=$localobject->update($user); |
|
| 208 | - |
|
| 209 | - print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
| 210 | - $this->assertLessThan($result, 0); |
|
| 211 | - return $localobject; |
|
| 200 | + global $conf,$user,$langs,$db; |
|
| 201 | + $conf=$this->savconf; |
|
| 202 | + $user=$this->savuser; |
|
| 203 | + $langs=$this->savlangs; |
|
| 204 | + $db=$this->savdb; |
|
| 205 | + |
|
| 206 | + $localobject->owner='New owner'; |
|
| 207 | + $result=$localobject->update($user); |
|
| 208 | + |
|
| 209 | + print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
| 210 | + $this->assertLessThan($result, 0); |
|
| 211 | + return $localobject; |
|
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | /** |
@@ -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 testCompanyBankAccountCreate() |
| 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 CompanyBankAccount($this->savdb); |
|
| 134 | + $localobject = new CompanyBankAccount($this->savdb); |
|
| 135 | 135 | $localobject->initAsSpecimen(); |
| 136 | - $result=$localobject->create($user); |
|
| 136 | + $result = $localobject->create($user); |
|
| 137 | 137 | |
| 138 | 138 | print __METHOD__." result=".$result." id=".$localobject->id."\n"; |
| 139 | 139 | $this->assertLessThan($result, 0); |
@@ -151,14 +151,14 @@ discard block |
||
| 151 | 151 | */ |
| 152 | 152 | public function testCompanyBankAccountFetch($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 CompanyBankAccount($this->savdb); |
|
| 161 | - $result=$localobject->fetch($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 CompanyBankAccount($this->savdb); |
|
| 161 | + $result = $localobject->fetch($id); |
|
| 162 | 162 | print __METHOD__." id=".$id." result=".$result."\n"; |
| 163 | 163 | $this->assertLessThan($result, 0); |
| 164 | 164 | return $localobject; |
@@ -174,13 +174,13 @@ discard block |
||
| 174 | 174 | */ |
| 175 | 175 | public function testCompanyBankAccountSetAsDefault($localobject) |
| 176 | 176 | { |
| 177 | - global $conf,$user,$langs,$db; |
|
| 178 | - $conf=$this->savconf; |
|
| 179 | - $user=$this->savuser; |
|
| 180 | - $langs=$this->savlangs; |
|
| 181 | - $db=$this->savdb; |
|
| 177 | + global $conf, $user, $langs, $db; |
|
| 178 | + $conf = $this->savconf; |
|
| 179 | + $user = $this->savuser; |
|
| 180 | + $langs = $this->savlangs; |
|
| 181 | + $db = $this->savdb; |
|
| 182 | 182 | |
| 183 | - $result=$localobject->setAsDefault($localobject->id); |
|
| 183 | + $result = $localobject->setAsDefault($localobject->id); |
|
| 184 | 184 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
| 185 | 185 | $this->assertLessThan($result, 0); |
| 186 | 186 | return $localobject; |
@@ -197,14 +197,14 @@ discard block |
||
| 197 | 197 | */ |
| 198 | 198 | public function testCompanyBankAccountUpdate($localobject) |
| 199 | 199 | { |
| 200 | - global $conf,$user,$langs,$db; |
|
| 201 | - $conf=$this->savconf; |
|
| 202 | - $user=$this->savuser; |
|
| 203 | - $langs=$this->savlangs; |
|
| 204 | - $db=$this->savdb; |
|
| 200 | + global $conf, $user, $langs, $db; |
|
| 201 | + $conf = $this->savconf; |
|
| 202 | + $user = $this->savuser; |
|
| 203 | + $langs = $this->savlangs; |
|
| 204 | + $db = $this->savdb; |
|
| 205 | 205 | |
| 206 | - $localobject->owner='New owner'; |
|
| 207 | - $result=$localobject->update($user); |
|
| 206 | + $localobject->owner = 'New owner'; |
|
| 207 | + $result = $localobject->update($user); |
|
| 208 | 208 | |
| 209 | 209 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
| 210 | 210 | $this->assertLessThan($result, 0); |
@@ -222,14 +222,14 @@ discard block |
||
| 222 | 222 | */ |
| 223 | 223 | public function testCompanyBankAccountOther($localobject) |
| 224 | 224 | { |
| 225 | - global $conf,$user,$langs,$db; |
|
| 226 | - $conf=$this->savconf; |
|
| 227 | - $user=$this->savuser; |
|
| 228 | - $langs=$this->savlangs; |
|
| 229 | - $db=$this->savdb; |
|
| 230 | - |
|
| 231 | - $localobject->owner='New owner'; |
|
| 232 | - $result=$localobject->update($user); |
|
| 225 | + global $conf, $user, $langs, $db; |
|
| 226 | + $conf = $this->savconf; |
|
| 227 | + $user = $this->savuser; |
|
| 228 | + $langs = $this->savlangs; |
|
| 229 | + $db = $this->savdb; |
|
| 230 | + |
|
| 231 | + $localobject->owner = 'New owner'; |
|
| 232 | + $result = $localobject->update($user); |
|
| 233 | 233 | |
| 234 | 234 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
| 235 | 235 | $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,74 +47,74 @@ discard block |
||
| 47 | 47 | */ |
| 48 | 48 | class MarginsLibTest 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 DateLibTest |
|
| 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 DateLibTest |
|
| 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(); |
|
| 64 | + |
|
| 65 | + //$this->sharedFixture |
|
| 66 | + global $conf,$user,$langs,$db; |
|
| 67 | + $this->savconf=$conf; |
|
| 68 | + $this->savuser=$user; |
|
| 69 | + $this->savlangs=$langs; |
|
| 70 | + $this->savdb=$db; |
|
| 71 | + |
|
| 72 | + print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
|
| 73 | + //print " - db ".$db->db; |
|
| 74 | + print "\n"; |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + // Static methods |
|
| 78 | + public static function setUpBeforeClass() |
|
| 79 | + { |
|
| 80 | + global $conf,$user,$langs,$db; |
|
| 81 | + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
| 82 | 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; |
|
| 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,29 +124,29 @@ discard block |
||
| 124 | 124 | */ |
| 125 | 125 | public function testGetMarginInfos() |
| 126 | 126 | { |
| 127 | - global $conf,$user,$langs,$db; |
|
| 128 | - $conf=$this->savconf; |
|
| 129 | - $user=$this->savuser; |
|
| 130 | - $langs=$this->savlangs; |
|
| 131 | - $db=$this->savdb; |
|
| 132 | - |
|
| 133 | - $result=getMarginInfos(10, 0, 19.6, 0, 0, 0, 8); |
|
| 134 | - //var_dump($result); |
|
| 135 | - print __METHOD__." result[0]=".$result[0]."\n"; |
|
| 136 | - $this->assertEquals(8,$result[0]); |
|
| 137 | - print __METHOD__." result[1]=".$result[1]."\n"; |
|
| 138 | - $this->assertEquals(25,$result[1]); |
|
| 139 | - print __METHOD__." result[2]=".$result[2]."\n"; |
|
| 140 | - $this->assertEquals(20,$result[2]); |
|
| 141 | - |
|
| 142 | - $result=getMarginInfos(10, 10, 19.6, 0, 0, 0, 8); |
|
| 143 | - print __METHOD__." result[0]=".$result[0]."\n"; |
|
| 144 | - $this->assertEquals(8,$result[0]); |
|
| 145 | - print __METHOD__." result[1]=".$result[1]."\n"; |
|
| 146 | - $this->assertEquals(12.5,$result[1]); |
|
| 147 | - print __METHOD__." result[2]=".$result[2]."\n"; |
|
| 148 | - $this->assertEquals(1/9*100,$result[2]); |
|
| 149 | - |
|
| 150 | - return 0; |
|
| 127 | + global $conf,$user,$langs,$db; |
|
| 128 | + $conf=$this->savconf; |
|
| 129 | + $user=$this->savuser; |
|
| 130 | + $langs=$this->savlangs; |
|
| 131 | + $db=$this->savdb; |
|
| 132 | + |
|
| 133 | + $result=getMarginInfos(10, 0, 19.6, 0, 0, 0, 8); |
|
| 134 | + //var_dump($result); |
|
| 135 | + print __METHOD__." result[0]=".$result[0]."\n"; |
|
| 136 | + $this->assertEquals(8,$result[0]); |
|
| 137 | + print __METHOD__." result[1]=".$result[1]."\n"; |
|
| 138 | + $this->assertEquals(25,$result[1]); |
|
| 139 | + print __METHOD__." result[2]=".$result[2]."\n"; |
|
| 140 | + $this->assertEquals(20,$result[2]); |
|
| 141 | + |
|
| 142 | + $result=getMarginInfos(10, 10, 19.6, 0, 0, 0, 8); |
|
| 143 | + print __METHOD__." result[0]=".$result[0]."\n"; |
|
| 144 | + $this->assertEquals(8,$result[0]); |
|
| 145 | + print __METHOD__." result[1]=".$result[1]."\n"; |
|
| 146 | + $this->assertEquals(12.5,$result[1]); |
|
| 147 | + print __METHOD__." result[2]=".$result[2]."\n"; |
|
| 148 | + $this->assertEquals(1/9*100,$result[2]); |
|
| 149 | + |
|
| 150 | + return 0; |
|
| 151 | 151 | } |
| 152 | 152 | } |
@@ -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,28 +124,28 @@ discard block |
||
| 124 | 124 | */ |
| 125 | 125 | public function testGetMarginInfos() |
| 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 | - $result=getMarginInfos(10, 0, 19.6, 0, 0, 0, 8); |
|
| 133 | + $result = getMarginInfos(10, 0, 19.6, 0, 0, 0, 8); |
|
| 134 | 134 | //var_dump($result); |
| 135 | 135 | print __METHOD__." result[0]=".$result[0]."\n"; |
| 136 | - $this->assertEquals(8,$result[0]); |
|
| 136 | + $this->assertEquals(8, $result[0]); |
|
| 137 | 137 | print __METHOD__." result[1]=".$result[1]."\n"; |
| 138 | - $this->assertEquals(25,$result[1]); |
|
| 138 | + $this->assertEquals(25, $result[1]); |
|
| 139 | 139 | print __METHOD__." result[2]=".$result[2]."\n"; |
| 140 | - $this->assertEquals(20,$result[2]); |
|
| 140 | + $this->assertEquals(20, $result[2]); |
|
| 141 | 141 | |
| 142 | - $result=getMarginInfos(10, 10, 19.6, 0, 0, 0, 8); |
|
| 142 | + $result = getMarginInfos(10, 10, 19.6, 0, 0, 0, 8); |
|
| 143 | 143 | print __METHOD__." result[0]=".$result[0]."\n"; |
| 144 | - $this->assertEquals(8,$result[0]); |
|
| 144 | + $this->assertEquals(8, $result[0]); |
|
| 145 | 145 | print __METHOD__." result[1]=".$result[1]."\n"; |
| 146 | - $this->assertEquals(12.5,$result[1]); |
|
| 146 | + $this->assertEquals(12.5, $result[1]); |
|
| 147 | 147 | print __METHOD__." result[2]=".$result[2]."\n"; |
| 148 | - $this->assertEquals(1/9*100,$result[2]); |
|
| 148 | + $this->assertEquals(1 / 9 * 100, $result[2]); |
|
| 149 | 149 | |
| 150 | 150 | return 0; |
| 151 | 151 | } |