@@ -32,9 +32,9 @@ discard block |
||
32 | 32 | |
33 | 33 | if (empty($user->id)) |
34 | 34 | { |
35 | - print "Load permissions for admin user nb 1\n"; |
|
36 | - $user->fetch(1); |
|
37 | - $user->getrights(); |
|
35 | + print "Load permissions for admin user nb 1\n"; |
|
36 | + $user->fetch(1); |
|
37 | + $user->getrights(); |
|
38 | 38 | } |
39 | 39 | $conf->global->MAIN_DISABLE_ALL_MAILS=1; |
40 | 40 | |
@@ -48,75 +48,75 @@ discard block |
||
48 | 48 | */ |
49 | 49 | class FactureRecTest extends PHPUnit_Framework_TestCase |
50 | 50 | { |
51 | - protected $savconf; |
|
52 | - protected $savuser; |
|
53 | - protected $savlangs; |
|
54 | - protected $savdb; |
|
55 | - |
|
56 | - /** |
|
57 | - * Constructor |
|
58 | - * We save global variables into local variables |
|
59 | - * |
|
60 | - * @return FactureTest |
|
61 | - */ |
|
62 | - function __construct() |
|
63 | - { |
|
64 | - parent::__construct(); |
|
65 | - |
|
66 | - //$this->sharedFixture |
|
67 | - global $conf,$user,$langs,$db; |
|
68 | - $this->savconf=$conf; |
|
69 | - $this->savuser=$user; |
|
70 | - $this->savlangs=$langs; |
|
71 | - $this->savdb=$db; |
|
72 | - |
|
73 | - print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
|
74 | - //print " - db ".$db->db; |
|
75 | - print "\n"; |
|
76 | - } |
|
77 | - |
|
78 | - // Static methods |
|
79 | - public static function setUpBeforeClass() |
|
51 | + protected $savconf; |
|
52 | + protected $savuser; |
|
53 | + protected $savlangs; |
|
54 | + protected $savdb; |
|
55 | + |
|
56 | + /** |
|
57 | + * Constructor |
|
58 | + * We save global variables into local variables |
|
59 | + * |
|
60 | + * @return FactureTest |
|
61 | + */ |
|
62 | + function __construct() |
|
80 | 63 | { |
81 | - global $conf,$user,$langs,$db; |
|
82 | - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
64 | + parent::__construct(); |
|
65 | + |
|
66 | + //$this->sharedFixture |
|
67 | + global $conf,$user,$langs,$db; |
|
68 | + $this->savconf=$conf; |
|
69 | + $this->savuser=$user; |
|
70 | + $this->savlangs=$langs; |
|
71 | + $this->savdb=$db; |
|
72 | + |
|
73 | + print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
|
74 | + //print " - db ".$db->db; |
|
75 | + print "\n"; |
|
76 | + } |
|
77 | + |
|
78 | + // Static methods |
|
79 | + public static function setUpBeforeClass() |
|
80 | + { |
|
81 | + global $conf,$user,$langs,$db; |
|
82 | + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
83 | 83 | |
84 | - print __METHOD__."\n"; |
|
84 | + print __METHOD__."\n"; |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | // tear down after class |
88 | 88 | public static function tearDownAfterClass() |
89 | 89 | { |
90 | - global $conf,$user,$langs,$db; |
|
91 | - $db->rollback(); |
|
90 | + global $conf,$user,$langs,$db; |
|
91 | + $db->rollback(); |
|
92 | 92 | |
93 | - print __METHOD__."\n"; |
|
93 | + print __METHOD__."\n"; |
|
94 | 94 | } |
95 | 95 | |
96 | - /** |
|
97 | - * Init phpunit tests |
|
98 | - * |
|
99 | - * @return void |
|
100 | - */ |
|
96 | + /** |
|
97 | + * Init phpunit tests |
|
98 | + * |
|
99 | + * @return void |
|
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 | - print __METHOD__."\n"; |
|
109 | + print __METHOD__."\n"; |
|
110 | 110 | } |
111 | 111 | |
112 | - /** |
|
113 | - * End phpunit tests |
|
114 | - * |
|
115 | - * @return void |
|
116 | - */ |
|
117 | - protected function tearDown() |
|
112 | + /** |
|
113 | + * End phpunit tests |
|
114 | + * |
|
115 | + * @return void |
|
116 | + */ |
|
117 | + protected function tearDown() |
|
118 | 118 | { |
119 | - print __METHOD__."\n"; |
|
119 | + print __METHOD__."\n"; |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -126,23 +126,23 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public function testFactureRecCreate() |
128 | 128 | { |
129 | - global $conf,$user,$langs,$db; |
|
130 | - $conf=$this->savconf; |
|
131 | - $user=$this->savuser; |
|
132 | - $langs=$this->savlangs; |
|
133 | - $db=$this->savdb; |
|
134 | - |
|
135 | - $localobjectinv=new Facture($this->savdb); |
|
136 | - $localobjectinv->initAsSpecimen(); |
|
137 | - $localobjectinv->create($user); |
|
138 | - |
|
139 | - $localobject=new FactureRec($this->savdb); |
|
140 | - $localobject->initAsSpecimen(); |
|
141 | - $result=$localobject->create($user, $localobjectinv->id); |
|
142 | - |
|
143 | - $this->assertLessThan($result, 0); |
|
144 | - print __METHOD__." result=".$result."\n"; |
|
145 | - return $result; |
|
129 | + global $conf,$user,$langs,$db; |
|
130 | + $conf=$this->savconf; |
|
131 | + $user=$this->savuser; |
|
132 | + $langs=$this->savlangs; |
|
133 | + $db=$this->savdb; |
|
134 | + |
|
135 | + $localobjectinv=new Facture($this->savdb); |
|
136 | + $localobjectinv->initAsSpecimen(); |
|
137 | + $localobjectinv->create($user); |
|
138 | + |
|
139 | + $localobject=new FactureRec($this->savdb); |
|
140 | + $localobject->initAsSpecimen(); |
|
141 | + $result=$localobject->create($user, $localobjectinv->id); |
|
142 | + |
|
143 | + $this->assertLessThan($result, 0); |
|
144 | + print __METHOD__." result=".$result."\n"; |
|
145 | + return $result; |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | * @param Object $oB Object operand 2 |
170 | 170 | * @param boolean $ignoretype False will not report diff if type of value differs |
171 | 171 | * @param array $fieldstoignorearray Array of fields to ignore in diff |
172 | - * @return array Array with differences |
|
172 | + * @return array Array with differences |
|
173 | 173 | */ |
174 | 174 | public function objCompare($oA,$oB,$ignoretype=true,$fieldstoignorearray=array('id')) |
175 | 175 | { |
@@ -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'; |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | $user->fetch(1); |
37 | 37 | $user->getrights(); |
38 | 38 | } |
39 | -$conf->global->MAIN_DISABLE_ALL_MAILS=1; |
|
39 | +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
|
40 | 40 | |
41 | 41 | |
42 | 42 | /** |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | parent::__construct(); |
65 | 65 | |
66 | 66 | //$this->sharedFixture |
67 | - global $conf,$user,$langs,$db; |
|
68 | - $this->savconf=$conf; |
|
69 | - $this->savuser=$user; |
|
70 | - $this->savlangs=$langs; |
|
71 | - $this->savdb=$db; |
|
67 | + global $conf, $user, $langs, $db; |
|
68 | + $this->savconf = $conf; |
|
69 | + $this->savuser = $user; |
|
70 | + $this->savlangs = $langs; |
|
71 | + $this->savdb = $db; |
|
72 | 72 | |
73 | 73 | print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
74 | 74 | //print " - db ".$db->db; |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | // Static methods |
79 | 79 | public static function setUpBeforeClass() |
80 | 80 | { |
81 | - global $conf,$user,$langs,$db; |
|
82 | - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
81 | + global $conf, $user, $langs, $db; |
|
82 | + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
83 | 83 | |
84 | 84 | print __METHOD__."\n"; |
85 | 85 | } |
@@ -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 | } |
@@ -126,19 +126,19 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public function testFactureRecCreate() |
128 | 128 | { |
129 | - global $conf,$user,$langs,$db; |
|
130 | - $conf=$this->savconf; |
|
131 | - $user=$this->savuser; |
|
132 | - $langs=$this->savlangs; |
|
133 | - $db=$this->savdb; |
|
129 | + global $conf, $user, $langs, $db; |
|
130 | + $conf = $this->savconf; |
|
131 | + $user = $this->savuser; |
|
132 | + $langs = $this->savlangs; |
|
133 | + $db = $this->savdb; |
|
134 | 134 | |
135 | - $localobjectinv=new Facture($this->savdb); |
|
135 | + $localobjectinv = new Facture($this->savdb); |
|
136 | 136 | $localobjectinv->initAsSpecimen(); |
137 | 137 | $localobjectinv->create($user); |
138 | 138 | |
139 | - $localobject=new FactureRec($this->savdb); |
|
139 | + $localobject = new FactureRec($this->savdb); |
|
140 | 140 | $localobject->initAsSpecimen(); |
141 | - $result=$localobject->create($user, $localobjectinv->id); |
|
141 | + $result = $localobject->create($user, $localobjectinv->id); |
|
142 | 142 | |
143 | 143 | $this->assertLessThan($result, 0); |
144 | 144 | print __METHOD__." result=".$result."\n"; |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | */ |
159 | 159 | public function changeProperties(&$localobject) |
160 | 160 | { |
161 | - $localobject->note_private='New note'; |
|
161 | + $localobject->note_private = 'New note'; |
|
162 | 162 | //$localobject->note='New note after update'; |
163 | 163 | } |
164 | 164 | |
@@ -171,29 +171,29 @@ discard block |
||
171 | 171 | * @param array $fieldstoignorearray Array of fields to ignore in diff |
172 | 172 | * @return array Array with differences |
173 | 173 | */ |
174 | - public function objCompare($oA,$oB,$ignoretype=true,$fieldstoignorearray=array('id')) |
|
174 | + public function objCompare($oA, $oB, $ignoretype = true, $fieldstoignorearray = array('id')) |
|
175 | 175 | { |
176 | - $retAr=array(); |
|
176 | + $retAr = array(); |
|
177 | 177 | |
178 | 178 | if (get_class($oA) !== get_class($oB)) |
179 | 179 | { |
180 | - $retAr[]="Supplied objects are not of same class."; |
|
180 | + $retAr[] = "Supplied objects are not of same class."; |
|
181 | 181 | } |
182 | 182 | else |
183 | 183 | { |
184 | - $oVarsA=get_object_vars($oA); |
|
185 | - $oVarsB=get_object_vars($oB); |
|
186 | - $aKeys=array_keys($oVarsA); |
|
187 | - foreach($aKeys as $sKey) |
|
184 | + $oVarsA = get_object_vars($oA); |
|
185 | + $oVarsB = get_object_vars($oB); |
|
186 | + $aKeys = array_keys($oVarsA); |
|
187 | + foreach ($aKeys as $sKey) |
|
188 | 188 | { |
189 | - if (in_array($sKey,$fieldstoignorearray)) continue; |
|
190 | - if (! $ignoretype && $oVarsA[$sKey] !== $oVarsB[$sKey]) |
|
189 | + if (in_array($sKey, $fieldstoignorearray)) continue; |
|
190 | + if (!$ignoretype && $oVarsA[$sKey] !== $oVarsB[$sKey]) |
|
191 | 191 | { |
192 | - $retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey])?get_class($oVarsA[$sKey]):$oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey])?get_class($oVarsB[$sKey]):$oVarsB[$sKey]); |
|
192 | + $retAr[] = $sKey.' : '.(is_object($oVarsA[$sKey]) ?get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ?get_class($oVarsB[$sKey]) : $oVarsB[$sKey]); |
|
193 | 193 | } |
194 | 194 | if ($ignoretype && $oVarsA[$sKey] != $oVarsB[$sKey]) |
195 | 195 | { |
196 | - $retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey])?get_class($oVarsA[$sKey]):$oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey])?get_class($oVarsB[$sKey]):$oVarsB[$sKey]); |
|
196 | + $retAr[] = $sKey.' : '.(is_object($oVarsA[$sKey]) ?get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ?get_class($oVarsB[$sKey]) : $oVarsB[$sKey]); |
|
197 | 197 | } |
198 | 198 | } |
199 | 199 | } |
@@ -356,15 +356,16 @@ |
||
356 | 356 | if (get_class($oA) !== get_class($oB)) |
357 | 357 | { |
358 | 358 | $retAr[]="Supplied objects are not of same class."; |
359 | - } |
|
360 | - else |
|
359 | + } else |
|
361 | 360 | { |
362 | 361 | $oVarsA=get_object_vars($oA); |
363 | 362 | $oVarsB=get_object_vars($oB); |
364 | 363 | $aKeys=array_keys($oVarsA); |
365 | 364 | foreach($aKeys as $sKey) |
366 | 365 | { |
367 | - if (in_array($sKey,$fieldstoignorearray)) continue; |
|
366 | + if (in_array($sKey,$fieldstoignorearray)) { |
|
367 | + continue; |
|
368 | + } |
|
368 | 369 | if (! $ignoretype && $oVarsA[$sKey] !== $oVarsB[$sKey]) |
369 | 370 | { |
370 | 371 | $retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey])?get_class($oVarsA[$sKey]):$oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey])?get_class($oVarsB[$sKey]):$oVarsB[$sKey]); |
@@ -72,9 +72,9 @@ discard block |
||
72 | 72 | */ |
73 | 73 | function __construct() |
74 | 74 | { |
75 | - parent::__construct(); |
|
75 | + parent::__construct(); |
|
76 | 76 | |
77 | - //$this->sharedFixture |
|
77 | + //$this->sharedFixture |
|
78 | 78 | global $conf,$user,$langs,$db; |
79 | 79 | $this->savconf=$conf; |
80 | 80 | $this->savuser=$user; |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | $result=strpos($filecontent,'"'); |
166 | 166 | if ($result) |
167 | 167 | { |
168 | - $result=(! strpos($filecontent,'["') && ! strpos($filecontent,'{"')); |
|
168 | + $result=(! strpos($filecontent,'["') && ! strpos($filecontent,'{"')); |
|
169 | 169 | } |
170 | 170 | print __METHOD__." Result for checking we don't have double quote = ".$result."\n"; |
171 | 171 | $this->assertTrue($result===false, 'Found double quote that is not [" neither {" (used for json content) into '.$file.'. Bad.'); |
@@ -23,23 +23,23 @@ discard block |
||
23 | 23 | * \remarks To run this script as CLI: phpunit filename.php |
24 | 24 | */ |
25 | 25 | |
26 | -global $conf,$user,$langs,$db; |
|
26 | +global $conf, $user, $langs, $db; |
|
27 | 27 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
28 | 28 | //require_once 'PHPUnit/Autoload.php'; |
29 | 29 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
30 | 30 | require_once dirname(__FILE__).'/../../htdocs/core/lib/security.lib.php'; |
31 | 31 | require_once dirname(__FILE__).'/../../htdocs/core/lib/security2.lib.php'; |
32 | 32 | |
33 | -if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); |
|
34 | -if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); |
|
35 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
36 | -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); |
|
37 | -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); |
|
38 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); |
|
39 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show |
|
40 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php |
|
41 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
42 | -if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) |
|
33 | +if (!defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); |
|
34 | +if (!defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); |
|
35 | +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); |
|
36 | +if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); |
|
37 | +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); |
|
38 | +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); |
|
39 | +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no menu to show |
|
40 | +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php |
|
41 | +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); |
|
42 | +if (!defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) |
|
43 | 43 | |
44 | 44 | if (empty($user->id)) |
45 | 45 | { |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $user->fetch(1); |
48 | 48 | $user->getrights(); |
49 | 49 | } |
50 | -$conf->global->MAIN_DISABLE_ALL_MAILS=1; |
|
50 | +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
|
51 | 51 | |
52 | 52 | |
53 | 53 | /** |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | parent::__construct(); |
76 | 76 | |
77 | 77 | //$this->sharedFixture |
78 | - global $conf,$user,$langs,$db; |
|
79 | - $this->savconf=$conf; |
|
80 | - $this->savuser=$user; |
|
81 | - $this->savlangs=$langs; |
|
82 | - $this->savdb=$db; |
|
78 | + global $conf, $user, $langs, $db; |
|
79 | + $this->savconf = $conf; |
|
80 | + $this->savuser = $user; |
|
81 | + $this->savlangs = $langs; |
|
82 | + $this->savdb = $db; |
|
83 | 83 | |
84 | 84 | print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
85 | 85 | //print " - db ".$db->db; |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | // Static methods |
90 | 90 | public static function setUpBeforeClass() |
91 | 91 | { |
92 | - global $conf,$user,$langs,$db; |
|
92 | + global $conf, $user, $langs, $db; |
|
93 | 93 | $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
94 | 94 | |
95 | 95 | print __METHOD__."\n"; |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | // tear down after class |
99 | 99 | public static function tearDownAfterClass() |
100 | 100 | { |
101 | - global $conf,$user,$langs,$db; |
|
101 | + global $conf, $user, $langs, $db; |
|
102 | 102 | $db->rollback(); |
103 | 103 | |
104 | 104 | print __METHOD__."\n"; |
@@ -111,11 +111,11 @@ discard block |
||
111 | 111 | */ |
112 | 112 | protected function setUp() |
113 | 113 | { |
114 | - global $conf,$user,$langs,$db; |
|
115 | - $conf=$this->savconf; |
|
116 | - $user=$this->savuser; |
|
117 | - $langs=$this->savlangs; |
|
118 | - $db=$this->savdb; |
|
114 | + global $conf, $user, $langs, $db; |
|
115 | + $conf = $this->savconf; |
|
116 | + $user = $this->savuser; |
|
117 | + $langs = $this->savlangs; |
|
118 | + $db = $this->savdb; |
|
119 | 119 | |
120 | 120 | print __METHOD__."\n"; |
121 | 121 | } |
@@ -137,11 +137,11 @@ discard block |
||
137 | 137 | */ |
138 | 138 | public function testSql() |
139 | 139 | { |
140 | - global $conf,$user,$langs,$db; |
|
141 | - $conf=$this->savconf; |
|
142 | - $user=$this->savuser; |
|
143 | - $langs=$this->savlangs; |
|
144 | - $db=$this->savdb; |
|
140 | + global $conf, $user, $langs, $db; |
|
141 | + $conf = $this->savconf; |
|
142 | + $user = $this->savuser; |
|
143 | + $langs = $this->savlangs; |
|
144 | + $db = $this->savdb; |
|
145 | 145 | |
146 | 146 | $listofsqldir = array(DOL_DOCUMENT_ROOT.'/install/mysql/data', DOL_DOCUMENT_ROOT.'/install/mysql/tables', DOL_DOCUMENT_ROOT.'/install/mysql/migration'); |
147 | 147 | |
@@ -150,37 +150,37 @@ discard block |
||
150 | 150 | print 'Process dir '.$dir."\n"; |
151 | 151 | $filesarray = scandir($dir); |
152 | 152 | |
153 | - foreach($filesarray as $key => $file) |
|
153 | + foreach ($filesarray as $key => $file) |
|
154 | 154 | { |
155 | - if (! preg_match('/\.sql$/',$file)) |
|
155 | + if (!preg_match('/\.sql$/', $file)) |
|
156 | 156 | continue; |
157 | 157 | |
158 | 158 | print 'Check sql file '.$file."\n"; |
159 | - $filecontent=file_get_contents($dir.'/'.$file); |
|
159 | + $filecontent = file_get_contents($dir.'/'.$file); |
|
160 | 160 | |
161 | - $result=strpos($filecontent,'`'); |
|
161 | + $result = strpos($filecontent, '`'); |
|
162 | 162 | print __METHOD__." Result for checking we don't have back quote = ".$result."\n"; |
163 | - $this->assertTrue($result===false, 'Found back quote into '.$file.'. Bad.'); |
|
163 | + $this->assertTrue($result === false, 'Found back quote into '.$file.'. Bad.'); |
|
164 | 164 | |
165 | - $result=strpos($filecontent,'"'); |
|
165 | + $result = strpos($filecontent, '"'); |
|
166 | 166 | if ($result) |
167 | 167 | { |
168 | - $result=(! strpos($filecontent,'["') && ! strpos($filecontent,'{"')); |
|
168 | + $result = (!strpos($filecontent, '["') && !strpos($filecontent, '{"')); |
|
169 | 169 | } |
170 | 170 | print __METHOD__." Result for checking we don't have double quote = ".$result."\n"; |
171 | - $this->assertTrue($result===false, 'Found double quote that is not [" neither {" (used for json content) into '.$file.'. Bad.'); |
|
171 | + $this->assertTrue($result === false, 'Found double quote that is not [" neither {" (used for json content) into '.$file.'. Bad.'); |
|
172 | 172 | |
173 | - $result=strpos($filecontent,'int('); |
|
173 | + $result = strpos($filecontent, 'int('); |
|
174 | 174 | print __METHOD__." Result for checking we don't have 'int(' instead of 'integer' = ".$result."\n"; |
175 | - $this->assertTrue($result===false, 'Found int(x) or tinyint(x) instead of integer or tinyint into '.$file.'. Bad.'); |
|
175 | + $this->assertTrue($result === false, 'Found int(x) or tinyint(x) instead of integer or tinyint into '.$file.'. Bad.'); |
|
176 | 176 | |
177 | - $result=strpos($filecontent,'ON DELETE CASCADE'); |
|
177 | + $result = strpos($filecontent, 'ON DELETE CASCADE'); |
|
178 | 178 | print __METHOD__." Result for checking we don't have 'ON DELETE CASCADE' = ".$result."\n"; |
179 | - $this->assertTrue($result===false, 'Found ON DELETE CASCADE into '.$file.'. Bad.'); |
|
179 | + $this->assertTrue($result === false, 'Found ON DELETE CASCADE into '.$file.'. Bad.'); |
|
180 | 180 | |
181 | - $result=strpos($filecontent,'NUMERIC('); |
|
181 | + $result = strpos($filecontent, 'NUMERIC('); |
|
182 | 182 | print __METHOD__." Result for checking we don't have 'NUMERIC(' = ".$result."\n"; |
183 | - $this->assertTrue($result===false, 'Found NUMERIC( into '.$file.'. Bad.'); |
|
183 | + $this->assertTrue($result === false, 'Found NUMERIC( into '.$file.'. Bad.'); |
|
184 | 184 | |
185 | 185 | if ($dir == DOL_DOCUMENT_ROOT.'/install/mysql/migration') |
186 | 186 | { |
@@ -192,18 +192,18 @@ discard block |
||
192 | 192 | } |
193 | 193 | else |
194 | 194 | { |
195 | - if (preg_match('/\.key\.sql$/',$file)) |
|
195 | + if (preg_match('/\.key\.sql$/', $file)) |
|
196 | 196 | { |
197 | 197 | // Test for key files only |
198 | 198 | } |
199 | 199 | else |
200 | 200 | { |
201 | 201 | // Test for non key files only |
202 | - $result=(strpos($filecontent,'KEY ') && strpos($filecontent,'PRIMARY KEY') == 0); |
|
202 | + $result = (strpos($filecontent, 'KEY ') && strpos($filecontent, 'PRIMARY KEY') == 0); |
|
203 | 203 | print __METHOD__." Result for checking we don't have ' KEY ' instead of a sql file to create index = ".$result."\n"; |
204 | - $this->assertTrue($result===false, 'Found KEY into '.$file.'. Bad.'); |
|
204 | + $this->assertTrue($result === false, 'Found KEY into '.$file.'. Bad.'); |
|
205 | 205 | |
206 | - $result=stripos($filecontent,'ENGINE=innodb'); |
|
206 | + $result = stripos($filecontent, 'ENGINE=innodb'); |
|
207 | 207 | print __METHOD__." Result for checking we have the ENGINE=innodb string = ".$result."\n"; |
208 | 208 | $this->assertGreaterThan(0, $result, 'The ENGINE=innodb was not found into '.$file.'. Add it or just fix syntax to match case.'); |
209 | 209 | } |
@@ -221,27 +221,27 @@ discard block |
||
221 | 221 | */ |
222 | 222 | public function testInitData() |
223 | 223 | { |
224 | - global $conf,$user,$langs,$db; |
|
225 | - $conf=$this->savconf; |
|
226 | - $user=$this->savuser; |
|
227 | - $langs=$this->savlangs; |
|
228 | - $db=$this->savdb; |
|
224 | + global $conf, $user, $langs, $db; |
|
225 | + $conf = $this->savconf; |
|
226 | + $user = $this->savuser; |
|
227 | + $langs = $this->savlangs; |
|
228 | + $db = $this->savdb; |
|
229 | 229 | |
230 | 230 | $filesarray = scandir(DOL_DOCUMENT_ROOT.'/../dev/initdata'); |
231 | - foreach($filesarray as $key => $file) { |
|
232 | - if (! preg_match('/\.sql$/',$file)) |
|
231 | + foreach ($filesarray as $key => $file) { |
|
232 | + if (!preg_match('/\.sql$/', $file)) |
|
233 | 233 | continue; |
234 | 234 | |
235 | 235 | print 'Check sql file '.$file."\n"; |
236 | - $filecontent=file_get_contents(DOL_DOCUMENT_ROOT.'/../dev/initdata/'.$file); |
|
236 | + $filecontent = file_get_contents(DOL_DOCUMENT_ROOT.'/../dev/initdata/'.$file); |
|
237 | 237 | |
238 | - $result=strpos($filecontent,'@gmail.com'); |
|
238 | + $result = strpos($filecontent, '@gmail.com'); |
|
239 | 239 | print __METHOD__." Result for checking we don't have personal data = ".$result."\n"; |
240 | - $this->assertTrue($result===false, 'Found a bad key into file '.$file); |
|
240 | + $this->assertTrue($result === false, 'Found a bad key into file '.$file); |
|
241 | 241 | |
242 | - $result=strpos($filecontent,'eldy@'); |
|
242 | + $result = strpos($filecontent, 'eldy@'); |
|
243 | 243 | print __METHOD__." Result for checking we don't have personal data = ".$result."\n"; |
244 | - $this->assertTrue($result===false, 'Found a bad key into file '.$file); |
|
244 | + $this->assertTrue($result === false, 'Found a bad key into file '.$file); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | return; |
@@ -30,16 +30,39 @@ discard block |
||
30 | 30 | require_once dirname(__FILE__).'/../../htdocs/core/lib/security.lib.php'; |
31 | 31 | require_once dirname(__FILE__).'/../../htdocs/core/lib/security2.lib.php'; |
32 | 32 | |
33 | -if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); |
|
34 | -if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); |
|
35 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
36 | -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); |
|
37 | -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); |
|
38 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); |
|
39 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show |
|
40 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php |
|
41 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
42 | -if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) |
|
33 | +if (! defined('NOREQUIREUSER')) { |
|
34 | + define('NOREQUIREUSER','1'); |
|
35 | +} |
|
36 | +if (! defined('NOREQUIREDB')) { |
|
37 | + define('NOREQUIREDB','1'); |
|
38 | +} |
|
39 | +if (! defined('NOREQUIRESOC')) { |
|
40 | + define('NOREQUIRESOC','1'); |
|
41 | +} |
|
42 | +if (! defined('NOREQUIRETRAN')) { |
|
43 | + define('NOREQUIRETRAN','1'); |
|
44 | +} |
|
45 | +if (! defined('NOCSRFCHECK')) { |
|
46 | + define('NOCSRFCHECK','1'); |
|
47 | +} |
|
48 | +if (! defined('NOTOKENRENEWAL')) { |
|
49 | + define('NOTOKENRENEWAL','1'); |
|
50 | +} |
|
51 | +if (! defined('NOREQUIREMENU')) { |
|
52 | + define('NOREQUIREMENU','1'); |
|
53 | +} |
|
54 | +// If there is no menu to show |
|
55 | +if (! defined('NOREQUIREHTML')) { |
|
56 | + define('NOREQUIREHTML','1'); |
|
57 | +} |
|
58 | +// If we don't need to load the html.form.class.php |
|
59 | +if (! defined('NOREQUIREAJAX')) { |
|
60 | + define('NOREQUIREAJAX','1'); |
|
61 | +} |
|
62 | +if (! defined("NOLOGIN")) { |
|
63 | + define("NOLOGIN",'1'); |
|
64 | +} |
|
65 | +// If this page is public (can be called outside logged session) |
|
43 | 66 | |
44 | 67 | if (empty($user->id)) |
45 | 68 | { |
@@ -152,8 +175,9 @@ discard block |
||
152 | 175 | |
153 | 176 | foreach($filesarray as $key => $file) |
154 | 177 | { |
155 | - if (! preg_match('/\.sql$/',$file)) |
|
156 | - continue; |
|
178 | + if (! preg_match('/\.sql$/',$file)) { |
|
179 | + continue; |
|
180 | + } |
|
157 | 181 | |
158 | 182 | print 'Check sql file '.$file."\n"; |
159 | 183 | $filecontent=file_get_contents($dir.'/'.$file); |
@@ -185,18 +209,15 @@ discard block |
||
185 | 209 | if ($dir == DOL_DOCUMENT_ROOT.'/install/mysql/migration') |
186 | 210 | { |
187 | 211 | // Test for migration files only |
188 | - } |
|
189 | - elseif ($dir == DOL_DOCUMENT_ROOT.'/install/mysql/data') |
|
212 | + } elseif ($dir == DOL_DOCUMENT_ROOT.'/install/mysql/data') |
|
190 | 213 | { |
191 | 214 | // Test for data files only |
192 | - } |
|
193 | - else |
|
215 | + } else |
|
194 | 216 | { |
195 | 217 | if (preg_match('/\.key\.sql$/',$file)) |
196 | 218 | { |
197 | 219 | // Test for key files only |
198 | - } |
|
199 | - else |
|
220 | + } else |
|
200 | 221 | { |
201 | 222 | // Test for non key files only |
202 | 223 | $result=(strpos($filecontent,'KEY ') && strpos($filecontent,'PRIMARY KEY') == 0); |
@@ -229,8 +250,9 @@ discard block |
||
229 | 250 | |
230 | 251 | $filesarray = scandir(DOL_DOCUMENT_ROOT.'/../dev/initdata'); |
231 | 252 | foreach($filesarray as $key => $file) { |
232 | - if (! preg_match('/\.sql$/',$file)) |
|
233 | - continue; |
|
253 | + if (! preg_match('/\.sql$/',$file)) { |
|
254 | + continue; |
|
255 | + } |
|
234 | 256 | |
235 | 257 | print 'Check sql file '.$file."\n"; |
236 | 258 | $filecontent=file_get_contents(DOL_DOCUMENT_ROOT.'/../dev/initdata/'.$file); |
@@ -72,9 +72,9 @@ discard block |
||
72 | 72 | */ |
73 | 73 | function __construct() |
74 | 74 | { |
75 | - parent::__construct(); |
|
75 | + parent::__construct(); |
|
76 | 76 | |
77 | - //$this->sharedFixture |
|
77 | + //$this->sharedFixture |
|
78 | 78 | global $conf,$user,$langs,$db; |
79 | 79 | $this->savconf=$conf; |
80 | 80 | $this->savuser=$user; |
@@ -164,12 +164,12 @@ discard block |
||
164 | 164 | preg_match_all('/(..)\s*\.\s*\$this->db->idate\(/', $filecontent, $matches, PREG_SET_ORDER); |
165 | 165 | foreach($matches as $key => $val) |
166 | 166 | { |
167 | - if ($val[1] != '\'"' && $val[1] != '\'\'') |
|
168 | - { |
|
169 | - $ok=false; |
|
170 | - break; |
|
171 | - } |
|
172 | - //if ($reg[0] != 'db') $ok=false; |
|
167 | + if ($val[1] != '\'"' && $val[1] != '\'\'') |
|
168 | + { |
|
169 | + $ok=false; |
|
170 | + break; |
|
171 | + } |
|
172 | + //if ($reg[0] != 'db') $ok=false; |
|
173 | 173 | } |
174 | 174 | //print __METHOD__." Result for checking we don't have non escaped string in sql requests for file ".$file."\n"; |
175 | 175 | $this->assertTrue($ok, 'Found a $this->db->idate to forge a sql request without quotes around this date field '.$file['fullname'].' :: '.$val[0]); |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | preg_match_all('/(..............)\$_SERVER\[\'QUERY_STRING\'\]/', $filecontent, $matches, PREG_SET_ORDER); |
202 | 202 | foreach($matches as $key => $val) |
203 | 203 | { |
204 | - if ($val[1] != 'scape_htmltag(' && $val[1] != 'ing_nohtmltag(' && $val[1] != 'dol_escape_js(') |
|
204 | + if ($val[1] != 'scape_htmltag(' && $val[1] != 'ing_nohtmltag(' && $val[1] != 'dol_escape_js(') |
|
205 | 205 | { |
206 | 206 | $ok=false; |
207 | 207 | break; |
@@ -217,8 +217,8 @@ discard block |
||
217 | 217 | preg_match_all('/print_liste_field_titre\(\$langs/', $filecontent, $matches, PREG_SET_ORDER); |
218 | 218 | foreach($matches as $key => $val) |
219 | 219 | { |
220 | - $ok=false; |
|
221 | - break; |
|
220 | + $ok=false; |
|
221 | + break; |
|
222 | 222 | } |
223 | 223 | $this->assertTrue($ok, 'Found a use of print_liste_field_titre with fist parameter that is a translated value instead of just the translation key in file '.$file['fullname'].'. Bad.'); |
224 | 224 | |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | preg_match_all('/<br \/>/', $filecontent, $matches, PREG_SET_ORDER); |
231 | 231 | foreach($matches as $key => $val) |
232 | 232 | { |
233 | - if ($file['name'] != 'functions.lib.php') |
|
233 | + if ($file['name'] != 'functions.lib.php') |
|
234 | 234 | { |
235 | 235 | $ok=false; |
236 | 236 | break; |
@@ -23,23 +23,23 @@ discard block |
||
23 | 23 | * \remarks To run this script as CLI: phpunit filename.php |
24 | 24 | */ |
25 | 25 | |
26 | -global $conf,$user,$langs,$db; |
|
26 | +global $conf, $user, $langs, $db; |
|
27 | 27 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
28 | 28 | //require_once 'PHPUnit/Autoload.php'; |
29 | 29 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
30 | 30 | require_once dirname(__FILE__).'/../../htdocs/core/lib/security.lib.php'; |
31 | 31 | require_once dirname(__FILE__).'/../../htdocs/core/lib/security2.lib.php'; |
32 | 32 | |
33 | -if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); |
|
34 | -if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); |
|
35 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
36 | -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); |
|
37 | -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); |
|
38 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); |
|
39 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show |
|
40 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php |
|
41 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
42 | -if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) |
|
33 | +if (!defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); |
|
34 | +if (!defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); |
|
35 | +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); |
|
36 | +if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); |
|
37 | +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); |
|
38 | +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); |
|
39 | +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no menu to show |
|
40 | +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php |
|
41 | +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); |
|
42 | +if (!defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) |
|
43 | 43 | |
44 | 44 | if (empty($user->id)) |
45 | 45 | { |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $user->fetch(1); |
48 | 48 | $user->getrights(); |
49 | 49 | } |
50 | -$conf->global->MAIN_DISABLE_ALL_MAILS=1; |
|
50 | +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
|
51 | 51 | |
52 | 52 | |
53 | 53 | /** |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | parent::__construct(); |
76 | 76 | |
77 | 77 | //$this->sharedFixture |
78 | - global $conf,$user,$langs,$db; |
|
79 | - $this->savconf=$conf; |
|
80 | - $this->savuser=$user; |
|
81 | - $this->savlangs=$langs; |
|
82 | - $this->savdb=$db; |
|
78 | + global $conf, $user, $langs, $db; |
|
79 | + $this->savconf = $conf; |
|
80 | + $this->savuser = $user; |
|
81 | + $this->savlangs = $langs; |
|
82 | + $this->savdb = $db; |
|
83 | 83 | |
84 | 84 | print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
85 | 85 | //print " - db ".$db->db; |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | // Static methods |
90 | 90 | public static function setUpBeforeClass() |
91 | 91 | { |
92 | - global $conf,$user,$langs,$db; |
|
92 | + global $conf, $user, $langs, $db; |
|
93 | 93 | $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
94 | 94 | |
95 | 95 | print __METHOD__."\n"; |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | // tear down after class |
99 | 99 | public static function tearDownAfterClass() |
100 | 100 | { |
101 | - global $conf,$user,$langs,$db; |
|
101 | + global $conf, $user, $langs, $db; |
|
102 | 102 | $db->rollback(); |
103 | 103 | |
104 | 104 | print __METHOD__."\n"; |
@@ -111,11 +111,11 @@ discard block |
||
111 | 111 | */ |
112 | 112 | protected function setUp() |
113 | 113 | { |
114 | - global $conf,$user,$langs,$db; |
|
115 | - $conf=$this->savconf; |
|
116 | - $user=$this->savuser; |
|
117 | - $langs=$this->savlangs; |
|
118 | - $db=$this->savdb; |
|
114 | + global $conf, $user, $langs, $db; |
|
115 | + $conf = $this->savconf; |
|
116 | + $user = $this->savuser; |
|
117 | + $langs = $this->savlangs; |
|
118 | + $db = $this->savdb; |
|
119 | 119 | |
120 | 120 | print __METHOD__."\n"; |
121 | 121 | } |
@@ -137,16 +137,16 @@ discard block |
||
137 | 137 | */ |
138 | 138 | public function testPHP() |
139 | 139 | { |
140 | - global $conf,$user,$langs,$db; |
|
141 | - $conf=$this->savconf; |
|
142 | - $user=$this->savuser; |
|
143 | - $langs=$this->savlangs; |
|
144 | - $db=$this->savdb; |
|
140 | + global $conf, $user, $langs, $db; |
|
141 | + $conf = $this->savconf; |
|
142 | + $user = $this->savuser; |
|
143 | + $langs = $this->savlangs; |
|
144 | + $db = $this->savdb; |
|
145 | 145 | |
146 | 146 | include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
147 | 147 | $filesarray = dol_dir_list(DOL_DOCUMENT_ROOT, 'files', 1, '\.php', null, 'fullname'); |
148 | 148 | |
149 | - foreach($filesarray as $key => $file) |
|
149 | + foreach ($filesarray as $key => $file) |
|
150 | 150 | { |
151 | 151 | if (preg_match('/\/htdocs\/includes\//', $file['fullname'])) continue; |
152 | 152 | if (preg_match('/\/htdocs\/custom\//', $file['fullname'])) continue; |
@@ -155,18 +155,18 @@ discard block |
||
155 | 155 | if (preg_match('/\/htdocs\/teclib/', $file['fullname'])) continue; |
156 | 156 | |
157 | 157 | print 'Check php file '.$file['fullname']."\n"; |
158 | - $filecontent=file_get_contents($file['fullname']); |
|
158 | + $filecontent = file_get_contents($file['fullname']); |
|
159 | 159 | |
160 | 160 | |
161 | - $ok=true; |
|
162 | - $matches=array(); |
|
161 | + $ok = true; |
|
162 | + $matches = array(); |
|
163 | 163 | // Check string ='".$this->xxx with xxx that is not 'escape'. It means we forget a db->escape when forging sql request. |
164 | 164 | preg_match_all('/(..)\s*\.\s*\$this->db->idate\(/', $filecontent, $matches, PREG_SET_ORDER); |
165 | - foreach($matches as $key => $val) |
|
165 | + foreach ($matches as $key => $val) |
|
166 | 166 | { |
167 | 167 | if ($val[1] != '\'"' && $val[1] != '\'\'') |
168 | 168 | { |
169 | - $ok=false; |
|
169 | + $ok = false; |
|
170 | 170 | break; |
171 | 171 | } |
172 | 172 | //if ($reg[0] != 'db') $ok=false; |
@@ -176,15 +176,15 @@ discard block |
||
176 | 176 | //exit; |
177 | 177 | |
178 | 178 | |
179 | - $ok=true; |
|
180 | - $matches=array(); |
|
179 | + $ok = true; |
|
180 | + $matches = array(); |
|
181 | 181 | // Check string ='".$this->xxx with xxx that is not 'escape'. It means we forget a db->escape when forging sql request. |
182 | 182 | preg_match_all('/(=|sql.+)\s*\'"\s*\.\s*\$this->(....)/', $filecontent, $matches, PREG_SET_ORDER); |
183 | - foreach($matches as $key => $val) |
|
183 | + foreach ($matches as $key => $val) |
|
184 | 184 | { |
185 | 185 | if ($val[2] != 'db->' && $val[2] != 'esca') |
186 | 186 | { |
187 | - $ok=false; |
|
187 | + $ok = false; |
|
188 | 188 | break; |
189 | 189 | } |
190 | 190 | //if ($reg[0] != 'db') $ok=false; |
@@ -195,15 +195,15 @@ discard block |
||
195 | 195 | |
196 | 196 | |
197 | 197 | // Test that output of $_SERVER\[\'QUERY_STRING\'\] is escaped. |
198 | - $ok=true; |
|
199 | - $matches=array(); |
|
198 | + $ok = true; |
|
199 | + $matches = array(); |
|
200 | 200 | // Check string ='".$this->xxx with xxx that is not 'escape'. It means we forget a db->escape when forging sql request. |
201 | 201 | preg_match_all('/(..............)\$_SERVER\[\'QUERY_STRING\'\]/', $filecontent, $matches, PREG_SET_ORDER); |
202 | - foreach($matches as $key => $val) |
|
202 | + foreach ($matches as $key => $val) |
|
203 | 203 | { |
204 | 204 | if ($val[1] != 'scape_htmltag(' && $val[1] != 'ing_nohtmltag(' && $val[1] != 'dol_escape_js(') |
205 | 205 | { |
206 | - $ok=false; |
|
206 | + $ok = false; |
|
207 | 207 | break; |
208 | 208 | } |
209 | 209 | } |
@@ -211,28 +211,28 @@ discard block |
||
211 | 211 | |
212 | 212 | |
213 | 213 | // Test that first param of print_liste_field_titre is a translation key and not the translated value |
214 | - $ok=true; |
|
215 | - $matches=array(); |
|
214 | + $ok = true; |
|
215 | + $matches = array(); |
|
216 | 216 | // Check string ='".$this->xxx with xxx that is not 'escape'. It means we forget a db->escape when forging sql request. |
217 | 217 | preg_match_all('/print_liste_field_titre\(\$langs/', $filecontent, $matches, PREG_SET_ORDER); |
218 | - foreach($matches as $key => $val) |
|
218 | + foreach ($matches as $key => $val) |
|
219 | 219 | { |
220 | - $ok=false; |
|
220 | + $ok = false; |
|
221 | 221 | break; |
222 | 222 | } |
223 | 223 | $this->assertTrue($ok, 'Found a use of print_liste_field_titre with fist parameter that is a translated value instead of just the translation key in file '.$file['fullname'].'. Bad.'); |
224 | 224 | |
225 | 225 | |
226 | 226 | // Test we don't have <br /> |
227 | - $ok=true; |
|
228 | - $matches=array(); |
|
227 | + $ok = true; |
|
228 | + $matches = array(); |
|
229 | 229 | // Check string ='".$this->xxx with xxx that is not 'escape'. It means we forget a db->escape when forging sql request. |
230 | 230 | preg_match_all('/<br \/>/', $filecontent, $matches, PREG_SET_ORDER); |
231 | - foreach($matches as $key => $val) |
|
231 | + foreach ($matches as $key => $val) |
|
232 | 232 | { |
233 | 233 | if ($file['name'] != 'functions.lib.php') |
234 | 234 | { |
235 | - $ok=false; |
|
235 | + $ok = false; |
|
236 | 236 | break; |
237 | 237 | } |
238 | 238 | } |
@@ -30,16 +30,39 @@ discard block |
||
30 | 30 | require_once dirname(__FILE__).'/../../htdocs/core/lib/security.lib.php'; |
31 | 31 | require_once dirname(__FILE__).'/../../htdocs/core/lib/security2.lib.php'; |
32 | 32 | |
33 | -if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); |
|
34 | -if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); |
|
35 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
36 | -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); |
|
37 | -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); |
|
38 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); |
|
39 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show |
|
40 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php |
|
41 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
42 | -if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) |
|
33 | +if (! defined('NOREQUIREUSER')) { |
|
34 | + define('NOREQUIREUSER','1'); |
|
35 | +} |
|
36 | +if (! defined('NOREQUIREDB')) { |
|
37 | + define('NOREQUIREDB','1'); |
|
38 | +} |
|
39 | +if (! defined('NOREQUIRESOC')) { |
|
40 | + define('NOREQUIRESOC','1'); |
|
41 | +} |
|
42 | +if (! defined('NOREQUIRETRAN')) { |
|
43 | + define('NOREQUIRETRAN','1'); |
|
44 | +} |
|
45 | +if (! defined('NOCSRFCHECK')) { |
|
46 | + define('NOCSRFCHECK','1'); |
|
47 | +} |
|
48 | +if (! defined('NOTOKENRENEWAL')) { |
|
49 | + define('NOTOKENRENEWAL','1'); |
|
50 | +} |
|
51 | +if (! defined('NOREQUIREMENU')) { |
|
52 | + define('NOREQUIREMENU','1'); |
|
53 | +} |
|
54 | +// If there is no menu to show |
|
55 | +if (! defined('NOREQUIREHTML')) { |
|
56 | + define('NOREQUIREHTML','1'); |
|
57 | +} |
|
58 | +// If we don't need to load the html.form.class.php |
|
59 | +if (! defined('NOREQUIREAJAX')) { |
|
60 | + define('NOREQUIREAJAX','1'); |
|
61 | +} |
|
62 | +if (! defined("NOLOGIN")) { |
|
63 | + define("NOLOGIN",'1'); |
|
64 | +} |
|
65 | +// If this page is public (can be called outside logged session) |
|
43 | 66 | |
44 | 67 | if (empty($user->id)) |
45 | 68 | { |
@@ -148,11 +171,21 @@ discard block |
||
148 | 171 | |
149 | 172 | foreach($filesarray as $key => $file) |
150 | 173 | { |
151 | - if (preg_match('/\/htdocs\/includes\//', $file['fullname'])) continue; |
|
152 | - if (preg_match('/\/htdocs\/custom\//', $file['fullname'])) continue; |
|
153 | - if (preg_match('/\/htdocs\/dolimed/', $file['fullname'])) continue; |
|
154 | - if (preg_match('/\/htdocs\/nltechno/', $file['fullname'])) continue; |
|
155 | - if (preg_match('/\/htdocs\/teclib/', $file['fullname'])) continue; |
|
174 | + if (preg_match('/\/htdocs\/includes\//', $file['fullname'])) { |
|
175 | + continue; |
|
176 | + } |
|
177 | + if (preg_match('/\/htdocs\/custom\//', $file['fullname'])) { |
|
178 | + continue; |
|
179 | + } |
|
180 | + if (preg_match('/\/htdocs\/dolimed/', $file['fullname'])) { |
|
181 | + continue; |
|
182 | + } |
|
183 | + if (preg_match('/\/htdocs\/nltechno/', $file['fullname'])) { |
|
184 | + continue; |
|
185 | + } |
|
186 | + if (preg_match('/\/htdocs\/teclib/', $file['fullname'])) { |
|
187 | + continue; |
|
188 | + } |
|
156 | 189 | |
157 | 190 | print 'Check php file '.$file['fullname']."\n"; |
158 | 191 | $filecontent=file_get_contents($file['fullname']); |
@@ -30,9 +30,9 @@ discard block |
||
30 | 30 | |
31 | 31 | if (empty($user->id)) |
32 | 32 | { |
33 | - print "Load permissions for admin user nb 1\n"; |
|
34 | - $user->fetch(1); |
|
35 | - $user->getrights(); |
|
33 | + print "Load permissions for admin user nb 1\n"; |
|
34 | + $user->fetch(1); |
|
35 | + $user->getrights(); |
|
36 | 36 | } |
37 | 37 | $conf->global->MAIN_DISABLE_ALL_MAILS=1; |
38 | 38 | |
@@ -46,76 +46,76 @@ discard block |
||
46 | 46 | */ |
47 | 47 | class NumberingModulesTest extends PHPUnit_Framework_TestCase |
48 | 48 | { |
49 | - protected $savconf; |
|
50 | - protected $savuser; |
|
51 | - protected $savlangs; |
|
52 | - protected $savdb; |
|
53 | - |
|
54 | - /** |
|
55 | - * Constructor |
|
56 | - * We save global variables into local variables |
|
57 | - * |
|
58 | - * @return NumberingModulesTest |
|
59 | - */ |
|
60 | - function __construct() |
|
61 | - { |
|
62 | - parent::__construct(); |
|
63 | - |
|
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; |
|
70 | - |
|
71 | - print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
|
72 | - //print " - db ".$db->db; |
|
73 | - print "\n"; |
|
74 | - } |
|
75 | - |
|
76 | - // Static methods |
|
77 | - public static function setUpBeforeClass() |
|
49 | + protected $savconf; |
|
50 | + protected $savuser; |
|
51 | + protected $savlangs; |
|
52 | + protected $savdb; |
|
53 | + |
|
54 | + /** |
|
55 | + * Constructor |
|
56 | + * We save global variables into local variables |
|
57 | + * |
|
58 | + * @return NumberingModulesTest |
|
59 | + */ |
|
60 | + function __construct() |
|
61 | + { |
|
62 | + parent::__construct(); |
|
63 | + |
|
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; |
|
70 | + |
|
71 | + print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
|
72 | + //print " - db ".$db->db; |
|
73 | + print "\n"; |
|
74 | + } |
|
75 | + |
|
76 | + // Static methods |
|
77 | + public static function setUpBeforeClass() |
|
78 | 78 | { |
79 | - global $conf,$user,$langs,$db; |
|
79 | + global $conf,$user,$langs,$db; |
|
80 | 80 | |
81 | - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
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 | 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 | /** |
@@ -125,454 +125,454 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function testFactureMercure() |
127 | 127 | { |
128 | - global $conf,$user,$langs,$db,$mysoc; |
|
129 | - $conf=$this->savconf; |
|
130 | - $user=$this->savuser; |
|
131 | - $langs=$this->savlangs; |
|
132 | - $db=$this->savdb; |
|
133 | - |
|
134 | - require_once dirname(__FILE__).'/../../htdocs/compta/facture/class/facture.class.php'; |
|
135 | - require_once dirname(__FILE__).'/../../htdocs/core/modules/facture/mod_facture_mercure.php'; |
|
136 | - |
|
137 | - // First we try with a simple mask, with no reset |
|
138 | - // and we test counter is still increase second year. |
|
139 | - $conf->global->FACTURE_ADDON='mercure'; |
|
140 | - $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}-{0000}'; |
|
141 | - $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}-{0000}'; |
|
142 | - $conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED=0; |
|
143 | - |
|
144 | - $localobject=new Facture($this->savdb); |
|
145 | - $localobject->initAsSpecimen(); |
|
146 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1915); // we use year 1915 to be sure to not have existing invoice for this year |
|
147 | - $numbering=new mod_facture_mercure(); |
|
148 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
149 | - print __METHOD__." result=".$result."\n"; |
|
150 | - $this->assertEquals('1915-0001', $result, 'Test for {yyyy}-{0000}, 1st invoice'); // counter must start to 1 |
|
151 | - $result2=$localobject->create($user,1); |
|
152 | - print __METHOD__." result2=".$result."\n"; |
|
153 | - $result3=$localobject->validate($user, $result); // create invoice by forcing ref |
|
154 | - print __METHOD__." result3=".$result."\n"; |
|
155 | - $this->assertEquals(1, $result3, 'Test validation of invoice with forced ref is ok'); // counter must start to 1 |
|
156 | - $result=$localobject->is_erasable(); |
|
157 | - print __METHOD__." is_erasable=".$result."\n"; |
|
158 | - $this->assertGreaterThanOrEqual(1, $result, 'Test for is_erasable, 1st invoice'); // Can be deleted |
|
159 | - $localobject2=new Facture($this->savdb); |
|
160 | - $localobject2->initAsSpecimen(); |
|
161 | - $localobject2->date=dol_mktime(12, 0, 0, 1, 1, 1916); // we use following year for second invoice (there is no reset into mask) |
|
162 | - $numbering=new mod_facture_mercure(); |
|
163 | - $result=$numbering->getNextValue($mysoc, $localobject2, 'last'); |
|
164 | - print __METHOD__." result=".$result."\n"; |
|
165 | - $this->assertEquals('1915-0001', $result, "Test to get last value with param 'last'"); |
|
166 | - $result=$numbering->getNextValue($mysoc, $localobject2); |
|
167 | - print __METHOD__." result=".$result."\n"; |
|
168 | - $this->assertEquals('1916-0002', $result); // counter must be now 2 (not reseted) |
|
169 | - $result2=$localobject2->create($user,1); |
|
170 | - print __METHOD__." result2=".$result."\n"; |
|
171 | - $result3=$localobject2->validate($user, $result); // create invoice by forcing ref |
|
172 | - print __METHOD__." result3=".$result."\n"; |
|
173 | - $this->assertEquals(1, $result3, 'Test validation of invoice with forced ref is ok'); // counter must start to 1 |
|
174 | - $result=$localobject2->is_erasable(); |
|
175 | - print __METHOD__." is_erasable=".$result."\n"; |
|
176 | - $this->assertGreaterThanOrEqual(1, $result); // Can be deleted |
|
177 | - $result=$localobject->is_erasable(); |
|
178 | - print __METHOD__." is_erasable=".$result."\n"; |
|
179 | - $this->assertLessThanOrEqual(0, $result, 'Test for {yyyy}-{0000} that is_erasable is 0 for 1st invoice'); // 1 can no more be deleted (2 is more recent) |
|
180 | - |
|
181 | - // Now we try with a reset |
|
182 | - $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}-{0000@1}'; |
|
183 | - $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}-{0000@1}'; |
|
184 | - |
|
185 | - $localobject=new Facture($this->savdb); |
|
186 | - $localobject->initAsSpecimen(); |
|
187 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1910); // we use year 1910 to be sure to not have existing invoice for this year |
|
188 | - $numbering=new mod_facture_mercure(); |
|
189 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
190 | - $result2=$localobject->create($user,1); |
|
191 | - $result3=$localobject->validate($user, $result); |
|
192 | - print __METHOD__." result=".$result."\n"; |
|
193 | - $this->assertEquals('1910-0001', $result, 'Test for {yyyy}-{0000@1} 1st invoice'); // counter must start to 1 |
|
194 | - $localobject2=new Facture($this->savdb); |
|
195 | - $localobject2->initAsSpecimen(); |
|
196 | - $localobject2->date=dol_mktime(12, 0, 0, 1, 1, 1910); // we use same year for second invoice (and there is a reset required) |
|
197 | - $numbering=new mod_facture_mercure(); |
|
198 | - $result=$numbering->getNextValue($mysoc, $localobject2); |
|
199 | - print __METHOD__." result=".$result."\n"; |
|
200 | - $this->assertEquals('1910-0002', $result, 'Test for {yyyy}-{0000@1} 2nd invoice, same day'); // counter must be now 2 |
|
201 | - $localobject3=new Facture($this->savdb); |
|
202 | - $localobject3->initAsSpecimen(); |
|
203 | - $localobject3->date=dol_mktime(12, 0, 0, 1, 1, 1911); // we use next year for third invoice (and there is a reset required) |
|
204 | - $numbering=new mod_facture_mercure(); |
|
205 | - $result=$numbering->getNextValue($mysoc, $localobject3); |
|
206 | - print __METHOD__." result=".$result."\n"; |
|
207 | - $this->assertEquals('1911-0001', $result, 'Test for {yyyy}-{0000@1} 3nd invoice, same day'); // counter must be now 1 |
|
208 | - |
|
209 | - // Same but we add month after year |
|
210 | - $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@1}'; |
|
211 | - $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@1}'; |
|
212 | - $localobject=new Facture($this->savdb); |
|
213 | - $localobject->initAsSpecimen(); |
|
214 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1920); // we use year 1920 to be sure to not have existing invoice for this year |
|
215 | - $numbering=new mod_facture_mercure(); |
|
216 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
217 | - $result2=$localobject->create($user,1); |
|
218 | - $result3=$localobject->validate($user, $result); |
|
219 | - print __METHOD__." result=".$result."\n"; |
|
220 | - $this->assertEquals('192001-0001', $result, 'Test for {yyyy}{mm}-{0000@1} 1st invoice'); // counter must start to 1 |
|
221 | - $result=$localobject->is_erasable(); |
|
222 | - print __METHOD__." is_erasable=".$result."\n"; |
|
223 | - $this->assertGreaterThanOrEqual(1, $result); // Can be deleted |
|
224 | - $localobject2=new Facture($this->savdb); |
|
225 | - $localobject2->initAsSpecimen(); |
|
226 | - $localobject2->date=dol_mktime(12, 0, 0, 1, 1, 1921); // we use following year for second invoice (and there is a reset required) |
|
227 | - $numbering=new mod_facture_mercure(); |
|
228 | - $result=$numbering->getNextValue($mysoc, $localobject2); |
|
229 | - $result2=$localobject2->create($user,1); |
|
230 | - $result3=$localobject2->validate($user, $result); |
|
231 | - print __METHOD__." result=".$result."\n"; |
|
232 | - $this->assertEquals('192101-0001', $result); // counter must be reseted to 1 |
|
233 | - $result=$localobject2->is_erasable(); |
|
234 | - print __METHOD__." is_erasable=".$result."\n"; |
|
235 | - $this->assertGreaterThanOrEqual(1, $result); // Can be deleted |
|
236 | - $result=$localobject->is_erasable(); |
|
237 | - print __METHOD__." is_erasable=".$result."\n"; |
|
238 | - $this->assertGreaterThanOrEqual(1, $result); // Case 1 can be deleted (because there was a reset for case 2) |
|
239 | - |
|
240 | - // Same but we add month before year and use a year on 2 digits |
|
241 | - $conf->global->FACTURE_MERCURE_MASK_CREDIT='[mm}{yy}-{0000@1}'; |
|
242 | - $conf->global->FACTURE_MERCURE_MASK_INVOICE='{mm}{yy}-{0000@1}'; |
|
243 | - $localobject=new Facture($this->savdb); |
|
244 | - $localobject->initAsSpecimen(); |
|
245 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1925); // we use year 1925 to be sure to not have existing invoice for this year |
|
246 | - $numbering=new mod_facture_mercure(); |
|
247 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
248 | - $result2=$localobject->create($user,1); |
|
249 | - $result3=$localobject->validate($user, $result); |
|
250 | - print __METHOD__." result=".$result."\n"; |
|
251 | - $this->assertEquals('0125-0001', $result, 'Test for {mm}{yy}-{0000@1} 1st invoice'); // counter must start to 1 |
|
252 | - $result=$localobject->is_erasable(); // This call get getNextNumRef with param 'last' |
|
253 | - print __METHOD__." is_erasable=".$result."\n"; |
|
254 | - $this->assertGreaterThanOrEqual(1, $result); // Can be deleted |
|
255 | - $localobject2=new Facture($this->savdb); |
|
256 | - $localobject2->initAsSpecimen(); |
|
257 | - $localobject2->date=dol_mktime(12, 0, 0, 1, 1, 1925); // we use same year 1925 for second invoice (and there is a reset required) |
|
258 | - $numbering=new mod_facture_mercure(); |
|
259 | - $result=$numbering->getNextValue($mysoc, $localobject2); |
|
260 | - $result2=$localobject2->create($user,1); |
|
261 | - $result3=$localobject2->validate($user, $result); |
|
262 | - print __METHOD__." result=".$result."\n"; |
|
263 | - $this->assertEquals('0125-0002', $result, 'Test for {mm}{yy}-{0000@1} 2st invoice'); // counter must be now 2 |
|
264 | - $result=$localobject2->is_erasable(); |
|
265 | - print __METHOD__." is_erasable=".$result."\n"; |
|
266 | - $this->assertGreaterThanOrEqual(1, $result); // Can be deleted |
|
267 | - $result=$localobject->is_erasable(); |
|
268 | - print __METHOD__." is_erasable=".$result."\n"; |
|
269 | - $this->assertLessThanOrEqual(0, $result); // Case 1 can not be deleted (because there is an invoice 2) |
|
270 | - $localobject3=new Facture($this->savdb); |
|
271 | - $localobject3->initAsSpecimen(); |
|
272 | - $localobject3->date=dol_mktime(12, 0, 0, 1, 1, 1926); // we use following year for third invoice (and there is a reset required) |
|
273 | - $numbering=new mod_facture_mercure(); |
|
274 | - $result=$numbering->getNextValue($mysoc, $localobject3); |
|
275 | - print __METHOD__." result=".$result."\n"; |
|
276 | - $this->assertEquals('0126-0001', $result, 'Test for {mm}{yy}-{0000@1} 3rd invoice'); // counter must be now 1 |
|
277 | - |
|
278 | - // Try an offset when an invoice already exists |
|
279 | - $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000+9990}'; |
|
280 | - $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000+9990}'; |
|
281 | - $result=$numbering->getNextValue($mysoc, $localobject2); |
|
282 | - |
|
283 | - // Now we try with a different fiscal month (forced by mask) |
|
284 | - $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@6}'; |
|
285 | - $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@6}'; |
|
286 | - |
|
287 | - $localobject=new Facture($this->savdb); |
|
288 | - $localobject->initAsSpecimen(); |
|
289 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1930); // we use year 1930 to be sure to not have existing invoice for this year |
|
290 | - $numbering=new mod_facture_mercure(); |
|
291 | - $result=$numbering->getNextValue($mysoc, $localobject, 'last'); |
|
292 | - print __METHOD__." result for last=".$result."\n"; |
|
293 | - $this->assertEquals('', $result); // no existing ref into reset range |
|
294 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
295 | - $result2=$localobject->create($user,1); |
|
296 | - $result3=$localobject->validate($user, $result); |
|
297 | - print __METHOD__." result=".$result."\n"; |
|
298 | - $this->assertEquals('193001-0001', $result); // counter must start to 1 |
|
299 | - $result=$numbering->getNextValue($mysoc, $localobject, 'last'); |
|
300 | - print __METHOD__." result for last=".$result."\n"; |
|
301 | - $this->assertEquals('193001-0001', $result); // last ref into reset range should be same than last created |
|
302 | - |
|
303 | - $localobject=new Facture($this->savdb); |
|
304 | - $localobject->initAsSpecimen(); |
|
305 | - $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1930); // we use same year but fiscal month after |
|
306 | - $numbering=new mod_facture_mercure(); |
|
307 | - $result=$numbering->getNextValue($mysoc, $localobject, 'last'); |
|
308 | - print __METHOD__." result for last=".$result."\n"; |
|
309 | - $this->assertEquals('', $result); // last ref into reset range should be '' |
|
310 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
311 | - $result2=$localobject->create($user,1); |
|
312 | - $result3=$localobject->validate($user, $result); |
|
313 | - print __METHOD__." result=".$result."\n"; |
|
314 | - $this->assertEquals('193012-0001', $result); // counter must be reset to 1 |
|
315 | - |
|
316 | - $localobject=new Facture($this->savdb); |
|
317 | - $localobject->initAsSpecimen(); |
|
318 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1931); // we use same fiscal year but different year |
|
319 | - $numbering=new mod_facture_mercure(); |
|
320 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
321 | - $result2=$localobject->create($user,1); |
|
322 | - $result3=$localobject->validate($user, $result); |
|
323 | - print __METHOD__." result=".$result."\n"; |
|
324 | - $this->assertEquals('193101-0002', $result); // counter must be 2 |
|
325 | - |
|
326 | - $localobject=new Facture($this->savdb); |
|
327 | - $localobject->initAsSpecimen(); |
|
328 | - $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1931); // we use different fiscal year but same year |
|
329 | - $numbering=new mod_facture_mercure(); |
|
330 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
331 | - print __METHOD__." result=".$result."\n"; |
|
332 | - $this->assertEquals('193112-0001', $result); // counter must be reset to 1 |
|
333 | - |
|
334 | - |
|
335 | - // Now we try with a different fiscal month (defined by SOCIETE_FISCAL_MONTH_START) |
|
336 | - $conf->global->SOCIETE_FISCAL_MONTH_START=6; |
|
337 | - $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@0}'; |
|
338 | - $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@0}'; |
|
339 | - |
|
340 | - $localobject=new Facture($this->savdb); |
|
341 | - $localobject->initAsSpecimen(); |
|
342 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1940); // we use year 1940 to be sure to not have existing invoice for this year |
|
343 | - $numbering=new mod_facture_mercure(); |
|
344 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
345 | - $result2=$localobject->create($user,1); |
|
346 | - $result3=$localobject->validate($user, $result); |
|
347 | - print __METHOD__." result=".$result."\n"; |
|
348 | - $this->assertEquals('194001-0001', $result); // counter must start to 1 |
|
349 | - |
|
350 | - $localobject=new Facture($this->savdb); |
|
351 | - $localobject->initAsSpecimen(); |
|
352 | - $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1940); // we use same year but fiscal month after |
|
353 | - $numbering=new mod_facture_mercure(); |
|
354 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
355 | - $result2=$localobject->create($user,1); |
|
356 | - $result3=$localobject->validate($user, $result); |
|
357 | - print __METHOD__." result=".$result."\n"; |
|
358 | - $this->assertEquals('194012-0001', $result); // counter must be reset to 1 |
|
359 | - |
|
360 | - $localobject=new Facture($this->savdb); |
|
361 | - $localobject->initAsSpecimen(); |
|
362 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1941); // we use same fiscal year but different year |
|
363 | - $numbering=new mod_facture_mercure(); |
|
364 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
365 | - $result2=$localobject->create($user,1); |
|
366 | - $result3=$localobject->validate($user, $result); |
|
367 | - print __METHOD__." result=".$result."\n"; |
|
368 | - $this->assertEquals('194101-0002', $result); // counter must be 2 |
|
369 | - |
|
370 | - $localobject=new Facture($this->savdb); |
|
371 | - $localobject->initAsSpecimen(); |
|
372 | - $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1941); // we use different discal year but same year |
|
373 | - $numbering=new mod_facture_mercure(); |
|
374 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
375 | - print __METHOD__." result=".$result."\n"; |
|
376 | - $this->assertEquals('194112-0001', $result); // counter must be reset to 1 |
|
377 | - |
|
378 | - |
|
379 | - // Now we try with a different fiscal month (defined by SOCIETE_FISCAL_MONTH_START) and we always want year of element |
|
380 | - $conf->global->SOCIETE_FISCAL_MONTH_START=6; |
|
381 | - $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@=}'; |
|
382 | - $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@=}'; |
|
383 | - |
|
384 | - $localobject=new Facture($this->savdb); |
|
385 | - $localobject->initAsSpecimen(); |
|
386 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1950); // we use year 1950 to be sure to not have existing invoice for this year |
|
387 | - $numbering=new mod_facture_mercure(); |
|
388 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
389 | - $result2=$localobject->create($user,1); |
|
390 | - $result3=$localobject->validate($user, $result); |
|
391 | - print __METHOD__." result=".$result."\n"; |
|
392 | - $this->assertEquals('195001-0001', $result); // counter must start to 1 |
|
393 | - |
|
394 | - $localobject=new Facture($this->savdb); |
|
395 | - $localobject->initAsSpecimen(); |
|
396 | - $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1950); // we use same year but fiscal month after |
|
397 | - $numbering=new mod_facture_mercure(); |
|
398 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
399 | - $result2=$localobject->create($user,1); |
|
400 | - $result3=$localobject->validate($user, $result); |
|
401 | - print __METHOD__." result=".$result."\n"; |
|
402 | - $this->assertEquals('195012-0001', $result); // counter must be reset to 1 |
|
403 | - |
|
404 | - $localobject=new Facture($this->savdb); |
|
405 | - $localobject->initAsSpecimen(); |
|
406 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1951); // we use same fiscal year but different year |
|
407 | - $numbering=new mod_facture_mercure(); |
|
408 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
409 | - $result2=$localobject->create($user,1); |
|
410 | - $result3=$localobject->validate($user, $result); |
|
411 | - print __METHOD__." result=".$result."\n"; |
|
412 | - $this->assertEquals('195101-0002', $result); // counter must be 2 |
|
413 | - |
|
414 | - $localobject=new Facture($this->savdb); |
|
415 | - $localobject->initAsSpecimen(); |
|
416 | - $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1951); // we use different discal year but same year |
|
417 | - $numbering=new mod_facture_mercure(); |
|
418 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
419 | - print __METHOD__." result=".$result."\n"; |
|
420 | - $this->assertEquals('195112-0001', $result); // counter must be reset to 1 |
|
421 | - |
|
422 | - |
|
423 | - // Now we try with a different fiscal month (defined by SOCIETE_FISCAL_MONTH_START) and we always want start year |
|
424 | - $conf->global->SOCIETE_FISCAL_MONTH_START=6; |
|
425 | - $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@-}'; |
|
426 | - $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@-}'; |
|
427 | - |
|
428 | - $localobject=new Facture($this->savdb); |
|
429 | - $localobject->initAsSpecimen(); |
|
430 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1960); // we use year 1960 to be sure to not have existing invoice for this year |
|
431 | - $numbering=new mod_facture_mercure(); |
|
432 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
433 | - $result2=$localobject->create($user,1); |
|
434 | - $result3=$localobject->validate($user, $result); |
|
435 | - print __METHOD__." result=".$result."\n"; |
|
436 | - $this->assertEquals('195901-0001', $result); // counter must start to 1 |
|
437 | - |
|
438 | - $localobject=new Facture($this->savdb); |
|
439 | - $localobject->initAsSpecimen(); |
|
440 | - $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1960); // we use same year but fiscal month after |
|
441 | - $numbering=new mod_facture_mercure(); |
|
442 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
443 | - $result2=$localobject->create($user,1); |
|
444 | - $result3=$localobject->validate($user, $result); |
|
445 | - print __METHOD__." result=".$result."\n"; |
|
446 | - $this->assertEquals('196012-0001', $result); // counter must be reset to 1 |
|
447 | - |
|
448 | - $localobject=new Facture($this->savdb); |
|
449 | - $localobject->initAsSpecimen(); |
|
450 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1961); // we use same fiscal year but different year |
|
451 | - $numbering=new mod_facture_mercure(); |
|
452 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
453 | - $result2=$localobject->create($user,1); |
|
454 | - $result3=$localobject->validate($user, $result); |
|
455 | - print __METHOD__." result=".$result."\n"; |
|
456 | - $this->assertEquals('196001-0002', $result); // counter must be 2 |
|
457 | - |
|
458 | - $localobject=new Facture($this->savdb); |
|
459 | - $localobject->initAsSpecimen(); |
|
460 | - $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1961); // we use different discal year but same year |
|
461 | - $numbering=new mod_facture_mercure(); |
|
462 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
463 | - print __METHOD__." result=".$result."\n"; |
|
464 | - $this->assertEquals('196112-0001', $result); // counter must be reset to 1 |
|
465 | - |
|
466 | - |
|
467 | - // Now we try with a different fiscal month (defined by SOCIETE_FISCAL_MONTH_START) and we always want end year |
|
468 | - $conf->global->SOCIETE_FISCAL_MONTH_START=6; |
|
469 | - $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@+}'; |
|
470 | - $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@+}'; |
|
471 | - |
|
472 | - $localobject=new Facture($this->savdb); |
|
473 | - $localobject->initAsSpecimen(); |
|
474 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1970); // we use year 1970 to be sure to not have existing invoice for this year |
|
475 | - $numbering=new mod_facture_mercure(); |
|
476 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
477 | - $result2=$localobject->create($user,1); |
|
478 | - $result3=$localobject->validate($user, $result); |
|
479 | - print __METHOD__." result=".$result."\n"; |
|
480 | - $this->assertEquals('197001-0001', $result); // counter must start to 1 |
|
481 | - |
|
482 | - $localobject=new Facture($this->savdb); |
|
483 | - $localobject->initAsSpecimen(); |
|
484 | - $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1970); // we use same year but fiscal month after |
|
485 | - $numbering=new mod_facture_mercure(); |
|
486 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
487 | - $result2=$localobject->create($user,1); |
|
488 | - $result3=$localobject->validate($user, $result); |
|
489 | - print __METHOD__." result=".$result."\n"; |
|
490 | - $this->assertEquals('197112-0001', $result); // counter must be reset to 1 |
|
491 | - |
|
492 | - $localobject=new Facture($this->savdb); |
|
493 | - $localobject->initAsSpecimen(); |
|
494 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1971); // we use same fiscal year but different year |
|
495 | - $numbering=new mod_facture_mercure(); |
|
496 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
497 | - $result2=$localobject->create($user,1); |
|
498 | - $result3=$localobject->validate($user, $result); |
|
499 | - print __METHOD__." result=".$result."\n"; |
|
500 | - $this->assertEquals('197101-0002', $result); // counter must be 2 |
|
501 | - |
|
502 | - $localobject=new Facture($this->savdb); |
|
503 | - $localobject->initAsSpecimen(); |
|
504 | - $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1971); // we use different fiscal year but same year |
|
505 | - $numbering=new mod_facture_mercure(); |
|
506 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
507 | - print __METHOD__." result=".$result."\n"; |
|
508 | - $this->assertEquals('197212-0001', $result); // counter must be reset to 1 |
|
509 | - |
|
510 | - // Now we try with a reset every month (@99) |
|
511 | - $conf->global->SOCIETE_FISCAL_MONTH_START=6; |
|
512 | - $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@99}'; |
|
513 | - $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@99}'; |
|
514 | - |
|
515 | - $localobject=new Facture($this->savdb); |
|
516 | - $localobject->initAsSpecimen(); |
|
517 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1980); // we use year 1980 to be sure to not have existing invoice for this year |
|
518 | - $numbering=new mod_facture_mercure(); |
|
519 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
520 | - $result2=$localobject->create($user,1); |
|
521 | - $result3=$localobject->validate($user, $result); |
|
522 | - print __METHOD__." result=".$result."\n"; |
|
523 | - $this->assertEquals('198001-0001', $result); // counter must start to 1 |
|
524 | - |
|
525 | - $localobject=new Facture($this->savdb); |
|
526 | - $localobject->initAsSpecimen(); |
|
527 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1980); // we use year 1980 to be sure to not have existing invoice for this year |
|
528 | - $numbering=new mod_facture_mercure(); |
|
529 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
530 | - $result2=$localobject->create($user,1); |
|
531 | - $result3=$localobject->validate($user, $result); |
|
532 | - print __METHOD__." result=".$result."\n"; |
|
533 | - $this->assertEquals('198001-0002', $result); // counter must start to 2 |
|
534 | - |
|
535 | - $localobject=new Facture($this->savdb); |
|
536 | - $localobject->initAsSpecimen(); |
|
537 | - $localobject->date=dol_mktime(12, 0, 0, 2, 1, 1980); // we use year 1980 to be sure to not have existing invoice for this year |
|
538 | - $numbering=new mod_facture_mercure(); |
|
539 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
540 | - $result2=$localobject->create($user,1); |
|
541 | - $result3=$localobject->validate($user, $result); |
|
542 | - print __METHOD__." result=".$result."\n"; |
|
543 | - $this->assertEquals('198002-0001', $result); // counter must start to 1 |
|
544 | - |
|
545 | - $localobject=new Facture($this->savdb); |
|
546 | - $localobject->initAsSpecimen(); |
|
547 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1981); // we use year 1981 to be sure to not have existing invoice for this year |
|
548 | - $numbering=new mod_facture_mercure(); |
|
549 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
550 | - $result2=$localobject->create($user,1); |
|
551 | - $result3=$localobject->validate($user, $result); |
|
552 | - print __METHOD__." result=".$result."\n"; |
|
553 | - $this->assertEquals('198101-0001', $result); // counter must start to 1 |
|
554 | - |
|
555 | - // Test with {t} tag |
|
556 | - $conf->global->SOCIETE_FISCAL_MONTH_START=1; |
|
557 | - $conf->global->FACTURE_MERCURE_MASK_CREDIT='{t}{yyyy}{mm}-{0000}'; |
|
558 | - $conf->global->FACTURE_MERCURE_MASK_INVOICE='{t}{yyyy}{mm}-{0000}'; |
|
559 | - |
|
560 | - $tmpthirdparty=new Societe($this->savdb); |
|
561 | - $tmpthirdparty->initAsSpecimen(); |
|
562 | - $tmpthirdparty->typent_code = 'TE_ABC'; |
|
563 | - |
|
564 | - $localobject=new Facture($this->savdb); |
|
565 | - $localobject->initAsSpecimen(); |
|
566 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1982); // we use year 1982 to be sure to not have existing invoice for this year |
|
567 | - $numbering=new mod_facture_mercure(); |
|
568 | - $result=$numbering->getNextValue($tmpthirdparty, $localobject); |
|
569 | - $result2=$localobject->create($user,1); |
|
570 | - $result3=$localobject->validate($user, $result); |
|
571 | - print __METHOD__." result=".$result."\n"; |
|
572 | - $this->assertEquals('A198201-0001', $result); // counter must start to 1 |
|
573 | - |
|
574 | - |
|
575 | - |
|
576 | - return $result; |
|
128 | + global $conf,$user,$langs,$db,$mysoc; |
|
129 | + $conf=$this->savconf; |
|
130 | + $user=$this->savuser; |
|
131 | + $langs=$this->savlangs; |
|
132 | + $db=$this->savdb; |
|
133 | + |
|
134 | + require_once dirname(__FILE__).'/../../htdocs/compta/facture/class/facture.class.php'; |
|
135 | + require_once dirname(__FILE__).'/../../htdocs/core/modules/facture/mod_facture_mercure.php'; |
|
136 | + |
|
137 | + // First we try with a simple mask, with no reset |
|
138 | + // and we test counter is still increase second year. |
|
139 | + $conf->global->FACTURE_ADDON='mercure'; |
|
140 | + $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}-{0000}'; |
|
141 | + $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}-{0000}'; |
|
142 | + $conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED=0; |
|
143 | + |
|
144 | + $localobject=new Facture($this->savdb); |
|
145 | + $localobject->initAsSpecimen(); |
|
146 | + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1915); // we use year 1915 to be sure to not have existing invoice for this year |
|
147 | + $numbering=new mod_facture_mercure(); |
|
148 | + $result=$numbering->getNextValue($mysoc, $localobject); |
|
149 | + print __METHOD__." result=".$result."\n"; |
|
150 | + $this->assertEquals('1915-0001', $result, 'Test for {yyyy}-{0000}, 1st invoice'); // counter must start to 1 |
|
151 | + $result2=$localobject->create($user,1); |
|
152 | + print __METHOD__." result2=".$result."\n"; |
|
153 | + $result3=$localobject->validate($user, $result); // create invoice by forcing ref |
|
154 | + print __METHOD__." result3=".$result."\n"; |
|
155 | + $this->assertEquals(1, $result3, 'Test validation of invoice with forced ref is ok'); // counter must start to 1 |
|
156 | + $result=$localobject->is_erasable(); |
|
157 | + print __METHOD__." is_erasable=".$result."\n"; |
|
158 | + $this->assertGreaterThanOrEqual(1, $result, 'Test for is_erasable, 1st invoice'); // Can be deleted |
|
159 | + $localobject2=new Facture($this->savdb); |
|
160 | + $localobject2->initAsSpecimen(); |
|
161 | + $localobject2->date=dol_mktime(12, 0, 0, 1, 1, 1916); // we use following year for second invoice (there is no reset into mask) |
|
162 | + $numbering=new mod_facture_mercure(); |
|
163 | + $result=$numbering->getNextValue($mysoc, $localobject2, 'last'); |
|
164 | + print __METHOD__." result=".$result."\n"; |
|
165 | + $this->assertEquals('1915-0001', $result, "Test to get last value with param 'last'"); |
|
166 | + $result=$numbering->getNextValue($mysoc, $localobject2); |
|
167 | + print __METHOD__." result=".$result."\n"; |
|
168 | + $this->assertEquals('1916-0002', $result); // counter must be now 2 (not reseted) |
|
169 | + $result2=$localobject2->create($user,1); |
|
170 | + print __METHOD__." result2=".$result."\n"; |
|
171 | + $result3=$localobject2->validate($user, $result); // create invoice by forcing ref |
|
172 | + print __METHOD__." result3=".$result."\n"; |
|
173 | + $this->assertEquals(1, $result3, 'Test validation of invoice with forced ref is ok'); // counter must start to 1 |
|
174 | + $result=$localobject2->is_erasable(); |
|
175 | + print __METHOD__." is_erasable=".$result."\n"; |
|
176 | + $this->assertGreaterThanOrEqual(1, $result); // Can be deleted |
|
177 | + $result=$localobject->is_erasable(); |
|
178 | + print __METHOD__." is_erasable=".$result."\n"; |
|
179 | + $this->assertLessThanOrEqual(0, $result, 'Test for {yyyy}-{0000} that is_erasable is 0 for 1st invoice'); // 1 can no more be deleted (2 is more recent) |
|
180 | + |
|
181 | + // Now we try with a reset |
|
182 | + $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}-{0000@1}'; |
|
183 | + $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}-{0000@1}'; |
|
184 | + |
|
185 | + $localobject=new Facture($this->savdb); |
|
186 | + $localobject->initAsSpecimen(); |
|
187 | + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1910); // we use year 1910 to be sure to not have existing invoice for this year |
|
188 | + $numbering=new mod_facture_mercure(); |
|
189 | + $result=$numbering->getNextValue($mysoc, $localobject); |
|
190 | + $result2=$localobject->create($user,1); |
|
191 | + $result3=$localobject->validate($user, $result); |
|
192 | + print __METHOD__." result=".$result."\n"; |
|
193 | + $this->assertEquals('1910-0001', $result, 'Test for {yyyy}-{0000@1} 1st invoice'); // counter must start to 1 |
|
194 | + $localobject2=new Facture($this->savdb); |
|
195 | + $localobject2->initAsSpecimen(); |
|
196 | + $localobject2->date=dol_mktime(12, 0, 0, 1, 1, 1910); // we use same year for second invoice (and there is a reset required) |
|
197 | + $numbering=new mod_facture_mercure(); |
|
198 | + $result=$numbering->getNextValue($mysoc, $localobject2); |
|
199 | + print __METHOD__." result=".$result."\n"; |
|
200 | + $this->assertEquals('1910-0002', $result, 'Test for {yyyy}-{0000@1} 2nd invoice, same day'); // counter must be now 2 |
|
201 | + $localobject3=new Facture($this->savdb); |
|
202 | + $localobject3->initAsSpecimen(); |
|
203 | + $localobject3->date=dol_mktime(12, 0, 0, 1, 1, 1911); // we use next year for third invoice (and there is a reset required) |
|
204 | + $numbering=new mod_facture_mercure(); |
|
205 | + $result=$numbering->getNextValue($mysoc, $localobject3); |
|
206 | + print __METHOD__." result=".$result."\n"; |
|
207 | + $this->assertEquals('1911-0001', $result, 'Test for {yyyy}-{0000@1} 3nd invoice, same day'); // counter must be now 1 |
|
208 | + |
|
209 | + // Same but we add month after year |
|
210 | + $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@1}'; |
|
211 | + $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@1}'; |
|
212 | + $localobject=new Facture($this->savdb); |
|
213 | + $localobject->initAsSpecimen(); |
|
214 | + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1920); // we use year 1920 to be sure to not have existing invoice for this year |
|
215 | + $numbering=new mod_facture_mercure(); |
|
216 | + $result=$numbering->getNextValue($mysoc, $localobject); |
|
217 | + $result2=$localobject->create($user,1); |
|
218 | + $result3=$localobject->validate($user, $result); |
|
219 | + print __METHOD__." result=".$result."\n"; |
|
220 | + $this->assertEquals('192001-0001', $result, 'Test for {yyyy}{mm}-{0000@1} 1st invoice'); // counter must start to 1 |
|
221 | + $result=$localobject->is_erasable(); |
|
222 | + print __METHOD__." is_erasable=".$result."\n"; |
|
223 | + $this->assertGreaterThanOrEqual(1, $result); // Can be deleted |
|
224 | + $localobject2=new Facture($this->savdb); |
|
225 | + $localobject2->initAsSpecimen(); |
|
226 | + $localobject2->date=dol_mktime(12, 0, 0, 1, 1, 1921); // we use following year for second invoice (and there is a reset required) |
|
227 | + $numbering=new mod_facture_mercure(); |
|
228 | + $result=$numbering->getNextValue($mysoc, $localobject2); |
|
229 | + $result2=$localobject2->create($user,1); |
|
230 | + $result3=$localobject2->validate($user, $result); |
|
231 | + print __METHOD__." result=".$result."\n"; |
|
232 | + $this->assertEquals('192101-0001', $result); // counter must be reseted to 1 |
|
233 | + $result=$localobject2->is_erasable(); |
|
234 | + print __METHOD__." is_erasable=".$result."\n"; |
|
235 | + $this->assertGreaterThanOrEqual(1, $result); // Can be deleted |
|
236 | + $result=$localobject->is_erasable(); |
|
237 | + print __METHOD__." is_erasable=".$result."\n"; |
|
238 | + $this->assertGreaterThanOrEqual(1, $result); // Case 1 can be deleted (because there was a reset for case 2) |
|
239 | + |
|
240 | + // Same but we add month before year and use a year on 2 digits |
|
241 | + $conf->global->FACTURE_MERCURE_MASK_CREDIT='[mm}{yy}-{0000@1}'; |
|
242 | + $conf->global->FACTURE_MERCURE_MASK_INVOICE='{mm}{yy}-{0000@1}'; |
|
243 | + $localobject=new Facture($this->savdb); |
|
244 | + $localobject->initAsSpecimen(); |
|
245 | + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1925); // we use year 1925 to be sure to not have existing invoice for this year |
|
246 | + $numbering=new mod_facture_mercure(); |
|
247 | + $result=$numbering->getNextValue($mysoc, $localobject); |
|
248 | + $result2=$localobject->create($user,1); |
|
249 | + $result3=$localobject->validate($user, $result); |
|
250 | + print __METHOD__." result=".$result."\n"; |
|
251 | + $this->assertEquals('0125-0001', $result, 'Test for {mm}{yy}-{0000@1} 1st invoice'); // counter must start to 1 |
|
252 | + $result=$localobject->is_erasable(); // This call get getNextNumRef with param 'last' |
|
253 | + print __METHOD__." is_erasable=".$result."\n"; |
|
254 | + $this->assertGreaterThanOrEqual(1, $result); // Can be deleted |
|
255 | + $localobject2=new Facture($this->savdb); |
|
256 | + $localobject2->initAsSpecimen(); |
|
257 | + $localobject2->date=dol_mktime(12, 0, 0, 1, 1, 1925); // we use same year 1925 for second invoice (and there is a reset required) |
|
258 | + $numbering=new mod_facture_mercure(); |
|
259 | + $result=$numbering->getNextValue($mysoc, $localobject2); |
|
260 | + $result2=$localobject2->create($user,1); |
|
261 | + $result3=$localobject2->validate($user, $result); |
|
262 | + print __METHOD__." result=".$result."\n"; |
|
263 | + $this->assertEquals('0125-0002', $result, 'Test for {mm}{yy}-{0000@1} 2st invoice'); // counter must be now 2 |
|
264 | + $result=$localobject2->is_erasable(); |
|
265 | + print __METHOD__." is_erasable=".$result."\n"; |
|
266 | + $this->assertGreaterThanOrEqual(1, $result); // Can be deleted |
|
267 | + $result=$localobject->is_erasable(); |
|
268 | + print __METHOD__." is_erasable=".$result."\n"; |
|
269 | + $this->assertLessThanOrEqual(0, $result); // Case 1 can not be deleted (because there is an invoice 2) |
|
270 | + $localobject3=new Facture($this->savdb); |
|
271 | + $localobject3->initAsSpecimen(); |
|
272 | + $localobject3->date=dol_mktime(12, 0, 0, 1, 1, 1926); // we use following year for third invoice (and there is a reset required) |
|
273 | + $numbering=new mod_facture_mercure(); |
|
274 | + $result=$numbering->getNextValue($mysoc, $localobject3); |
|
275 | + print __METHOD__." result=".$result."\n"; |
|
276 | + $this->assertEquals('0126-0001', $result, 'Test for {mm}{yy}-{0000@1} 3rd invoice'); // counter must be now 1 |
|
277 | + |
|
278 | + // Try an offset when an invoice already exists |
|
279 | + $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000+9990}'; |
|
280 | + $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000+9990}'; |
|
281 | + $result=$numbering->getNextValue($mysoc, $localobject2); |
|
282 | + |
|
283 | + // Now we try with a different fiscal month (forced by mask) |
|
284 | + $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@6}'; |
|
285 | + $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@6}'; |
|
286 | + |
|
287 | + $localobject=new Facture($this->savdb); |
|
288 | + $localobject->initAsSpecimen(); |
|
289 | + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1930); // we use year 1930 to be sure to not have existing invoice for this year |
|
290 | + $numbering=new mod_facture_mercure(); |
|
291 | + $result=$numbering->getNextValue($mysoc, $localobject, 'last'); |
|
292 | + print __METHOD__." result for last=".$result."\n"; |
|
293 | + $this->assertEquals('', $result); // no existing ref into reset range |
|
294 | + $result=$numbering->getNextValue($mysoc, $localobject); |
|
295 | + $result2=$localobject->create($user,1); |
|
296 | + $result3=$localobject->validate($user, $result); |
|
297 | + print __METHOD__." result=".$result."\n"; |
|
298 | + $this->assertEquals('193001-0001', $result); // counter must start to 1 |
|
299 | + $result=$numbering->getNextValue($mysoc, $localobject, 'last'); |
|
300 | + print __METHOD__." result for last=".$result."\n"; |
|
301 | + $this->assertEquals('193001-0001', $result); // last ref into reset range should be same than last created |
|
302 | + |
|
303 | + $localobject=new Facture($this->savdb); |
|
304 | + $localobject->initAsSpecimen(); |
|
305 | + $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1930); // we use same year but fiscal month after |
|
306 | + $numbering=new mod_facture_mercure(); |
|
307 | + $result=$numbering->getNextValue($mysoc, $localobject, 'last'); |
|
308 | + print __METHOD__." result for last=".$result."\n"; |
|
309 | + $this->assertEquals('', $result); // last ref into reset range should be '' |
|
310 | + $result=$numbering->getNextValue($mysoc, $localobject); |
|
311 | + $result2=$localobject->create($user,1); |
|
312 | + $result3=$localobject->validate($user, $result); |
|
313 | + print __METHOD__." result=".$result."\n"; |
|
314 | + $this->assertEquals('193012-0001', $result); // counter must be reset to 1 |
|
315 | + |
|
316 | + $localobject=new Facture($this->savdb); |
|
317 | + $localobject->initAsSpecimen(); |
|
318 | + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1931); // we use same fiscal year but different year |
|
319 | + $numbering=new mod_facture_mercure(); |
|
320 | + $result=$numbering->getNextValue($mysoc, $localobject); |
|
321 | + $result2=$localobject->create($user,1); |
|
322 | + $result3=$localobject->validate($user, $result); |
|
323 | + print __METHOD__." result=".$result."\n"; |
|
324 | + $this->assertEquals('193101-0002', $result); // counter must be 2 |
|
325 | + |
|
326 | + $localobject=new Facture($this->savdb); |
|
327 | + $localobject->initAsSpecimen(); |
|
328 | + $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1931); // we use different fiscal year but same year |
|
329 | + $numbering=new mod_facture_mercure(); |
|
330 | + $result=$numbering->getNextValue($mysoc, $localobject); |
|
331 | + print __METHOD__." result=".$result."\n"; |
|
332 | + $this->assertEquals('193112-0001', $result); // counter must be reset to 1 |
|
333 | + |
|
334 | + |
|
335 | + // Now we try with a different fiscal month (defined by SOCIETE_FISCAL_MONTH_START) |
|
336 | + $conf->global->SOCIETE_FISCAL_MONTH_START=6; |
|
337 | + $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@0}'; |
|
338 | + $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@0}'; |
|
339 | + |
|
340 | + $localobject=new Facture($this->savdb); |
|
341 | + $localobject->initAsSpecimen(); |
|
342 | + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1940); // we use year 1940 to be sure to not have existing invoice for this year |
|
343 | + $numbering=new mod_facture_mercure(); |
|
344 | + $result=$numbering->getNextValue($mysoc, $localobject); |
|
345 | + $result2=$localobject->create($user,1); |
|
346 | + $result3=$localobject->validate($user, $result); |
|
347 | + print __METHOD__." result=".$result."\n"; |
|
348 | + $this->assertEquals('194001-0001', $result); // counter must start to 1 |
|
349 | + |
|
350 | + $localobject=new Facture($this->savdb); |
|
351 | + $localobject->initAsSpecimen(); |
|
352 | + $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1940); // we use same year but fiscal month after |
|
353 | + $numbering=new mod_facture_mercure(); |
|
354 | + $result=$numbering->getNextValue($mysoc, $localobject); |
|
355 | + $result2=$localobject->create($user,1); |
|
356 | + $result3=$localobject->validate($user, $result); |
|
357 | + print __METHOD__." result=".$result."\n"; |
|
358 | + $this->assertEquals('194012-0001', $result); // counter must be reset to 1 |
|
359 | + |
|
360 | + $localobject=new Facture($this->savdb); |
|
361 | + $localobject->initAsSpecimen(); |
|
362 | + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1941); // we use same fiscal year but different year |
|
363 | + $numbering=new mod_facture_mercure(); |
|
364 | + $result=$numbering->getNextValue($mysoc, $localobject); |
|
365 | + $result2=$localobject->create($user,1); |
|
366 | + $result3=$localobject->validate($user, $result); |
|
367 | + print __METHOD__." result=".$result."\n"; |
|
368 | + $this->assertEquals('194101-0002', $result); // counter must be 2 |
|
369 | + |
|
370 | + $localobject=new Facture($this->savdb); |
|
371 | + $localobject->initAsSpecimen(); |
|
372 | + $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1941); // we use different discal year but same year |
|
373 | + $numbering=new mod_facture_mercure(); |
|
374 | + $result=$numbering->getNextValue($mysoc, $localobject); |
|
375 | + print __METHOD__." result=".$result."\n"; |
|
376 | + $this->assertEquals('194112-0001', $result); // counter must be reset to 1 |
|
377 | + |
|
378 | + |
|
379 | + // Now we try with a different fiscal month (defined by SOCIETE_FISCAL_MONTH_START) and we always want year of element |
|
380 | + $conf->global->SOCIETE_FISCAL_MONTH_START=6; |
|
381 | + $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@=}'; |
|
382 | + $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@=}'; |
|
383 | + |
|
384 | + $localobject=new Facture($this->savdb); |
|
385 | + $localobject->initAsSpecimen(); |
|
386 | + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1950); // we use year 1950 to be sure to not have existing invoice for this year |
|
387 | + $numbering=new mod_facture_mercure(); |
|
388 | + $result=$numbering->getNextValue($mysoc, $localobject); |
|
389 | + $result2=$localobject->create($user,1); |
|
390 | + $result3=$localobject->validate($user, $result); |
|
391 | + print __METHOD__." result=".$result."\n"; |
|
392 | + $this->assertEquals('195001-0001', $result); // counter must start to 1 |
|
393 | + |
|
394 | + $localobject=new Facture($this->savdb); |
|
395 | + $localobject->initAsSpecimen(); |
|
396 | + $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1950); // we use same year but fiscal month after |
|
397 | + $numbering=new mod_facture_mercure(); |
|
398 | + $result=$numbering->getNextValue($mysoc, $localobject); |
|
399 | + $result2=$localobject->create($user,1); |
|
400 | + $result3=$localobject->validate($user, $result); |
|
401 | + print __METHOD__." result=".$result."\n"; |
|
402 | + $this->assertEquals('195012-0001', $result); // counter must be reset to 1 |
|
403 | + |
|
404 | + $localobject=new Facture($this->savdb); |
|
405 | + $localobject->initAsSpecimen(); |
|
406 | + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1951); // we use same fiscal year but different year |
|
407 | + $numbering=new mod_facture_mercure(); |
|
408 | + $result=$numbering->getNextValue($mysoc, $localobject); |
|
409 | + $result2=$localobject->create($user,1); |
|
410 | + $result3=$localobject->validate($user, $result); |
|
411 | + print __METHOD__." result=".$result."\n"; |
|
412 | + $this->assertEquals('195101-0002', $result); // counter must be 2 |
|
413 | + |
|
414 | + $localobject=new Facture($this->savdb); |
|
415 | + $localobject->initAsSpecimen(); |
|
416 | + $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1951); // we use different discal year but same year |
|
417 | + $numbering=new mod_facture_mercure(); |
|
418 | + $result=$numbering->getNextValue($mysoc, $localobject); |
|
419 | + print __METHOD__." result=".$result."\n"; |
|
420 | + $this->assertEquals('195112-0001', $result); // counter must be reset to 1 |
|
421 | + |
|
422 | + |
|
423 | + // Now we try with a different fiscal month (defined by SOCIETE_FISCAL_MONTH_START) and we always want start year |
|
424 | + $conf->global->SOCIETE_FISCAL_MONTH_START=6; |
|
425 | + $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@-}'; |
|
426 | + $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@-}'; |
|
427 | + |
|
428 | + $localobject=new Facture($this->savdb); |
|
429 | + $localobject->initAsSpecimen(); |
|
430 | + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1960); // we use year 1960 to be sure to not have existing invoice for this year |
|
431 | + $numbering=new mod_facture_mercure(); |
|
432 | + $result=$numbering->getNextValue($mysoc, $localobject); |
|
433 | + $result2=$localobject->create($user,1); |
|
434 | + $result3=$localobject->validate($user, $result); |
|
435 | + print __METHOD__." result=".$result."\n"; |
|
436 | + $this->assertEquals('195901-0001', $result); // counter must start to 1 |
|
437 | + |
|
438 | + $localobject=new Facture($this->savdb); |
|
439 | + $localobject->initAsSpecimen(); |
|
440 | + $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1960); // we use same year but fiscal month after |
|
441 | + $numbering=new mod_facture_mercure(); |
|
442 | + $result=$numbering->getNextValue($mysoc, $localobject); |
|
443 | + $result2=$localobject->create($user,1); |
|
444 | + $result3=$localobject->validate($user, $result); |
|
445 | + print __METHOD__." result=".$result."\n"; |
|
446 | + $this->assertEquals('196012-0001', $result); // counter must be reset to 1 |
|
447 | + |
|
448 | + $localobject=new Facture($this->savdb); |
|
449 | + $localobject->initAsSpecimen(); |
|
450 | + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1961); // we use same fiscal year but different year |
|
451 | + $numbering=new mod_facture_mercure(); |
|
452 | + $result=$numbering->getNextValue($mysoc, $localobject); |
|
453 | + $result2=$localobject->create($user,1); |
|
454 | + $result3=$localobject->validate($user, $result); |
|
455 | + print __METHOD__." result=".$result."\n"; |
|
456 | + $this->assertEquals('196001-0002', $result); // counter must be 2 |
|
457 | + |
|
458 | + $localobject=new Facture($this->savdb); |
|
459 | + $localobject->initAsSpecimen(); |
|
460 | + $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1961); // we use different discal year but same year |
|
461 | + $numbering=new mod_facture_mercure(); |
|
462 | + $result=$numbering->getNextValue($mysoc, $localobject); |
|
463 | + print __METHOD__." result=".$result."\n"; |
|
464 | + $this->assertEquals('196112-0001', $result); // counter must be reset to 1 |
|
465 | + |
|
466 | + |
|
467 | + // Now we try with a different fiscal month (defined by SOCIETE_FISCAL_MONTH_START) and we always want end year |
|
468 | + $conf->global->SOCIETE_FISCAL_MONTH_START=6; |
|
469 | + $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@+}'; |
|
470 | + $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@+}'; |
|
471 | + |
|
472 | + $localobject=new Facture($this->savdb); |
|
473 | + $localobject->initAsSpecimen(); |
|
474 | + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1970); // we use year 1970 to be sure to not have existing invoice for this year |
|
475 | + $numbering=new mod_facture_mercure(); |
|
476 | + $result=$numbering->getNextValue($mysoc, $localobject); |
|
477 | + $result2=$localobject->create($user,1); |
|
478 | + $result3=$localobject->validate($user, $result); |
|
479 | + print __METHOD__." result=".$result."\n"; |
|
480 | + $this->assertEquals('197001-0001', $result); // counter must start to 1 |
|
481 | + |
|
482 | + $localobject=new Facture($this->savdb); |
|
483 | + $localobject->initAsSpecimen(); |
|
484 | + $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1970); // we use same year but fiscal month after |
|
485 | + $numbering=new mod_facture_mercure(); |
|
486 | + $result=$numbering->getNextValue($mysoc, $localobject); |
|
487 | + $result2=$localobject->create($user,1); |
|
488 | + $result3=$localobject->validate($user, $result); |
|
489 | + print __METHOD__." result=".$result."\n"; |
|
490 | + $this->assertEquals('197112-0001', $result); // counter must be reset to 1 |
|
491 | + |
|
492 | + $localobject=new Facture($this->savdb); |
|
493 | + $localobject->initAsSpecimen(); |
|
494 | + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1971); // we use same fiscal year but different year |
|
495 | + $numbering=new mod_facture_mercure(); |
|
496 | + $result=$numbering->getNextValue($mysoc, $localobject); |
|
497 | + $result2=$localobject->create($user,1); |
|
498 | + $result3=$localobject->validate($user, $result); |
|
499 | + print __METHOD__." result=".$result."\n"; |
|
500 | + $this->assertEquals('197101-0002', $result); // counter must be 2 |
|
501 | + |
|
502 | + $localobject=new Facture($this->savdb); |
|
503 | + $localobject->initAsSpecimen(); |
|
504 | + $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1971); // we use different fiscal year but same year |
|
505 | + $numbering=new mod_facture_mercure(); |
|
506 | + $result=$numbering->getNextValue($mysoc, $localobject); |
|
507 | + print __METHOD__." result=".$result."\n"; |
|
508 | + $this->assertEquals('197212-0001', $result); // counter must be reset to 1 |
|
509 | + |
|
510 | + // Now we try with a reset every month (@99) |
|
511 | + $conf->global->SOCIETE_FISCAL_MONTH_START=6; |
|
512 | + $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@99}'; |
|
513 | + $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@99}'; |
|
514 | + |
|
515 | + $localobject=new Facture($this->savdb); |
|
516 | + $localobject->initAsSpecimen(); |
|
517 | + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1980); // we use year 1980 to be sure to not have existing invoice for this year |
|
518 | + $numbering=new mod_facture_mercure(); |
|
519 | + $result=$numbering->getNextValue($mysoc, $localobject); |
|
520 | + $result2=$localobject->create($user,1); |
|
521 | + $result3=$localobject->validate($user, $result); |
|
522 | + print __METHOD__." result=".$result."\n"; |
|
523 | + $this->assertEquals('198001-0001', $result); // counter must start to 1 |
|
524 | + |
|
525 | + $localobject=new Facture($this->savdb); |
|
526 | + $localobject->initAsSpecimen(); |
|
527 | + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1980); // we use year 1980 to be sure to not have existing invoice for this year |
|
528 | + $numbering=new mod_facture_mercure(); |
|
529 | + $result=$numbering->getNextValue($mysoc, $localobject); |
|
530 | + $result2=$localobject->create($user,1); |
|
531 | + $result3=$localobject->validate($user, $result); |
|
532 | + print __METHOD__." result=".$result."\n"; |
|
533 | + $this->assertEquals('198001-0002', $result); // counter must start to 2 |
|
534 | + |
|
535 | + $localobject=new Facture($this->savdb); |
|
536 | + $localobject->initAsSpecimen(); |
|
537 | + $localobject->date=dol_mktime(12, 0, 0, 2, 1, 1980); // we use year 1980 to be sure to not have existing invoice for this year |
|
538 | + $numbering=new mod_facture_mercure(); |
|
539 | + $result=$numbering->getNextValue($mysoc, $localobject); |
|
540 | + $result2=$localobject->create($user,1); |
|
541 | + $result3=$localobject->validate($user, $result); |
|
542 | + print __METHOD__." result=".$result."\n"; |
|
543 | + $this->assertEquals('198002-0001', $result); // counter must start to 1 |
|
544 | + |
|
545 | + $localobject=new Facture($this->savdb); |
|
546 | + $localobject->initAsSpecimen(); |
|
547 | + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1981); // we use year 1981 to be sure to not have existing invoice for this year |
|
548 | + $numbering=new mod_facture_mercure(); |
|
549 | + $result=$numbering->getNextValue($mysoc, $localobject); |
|
550 | + $result2=$localobject->create($user,1); |
|
551 | + $result3=$localobject->validate($user, $result); |
|
552 | + print __METHOD__." result=".$result."\n"; |
|
553 | + $this->assertEquals('198101-0001', $result); // counter must start to 1 |
|
554 | + |
|
555 | + // Test with {t} tag |
|
556 | + $conf->global->SOCIETE_FISCAL_MONTH_START=1; |
|
557 | + $conf->global->FACTURE_MERCURE_MASK_CREDIT='{t}{yyyy}{mm}-{0000}'; |
|
558 | + $conf->global->FACTURE_MERCURE_MASK_INVOICE='{t}{yyyy}{mm}-{0000}'; |
|
559 | + |
|
560 | + $tmpthirdparty=new Societe($this->savdb); |
|
561 | + $tmpthirdparty->initAsSpecimen(); |
|
562 | + $tmpthirdparty->typent_code = 'TE_ABC'; |
|
563 | + |
|
564 | + $localobject=new Facture($this->savdb); |
|
565 | + $localobject->initAsSpecimen(); |
|
566 | + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1982); // we use year 1982 to be sure to not have existing invoice for this year |
|
567 | + $numbering=new mod_facture_mercure(); |
|
568 | + $result=$numbering->getNextValue($tmpthirdparty, $localobject); |
|
569 | + $result2=$localobject->create($user,1); |
|
570 | + $result3=$localobject->validate($user, $result); |
|
571 | + print __METHOD__." result=".$result."\n"; |
|
572 | + $this->assertEquals('A198201-0001', $result); // counter must start to 1 |
|
573 | + |
|
574 | + |
|
575 | + |
|
576 | + return $result; |
|
577 | 577 | } |
578 | 578 | } |
@@ -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,9 +76,9 @@ discard block |
||
76 | 76 | // Static methods |
77 | 77 | public static function setUpBeforeClass() |
78 | 78 | { |
79 | - global $conf,$user,$langs,$db; |
|
79 | + global $conf, $user, $langs, $db; |
|
80 | 80 | |
81 | - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
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 | } |
@@ -125,451 +125,451 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function testFactureMercure() |
127 | 127 | { |
128 | - global $conf,$user,$langs,$db,$mysoc; |
|
129 | - $conf=$this->savconf; |
|
130 | - $user=$this->savuser; |
|
131 | - $langs=$this->savlangs; |
|
132 | - $db=$this->savdb; |
|
128 | + global $conf, $user, $langs, $db, $mysoc; |
|
129 | + $conf = $this->savconf; |
|
130 | + $user = $this->savuser; |
|
131 | + $langs = $this->savlangs; |
|
132 | + $db = $this->savdb; |
|
133 | 133 | |
134 | 134 | require_once dirname(__FILE__).'/../../htdocs/compta/facture/class/facture.class.php'; |
135 | 135 | require_once dirname(__FILE__).'/../../htdocs/core/modules/facture/mod_facture_mercure.php'; |
136 | 136 | |
137 | 137 | // First we try with a simple mask, with no reset |
138 | 138 | // and we test counter is still increase second year. |
139 | - $conf->global->FACTURE_ADDON='mercure'; |
|
140 | - $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}-{0000}'; |
|
141 | - $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}-{0000}'; |
|
142 | - $conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED=0; |
|
139 | + $conf->global->FACTURE_ADDON = 'mercure'; |
|
140 | + $conf->global->FACTURE_MERCURE_MASK_CREDIT = '{yyyy}-{0000}'; |
|
141 | + $conf->global->FACTURE_MERCURE_MASK_INVOICE = '{yyyy}-{0000}'; |
|
142 | + $conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED = 0; |
|
143 | 143 | |
144 | - $localobject=new Facture($this->savdb); |
|
144 | + $localobject = new Facture($this->savdb); |
|
145 | 145 | $localobject->initAsSpecimen(); |
146 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1915); // we use year 1915 to be sure to not have existing invoice for this year |
|
147 | - $numbering=new mod_facture_mercure(); |
|
148 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
146 | + $localobject->date = dol_mktime(12, 0, 0, 1, 1, 1915); // we use year 1915 to be sure to not have existing invoice for this year |
|
147 | + $numbering = new mod_facture_mercure(); |
|
148 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
149 | 149 | print __METHOD__." result=".$result."\n"; |
150 | - $this->assertEquals('1915-0001', $result, 'Test for {yyyy}-{0000}, 1st invoice'); // counter must start to 1 |
|
151 | - $result2=$localobject->create($user,1); |
|
150 | + $this->assertEquals('1915-0001', $result, 'Test for {yyyy}-{0000}, 1st invoice'); // counter must start to 1 |
|
151 | + $result2 = $localobject->create($user, 1); |
|
152 | 152 | print __METHOD__." result2=".$result."\n"; |
153 | - $result3=$localobject->validate($user, $result); // create invoice by forcing ref |
|
153 | + $result3 = $localobject->validate($user, $result); // create invoice by forcing ref |
|
154 | 154 | print __METHOD__." result3=".$result."\n"; |
155 | - $this->assertEquals(1, $result3, 'Test validation of invoice with forced ref is ok'); // counter must start to 1 |
|
156 | - $result=$localobject->is_erasable(); |
|
155 | + $this->assertEquals(1, $result3, 'Test validation of invoice with forced ref is ok'); // counter must start to 1 |
|
156 | + $result = $localobject->is_erasable(); |
|
157 | 157 | print __METHOD__." is_erasable=".$result."\n"; |
158 | - $this->assertGreaterThanOrEqual(1, $result, 'Test for is_erasable, 1st invoice'); // Can be deleted |
|
159 | - $localobject2=new Facture($this->savdb); |
|
158 | + $this->assertGreaterThanOrEqual(1, $result, 'Test for is_erasable, 1st invoice'); // Can be deleted |
|
159 | + $localobject2 = new Facture($this->savdb); |
|
160 | 160 | $localobject2->initAsSpecimen(); |
161 | - $localobject2->date=dol_mktime(12, 0, 0, 1, 1, 1916); // we use following year for second invoice (there is no reset into mask) |
|
162 | - $numbering=new mod_facture_mercure(); |
|
163 | - $result=$numbering->getNextValue($mysoc, $localobject2, 'last'); |
|
161 | + $localobject2->date = dol_mktime(12, 0, 0, 1, 1, 1916); // we use following year for second invoice (there is no reset into mask) |
|
162 | + $numbering = new mod_facture_mercure(); |
|
163 | + $result = $numbering->getNextValue($mysoc, $localobject2, 'last'); |
|
164 | 164 | print __METHOD__." result=".$result."\n"; |
165 | 165 | $this->assertEquals('1915-0001', $result, "Test to get last value with param 'last'"); |
166 | - $result=$numbering->getNextValue($mysoc, $localobject2); |
|
166 | + $result = $numbering->getNextValue($mysoc, $localobject2); |
|
167 | 167 | print __METHOD__." result=".$result."\n"; |
168 | - $this->assertEquals('1916-0002', $result); // counter must be now 2 (not reseted) |
|
169 | - $result2=$localobject2->create($user,1); |
|
168 | + $this->assertEquals('1916-0002', $result); // counter must be now 2 (not reseted) |
|
169 | + $result2 = $localobject2->create($user, 1); |
|
170 | 170 | print __METHOD__." result2=".$result."\n"; |
171 | - $result3=$localobject2->validate($user, $result); // create invoice by forcing ref |
|
171 | + $result3 = $localobject2->validate($user, $result); // create invoice by forcing ref |
|
172 | 172 | print __METHOD__." result3=".$result."\n"; |
173 | - $this->assertEquals(1, $result3, 'Test validation of invoice with forced ref is ok'); // counter must start to 1 |
|
174 | - $result=$localobject2->is_erasable(); |
|
173 | + $this->assertEquals(1, $result3, 'Test validation of invoice with forced ref is ok'); // counter must start to 1 |
|
174 | + $result = $localobject2->is_erasable(); |
|
175 | 175 | print __METHOD__." is_erasable=".$result."\n"; |
176 | - $this->assertGreaterThanOrEqual(1, $result); // Can be deleted |
|
177 | - $result=$localobject->is_erasable(); |
|
176 | + $this->assertGreaterThanOrEqual(1, $result); // Can be deleted |
|
177 | + $result = $localobject->is_erasable(); |
|
178 | 178 | print __METHOD__." is_erasable=".$result."\n"; |
179 | - $this->assertLessThanOrEqual(0, $result, 'Test for {yyyy}-{0000} that is_erasable is 0 for 1st invoice'); // 1 can no more be deleted (2 is more recent) |
|
179 | + $this->assertLessThanOrEqual(0, $result, 'Test for {yyyy}-{0000} that is_erasable is 0 for 1st invoice'); // 1 can no more be deleted (2 is more recent) |
|
180 | 180 | |
181 | 181 | // Now we try with a reset |
182 | - $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}-{0000@1}'; |
|
183 | - $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}-{0000@1}'; |
|
182 | + $conf->global->FACTURE_MERCURE_MASK_CREDIT = '{yyyy}-{0000@1}'; |
|
183 | + $conf->global->FACTURE_MERCURE_MASK_INVOICE = '{yyyy}-{0000@1}'; |
|
184 | 184 | |
185 | - $localobject=new Facture($this->savdb); |
|
185 | + $localobject = new Facture($this->savdb); |
|
186 | 186 | $localobject->initAsSpecimen(); |
187 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1910); // we use year 1910 to be sure to not have existing invoice for this year |
|
188 | - $numbering=new mod_facture_mercure(); |
|
189 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
190 | - $result2=$localobject->create($user,1); |
|
191 | - $result3=$localobject->validate($user, $result); |
|
187 | + $localobject->date = dol_mktime(12, 0, 0, 1, 1, 1910); // we use year 1910 to be sure to not have existing invoice for this year |
|
188 | + $numbering = new mod_facture_mercure(); |
|
189 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
190 | + $result2 = $localobject->create($user, 1); |
|
191 | + $result3 = $localobject->validate($user, $result); |
|
192 | 192 | print __METHOD__." result=".$result."\n"; |
193 | - $this->assertEquals('1910-0001', $result, 'Test for {yyyy}-{0000@1} 1st invoice'); // counter must start to 1 |
|
194 | - $localobject2=new Facture($this->savdb); |
|
193 | + $this->assertEquals('1910-0001', $result, 'Test for {yyyy}-{0000@1} 1st invoice'); // counter must start to 1 |
|
194 | + $localobject2 = new Facture($this->savdb); |
|
195 | 195 | $localobject2->initAsSpecimen(); |
196 | - $localobject2->date=dol_mktime(12, 0, 0, 1, 1, 1910); // we use same year for second invoice (and there is a reset required) |
|
197 | - $numbering=new mod_facture_mercure(); |
|
198 | - $result=$numbering->getNextValue($mysoc, $localobject2); |
|
196 | + $localobject2->date = dol_mktime(12, 0, 0, 1, 1, 1910); // we use same year for second invoice (and there is a reset required) |
|
197 | + $numbering = new mod_facture_mercure(); |
|
198 | + $result = $numbering->getNextValue($mysoc, $localobject2); |
|
199 | 199 | print __METHOD__." result=".$result."\n"; |
200 | - $this->assertEquals('1910-0002', $result, 'Test for {yyyy}-{0000@1} 2nd invoice, same day'); // counter must be now 2 |
|
201 | - $localobject3=new Facture($this->savdb); |
|
200 | + $this->assertEquals('1910-0002', $result, 'Test for {yyyy}-{0000@1} 2nd invoice, same day'); // counter must be now 2 |
|
201 | + $localobject3 = new Facture($this->savdb); |
|
202 | 202 | $localobject3->initAsSpecimen(); |
203 | - $localobject3->date=dol_mktime(12, 0, 0, 1, 1, 1911); // we use next year for third invoice (and there is a reset required) |
|
204 | - $numbering=new mod_facture_mercure(); |
|
205 | - $result=$numbering->getNextValue($mysoc, $localobject3); |
|
203 | + $localobject3->date = dol_mktime(12, 0, 0, 1, 1, 1911); // we use next year for third invoice (and there is a reset required) |
|
204 | + $numbering = new mod_facture_mercure(); |
|
205 | + $result = $numbering->getNextValue($mysoc, $localobject3); |
|
206 | 206 | print __METHOD__." result=".$result."\n"; |
207 | - $this->assertEquals('1911-0001', $result, 'Test for {yyyy}-{0000@1} 3nd invoice, same day'); // counter must be now 1 |
|
207 | + $this->assertEquals('1911-0001', $result, 'Test for {yyyy}-{0000@1} 3nd invoice, same day'); // counter must be now 1 |
|
208 | 208 | |
209 | 209 | // Same but we add month after year |
210 | - $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@1}'; |
|
211 | - $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@1}'; |
|
212 | - $localobject=new Facture($this->savdb); |
|
210 | + $conf->global->FACTURE_MERCURE_MASK_CREDIT = '{yyyy}{mm}-{0000@1}'; |
|
211 | + $conf->global->FACTURE_MERCURE_MASK_INVOICE = '{yyyy}{mm}-{0000@1}'; |
|
212 | + $localobject = new Facture($this->savdb); |
|
213 | 213 | $localobject->initAsSpecimen(); |
214 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1920); // we use year 1920 to be sure to not have existing invoice for this year |
|
215 | - $numbering=new mod_facture_mercure(); |
|
216 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
217 | - $result2=$localobject->create($user,1); |
|
218 | - $result3=$localobject->validate($user, $result); |
|
214 | + $localobject->date = dol_mktime(12, 0, 0, 1, 1, 1920); // we use year 1920 to be sure to not have existing invoice for this year |
|
215 | + $numbering = new mod_facture_mercure(); |
|
216 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
217 | + $result2 = $localobject->create($user, 1); |
|
218 | + $result3 = $localobject->validate($user, $result); |
|
219 | 219 | print __METHOD__." result=".$result."\n"; |
220 | - $this->assertEquals('192001-0001', $result, 'Test for {yyyy}{mm}-{0000@1} 1st invoice'); // counter must start to 1 |
|
221 | - $result=$localobject->is_erasable(); |
|
220 | + $this->assertEquals('192001-0001', $result, 'Test for {yyyy}{mm}-{0000@1} 1st invoice'); // counter must start to 1 |
|
221 | + $result = $localobject->is_erasable(); |
|
222 | 222 | print __METHOD__." is_erasable=".$result."\n"; |
223 | - $this->assertGreaterThanOrEqual(1, $result); // Can be deleted |
|
224 | - $localobject2=new Facture($this->savdb); |
|
223 | + $this->assertGreaterThanOrEqual(1, $result); // Can be deleted |
|
224 | + $localobject2 = new Facture($this->savdb); |
|
225 | 225 | $localobject2->initAsSpecimen(); |
226 | - $localobject2->date=dol_mktime(12, 0, 0, 1, 1, 1921); // we use following year for second invoice (and there is a reset required) |
|
227 | - $numbering=new mod_facture_mercure(); |
|
228 | - $result=$numbering->getNextValue($mysoc, $localobject2); |
|
229 | - $result2=$localobject2->create($user,1); |
|
230 | - $result3=$localobject2->validate($user, $result); |
|
226 | + $localobject2->date = dol_mktime(12, 0, 0, 1, 1, 1921); // we use following year for second invoice (and there is a reset required) |
|
227 | + $numbering = new mod_facture_mercure(); |
|
228 | + $result = $numbering->getNextValue($mysoc, $localobject2); |
|
229 | + $result2 = $localobject2->create($user, 1); |
|
230 | + $result3 = $localobject2->validate($user, $result); |
|
231 | 231 | print __METHOD__." result=".$result."\n"; |
232 | - $this->assertEquals('192101-0001', $result); // counter must be reseted to 1 |
|
233 | - $result=$localobject2->is_erasable(); |
|
232 | + $this->assertEquals('192101-0001', $result); // counter must be reseted to 1 |
|
233 | + $result = $localobject2->is_erasable(); |
|
234 | 234 | print __METHOD__." is_erasable=".$result."\n"; |
235 | - $this->assertGreaterThanOrEqual(1, $result); // Can be deleted |
|
236 | - $result=$localobject->is_erasable(); |
|
235 | + $this->assertGreaterThanOrEqual(1, $result); // Can be deleted |
|
236 | + $result = $localobject->is_erasable(); |
|
237 | 237 | print __METHOD__." is_erasable=".$result."\n"; |
238 | - $this->assertGreaterThanOrEqual(1, $result); // Case 1 can be deleted (because there was a reset for case 2) |
|
238 | + $this->assertGreaterThanOrEqual(1, $result); // Case 1 can be deleted (because there was a reset for case 2) |
|
239 | 239 | |
240 | 240 | // Same but we add month before year and use a year on 2 digits |
241 | - $conf->global->FACTURE_MERCURE_MASK_CREDIT='[mm}{yy}-{0000@1}'; |
|
242 | - $conf->global->FACTURE_MERCURE_MASK_INVOICE='{mm}{yy}-{0000@1}'; |
|
243 | - $localobject=new Facture($this->savdb); |
|
241 | + $conf->global->FACTURE_MERCURE_MASK_CREDIT = '[mm}{yy}-{0000@1}'; |
|
242 | + $conf->global->FACTURE_MERCURE_MASK_INVOICE = '{mm}{yy}-{0000@1}'; |
|
243 | + $localobject = new Facture($this->savdb); |
|
244 | 244 | $localobject->initAsSpecimen(); |
245 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1925); // we use year 1925 to be sure to not have existing invoice for this year |
|
246 | - $numbering=new mod_facture_mercure(); |
|
247 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
248 | - $result2=$localobject->create($user,1); |
|
249 | - $result3=$localobject->validate($user, $result); |
|
245 | + $localobject->date = dol_mktime(12, 0, 0, 1, 1, 1925); // we use year 1925 to be sure to not have existing invoice for this year |
|
246 | + $numbering = new mod_facture_mercure(); |
|
247 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
248 | + $result2 = $localobject->create($user, 1); |
|
249 | + $result3 = $localobject->validate($user, $result); |
|
250 | 250 | print __METHOD__." result=".$result."\n"; |
251 | - $this->assertEquals('0125-0001', $result, 'Test for {mm}{yy}-{0000@1} 1st invoice'); // counter must start to 1 |
|
252 | - $result=$localobject->is_erasable(); // This call get getNextNumRef with param 'last' |
|
251 | + $this->assertEquals('0125-0001', $result, 'Test for {mm}{yy}-{0000@1} 1st invoice'); // counter must start to 1 |
|
252 | + $result = $localobject->is_erasable(); // This call get getNextNumRef with param 'last' |
|
253 | 253 | print __METHOD__." is_erasable=".$result."\n"; |
254 | - $this->assertGreaterThanOrEqual(1, $result); // Can be deleted |
|
255 | - $localobject2=new Facture($this->savdb); |
|
254 | + $this->assertGreaterThanOrEqual(1, $result); // Can be deleted |
|
255 | + $localobject2 = new Facture($this->savdb); |
|
256 | 256 | $localobject2->initAsSpecimen(); |
257 | - $localobject2->date=dol_mktime(12, 0, 0, 1, 1, 1925); // we use same year 1925 for second invoice (and there is a reset required) |
|
258 | - $numbering=new mod_facture_mercure(); |
|
259 | - $result=$numbering->getNextValue($mysoc, $localobject2); |
|
260 | - $result2=$localobject2->create($user,1); |
|
261 | - $result3=$localobject2->validate($user, $result); |
|
257 | + $localobject2->date = dol_mktime(12, 0, 0, 1, 1, 1925); // we use same year 1925 for second invoice (and there is a reset required) |
|
258 | + $numbering = new mod_facture_mercure(); |
|
259 | + $result = $numbering->getNextValue($mysoc, $localobject2); |
|
260 | + $result2 = $localobject2->create($user, 1); |
|
261 | + $result3 = $localobject2->validate($user, $result); |
|
262 | 262 | print __METHOD__." result=".$result."\n"; |
263 | - $this->assertEquals('0125-0002', $result, 'Test for {mm}{yy}-{0000@1} 2st invoice'); // counter must be now 2 |
|
264 | - $result=$localobject2->is_erasable(); |
|
263 | + $this->assertEquals('0125-0002', $result, 'Test for {mm}{yy}-{0000@1} 2st invoice'); // counter must be now 2 |
|
264 | + $result = $localobject2->is_erasable(); |
|
265 | 265 | print __METHOD__." is_erasable=".$result."\n"; |
266 | - $this->assertGreaterThanOrEqual(1, $result); // Can be deleted |
|
267 | - $result=$localobject->is_erasable(); |
|
266 | + $this->assertGreaterThanOrEqual(1, $result); // Can be deleted |
|
267 | + $result = $localobject->is_erasable(); |
|
268 | 268 | print __METHOD__." is_erasable=".$result."\n"; |
269 | - $this->assertLessThanOrEqual(0, $result); // Case 1 can not be deleted (because there is an invoice 2) |
|
270 | - $localobject3=new Facture($this->savdb); |
|
269 | + $this->assertLessThanOrEqual(0, $result); // Case 1 can not be deleted (because there is an invoice 2) |
|
270 | + $localobject3 = new Facture($this->savdb); |
|
271 | 271 | $localobject3->initAsSpecimen(); |
272 | - $localobject3->date=dol_mktime(12, 0, 0, 1, 1, 1926); // we use following year for third invoice (and there is a reset required) |
|
273 | - $numbering=new mod_facture_mercure(); |
|
274 | - $result=$numbering->getNextValue($mysoc, $localobject3); |
|
272 | + $localobject3->date = dol_mktime(12, 0, 0, 1, 1, 1926); // we use following year for third invoice (and there is a reset required) |
|
273 | + $numbering = new mod_facture_mercure(); |
|
274 | + $result = $numbering->getNextValue($mysoc, $localobject3); |
|
275 | 275 | print __METHOD__." result=".$result."\n"; |
276 | - $this->assertEquals('0126-0001', $result, 'Test for {mm}{yy}-{0000@1} 3rd invoice'); // counter must be now 1 |
|
276 | + $this->assertEquals('0126-0001', $result, 'Test for {mm}{yy}-{0000@1} 3rd invoice'); // counter must be now 1 |
|
277 | 277 | |
278 | 278 | // Try an offset when an invoice already exists |
279 | - $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000+9990}'; |
|
280 | - $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000+9990}'; |
|
281 | - $result=$numbering->getNextValue($mysoc, $localobject2); |
|
279 | + $conf->global->FACTURE_MERCURE_MASK_CREDIT = '{yyyy}{mm}-{0000+9990}'; |
|
280 | + $conf->global->FACTURE_MERCURE_MASK_INVOICE = '{yyyy}{mm}-{0000+9990}'; |
|
281 | + $result = $numbering->getNextValue($mysoc, $localobject2); |
|
282 | 282 | |
283 | 283 | // Now we try with a different fiscal month (forced by mask) |
284 | - $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@6}'; |
|
285 | - $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@6}'; |
|
284 | + $conf->global->FACTURE_MERCURE_MASK_CREDIT = '{yyyy}{mm}-{0000@6}'; |
|
285 | + $conf->global->FACTURE_MERCURE_MASK_INVOICE = '{yyyy}{mm}-{0000@6}'; |
|
286 | 286 | |
287 | - $localobject=new Facture($this->savdb); |
|
287 | + $localobject = new Facture($this->savdb); |
|
288 | 288 | $localobject->initAsSpecimen(); |
289 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1930); // we use year 1930 to be sure to not have existing invoice for this year |
|
290 | - $numbering=new mod_facture_mercure(); |
|
291 | - $result=$numbering->getNextValue($mysoc, $localobject, 'last'); |
|
289 | + $localobject->date = dol_mktime(12, 0, 0, 1, 1, 1930); // we use year 1930 to be sure to not have existing invoice for this year |
|
290 | + $numbering = new mod_facture_mercure(); |
|
291 | + $result = $numbering->getNextValue($mysoc, $localobject, 'last'); |
|
292 | 292 | print __METHOD__." result for last=".$result."\n"; |
293 | - $this->assertEquals('', $result); // no existing ref into reset range |
|
294 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
295 | - $result2=$localobject->create($user,1); |
|
296 | - $result3=$localobject->validate($user, $result); |
|
293 | + $this->assertEquals('', $result); // no existing ref into reset range |
|
294 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
295 | + $result2 = $localobject->create($user, 1); |
|
296 | + $result3 = $localobject->validate($user, $result); |
|
297 | 297 | print __METHOD__." result=".$result."\n"; |
298 | - $this->assertEquals('193001-0001', $result); // counter must start to 1 |
|
299 | - $result=$numbering->getNextValue($mysoc, $localobject, 'last'); |
|
298 | + $this->assertEquals('193001-0001', $result); // counter must start to 1 |
|
299 | + $result = $numbering->getNextValue($mysoc, $localobject, 'last'); |
|
300 | 300 | print __METHOD__." result for last=".$result."\n"; |
301 | - $this->assertEquals('193001-0001', $result); // last ref into reset range should be same than last created |
|
301 | + $this->assertEquals('193001-0001', $result); // last ref into reset range should be same than last created |
|
302 | 302 | |
303 | - $localobject=new Facture($this->savdb); |
|
303 | + $localobject = new Facture($this->savdb); |
|
304 | 304 | $localobject->initAsSpecimen(); |
305 | - $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1930); // we use same year but fiscal month after |
|
306 | - $numbering=new mod_facture_mercure(); |
|
307 | - $result=$numbering->getNextValue($mysoc, $localobject, 'last'); |
|
305 | + $localobject->date = dol_mktime(12, 0, 0, 12, 1, 1930); // we use same year but fiscal month after |
|
306 | + $numbering = new mod_facture_mercure(); |
|
307 | + $result = $numbering->getNextValue($mysoc, $localobject, 'last'); |
|
308 | 308 | print __METHOD__." result for last=".$result."\n"; |
309 | - $this->assertEquals('', $result); // last ref into reset range should be '' |
|
310 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
311 | - $result2=$localobject->create($user,1); |
|
312 | - $result3=$localobject->validate($user, $result); |
|
309 | + $this->assertEquals('', $result); // last ref into reset range should be '' |
|
310 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
311 | + $result2 = $localobject->create($user, 1); |
|
312 | + $result3 = $localobject->validate($user, $result); |
|
313 | 313 | print __METHOD__." result=".$result."\n"; |
314 | - $this->assertEquals('193012-0001', $result); // counter must be reset to 1 |
|
314 | + $this->assertEquals('193012-0001', $result); // counter must be reset to 1 |
|
315 | 315 | |
316 | - $localobject=new Facture($this->savdb); |
|
316 | + $localobject = new Facture($this->savdb); |
|
317 | 317 | $localobject->initAsSpecimen(); |
318 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1931); // we use same fiscal year but different year |
|
319 | - $numbering=new mod_facture_mercure(); |
|
320 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
321 | - $result2=$localobject->create($user,1); |
|
322 | - $result3=$localobject->validate($user, $result); |
|
318 | + $localobject->date = dol_mktime(12, 0, 0, 1, 1, 1931); // we use same fiscal year but different year |
|
319 | + $numbering = new mod_facture_mercure(); |
|
320 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
321 | + $result2 = $localobject->create($user, 1); |
|
322 | + $result3 = $localobject->validate($user, $result); |
|
323 | 323 | print __METHOD__." result=".$result."\n"; |
324 | - $this->assertEquals('193101-0002', $result); // counter must be 2 |
|
324 | + $this->assertEquals('193101-0002', $result); // counter must be 2 |
|
325 | 325 | |
326 | - $localobject=new Facture($this->savdb); |
|
326 | + $localobject = new Facture($this->savdb); |
|
327 | 327 | $localobject->initAsSpecimen(); |
328 | - $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1931); // we use different fiscal year but same year |
|
329 | - $numbering=new mod_facture_mercure(); |
|
330 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
328 | + $localobject->date = dol_mktime(12, 0, 0, 12, 1, 1931); // we use different fiscal year but same year |
|
329 | + $numbering = new mod_facture_mercure(); |
|
330 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
331 | 331 | print __METHOD__." result=".$result."\n"; |
332 | - $this->assertEquals('193112-0001', $result); // counter must be reset to 1 |
|
332 | + $this->assertEquals('193112-0001', $result); // counter must be reset to 1 |
|
333 | 333 | |
334 | 334 | |
335 | 335 | // Now we try with a different fiscal month (defined by SOCIETE_FISCAL_MONTH_START) |
336 | - $conf->global->SOCIETE_FISCAL_MONTH_START=6; |
|
337 | - $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@0}'; |
|
338 | - $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@0}'; |
|
336 | + $conf->global->SOCIETE_FISCAL_MONTH_START = 6; |
|
337 | + $conf->global->FACTURE_MERCURE_MASK_CREDIT = '{yyyy}{mm}-{0000@0}'; |
|
338 | + $conf->global->FACTURE_MERCURE_MASK_INVOICE = '{yyyy}{mm}-{0000@0}'; |
|
339 | 339 | |
340 | - $localobject=new Facture($this->savdb); |
|
340 | + $localobject = new Facture($this->savdb); |
|
341 | 341 | $localobject->initAsSpecimen(); |
342 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1940); // we use year 1940 to be sure to not have existing invoice for this year |
|
343 | - $numbering=new mod_facture_mercure(); |
|
344 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
345 | - $result2=$localobject->create($user,1); |
|
346 | - $result3=$localobject->validate($user, $result); |
|
342 | + $localobject->date = dol_mktime(12, 0, 0, 1, 1, 1940); // we use year 1940 to be sure to not have existing invoice for this year |
|
343 | + $numbering = new mod_facture_mercure(); |
|
344 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
345 | + $result2 = $localobject->create($user, 1); |
|
346 | + $result3 = $localobject->validate($user, $result); |
|
347 | 347 | print __METHOD__." result=".$result."\n"; |
348 | - $this->assertEquals('194001-0001', $result); // counter must start to 1 |
|
348 | + $this->assertEquals('194001-0001', $result); // counter must start to 1 |
|
349 | 349 | |
350 | - $localobject=new Facture($this->savdb); |
|
350 | + $localobject = new Facture($this->savdb); |
|
351 | 351 | $localobject->initAsSpecimen(); |
352 | - $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1940); // we use same year but fiscal month after |
|
353 | - $numbering=new mod_facture_mercure(); |
|
354 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
355 | - $result2=$localobject->create($user,1); |
|
356 | - $result3=$localobject->validate($user, $result); |
|
352 | + $localobject->date = dol_mktime(12, 0, 0, 12, 1, 1940); // we use same year but fiscal month after |
|
353 | + $numbering = new mod_facture_mercure(); |
|
354 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
355 | + $result2 = $localobject->create($user, 1); |
|
356 | + $result3 = $localobject->validate($user, $result); |
|
357 | 357 | print __METHOD__." result=".$result."\n"; |
358 | - $this->assertEquals('194012-0001', $result); // counter must be reset to 1 |
|
358 | + $this->assertEquals('194012-0001', $result); // counter must be reset to 1 |
|
359 | 359 | |
360 | - $localobject=new Facture($this->savdb); |
|
360 | + $localobject = new Facture($this->savdb); |
|
361 | 361 | $localobject->initAsSpecimen(); |
362 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1941); // we use same fiscal year but different year |
|
363 | - $numbering=new mod_facture_mercure(); |
|
364 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
365 | - $result2=$localobject->create($user,1); |
|
366 | - $result3=$localobject->validate($user, $result); |
|
362 | + $localobject->date = dol_mktime(12, 0, 0, 1, 1, 1941); // we use same fiscal year but different year |
|
363 | + $numbering = new mod_facture_mercure(); |
|
364 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
365 | + $result2 = $localobject->create($user, 1); |
|
366 | + $result3 = $localobject->validate($user, $result); |
|
367 | 367 | print __METHOD__." result=".$result."\n"; |
368 | - $this->assertEquals('194101-0002', $result); // counter must be 2 |
|
368 | + $this->assertEquals('194101-0002', $result); // counter must be 2 |
|
369 | 369 | |
370 | - $localobject=new Facture($this->savdb); |
|
370 | + $localobject = new Facture($this->savdb); |
|
371 | 371 | $localobject->initAsSpecimen(); |
372 | - $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1941); // we use different discal year but same year |
|
373 | - $numbering=new mod_facture_mercure(); |
|
374 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
372 | + $localobject->date = dol_mktime(12, 0, 0, 12, 1, 1941); // we use different discal year but same year |
|
373 | + $numbering = new mod_facture_mercure(); |
|
374 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
375 | 375 | print __METHOD__." result=".$result."\n"; |
376 | - $this->assertEquals('194112-0001', $result); // counter must be reset to 1 |
|
376 | + $this->assertEquals('194112-0001', $result); // counter must be reset to 1 |
|
377 | 377 | |
378 | 378 | |
379 | 379 | // Now we try with a different fiscal month (defined by SOCIETE_FISCAL_MONTH_START) and we always want year of element |
380 | - $conf->global->SOCIETE_FISCAL_MONTH_START=6; |
|
381 | - $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@=}'; |
|
382 | - $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@=}'; |
|
380 | + $conf->global->SOCIETE_FISCAL_MONTH_START = 6; |
|
381 | + $conf->global->FACTURE_MERCURE_MASK_CREDIT = '{yyyy}{mm}-{0000@=}'; |
|
382 | + $conf->global->FACTURE_MERCURE_MASK_INVOICE = '{yyyy}{mm}-{0000@=}'; |
|
383 | 383 | |
384 | - $localobject=new Facture($this->savdb); |
|
384 | + $localobject = new Facture($this->savdb); |
|
385 | 385 | $localobject->initAsSpecimen(); |
386 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1950); // we use year 1950 to be sure to not have existing invoice for this year |
|
387 | - $numbering=new mod_facture_mercure(); |
|
388 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
389 | - $result2=$localobject->create($user,1); |
|
390 | - $result3=$localobject->validate($user, $result); |
|
386 | + $localobject->date = dol_mktime(12, 0, 0, 1, 1, 1950); // we use year 1950 to be sure to not have existing invoice for this year |
|
387 | + $numbering = new mod_facture_mercure(); |
|
388 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
389 | + $result2 = $localobject->create($user, 1); |
|
390 | + $result3 = $localobject->validate($user, $result); |
|
391 | 391 | print __METHOD__." result=".$result."\n"; |
392 | - $this->assertEquals('195001-0001', $result); // counter must start to 1 |
|
392 | + $this->assertEquals('195001-0001', $result); // counter must start to 1 |
|
393 | 393 | |
394 | - $localobject=new Facture($this->savdb); |
|
394 | + $localobject = new Facture($this->savdb); |
|
395 | 395 | $localobject->initAsSpecimen(); |
396 | - $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1950); // we use same year but fiscal month after |
|
397 | - $numbering=new mod_facture_mercure(); |
|
398 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
399 | - $result2=$localobject->create($user,1); |
|
400 | - $result3=$localobject->validate($user, $result); |
|
396 | + $localobject->date = dol_mktime(12, 0, 0, 12, 1, 1950); // we use same year but fiscal month after |
|
397 | + $numbering = new mod_facture_mercure(); |
|
398 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
399 | + $result2 = $localobject->create($user, 1); |
|
400 | + $result3 = $localobject->validate($user, $result); |
|
401 | 401 | print __METHOD__." result=".$result."\n"; |
402 | - $this->assertEquals('195012-0001', $result); // counter must be reset to 1 |
|
402 | + $this->assertEquals('195012-0001', $result); // counter must be reset to 1 |
|
403 | 403 | |
404 | - $localobject=new Facture($this->savdb); |
|
404 | + $localobject = new Facture($this->savdb); |
|
405 | 405 | $localobject->initAsSpecimen(); |
406 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1951); // we use same fiscal year but different year |
|
407 | - $numbering=new mod_facture_mercure(); |
|
408 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
409 | - $result2=$localobject->create($user,1); |
|
410 | - $result3=$localobject->validate($user, $result); |
|
406 | + $localobject->date = dol_mktime(12, 0, 0, 1, 1, 1951); // we use same fiscal year but different year |
|
407 | + $numbering = new mod_facture_mercure(); |
|
408 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
409 | + $result2 = $localobject->create($user, 1); |
|
410 | + $result3 = $localobject->validate($user, $result); |
|
411 | 411 | print __METHOD__." result=".$result."\n"; |
412 | - $this->assertEquals('195101-0002', $result); // counter must be 2 |
|
412 | + $this->assertEquals('195101-0002', $result); // counter must be 2 |
|
413 | 413 | |
414 | - $localobject=new Facture($this->savdb); |
|
414 | + $localobject = new Facture($this->savdb); |
|
415 | 415 | $localobject->initAsSpecimen(); |
416 | - $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1951); // we use different discal year but same year |
|
417 | - $numbering=new mod_facture_mercure(); |
|
418 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
416 | + $localobject->date = dol_mktime(12, 0, 0, 12, 1, 1951); // we use different discal year but same year |
|
417 | + $numbering = new mod_facture_mercure(); |
|
418 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
419 | 419 | print __METHOD__." result=".$result."\n"; |
420 | - $this->assertEquals('195112-0001', $result); // counter must be reset to 1 |
|
420 | + $this->assertEquals('195112-0001', $result); // counter must be reset to 1 |
|
421 | 421 | |
422 | 422 | |
423 | 423 | // Now we try with a different fiscal month (defined by SOCIETE_FISCAL_MONTH_START) and we always want start year |
424 | - $conf->global->SOCIETE_FISCAL_MONTH_START=6; |
|
425 | - $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@-}'; |
|
426 | - $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@-}'; |
|
424 | + $conf->global->SOCIETE_FISCAL_MONTH_START = 6; |
|
425 | + $conf->global->FACTURE_MERCURE_MASK_CREDIT = '{yyyy}{mm}-{0000@-}'; |
|
426 | + $conf->global->FACTURE_MERCURE_MASK_INVOICE = '{yyyy}{mm}-{0000@-}'; |
|
427 | 427 | |
428 | - $localobject=new Facture($this->savdb); |
|
428 | + $localobject = new Facture($this->savdb); |
|
429 | 429 | $localobject->initAsSpecimen(); |
430 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1960); // we use year 1960 to be sure to not have existing invoice for this year |
|
431 | - $numbering=new mod_facture_mercure(); |
|
432 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
433 | - $result2=$localobject->create($user,1); |
|
434 | - $result3=$localobject->validate($user, $result); |
|
430 | + $localobject->date = dol_mktime(12, 0, 0, 1, 1, 1960); // we use year 1960 to be sure to not have existing invoice for this year |
|
431 | + $numbering = new mod_facture_mercure(); |
|
432 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
433 | + $result2 = $localobject->create($user, 1); |
|
434 | + $result3 = $localobject->validate($user, $result); |
|
435 | 435 | print __METHOD__." result=".$result."\n"; |
436 | - $this->assertEquals('195901-0001', $result); // counter must start to 1 |
|
436 | + $this->assertEquals('195901-0001', $result); // counter must start to 1 |
|
437 | 437 | |
438 | - $localobject=new Facture($this->savdb); |
|
438 | + $localobject = new Facture($this->savdb); |
|
439 | 439 | $localobject->initAsSpecimen(); |
440 | - $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1960); // we use same year but fiscal month after |
|
441 | - $numbering=new mod_facture_mercure(); |
|
442 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
443 | - $result2=$localobject->create($user,1); |
|
444 | - $result3=$localobject->validate($user, $result); |
|
440 | + $localobject->date = dol_mktime(12, 0, 0, 12, 1, 1960); // we use same year but fiscal month after |
|
441 | + $numbering = new mod_facture_mercure(); |
|
442 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
443 | + $result2 = $localobject->create($user, 1); |
|
444 | + $result3 = $localobject->validate($user, $result); |
|
445 | 445 | print __METHOD__." result=".$result."\n"; |
446 | - $this->assertEquals('196012-0001', $result); // counter must be reset to 1 |
|
446 | + $this->assertEquals('196012-0001', $result); // counter must be reset to 1 |
|
447 | 447 | |
448 | - $localobject=new Facture($this->savdb); |
|
448 | + $localobject = new Facture($this->savdb); |
|
449 | 449 | $localobject->initAsSpecimen(); |
450 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1961); // we use same fiscal year but different year |
|
451 | - $numbering=new mod_facture_mercure(); |
|
452 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
453 | - $result2=$localobject->create($user,1); |
|
454 | - $result3=$localobject->validate($user, $result); |
|
450 | + $localobject->date = dol_mktime(12, 0, 0, 1, 1, 1961); // we use same fiscal year but different year |
|
451 | + $numbering = new mod_facture_mercure(); |
|
452 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
453 | + $result2 = $localobject->create($user, 1); |
|
454 | + $result3 = $localobject->validate($user, $result); |
|
455 | 455 | print __METHOD__." result=".$result."\n"; |
456 | - $this->assertEquals('196001-0002', $result); // counter must be 2 |
|
456 | + $this->assertEquals('196001-0002', $result); // counter must be 2 |
|
457 | 457 | |
458 | - $localobject=new Facture($this->savdb); |
|
458 | + $localobject = new Facture($this->savdb); |
|
459 | 459 | $localobject->initAsSpecimen(); |
460 | - $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1961); // we use different discal year but same year |
|
461 | - $numbering=new mod_facture_mercure(); |
|
462 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
460 | + $localobject->date = dol_mktime(12, 0, 0, 12, 1, 1961); // we use different discal year but same year |
|
461 | + $numbering = new mod_facture_mercure(); |
|
462 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
463 | 463 | print __METHOD__." result=".$result."\n"; |
464 | - $this->assertEquals('196112-0001', $result); // counter must be reset to 1 |
|
464 | + $this->assertEquals('196112-0001', $result); // counter must be reset to 1 |
|
465 | 465 | |
466 | 466 | |
467 | 467 | // Now we try with a different fiscal month (defined by SOCIETE_FISCAL_MONTH_START) and we always want end year |
468 | - $conf->global->SOCIETE_FISCAL_MONTH_START=6; |
|
469 | - $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@+}'; |
|
470 | - $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@+}'; |
|
468 | + $conf->global->SOCIETE_FISCAL_MONTH_START = 6; |
|
469 | + $conf->global->FACTURE_MERCURE_MASK_CREDIT = '{yyyy}{mm}-{0000@+}'; |
|
470 | + $conf->global->FACTURE_MERCURE_MASK_INVOICE = '{yyyy}{mm}-{0000@+}'; |
|
471 | 471 | |
472 | - $localobject=new Facture($this->savdb); |
|
472 | + $localobject = new Facture($this->savdb); |
|
473 | 473 | $localobject->initAsSpecimen(); |
474 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1970); // we use year 1970 to be sure to not have existing invoice for this year |
|
475 | - $numbering=new mod_facture_mercure(); |
|
476 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
477 | - $result2=$localobject->create($user,1); |
|
478 | - $result3=$localobject->validate($user, $result); |
|
474 | + $localobject->date = dol_mktime(12, 0, 0, 1, 1, 1970); // we use year 1970 to be sure to not have existing invoice for this year |
|
475 | + $numbering = new mod_facture_mercure(); |
|
476 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
477 | + $result2 = $localobject->create($user, 1); |
|
478 | + $result3 = $localobject->validate($user, $result); |
|
479 | 479 | print __METHOD__." result=".$result."\n"; |
480 | - $this->assertEquals('197001-0001', $result); // counter must start to 1 |
|
480 | + $this->assertEquals('197001-0001', $result); // counter must start to 1 |
|
481 | 481 | |
482 | - $localobject=new Facture($this->savdb); |
|
482 | + $localobject = new Facture($this->savdb); |
|
483 | 483 | $localobject->initAsSpecimen(); |
484 | - $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1970); // we use same year but fiscal month after |
|
485 | - $numbering=new mod_facture_mercure(); |
|
486 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
487 | - $result2=$localobject->create($user,1); |
|
488 | - $result3=$localobject->validate($user, $result); |
|
484 | + $localobject->date = dol_mktime(12, 0, 0, 12, 1, 1970); // we use same year but fiscal month after |
|
485 | + $numbering = new mod_facture_mercure(); |
|
486 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
487 | + $result2 = $localobject->create($user, 1); |
|
488 | + $result3 = $localobject->validate($user, $result); |
|
489 | 489 | print __METHOD__." result=".$result."\n"; |
490 | - $this->assertEquals('197112-0001', $result); // counter must be reset to 1 |
|
490 | + $this->assertEquals('197112-0001', $result); // counter must be reset to 1 |
|
491 | 491 | |
492 | - $localobject=new Facture($this->savdb); |
|
492 | + $localobject = new Facture($this->savdb); |
|
493 | 493 | $localobject->initAsSpecimen(); |
494 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1971); // we use same fiscal year but different year |
|
495 | - $numbering=new mod_facture_mercure(); |
|
496 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
497 | - $result2=$localobject->create($user,1); |
|
498 | - $result3=$localobject->validate($user, $result); |
|
494 | + $localobject->date = dol_mktime(12, 0, 0, 1, 1, 1971); // we use same fiscal year but different year |
|
495 | + $numbering = new mod_facture_mercure(); |
|
496 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
497 | + $result2 = $localobject->create($user, 1); |
|
498 | + $result3 = $localobject->validate($user, $result); |
|
499 | 499 | print __METHOD__." result=".$result."\n"; |
500 | - $this->assertEquals('197101-0002', $result); // counter must be 2 |
|
500 | + $this->assertEquals('197101-0002', $result); // counter must be 2 |
|
501 | 501 | |
502 | - $localobject=new Facture($this->savdb); |
|
502 | + $localobject = new Facture($this->savdb); |
|
503 | 503 | $localobject->initAsSpecimen(); |
504 | - $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1971); // we use different fiscal year but same year |
|
505 | - $numbering=new mod_facture_mercure(); |
|
506 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
504 | + $localobject->date = dol_mktime(12, 0, 0, 12, 1, 1971); // we use different fiscal year but same year |
|
505 | + $numbering = new mod_facture_mercure(); |
|
506 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
507 | 507 | print __METHOD__." result=".$result."\n"; |
508 | - $this->assertEquals('197212-0001', $result); // counter must be reset to 1 |
|
508 | + $this->assertEquals('197212-0001', $result); // counter must be reset to 1 |
|
509 | 509 | |
510 | 510 | // Now we try with a reset every month (@99) |
511 | - $conf->global->SOCIETE_FISCAL_MONTH_START=6; |
|
512 | - $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@99}'; |
|
513 | - $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@99}'; |
|
511 | + $conf->global->SOCIETE_FISCAL_MONTH_START = 6; |
|
512 | + $conf->global->FACTURE_MERCURE_MASK_CREDIT = '{yyyy}{mm}-{0000@99}'; |
|
513 | + $conf->global->FACTURE_MERCURE_MASK_INVOICE = '{yyyy}{mm}-{0000@99}'; |
|
514 | 514 | |
515 | - $localobject=new Facture($this->savdb); |
|
515 | + $localobject = new Facture($this->savdb); |
|
516 | 516 | $localobject->initAsSpecimen(); |
517 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1980); // we use year 1980 to be sure to not have existing invoice for this year |
|
518 | - $numbering=new mod_facture_mercure(); |
|
519 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
520 | - $result2=$localobject->create($user,1); |
|
521 | - $result3=$localobject->validate($user, $result); |
|
517 | + $localobject->date = dol_mktime(12, 0, 0, 1, 1, 1980); // we use year 1980 to be sure to not have existing invoice for this year |
|
518 | + $numbering = new mod_facture_mercure(); |
|
519 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
520 | + $result2 = $localobject->create($user, 1); |
|
521 | + $result3 = $localobject->validate($user, $result); |
|
522 | 522 | print __METHOD__." result=".$result."\n"; |
523 | - $this->assertEquals('198001-0001', $result); // counter must start to 1 |
|
523 | + $this->assertEquals('198001-0001', $result); // counter must start to 1 |
|
524 | 524 | |
525 | - $localobject=new Facture($this->savdb); |
|
525 | + $localobject = new Facture($this->savdb); |
|
526 | 526 | $localobject->initAsSpecimen(); |
527 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1980); // we use year 1980 to be sure to not have existing invoice for this year |
|
528 | - $numbering=new mod_facture_mercure(); |
|
529 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
530 | - $result2=$localobject->create($user,1); |
|
531 | - $result3=$localobject->validate($user, $result); |
|
527 | + $localobject->date = dol_mktime(12, 0, 0, 1, 1, 1980); // we use year 1980 to be sure to not have existing invoice for this year |
|
528 | + $numbering = new mod_facture_mercure(); |
|
529 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
530 | + $result2 = $localobject->create($user, 1); |
|
531 | + $result3 = $localobject->validate($user, $result); |
|
532 | 532 | print __METHOD__." result=".$result."\n"; |
533 | - $this->assertEquals('198001-0002', $result); // counter must start to 2 |
|
533 | + $this->assertEquals('198001-0002', $result); // counter must start to 2 |
|
534 | 534 | |
535 | - $localobject=new Facture($this->savdb); |
|
535 | + $localobject = new Facture($this->savdb); |
|
536 | 536 | $localobject->initAsSpecimen(); |
537 | - $localobject->date=dol_mktime(12, 0, 0, 2, 1, 1980); // we use year 1980 to be sure to not have existing invoice for this year |
|
538 | - $numbering=new mod_facture_mercure(); |
|
539 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
540 | - $result2=$localobject->create($user,1); |
|
541 | - $result3=$localobject->validate($user, $result); |
|
537 | + $localobject->date = dol_mktime(12, 0, 0, 2, 1, 1980); // we use year 1980 to be sure to not have existing invoice for this year |
|
538 | + $numbering = new mod_facture_mercure(); |
|
539 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
540 | + $result2 = $localobject->create($user, 1); |
|
541 | + $result3 = $localobject->validate($user, $result); |
|
542 | 542 | print __METHOD__." result=".$result."\n"; |
543 | - $this->assertEquals('198002-0001', $result); // counter must start to 1 |
|
543 | + $this->assertEquals('198002-0001', $result); // counter must start to 1 |
|
544 | 544 | |
545 | - $localobject=new Facture($this->savdb); |
|
545 | + $localobject = new Facture($this->savdb); |
|
546 | 546 | $localobject->initAsSpecimen(); |
547 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1981); // we use year 1981 to be sure to not have existing invoice for this year |
|
548 | - $numbering=new mod_facture_mercure(); |
|
549 | - $result=$numbering->getNextValue($mysoc, $localobject); |
|
550 | - $result2=$localobject->create($user,1); |
|
551 | - $result3=$localobject->validate($user, $result); |
|
547 | + $localobject->date = dol_mktime(12, 0, 0, 1, 1, 1981); // we use year 1981 to be sure to not have existing invoice for this year |
|
548 | + $numbering = new mod_facture_mercure(); |
|
549 | + $result = $numbering->getNextValue($mysoc, $localobject); |
|
550 | + $result2 = $localobject->create($user, 1); |
|
551 | + $result3 = $localobject->validate($user, $result); |
|
552 | 552 | print __METHOD__." result=".$result."\n"; |
553 | - $this->assertEquals('198101-0001', $result); // counter must start to 1 |
|
553 | + $this->assertEquals('198101-0001', $result); // counter must start to 1 |
|
554 | 554 | |
555 | 555 | // Test with {t} tag |
556 | - $conf->global->SOCIETE_FISCAL_MONTH_START=1; |
|
557 | - $conf->global->FACTURE_MERCURE_MASK_CREDIT='{t}{yyyy}{mm}-{0000}'; |
|
558 | - $conf->global->FACTURE_MERCURE_MASK_INVOICE='{t}{yyyy}{mm}-{0000}'; |
|
556 | + $conf->global->SOCIETE_FISCAL_MONTH_START = 1; |
|
557 | + $conf->global->FACTURE_MERCURE_MASK_CREDIT = '{t}{yyyy}{mm}-{0000}'; |
|
558 | + $conf->global->FACTURE_MERCURE_MASK_INVOICE = '{t}{yyyy}{mm}-{0000}'; |
|
559 | 559 | |
560 | - $tmpthirdparty=new Societe($this->savdb); |
|
560 | + $tmpthirdparty = new Societe($this->savdb); |
|
561 | 561 | $tmpthirdparty->initAsSpecimen(); |
562 | 562 | $tmpthirdparty->typent_code = 'TE_ABC'; |
563 | 563 | |
564 | - $localobject=new Facture($this->savdb); |
|
564 | + $localobject = new Facture($this->savdb); |
|
565 | 565 | $localobject->initAsSpecimen(); |
566 | - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1982); // we use year 1982 to be sure to not have existing invoice for this year |
|
567 | - $numbering=new mod_facture_mercure(); |
|
568 | - $result=$numbering->getNextValue($tmpthirdparty, $localobject); |
|
569 | - $result2=$localobject->create($user,1); |
|
570 | - $result3=$localobject->validate($user, $result); |
|
566 | + $localobject->date = dol_mktime(12, 0, 0, 1, 1, 1982); // we use year 1982 to be sure to not have existing invoice for this year |
|
567 | + $numbering = new mod_facture_mercure(); |
|
568 | + $result = $numbering->getNextValue($tmpthirdparty, $localobject); |
|
569 | + $result2 = $localobject->create($user, 1); |
|
570 | + $result3 = $localobject->validate($user, $result); |
|
571 | 571 | print __METHOD__." result=".$result."\n"; |
572 | - $this->assertEquals('A198201-0001', $result); // counter must start to 1 |
|
572 | + $this->assertEquals('A198201-0001', $result); // counter must start to 1 |
|
573 | 573 | |
574 | 574 | |
575 | 575 |
@@ -30,9 +30,9 @@ discard block |
||
30 | 30 | |
31 | 31 | if (empty($user->id)) |
32 | 32 | { |
33 | - print "Load permissions for admin user nb 1\n"; |
|
34 | - $user->fetch(1); |
|
35 | - $user->getrights(); |
|
33 | + print "Load permissions for admin user nb 1\n"; |
|
34 | + $user->fetch(1); |
|
35 | + $user->getrights(); |
|
36 | 36 | } |
37 | 37 | $conf->global->MAIN_DISABLE_ALL_MAILS=1; |
38 | 38 | |
@@ -46,74 +46,74 @@ discard block |
||
46 | 46 | */ |
47 | 47 | class ModulesTest extends PHPUnit_Framework_TestCase |
48 | 48 | { |
49 | - protected $savconf; |
|
50 | - protected $savuser; |
|
51 | - protected $savlangs; |
|
52 | - protected $savdb; |
|
53 | - |
|
54 | - /** |
|
55 | - * Constructor |
|
56 | - * We save global variables into local variables |
|
57 | - * |
|
58 | - * @return BuildDocTest |
|
59 | - */ |
|
60 | - function __construct() |
|
61 | - { |
|
62 | - parent::__construct(); |
|
63 | - |
|
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; |
|
70 | - |
|
71 | - print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
|
72 | - //print " - db ".$db->db; |
|
73 | - print "\n"; |
|
74 | - } |
|
75 | - |
|
76 | - // Static methods |
|
77 | - public static function setUpBeforeClass() |
|
49 | + protected $savconf; |
|
50 | + protected $savuser; |
|
51 | + protected $savlangs; |
|
52 | + protected $savdb; |
|
53 | + |
|
54 | + /** |
|
55 | + * Constructor |
|
56 | + * We save global variables into local variables |
|
57 | + * |
|
58 | + * @return BuildDocTest |
|
59 | + */ |
|
60 | + function __construct() |
|
61 | + { |
|
62 | + parent::__construct(); |
|
63 | + |
|
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; |
|
70 | + |
|
71 | + print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
|
72 | + //print " - db ".$db->db; |
|
73 | + print "\n"; |
|
74 | + } |
|
75 | + |
|
76 | + // Static methods |
|
77 | + public static function setUpBeforeClass() |
|
78 | 78 | { |
79 | - global $conf,$user,$langs,$db; |
|
80 | - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
79 | + global $conf,$user,$langs,$db; |
|
80 | + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
81 | 81 | |
82 | - print __METHOD__."\n"; |
|
82 | + print __METHOD__."\n"; |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | // tear down after class |
86 | 86 | public static function tearDownAfterClass() |
87 | 87 | { |
88 | - global $conf,$user,$langs,$db; |
|
89 | - $db->rollback(); |
|
88 | + global $conf,$user,$langs,$db; |
|
89 | + $db->rollback(); |
|
90 | 90 | |
91 | - print __METHOD__."\n"; |
|
91 | + print __METHOD__."\n"; |
|
92 | 92 | } |
93 | 93 | |
94 | - /** |
|
95 | - * Init phpunit tests |
|
96 | - * |
|
97 | - * @return void |
|
98 | - */ |
|
94 | + /** |
|
95 | + * Init phpunit tests |
|
96 | + * |
|
97 | + * @return void |
|
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 | - print __METHOD__."\n"; |
|
107 | + print __METHOD__."\n"; |
|
108 | 108 | } |
109 | - /** |
|
110 | - * End phpunit tests |
|
111 | - * |
|
112 | - * @return void |
|
113 | - */ |
|
109 | + /** |
|
110 | + * End phpunit tests |
|
111 | + * |
|
112 | + * @return void |
|
113 | + */ |
|
114 | 114 | protected function tearDown() |
115 | 115 | { |
116 | - print __METHOD__."\n"; |
|
116 | + print __METHOD__."\n"; |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -123,34 +123,34 @@ discard block |
||
123 | 123 | */ |
124 | 124 | public function testModulesInit() |
125 | 125 | { |
126 | - global $conf,$user,$langs,$db; |
|
127 | - $conf=$this->savconf; |
|
128 | - $user=$this->savuser; |
|
129 | - $langs=$this->savlangs; |
|
130 | - $db=$this->savdb; |
|
131 | - |
|
132 | - $modulelist=array('Accounting','Adherent','Agenda','Banque','Barcode','BlockedLog','Bookmark', |
|
133 | - 'CashDesk','Categorie','ClickToDial','Collab','Commande','Comptabilite','Contrat','Cron','Deplacement','DocumentGeneration','Don','DynamicPrices', |
|
134 | - 'ECM','Expedition','ExpenseReport','Export','ExternalRss','ExternalSite', |
|
135 | - 'Facture','Fckeditor','Ficheinter','Fournisseur','FTP','GeoIPMaxmind','Gravatar','Holiday','HRM','Import','Incoterm','Label','Ldap','Loan', |
|
136 | - 'Mailing','MailmanSpip','Margin','ModuleBuilder','MultiCurrency', |
|
137 | - 'Notification','Oauth','OpenSurvey','Paybox','Paypal','Prelevement','Printing','Product','ProductBatch','Projet','Propale','ReceiptPrinter','Resource', |
|
138 | - 'Salaries','Service','Skype','Societe','Stock','Stripe','SupplierProposal','Syslog','Tax','Ticket','User','Variants','WebServices','WebServicesClient','Website','Workflow'); |
|
139 | - foreach($modulelist as $modlabel) |
|
140 | - { |
|
141 | - require_once DOL_DOCUMENT_ROOT.'/core/modules/mod'.$modlabel.'.class.php'; |
|
126 | + global $conf,$user,$langs,$db; |
|
127 | + $conf=$this->savconf; |
|
128 | + $user=$this->savuser; |
|
129 | + $langs=$this->savlangs; |
|
130 | + $db=$this->savdb; |
|
131 | + |
|
132 | + $modulelist=array('Accounting','Adherent','Agenda','Banque','Barcode','BlockedLog','Bookmark', |
|
133 | + 'CashDesk','Categorie','ClickToDial','Collab','Commande','Comptabilite','Contrat','Cron','Deplacement','DocumentGeneration','Don','DynamicPrices', |
|
134 | + 'ECM','Expedition','ExpenseReport','Export','ExternalRss','ExternalSite', |
|
135 | + 'Facture','Fckeditor','Ficheinter','Fournisseur','FTP','GeoIPMaxmind','Gravatar','Holiday','HRM','Import','Incoterm','Label','Ldap','Loan', |
|
136 | + 'Mailing','MailmanSpip','Margin','ModuleBuilder','MultiCurrency', |
|
137 | + 'Notification','Oauth','OpenSurvey','Paybox','Paypal','Prelevement','Printing','Product','ProductBatch','Projet','Propale','ReceiptPrinter','Resource', |
|
138 | + 'Salaries','Service','Skype','Societe','Stock','Stripe','SupplierProposal','Syslog','Tax','Ticket','User','Variants','WebServices','WebServicesClient','Website','Workflow'); |
|
139 | + foreach($modulelist as $modlabel) |
|
140 | + { |
|
141 | + require_once DOL_DOCUMENT_ROOT.'/core/modules/mod'.$modlabel.'.class.php'; |
|
142 | 142 | $class='mod'.$modlabel; |
143 | - $mod=new $class($db); |
|
143 | + $mod=new $class($db); |
|
144 | 144 | $result=$mod->remove(); |
145 | 145 | $result=$mod->init(); |
146 | - $this->assertLessThan($result, 0, $modlabel); |
|
147 | - print __METHOD__." test remove/init for module ".$modlabel.", result=".$result."\n"; |
|
148 | - |
|
149 | - if (in_array($modlabel, array('Ldap', 'MailmanSpip'))) |
|
150 | - { |
|
151 | - $result=$mod->remove(); |
|
152 | - } |
|
153 | - } |
|
146 | + $this->assertLessThan($result, 0, $modlabel); |
|
147 | + print __METHOD__." test remove/init for module ".$modlabel.", result=".$result."\n"; |
|
148 | + |
|
149 | + if (in_array($modlabel, array('Ldap', 'MailmanSpip'))) |
|
150 | + { |
|
151 | + $result=$mod->remove(); |
|
152 | + } |
|
153 | + } |
|
154 | 154 | |
155 | 155 | return 0; |
156 | 156 | } |
@@ -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,8 +76,8 @@ discard block |
||
76 | 76 | // Static methods |
77 | 77 | public static function setUpBeforeClass() |
78 | 78 | { |
79 | - global $conf,$user,$langs,$db; |
|
80 | - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
79 | + global $conf, $user, $langs, $db; |
|
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"; |
83 | 83 | } |
@@ -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,32 +123,32 @@ discard block |
||
123 | 123 | */ |
124 | 124 | public function testModulesInit() |
125 | 125 | { |
126 | - global $conf,$user,$langs,$db; |
|
127 | - $conf=$this->savconf; |
|
128 | - $user=$this->savuser; |
|
129 | - $langs=$this->savlangs; |
|
130 | - $db=$this->savdb; |
|
131 | - |
|
132 | - $modulelist=array('Accounting','Adherent','Agenda','Banque','Barcode','BlockedLog','Bookmark', |
|
133 | - 'CashDesk','Categorie','ClickToDial','Collab','Commande','Comptabilite','Contrat','Cron','Deplacement','DocumentGeneration','Don','DynamicPrices', |
|
134 | - 'ECM','Expedition','ExpenseReport','Export','ExternalRss','ExternalSite', |
|
135 | - 'Facture','Fckeditor','Ficheinter','Fournisseur','FTP','GeoIPMaxmind','Gravatar','Holiday','HRM','Import','Incoterm','Label','Ldap','Loan', |
|
136 | - 'Mailing','MailmanSpip','Margin','ModuleBuilder','MultiCurrency', |
|
137 | - 'Notification','Oauth','OpenSurvey','Paybox','Paypal','Prelevement','Printing','Product','ProductBatch','Projet','Propale','ReceiptPrinter','Resource', |
|
138 | - 'Salaries','Service','Skype','Societe','Stock','Stripe','SupplierProposal','Syslog','Tax','Ticket','User','Variants','WebServices','WebServicesClient','Website','Workflow'); |
|
139 | - foreach($modulelist as $modlabel) |
|
126 | + global $conf, $user, $langs, $db; |
|
127 | + $conf = $this->savconf; |
|
128 | + $user = $this->savuser; |
|
129 | + $langs = $this->savlangs; |
|
130 | + $db = $this->savdb; |
|
131 | + |
|
132 | + $modulelist = array('Accounting', 'Adherent', 'Agenda', 'Banque', 'Barcode', 'BlockedLog', 'Bookmark', |
|
133 | + 'CashDesk', 'Categorie', 'ClickToDial', 'Collab', 'Commande', 'Comptabilite', 'Contrat', 'Cron', 'Deplacement', 'DocumentGeneration', 'Don', 'DynamicPrices', |
|
134 | + 'ECM', 'Expedition', 'ExpenseReport', 'Export', 'ExternalRss', 'ExternalSite', |
|
135 | + 'Facture', 'Fckeditor', 'Ficheinter', 'Fournisseur', 'FTP', 'GeoIPMaxmind', 'Gravatar', 'Holiday', 'HRM', 'Import', 'Incoterm', 'Label', 'Ldap', 'Loan', |
|
136 | + 'Mailing', 'MailmanSpip', 'Margin', 'ModuleBuilder', 'MultiCurrency', |
|
137 | + 'Notification', 'Oauth', 'OpenSurvey', 'Paybox', 'Paypal', 'Prelevement', 'Printing', 'Product', 'ProductBatch', 'Projet', 'Propale', 'ReceiptPrinter', 'Resource', |
|
138 | + 'Salaries', 'Service', 'Skype', 'Societe', 'Stock', 'Stripe', 'SupplierProposal', 'Syslog', 'Tax', 'Ticket', 'User', 'Variants', 'WebServices', 'WebServicesClient', 'Website', 'Workflow'); |
|
139 | + foreach ($modulelist as $modlabel) |
|
140 | 140 | { |
141 | 141 | require_once DOL_DOCUMENT_ROOT.'/core/modules/mod'.$modlabel.'.class.php'; |
142 | - $class='mod'.$modlabel; |
|
143 | - $mod=new $class($db); |
|
144 | - $result=$mod->remove(); |
|
145 | - $result=$mod->init(); |
|
142 | + $class = 'mod'.$modlabel; |
|
143 | + $mod = new $class($db); |
|
144 | + $result = $mod->remove(); |
|
145 | + $result = $mod->init(); |
|
146 | 146 | $this->assertLessThan($result, 0, $modlabel); |
147 | 147 | print __METHOD__." test remove/init for module ".$modlabel.", result=".$result."\n"; |
148 | 148 | |
149 | 149 | if (in_array($modlabel, array('Ldap', 'MailmanSpip'))) |
150 | 150 | { |
151 | - $result=$mod->remove(); |
|
151 | + $result = $mod->remove(); |
|
152 | 152 | } |
153 | 153 | } |
154 | 154 |
@@ -32,9 +32,9 @@ discard block |
||
32 | 32 | |
33 | 33 | if (empty($user->id)) |
34 | 34 | { |
35 | - print "Load permissions for admin user nb 1\n"; |
|
36 | - $user->fetch(1); |
|
37 | - $user->getrights(); |
|
35 | + print "Load permissions for admin user nb 1\n"; |
|
36 | + $user->fetch(1); |
|
37 | + $user->getrights(); |
|
38 | 38 | } |
39 | 39 | $conf->global->MAIN_DISABLE_ALL_MAILS=1; |
40 | 40 | |
@@ -48,74 +48,74 @@ discard block |
||
48 | 48 | */ |
49 | 49 | class FactureFournisseurTest extends PHPUnit_Framework_TestCase |
50 | 50 | { |
51 | - protected $savconf; |
|
52 | - protected $savuser; |
|
53 | - protected $savlangs; |
|
54 | - protected $savdb; |
|
55 | - |
|
56 | - /** |
|
57 | - * Constructor |
|
58 | - * We save global variables into local variables |
|
59 | - * |
|
60 | - * @return FactureFournisseurTest |
|
61 | - */ |
|
62 | - function __construct() |
|
63 | - { |
|
64 | - parent::__construct(); |
|
65 | - |
|
66 | - //$this->sharedFixture |
|
67 | - global $conf,$user,$langs,$db; |
|
68 | - $this->savconf=$conf; |
|
69 | - $this->savuser=$user; |
|
70 | - $this->savlangs=$langs; |
|
71 | - $this->savdb=$db; |
|
72 | - |
|
73 | - print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
|
74 | - //print " - db ".$db->db; |
|
75 | - print "\n"; |
|
76 | - } |
|
77 | - |
|
78 | - // Static methods |
|
79 | - public static function setUpBeforeClass() |
|
51 | + protected $savconf; |
|
52 | + protected $savuser; |
|
53 | + protected $savlangs; |
|
54 | + protected $savdb; |
|
55 | + |
|
56 | + /** |
|
57 | + * Constructor |
|
58 | + * We save global variables into local variables |
|
59 | + * |
|
60 | + * @return FactureFournisseurTest |
|
61 | + */ |
|
62 | + function __construct() |
|
80 | 63 | { |
81 | - global $conf,$user,$langs,$db; |
|
82 | - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
64 | + parent::__construct(); |
|
83 | 65 | |
84 | - print __METHOD__."\n"; |
|
66 | + //$this->sharedFixture |
|
67 | + global $conf,$user,$langs,$db; |
|
68 | + $this->savconf=$conf; |
|
69 | + $this->savuser=$user; |
|
70 | + $this->savlangs=$langs; |
|
71 | + $this->savdb=$db; |
|
72 | + |
|
73 | + print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
|
74 | + //print " - db ".$db->db; |
|
75 | + print "\n"; |
|
76 | + } |
|
77 | + |
|
78 | + // Static methods |
|
79 | + public static function setUpBeforeClass() |
|
80 | + { |
|
81 | + global $conf,$user,$langs,$db; |
|
82 | + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
83 | + |
|
84 | + print __METHOD__."\n"; |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | // tear down after class |
88 | 88 | public static function tearDownAfterClass() |
89 | 89 | { |
90 | - global $conf,$user,$langs,$db; |
|
91 | - $db->rollback(); |
|
90 | + global $conf,$user,$langs,$db; |
|
91 | + $db->rollback(); |
|
92 | 92 | |
93 | - print __METHOD__."\n"; |
|
93 | + print __METHOD__."\n"; |
|
94 | 94 | } |
95 | 95 | |
96 | - /** |
|
97 | - * Init phpunit tests |
|
98 | - * |
|
99 | - * @return void |
|
100 | - */ |
|
96 | + /** |
|
97 | + * Init phpunit tests |
|
98 | + * |
|
99 | + * @return void |
|
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 | - print __METHOD__."\n"; |
|
109 | + print __METHOD__."\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 testFactureFournisseurCreate() |
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 FactureFournisseur($this->savdb); |
|
135 | - $localobject->initAsSpecimen(); |
|
136 | - $result=$localobject->create($user); |
|
137 | - |
|
138 | - $this->assertLessThan($result, 0); |
|
139 | - print __METHOD__." result=".$result."\n"; |
|
140 | - return $result; |
|
128 | + global $conf,$user,$langs,$db; |
|
129 | + $conf=$this->savconf; |
|
130 | + $user=$this->savuser; |
|
131 | + $langs=$this->savlangs; |
|
132 | + $db=$this->savdb; |
|
133 | + |
|
134 | + $localobject=new FactureFournisseur($this->savdb); |
|
135 | + $localobject->initAsSpecimen(); |
|
136 | + $result=$localobject->create($user); |
|
137 | + |
|
138 | + $this->assertLessThan($result, 0); |
|
139 | + print __METHOD__." result=".$result."\n"; |
|
140 | + return $result; |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
@@ -151,18 +151,18 @@ discard block |
||
151 | 151 | */ |
152 | 152 | public function testFactureFournisseurFetch($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 FactureFournisseur($this->savdb); |
|
161 | - $result=$localobject->fetch($id); |
|
162 | - |
|
163 | - $this->assertLessThan($result, 0); |
|
164 | - print __METHOD__." id=".$id." result=".$result."\n"; |
|
165 | - return $localobject; |
|
154 | + global $conf,$user,$langs,$db; |
|
155 | + $conf=$this->savconf; |
|
156 | + $user=$this->savuser; |
|
157 | + $langs=$this->savlangs; |
|
158 | + $db=$this->savdb; |
|
159 | + |
|
160 | + $localobject=new FactureFournisseur($this->savdb); |
|
161 | + $result=$localobject->fetch($id); |
|
162 | + |
|
163 | + $this->assertLessThan($result, 0); |
|
164 | + print __METHOD__." id=".$id." result=".$result."\n"; |
|
165 | + return $localobject; |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
@@ -176,18 +176,18 @@ discard block |
||
176 | 176 | */ |
177 | 177 | public function testFactureFournisseurUpdate($localobject) |
178 | 178 | { |
179 | - global $conf,$user,$langs,$db; |
|
180 | - $conf=$this->savconf; |
|
181 | - $user=$this->savuser; |
|
182 | - $langs=$this->savlangs; |
|
183 | - $db=$this->savdb; |
|
184 | - |
|
185 | - $localobject->note='New note after update'; |
|
186 | - $result=$localobject->update($user); |
|
187 | - |
|
188 | - print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
189 | - $this->assertLessThan($result, 0); |
|
190 | - return $localobject; |
|
179 | + global $conf,$user,$langs,$db; |
|
180 | + $conf=$this->savconf; |
|
181 | + $user=$this->savuser; |
|
182 | + $langs=$this->savlangs; |
|
183 | + $db=$this->savdb; |
|
184 | + |
|
185 | + $localobject->note='New note after update'; |
|
186 | + $result=$localobject->update($user); |
|
187 | + |
|
188 | + print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
189 | + $this->assertLessThan($result, 0); |
|
190 | + return $localobject; |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | /** |
@@ -201,20 +201,20 @@ discard block |
||
201 | 201 | */ |
202 | 202 | public function testFactureFournisseurValid($localobject) |
203 | 203 | { |
204 | - global $conf,$user,$langs,$db; |
|
205 | - $conf=$this->savconf; |
|
206 | - $user=$this->savuser; |
|
207 | - $langs=$this->savlangs; |
|
208 | - $db=$this->savdb; |
|
204 | + global $conf,$user,$langs,$db; |
|
205 | + $conf=$this->savconf; |
|
206 | + $user=$this->savuser; |
|
207 | + $langs=$this->savlangs; |
|
208 | + $db=$this->savdb; |
|
209 | 209 | |
210 | - $result=$localobject->validate($user); |
|
211 | - print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
210 | + $result=$localobject->validate($user); |
|
211 | + print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
212 | 212 | |
213 | - $this->assertLessThan($result, 0); |
|
214 | - return $localobject; |
|
213 | + $this->assertLessThan($result, 0); |
|
214 | + return $localobject; |
|
215 | 215 | } |
216 | 216 | |
217 | - /** |
|
217 | + /** |
|
218 | 218 | * testFactureFournisseurOther |
219 | 219 | * |
220 | 220 | * @param Object $localobject Supplier invoice |
@@ -254,18 +254,18 @@ discard block |
||
254 | 254 | */ |
255 | 255 | public function testFactureFournisseurDelete($id) |
256 | 256 | { |
257 | - global $conf,$user,$langs,$db; |
|
258 | - $conf=$this->savconf; |
|
259 | - $user=$this->savuser; |
|
260 | - $langs=$this->savlangs; |
|
261 | - $db=$this->savdb; |
|
262 | - |
|
263 | - $localobject=new FactureFournisseur($this->savdb); |
|
264 | - $result=$localobject->fetch($id); |
|
265 | - $result=$localobject->delete($user); |
|
266 | - |
|
267 | - print __METHOD__." id=".$id." result=".$result."\n"; |
|
268 | - $this->assertLessThan($result, 0); |
|
269 | - return $result; |
|
257 | + global $conf,$user,$langs,$db; |
|
258 | + $conf=$this->savconf; |
|
259 | + $user=$this->savuser; |
|
260 | + $langs=$this->savlangs; |
|
261 | + $db=$this->savdb; |
|
262 | + |
|
263 | + $localobject=new FactureFournisseur($this->savdb); |
|
264 | + $result=$localobject->fetch($id); |
|
265 | + $result=$localobject->delete($user); |
|
266 | + |
|
267 | + print __METHOD__." id=".$id." result=".$result."\n"; |
|
268 | + $this->assertLessThan($result, 0); |
|
269 | + return $result; |
|
270 | 270 | } |
271 | 271 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * \remarks To run this script as CLI: phpunit filename.php |
25 | 25 | */ |
26 | 26 | |
27 | -global $conf,$user,$langs,$db; |
|
27 | +global $conf, $user, $langs, $db; |
|
28 | 28 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
29 | 29 | //require_once 'PHPUnit/Autoload.php'; |
30 | 30 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | $user->fetch(1); |
37 | 37 | $user->getrights(); |
38 | 38 | } |
39 | -$conf->global->MAIN_DISABLE_ALL_MAILS=1; |
|
39 | +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
|
40 | 40 | |
41 | 41 | |
42 | 42 | /** |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | parent::__construct(); |
65 | 65 | |
66 | 66 | //$this->sharedFixture |
67 | - global $conf,$user,$langs,$db; |
|
68 | - $this->savconf=$conf; |
|
69 | - $this->savuser=$user; |
|
70 | - $this->savlangs=$langs; |
|
71 | - $this->savdb=$db; |
|
67 | + global $conf, $user, $langs, $db; |
|
68 | + $this->savconf = $conf; |
|
69 | + $this->savuser = $user; |
|
70 | + $this->savlangs = $langs; |
|
71 | + $this->savdb = $db; |
|
72 | 72 | |
73 | 73 | print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
74 | 74 | //print " - db ".$db->db; |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | // Static methods |
79 | 79 | public static function setUpBeforeClass() |
80 | 80 | { |
81 | - global $conf,$user,$langs,$db; |
|
82 | - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
81 | + global $conf, $user, $langs, $db; |
|
82 | + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
83 | 83 | |
84 | 84 | print __METHOD__."\n"; |
85 | 85 | } |
@@ -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 | } |
@@ -125,15 +125,15 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function testFactureFournisseurCreate() |
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 FactureFournisseur($this->savdb); |
|
134 | + $localobject = new FactureFournisseur($this->savdb); |
|
135 | 135 | $localobject->initAsSpecimen(); |
136 | - $result=$localobject->create($user); |
|
136 | + $result = $localobject->create($user); |
|
137 | 137 | |
138 | 138 | $this->assertLessThan($result, 0); |
139 | 139 | print __METHOD__." result=".$result."\n"; |
@@ -151,14 +151,14 @@ discard block |
||
151 | 151 | */ |
152 | 152 | public function testFactureFournisseurFetch($id) |
153 | 153 | { |
154 | - global $conf,$user,$langs,$db; |
|
155 | - $conf=$this->savconf; |
|
156 | - $user=$this->savuser; |
|
157 | - $langs=$this->savlangs; |
|
158 | - $db=$this->savdb; |
|
154 | + global $conf, $user, $langs, $db; |
|
155 | + $conf = $this->savconf; |
|
156 | + $user = $this->savuser; |
|
157 | + $langs = $this->savlangs; |
|
158 | + $db = $this->savdb; |
|
159 | 159 | |
160 | - $localobject=new FactureFournisseur($this->savdb); |
|
161 | - $result=$localobject->fetch($id); |
|
160 | + $localobject = new FactureFournisseur($this->savdb); |
|
161 | + $result = $localobject->fetch($id); |
|
162 | 162 | |
163 | 163 | $this->assertLessThan($result, 0); |
164 | 164 | print __METHOD__." id=".$id." result=".$result."\n"; |
@@ -176,14 +176,14 @@ discard block |
||
176 | 176 | */ |
177 | 177 | public function testFactureFournisseurUpdate($localobject) |
178 | 178 | { |
179 | - global $conf,$user,$langs,$db; |
|
180 | - $conf=$this->savconf; |
|
181 | - $user=$this->savuser; |
|
182 | - $langs=$this->savlangs; |
|
183 | - $db=$this->savdb; |
|
179 | + global $conf, $user, $langs, $db; |
|
180 | + $conf = $this->savconf; |
|
181 | + $user = $this->savuser; |
|
182 | + $langs = $this->savlangs; |
|
183 | + $db = $this->savdb; |
|
184 | 184 | |
185 | - $localobject->note='New note after update'; |
|
186 | - $result=$localobject->update($user); |
|
185 | + $localobject->note = 'New note after update'; |
|
186 | + $result = $localobject->update($user); |
|
187 | 187 | |
188 | 188 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
189 | 189 | $this->assertLessThan($result, 0); |
@@ -201,13 +201,13 @@ discard block |
||
201 | 201 | */ |
202 | 202 | public function testFactureFournisseurValid($localobject) |
203 | 203 | { |
204 | - global $conf,$user,$langs,$db; |
|
205 | - $conf=$this->savconf; |
|
206 | - $user=$this->savuser; |
|
207 | - $langs=$this->savlangs; |
|
208 | - $db=$this->savdb; |
|
204 | + global $conf, $user, $langs, $db; |
|
205 | + $conf = $this->savconf; |
|
206 | + $user = $this->savuser; |
|
207 | + $langs = $this->savlangs; |
|
208 | + $db = $this->savdb; |
|
209 | 209 | |
210 | - $result=$localobject->validate($user); |
|
210 | + $result = $localobject->validate($user); |
|
211 | 211 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
212 | 212 | |
213 | 213 | $this->assertLessThan($result, 0); |
@@ -225,11 +225,11 @@ discard block |
||
225 | 225 | */ |
226 | 226 | public function testFactureFournisseurOther($localobject) |
227 | 227 | { |
228 | - global $conf,$user,$langs,$db; |
|
229 | - $conf=$this->savconf; |
|
230 | - $user=$this->savuser; |
|
231 | - $langs=$this->savlangs; |
|
232 | - $db=$this->savdb; |
|
228 | + global $conf, $user, $langs, $db; |
|
229 | + $conf = $this->savconf; |
|
230 | + $user = $this->savuser; |
|
231 | + $langs = $this->savlangs; |
|
232 | + $db = $this->savdb; |
|
233 | 233 | |
234 | 234 | /*$result=$localobject->setstatus(0); |
235 | 235 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
@@ -254,15 +254,15 @@ discard block |
||
254 | 254 | */ |
255 | 255 | public function testFactureFournisseurDelete($id) |
256 | 256 | { |
257 | - global $conf,$user,$langs,$db; |
|
258 | - $conf=$this->savconf; |
|
259 | - $user=$this->savuser; |
|
260 | - $langs=$this->savlangs; |
|
261 | - $db=$this->savdb; |
|
262 | - |
|
263 | - $localobject=new FactureFournisseur($this->savdb); |
|
264 | - $result=$localobject->fetch($id); |
|
265 | - $result=$localobject->delete($user); |
|
257 | + global $conf, $user, $langs, $db; |
|
258 | + $conf = $this->savconf; |
|
259 | + $user = $this->savuser; |
|
260 | + $langs = $this->savlangs; |
|
261 | + $db = $this->savdb; |
|
262 | + |
|
263 | + $localobject = new FactureFournisseur($this->savdb); |
|
264 | + $result = $localobject->fetch($id); |
|
265 | + $result = $localobject->delete($user); |
|
266 | 266 | |
267 | 267 | print __METHOD__." id=".$id." result=".$result."\n"; |
268 | 268 | $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 PropalTest 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 PropalTest |
|
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 PropalTest |
|
60 | + */ |
|
61 | + function __construct() |
|
62 | + { |
|
63 | + parent::__construct(); |
|
64 | + |
|
65 | + //$this->sharedFixture |
|
66 | + global $conf,$user,$langs,$db; |
|
67 | + $this->savconf=$conf; |
|
68 | + $this->savuser=$user; |
|
69 | + $this->savlangs=$langs; |
|
70 | + $this->savdb=$db; |
|
71 | + |
|
72 | + print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
|
73 | + //print " - db ".$db->db; |
|
74 | + print "\n"; |
|
75 | + } |
|
76 | + |
|
77 | + // Static methods |
|
78 | + public static function setUpBeforeClass() |
|
79 | 79 | { |
80 | - global $conf,$user,$langs,$db; |
|
81 | - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
80 | + global $conf,$user,$langs,$db; |
|
81 | + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
82 | 82 | |
83 | - print __METHOD__."\n"; |
|
83 | + print __METHOD__."\n"; |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | // tear down after class |
87 | 87 | public static function tearDownAfterClass() |
88 | 88 | { |
89 | - global $conf,$user,$langs,$db; |
|
90 | - $db->rollback(); |
|
89 | + global $conf,$user,$langs,$db; |
|
90 | + $db->rollback(); |
|
91 | 91 | |
92 | - print __METHOD__."\n"; |
|
92 | + print __METHOD__."\n"; |
|
93 | 93 | } |
94 | 94 | |
95 | - /** |
|
96 | - * Init phpunit tests |
|
97 | - * |
|
98 | - * @return void |
|
99 | - */ |
|
95 | + /** |
|
96 | + * Init phpunit tests |
|
97 | + * |
|
98 | + * @return void |
|
99 | + */ |
|
100 | 100 | protected function setUp() |
101 | 101 | { |
102 | - global $conf,$user,$langs,$db; |
|
103 | - $conf=$this->savconf; |
|
104 | - $user=$this->savuser; |
|
105 | - $langs=$this->savlangs; |
|
106 | - $db=$this->savdb; |
|
107 | - |
|
108 | - print __METHOD__."\n"; |
|
109 | - //print $db->getVersion()."\n"; |
|
102 | + global $conf,$user,$langs,$db; |
|
103 | + $conf=$this->savconf; |
|
104 | + $user=$this->savuser; |
|
105 | + $langs=$this->savlangs; |
|
106 | + $db=$this->savdb; |
|
107 | + |
|
108 | + print __METHOD__."\n"; |
|
109 | + //print $db->getVersion()."\n"; |
|
110 | 110 | } |
111 | - /** |
|
112 | - * End phpunit tests |
|
113 | - * |
|
114 | - * @return void |
|
115 | - */ |
|
111 | + /** |
|
112 | + * End phpunit tests |
|
113 | + * |
|
114 | + * @return void |
|
115 | + */ |
|
116 | 116 | protected function tearDown() |
117 | 117 | { |
118 | - print __METHOD__."\n"; |
|
118 | + print __METHOD__."\n"; |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
@@ -125,19 +125,19 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function testPropalCreate() |
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 Propal($this->savdb); |
|
135 | - $localobject->initAsSpecimen(); |
|
136 | - $result=$localobject->create($user); |
|
137 | - |
|
138 | - $this->assertLessThan($result, 0); |
|
139 | - print __METHOD__." result=".$result."\n"; |
|
140 | - return $result; |
|
128 | + global $conf,$user,$langs,$db; |
|
129 | + $conf=$this->savconf; |
|
130 | + $user=$this->savuser; |
|
131 | + $langs=$this->savlangs; |
|
132 | + $db=$this->savdb; |
|
133 | + |
|
134 | + $localobject=new Propal($this->savdb); |
|
135 | + $localobject->initAsSpecimen(); |
|
136 | + $result=$localobject->create($user); |
|
137 | + |
|
138 | + $this->assertLessThan($result, 0); |
|
139 | + print __METHOD__." result=".$result."\n"; |
|
140 | + return $result; |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
@@ -151,18 +151,18 @@ discard block |
||
151 | 151 | */ |
152 | 152 | public function testPropalFetch($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 Propal($this->savdb); |
|
161 | - $result=$localobject->fetch($id); |
|
162 | - |
|
163 | - $this->assertLessThan($result, 0); |
|
164 | - print __METHOD__." id=".$id." result=".$result."\n"; |
|
165 | - return $localobject; |
|
154 | + global $conf,$user,$langs,$db; |
|
155 | + $conf=$this->savconf; |
|
156 | + $user=$this->savuser; |
|
157 | + $langs=$this->savlangs; |
|
158 | + $db=$this->savdb; |
|
159 | + |
|
160 | + $localobject=new Propal($this->savdb); |
|
161 | + $result=$localobject->fetch($id); |
|
162 | + |
|
163 | + $this->assertLessThan($result, 0); |
|
164 | + print __METHOD__." id=".$id." result=".$result."\n"; |
|
165 | + return $localobject; |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
@@ -176,18 +176,18 @@ discard block |
||
176 | 176 | */ |
177 | 177 | public function testPropalUpdate($localobject) |
178 | 178 | { |
179 | - global $conf,$user,$langs,$db; |
|
180 | - $conf=$this->savconf; |
|
181 | - $user=$this->savuser; |
|
182 | - $langs=$this->savlangs; |
|
183 | - $db=$this->savdb; |
|
184 | - |
|
185 | - $localobject->note_private='New note private after update'; |
|
186 | - $result=$localobject->update($user); |
|
187 | - |
|
188 | - $this->assertLessThan($result, 0); |
|
189 | - print __METHOD__." id=".$id." result=".$result."\n"; |
|
190 | - return $localobject; |
|
179 | + global $conf,$user,$langs,$db; |
|
180 | + $conf=$this->savconf; |
|
181 | + $user=$this->savuser; |
|
182 | + $langs=$this->savlangs; |
|
183 | + $db=$this->savdb; |
|
184 | + |
|
185 | + $localobject->note_private='New note private after update'; |
|
186 | + $result=$localobject->update($user); |
|
187 | + |
|
188 | + $this->assertLessThan($result, 0); |
|
189 | + print __METHOD__." id=".$id." result=".$result."\n"; |
|
190 | + return $localobject; |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | /** |
@@ -201,18 +201,18 @@ discard block |
||
201 | 201 | */ |
202 | 202 | public function testPropalAddLine($localobject) |
203 | 203 | { |
204 | - global $conf,$user,$langs,$db; |
|
205 | - $conf=$this->savconf; |
|
206 | - $user=$this->savuser; |
|
207 | - $langs=$this->savlangs; |
|
208 | - $db=$this->savdb; |
|
204 | + global $conf,$user,$langs,$db; |
|
205 | + $conf=$this->savconf; |
|
206 | + $user=$this->savuser; |
|
207 | + $langs=$this->savlangs; |
|
208 | + $db=$this->savdb; |
|
209 | 209 | |
210 | 210 | $localobject->fetch_thirdparty(); |
211 | - $result=$localobject->addline('Added line', 10, 2, 19.6); |
|
211 | + $result=$localobject->addline('Added line', 10, 2, 19.6); |
|
212 | 212 | |
213 | - $this->assertLessThan($result, 0); |
|
214 | - print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
215 | - return $localobject; |
|
213 | + $this->assertLessThan($result, 0); |
|
214 | + print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
215 | + return $localobject; |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | /** |
@@ -226,20 +226,20 @@ discard block |
||
226 | 226 | */ |
227 | 227 | public function testPropalValid($localobject) |
228 | 228 | { |
229 | - global $conf,$user,$langs,$db; |
|
230 | - $conf=$this->savconf; |
|
231 | - $user=$this->savuser; |
|
232 | - $langs=$this->savlangs; |
|
233 | - $db=$this->savdb; |
|
229 | + global $conf,$user,$langs,$db; |
|
230 | + $conf=$this->savconf; |
|
231 | + $user=$this->savuser; |
|
232 | + $langs=$this->savlangs; |
|
233 | + $db=$this->savdb; |
|
234 | 234 | |
235 | - $result=$localobject->valid($user); |
|
235 | + $result=$localobject->valid($user); |
|
236 | 236 | |
237 | - print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
238 | - $this->assertLessThan($result, 0); |
|
239 | - return $localobject; |
|
237 | + print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
238 | + $this->assertLessThan($result, 0); |
|
239 | + return $localobject; |
|
240 | 240 | } |
241 | 241 | |
242 | - /** |
|
242 | + /** |
|
243 | 243 | * testPropalOther |
244 | 244 | * |
245 | 245 | * @param Propal $localobject Proposal |
@@ -279,18 +279,18 @@ discard block |
||
279 | 279 | */ |
280 | 280 | public function testPropalDelete($id) |
281 | 281 | { |
282 | - global $conf,$user,$langs,$db; |
|
283 | - $conf=$this->savconf; |
|
284 | - $user=$this->savuser; |
|
285 | - $langs=$this->savlangs; |
|
286 | - $db=$this->savdb; |
|
287 | - |
|
288 | - $localobject=new Propal($this->savdb); |
|
289 | - $result=$localobject->fetch($id); |
|
290 | - $result=$localobject->delete($user); |
|
291 | - |
|
292 | - print __METHOD__." id=".$id." result=".$result."\n"; |
|
293 | - $this->assertLessThan($result, 0); |
|
294 | - return $result; |
|
282 | + global $conf,$user,$langs,$db; |
|
283 | + $conf=$this->savconf; |
|
284 | + $user=$this->savuser; |
|
285 | + $langs=$this->savlangs; |
|
286 | + $db=$this->savdb; |
|
287 | + |
|
288 | + $localobject=new Propal($this->savdb); |
|
289 | + $result=$localobject->fetch($id); |
|
290 | + $result=$localobject->delete($user); |
|
291 | + |
|
292 | + print __METHOD__." id=".$id." result=".$result."\n"; |
|
293 | + $this->assertLessThan($result, 0); |
|
294 | + return $result; |
|
295 | 295 | } |
296 | 296 | } |
@@ -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 testPropalCreate() |
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 Propal($this->savdb); |
|
134 | + $localobject = new Propal($this->savdb); |
|
135 | 135 | $localobject->initAsSpecimen(); |
136 | - $result=$localobject->create($user); |
|
136 | + $result = $localobject->create($user); |
|
137 | 137 | |
138 | 138 | $this->assertLessThan($result, 0); |
139 | 139 | print __METHOD__." result=".$result."\n"; |
@@ -151,14 +151,14 @@ discard block |
||
151 | 151 | */ |
152 | 152 | public function testPropalFetch($id) |
153 | 153 | { |
154 | - global $conf,$user,$langs,$db; |
|
155 | - $conf=$this->savconf; |
|
156 | - $user=$this->savuser; |
|
157 | - $langs=$this->savlangs; |
|
158 | - $db=$this->savdb; |
|
154 | + global $conf, $user, $langs, $db; |
|
155 | + $conf = $this->savconf; |
|
156 | + $user = $this->savuser; |
|
157 | + $langs = $this->savlangs; |
|
158 | + $db = $this->savdb; |
|
159 | 159 | |
160 | - $localobject=new Propal($this->savdb); |
|
161 | - $result=$localobject->fetch($id); |
|
160 | + $localobject = new Propal($this->savdb); |
|
161 | + $result = $localobject->fetch($id); |
|
162 | 162 | |
163 | 163 | $this->assertLessThan($result, 0); |
164 | 164 | print __METHOD__." id=".$id." result=".$result."\n"; |
@@ -176,14 +176,14 @@ discard block |
||
176 | 176 | */ |
177 | 177 | public function testPropalUpdate($localobject) |
178 | 178 | { |
179 | - global $conf,$user,$langs,$db; |
|
180 | - $conf=$this->savconf; |
|
181 | - $user=$this->savuser; |
|
182 | - $langs=$this->savlangs; |
|
183 | - $db=$this->savdb; |
|
179 | + global $conf, $user, $langs, $db; |
|
180 | + $conf = $this->savconf; |
|
181 | + $user = $this->savuser; |
|
182 | + $langs = $this->savlangs; |
|
183 | + $db = $this->savdb; |
|
184 | 184 | |
185 | - $localobject->note_private='New note private after update'; |
|
186 | - $result=$localobject->update($user); |
|
185 | + $localobject->note_private = 'New note private after update'; |
|
186 | + $result = $localobject->update($user); |
|
187 | 187 | |
188 | 188 | $this->assertLessThan($result, 0); |
189 | 189 | print __METHOD__." id=".$id." result=".$result."\n"; |
@@ -201,14 +201,14 @@ discard block |
||
201 | 201 | */ |
202 | 202 | public function testPropalAddLine($localobject) |
203 | 203 | { |
204 | - global $conf,$user,$langs,$db; |
|
205 | - $conf=$this->savconf; |
|
206 | - $user=$this->savuser; |
|
207 | - $langs=$this->savlangs; |
|
208 | - $db=$this->savdb; |
|
204 | + global $conf, $user, $langs, $db; |
|
205 | + $conf = $this->savconf; |
|
206 | + $user = $this->savuser; |
|
207 | + $langs = $this->savlangs; |
|
208 | + $db = $this->savdb; |
|
209 | 209 | |
210 | 210 | $localobject->fetch_thirdparty(); |
211 | - $result=$localobject->addline('Added line', 10, 2, 19.6); |
|
211 | + $result = $localobject->addline('Added line', 10, 2, 19.6); |
|
212 | 212 | |
213 | 213 | $this->assertLessThan($result, 0); |
214 | 214 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
@@ -226,13 +226,13 @@ discard block |
||
226 | 226 | */ |
227 | 227 | public function testPropalValid($localobject) |
228 | 228 | { |
229 | - global $conf,$user,$langs,$db; |
|
230 | - $conf=$this->savconf; |
|
231 | - $user=$this->savuser; |
|
232 | - $langs=$this->savlangs; |
|
233 | - $db=$this->savdb; |
|
229 | + global $conf, $user, $langs, $db; |
|
230 | + $conf = $this->savconf; |
|
231 | + $user = $this->savuser; |
|
232 | + $langs = $this->savlangs; |
|
233 | + $db = $this->savdb; |
|
234 | 234 | |
235 | - $result=$localobject->valid($user); |
|
235 | + $result = $localobject->valid($user); |
|
236 | 236 | |
237 | 237 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
238 | 238 | $this->assertLessThan($result, 0); |
@@ -250,11 +250,11 @@ discard block |
||
250 | 250 | */ |
251 | 251 | public function testPropalOther($localobject) |
252 | 252 | { |
253 | - global $conf,$user,$langs,$db; |
|
254 | - $conf=$this->savconf; |
|
255 | - $user=$this->savuser; |
|
256 | - $langs=$this->savlangs; |
|
257 | - $db=$this->savdb; |
|
253 | + global $conf, $user, $langs, $db; |
|
254 | + $conf = $this->savconf; |
|
255 | + $user = $this->savuser; |
|
256 | + $langs = $this->savlangs; |
|
257 | + $db = $this->savdb; |
|
258 | 258 | |
259 | 259 | /*$result=$localobject->setstatus(0); |
260 | 260 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
@@ -279,15 +279,15 @@ discard block |
||
279 | 279 | */ |
280 | 280 | public function testPropalDelete($id) |
281 | 281 | { |
282 | - global $conf,$user,$langs,$db; |
|
283 | - $conf=$this->savconf; |
|
284 | - $user=$this->savuser; |
|
285 | - $langs=$this->savlangs; |
|
286 | - $db=$this->savdb; |
|
287 | - |
|
288 | - $localobject=new Propal($this->savdb); |
|
289 | - $result=$localobject->fetch($id); |
|
290 | - $result=$localobject->delete($user); |
|
282 | + global $conf, $user, $langs, $db; |
|
283 | + $conf = $this->savconf; |
|
284 | + $user = $this->savuser; |
|
285 | + $langs = $this->savlangs; |
|
286 | + $db = $this->savdb; |
|
287 | + |
|
288 | + $localobject = new Propal($this->savdb); |
|
289 | + $result = $localobject->fetch($id); |
|
290 | + $result = $localobject->delete($user); |
|
291 | 291 | |
292 | 292 | print __METHOD__." id=".$id." result=".$result."\n"; |
293 | 293 | $this->assertLessThan($result, 0); |
@@ -32,15 +32,15 @@ discard block |
||
32 | 32 | |
33 | 33 | if ($langs->defaultlang != 'en_US') |
34 | 34 | { |
35 | - print "Error: Default language for company to run tests must be set to en_US or auto. Current is ".$langs->defaultlang."\n"; |
|
36 | - exit(1); |
|
35 | + print "Error: Default language for company to run tests must be set to en_US or auto. Current is ".$langs->defaultlang."\n"; |
|
36 | + exit(1); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | if (empty($user->id)) |
40 | 40 | { |
41 | - print "Load permissions for admin user nb 1\n"; |
|
42 | - $user->fetch(1); |
|
43 | - $user->getrights(); |
|
41 | + print "Load permissions for admin user nb 1\n"; |
|
42 | + $user->fetch(1); |
|
43 | + $user->getrights(); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | $conf->global->MAIN_DISABLE_ALL_MAILS=1; |
@@ -55,75 +55,75 @@ discard block |
||
55 | 55 | */ |
56 | 56 | class ContactTest extends PHPUnit_Framework_TestCase |
57 | 57 | { |
58 | - protected $savconf; |
|
59 | - protected $savuser; |
|
60 | - protected $savlangs; |
|
61 | - protected $savdb; |
|
62 | - |
|
63 | - /** |
|
64 | - * Constructor |
|
65 | - * We save global variables into local variables |
|
66 | - * |
|
67 | - * @return ContactTest |
|
68 | - */ |
|
69 | - function __construct() |
|
70 | - { |
|
71 | - parent::__construct(); |
|
72 | - |
|
73 | - //$this->sharedFixture |
|
74 | - global $conf,$user,$langs,$db; |
|
75 | - $this->savconf=$conf; |
|
76 | - $this->savuser=$user; |
|
77 | - $this->savlangs=$langs; |
|
78 | - $this->savdb=$db; |
|
79 | - |
|
80 | - print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
|
81 | - //print " - db ".$db->db; |
|
82 | - print "\n"; |
|
83 | - } |
|
84 | - |
|
85 | - // Static methods |
|
86 | - public static function setUpBeforeClass() |
|
58 | + protected $savconf; |
|
59 | + protected $savuser; |
|
60 | + protected $savlangs; |
|
61 | + protected $savdb; |
|
62 | + |
|
63 | + /** |
|
64 | + * Constructor |
|
65 | + * We save global variables into local variables |
|
66 | + * |
|
67 | + * @return ContactTest |
|
68 | + */ |
|
69 | + function __construct() |
|
87 | 70 | { |
88 | - global $conf,$user,$langs,$db; |
|
71 | + parent::__construct(); |
|
72 | + |
|
73 | + //$this->sharedFixture |
|
74 | + global $conf,$user,$langs,$db; |
|
75 | + $this->savconf=$conf; |
|
76 | + $this->savuser=$user; |
|
77 | + $this->savlangs=$langs; |
|
78 | + $this->savdb=$db; |
|
79 | + |
|
80 | + print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
|
81 | + //print " - db ".$db->db; |
|
82 | + print "\n"; |
|
83 | + } |
|
84 | + |
|
85 | + // Static methods |
|
86 | + public static function setUpBeforeClass() |
|
87 | + { |
|
88 | + global $conf,$user,$langs,$db; |
|
89 | 89 | |
90 | 90 | $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
91 | 91 | |
92 | - print __METHOD__."\n"; |
|
92 | + print __METHOD__."\n"; |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | // tear down after class |
96 | 96 | public static function tearDownAfterClass() |
97 | 97 | { |
98 | - global $conf,$user,$langs,$db; |
|
99 | - $db->rollback(); |
|
98 | + global $conf,$user,$langs,$db; |
|
99 | + $db->rollback(); |
|
100 | 100 | |
101 | - print __METHOD__."\n"; |
|
101 | + print __METHOD__."\n"; |
|
102 | 102 | } |
103 | 103 | |
104 | - /** |
|
105 | - * Init phpunit tests |
|
106 | - * |
|
107 | - * @return void |
|
108 | - */ |
|
104 | + /** |
|
105 | + * Init phpunit tests |
|
106 | + * |
|
107 | + * @return void |
|
108 | + */ |
|
109 | 109 | protected function setUp() |
110 | 110 | { |
111 | - global $conf,$user,$langs,$db; |
|
112 | - $conf=$this->savconf; |
|
113 | - $user=$this->savuser; |
|
114 | - $langs=$this->savlangs; |
|
115 | - $db=$this->savdb; |
|
111 | + global $conf,$user,$langs,$db; |
|
112 | + $conf=$this->savconf; |
|
113 | + $user=$this->savuser; |
|
114 | + $langs=$this->savlangs; |
|
115 | + $db=$this->savdb; |
|
116 | 116 | |
117 | - print __METHOD__."\n"; |
|
117 | + print __METHOD__."\n"; |
|
118 | 118 | } |
119 | - /** |
|
120 | - * End phpunit tests |
|
121 | - * |
|
122 | - * @return void |
|
123 | - */ |
|
119 | + /** |
|
120 | + * End phpunit tests |
|
121 | + * |
|
122 | + * @return void |
|
123 | + */ |
|
124 | 124 | protected function tearDown() |
125 | 125 | { |
126 | - print __METHOD__."\n"; |
|
126 | + print __METHOD__."\n"; |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
@@ -133,20 +133,20 @@ discard block |
||
133 | 133 | */ |
134 | 134 | public function testContactCreate() |
135 | 135 | { |
136 | - global $conf,$user,$langs,$db; |
|
137 | - $conf=$this->savconf; |
|
138 | - $user=$this->savuser; |
|
139 | - $langs=$this->savlangs; |
|
140 | - $db=$this->savdb; |
|
136 | + global $conf,$user,$langs,$db; |
|
137 | + $conf=$this->savconf; |
|
138 | + $user=$this->savuser; |
|
139 | + $langs=$this->savlangs; |
|
140 | + $db=$this->savdb; |
|
141 | 141 | |
142 | - $localobject=new Contact($this->savdb); |
|
143 | - $localobject->initAsSpecimen(); |
|
144 | - $result=$localobject->create($user); |
|
142 | + $localobject=new Contact($this->savdb); |
|
143 | + $localobject->initAsSpecimen(); |
|
144 | + $result=$localobject->create($user); |
|
145 | 145 | |
146 | 146 | print __METHOD__." result=".$result."\n"; |
147 | - $this->assertLessThan($result, 0); |
|
147 | + $this->assertLessThan($result, 0); |
|
148 | 148 | |
149 | - return $result; |
|
149 | + return $result; |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
@@ -159,19 +159,19 @@ discard block |
||
159 | 159 | */ |
160 | 160 | public function testContactFetch($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 Contact($this->savdb); |
|
169 | - $result=$localobject->fetch($id); |
|
168 | + $localobject=new Contact($this->savdb); |
|
169 | + $result=$localobject->fetch($id); |
|
170 | 170 | |
171 | 171 | print __METHOD__." id=".$id." result=".$result."\n"; |
172 | - $this->assertLessThan($result, 0); |
|
172 | + $this->assertLessThan($result, 0); |
|
173 | 173 | |
174 | - return $localobject; |
|
174 | + return $localobject; |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
@@ -185,84 +185,84 @@ discard block |
||
185 | 185 | */ |
186 | 186 | public function testContactUpdate($localobject) |
187 | 187 | { |
188 | - global $conf,$user,$langs,$db; |
|
189 | - $conf=$this->savconf; |
|
190 | - $user=$this->savuser; |
|
191 | - $langs=$this->savlangs; |
|
192 | - $db=$this->savdb; |
|
193 | - |
|
194 | - $localobject->oldcopy = clone $localobject; |
|
195 | - |
|
196 | - $localobject->note_private='New private note after update'; |
|
197 | - $localobject->note_public='New public note after update'; |
|
198 | - $localobject->lastname='New name'; |
|
199 | - $localobject->firstname='New firstname'; |
|
200 | - $localobject->address='New address'; |
|
201 | - $localobject->zip='New zip'; |
|
202 | - $localobject->town='New town'; |
|
203 | - $localobject->country_id=2; |
|
204 | - //$localobject->status=0; |
|
205 | - $localobject->phone_pro='New tel pro'; |
|
206 | - $localobject->phone_perso='New tel perso'; |
|
207 | - $localobject->phone_mobile='New tel mobile'; |
|
208 | - $localobject->fax='New fax'; |
|
209 | - $localobject->email='[email protected]'; |
|
210 | - $localobject->jabberid='New im id'; |
|
211 | - $localobject->default_lang='es_ES'; |
|
212 | - |
|
213 | - $result=$localobject->update($localobject->id,$user); |
|
214 | - print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
215 | - $this->assertLessThan($result, 0, 'Contact::update error'); |
|
216 | - |
|
217 | - $result=$localobject->update_note($localobject->note_private,'_private'); |
|
218 | - print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
219 | - $this->assertLessThan($result, 0, 'Contact::update_note (private) error'); |
|
220 | - |
|
221 | - $result=$localobject->update_note($localobject->note_public, '_public'); |
|
222 | - print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
223 | - $this->assertLessThan($result, 0, 'Contact::update_note (public) error'); |
|
224 | - |
|
225 | - $newobject=new Contact($this->savdb); |
|
226 | - $result=$newobject->fetch($localobject->id); |
|
188 | + global $conf,$user,$langs,$db; |
|
189 | + $conf=$this->savconf; |
|
190 | + $user=$this->savuser; |
|
191 | + $langs=$this->savlangs; |
|
192 | + $db=$this->savdb; |
|
193 | + |
|
194 | + $localobject->oldcopy = clone $localobject; |
|
195 | + |
|
196 | + $localobject->note_private='New private note after update'; |
|
197 | + $localobject->note_public='New public note after update'; |
|
198 | + $localobject->lastname='New name'; |
|
199 | + $localobject->firstname='New firstname'; |
|
200 | + $localobject->address='New address'; |
|
201 | + $localobject->zip='New zip'; |
|
202 | + $localobject->town='New town'; |
|
203 | + $localobject->country_id=2; |
|
204 | + //$localobject->status=0; |
|
205 | + $localobject->phone_pro='New tel pro'; |
|
206 | + $localobject->phone_perso='New tel perso'; |
|
207 | + $localobject->phone_mobile='New tel mobile'; |
|
208 | + $localobject->fax='New fax'; |
|
209 | + $localobject->email='[email protected]'; |
|
210 | + $localobject->jabberid='New im id'; |
|
211 | + $localobject->default_lang='es_ES'; |
|
212 | + |
|
213 | + $result=$localobject->update($localobject->id,$user); |
|
214 | + print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
215 | + $this->assertLessThan($result, 0, 'Contact::update error'); |
|
216 | + |
|
217 | + $result=$localobject->update_note($localobject->note_private,'_private'); |
|
218 | + print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
219 | + $this->assertLessThan($result, 0, 'Contact::update_note (private) error'); |
|
220 | + |
|
221 | + $result=$localobject->update_note($localobject->note_public, '_public'); |
|
227 | 222 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
228 | - $this->assertLessThan($result, 0, 'Contact::fetch error'); |
|
229 | - |
|
230 | - print __METHOD__." old=".$localobject->note_private." new=".$newobject->note_private."\n"; |
|
231 | - $this->assertEquals($localobject->note_private, $newobject->note_private); |
|
232 | - //print __METHOD__." old=".$localobject->note_public." new=".$newobject->note_public."\n"; |
|
233 | - //$this->assertEquals($localobject->note_public, $newobject->note_public); |
|
234 | - print __METHOD__." old=".$localobject->lastname." new=".$newobject->lastname."\n"; |
|
235 | - $this->assertEquals($localobject->lastname, $newobject->lastname); |
|
236 | - print __METHOD__." old=".$localobject->firstname." new=".$newobject->firstname."\n"; |
|
237 | - $this->assertEquals($localobject->firstname, $newobject->firstname); |
|
238 | - print __METHOD__." old=".$localobject->address." new=".$newobject->address."\n"; |
|
239 | - $this->assertEquals($localobject->address, $newobject->address); |
|
240 | - print __METHOD__." old=".$localobject->zip." new=".$newobject->zip."\n"; |
|
241 | - $this->assertEquals($localobject->zip, $newobject->zip); |
|
242 | - print __METHOD__." old=".$localobject->town." new=".$newobject->town."\n"; |
|
243 | - $this->assertEquals($localobject->town, $newobject->town); |
|
244 | - print __METHOD__." old=".$localobject->country_id." new=".$newobject->country_id."\n"; |
|
245 | - $this->assertEquals($localobject->country_id, $newobject->country_id); |
|
246 | - print __METHOD__." old=BE new=".$newobject->country_code."\n"; |
|
247 | - $this->assertEquals('BE', $newobject->country_code); |
|
248 | - //print __METHOD__." old=".$localobject->status." new=".$newobject->status."\n"; |
|
249 | - //$this->assertEquals($localobject->status, $newobject->status); |
|
250 | - print __METHOD__." old=".$localobject->phone_pro." new=".$newobject->phone_pro."\n"; |
|
251 | - $this->assertEquals($localobject->phone_pro, $newobject->phone_pro); |
|
252 | - print __METHOD__." old=".$localobject->phone_pro." new=".$newobject->phone_pro."\n"; |
|
253 | - $this->assertEquals($localobject->phone_perso, $newobject->phone_perso); |
|
254 | - print __METHOD__." old=".$localobject->phone_mobile." new=".$newobject->phone_mobile."\n"; |
|
255 | - $this->assertEquals($localobject->phone_mobile, $newobject->phone_mobile); |
|
256 | - print __METHOD__." old=".$localobject->fax." new=".$newobject->fax."\n"; |
|
257 | - $this->assertEquals($localobject->fax, $newobject->fax); |
|
258 | - print __METHOD__." old=".$localobject->email." new=".$newobject->email."\n"; |
|
259 | - $this->assertEquals($localobject->email, $newobject->email); |
|
260 | - print __METHOD__." old=".$localobject->jabberid." new=".$newobject->jabberid."\n"; |
|
261 | - $this->assertEquals($localobject->jabberid, $newobject->jabberid); |
|
262 | - print __METHOD__." old=".$localobject->default_lang." new=".$newobject->default_lang."\n"; |
|
263 | - $this->assertEquals($localobject->default_lang, $newobject->default_lang); |
|
264 | - |
|
265 | - return $localobject; |
|
223 | + $this->assertLessThan($result, 0, 'Contact::update_note (public) error'); |
|
224 | + |
|
225 | + $newobject=new Contact($this->savdb); |
|
226 | + $result=$newobject->fetch($localobject->id); |
|
227 | + print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
|
228 | + $this->assertLessThan($result, 0, 'Contact::fetch error'); |
|
229 | + |
|
230 | + print __METHOD__." old=".$localobject->note_private." new=".$newobject->note_private."\n"; |
|
231 | + $this->assertEquals($localobject->note_private, $newobject->note_private); |
|
232 | + //print __METHOD__." old=".$localobject->note_public." new=".$newobject->note_public."\n"; |
|
233 | + //$this->assertEquals($localobject->note_public, $newobject->note_public); |
|
234 | + print __METHOD__." old=".$localobject->lastname." new=".$newobject->lastname."\n"; |
|
235 | + $this->assertEquals($localobject->lastname, $newobject->lastname); |
|
236 | + print __METHOD__." old=".$localobject->firstname." new=".$newobject->firstname."\n"; |
|
237 | + $this->assertEquals($localobject->firstname, $newobject->firstname); |
|
238 | + print __METHOD__." old=".$localobject->address." new=".$newobject->address."\n"; |
|
239 | + $this->assertEquals($localobject->address, $newobject->address); |
|
240 | + print __METHOD__." old=".$localobject->zip." new=".$newobject->zip."\n"; |
|
241 | + $this->assertEquals($localobject->zip, $newobject->zip); |
|
242 | + print __METHOD__." old=".$localobject->town." new=".$newobject->town."\n"; |
|
243 | + $this->assertEquals($localobject->town, $newobject->town); |
|
244 | + print __METHOD__." old=".$localobject->country_id." new=".$newobject->country_id."\n"; |
|
245 | + $this->assertEquals($localobject->country_id, $newobject->country_id); |
|
246 | + print __METHOD__." old=BE new=".$newobject->country_code."\n"; |
|
247 | + $this->assertEquals('BE', $newobject->country_code); |
|
248 | + //print __METHOD__." old=".$localobject->status." new=".$newobject->status."\n"; |
|
249 | + //$this->assertEquals($localobject->status, $newobject->status); |
|
250 | + print __METHOD__." old=".$localobject->phone_pro." new=".$newobject->phone_pro."\n"; |
|
251 | + $this->assertEquals($localobject->phone_pro, $newobject->phone_pro); |
|
252 | + print __METHOD__." old=".$localobject->phone_pro." new=".$newobject->phone_pro."\n"; |
|
253 | + $this->assertEquals($localobject->phone_perso, $newobject->phone_perso); |
|
254 | + print __METHOD__." old=".$localobject->phone_mobile." new=".$newobject->phone_mobile."\n"; |
|
255 | + $this->assertEquals($localobject->phone_mobile, $newobject->phone_mobile); |
|
256 | + print __METHOD__." old=".$localobject->fax." new=".$newobject->fax."\n"; |
|
257 | + $this->assertEquals($localobject->fax, $newobject->fax); |
|
258 | + print __METHOD__." old=".$localobject->email." new=".$newobject->email."\n"; |
|
259 | + $this->assertEquals($localobject->email, $newobject->email); |
|
260 | + print __METHOD__." old=".$localobject->jabberid." new=".$newobject->jabberid."\n"; |
|
261 | + $this->assertEquals($localobject->jabberid, $newobject->jabberid); |
|
262 | + print __METHOD__." old=".$localobject->default_lang." new=".$newobject->default_lang."\n"; |
|
263 | + $this->assertEquals($localobject->default_lang, $newobject->default_lang); |
|
264 | + |
|
265 | + return $localobject; |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
@@ -276,13 +276,13 @@ discard block |
||
276 | 276 | */ |
277 | 277 | public function testContactOther($localobject) |
278 | 278 | { |
279 | - global $conf,$user,$langs,$db; |
|
280 | - $conf=$this->savconf; |
|
281 | - $user=$this->savuser; |
|
282 | - $langs=$this->savlangs; |
|
283 | - $db=$this->savdb; |
|
279 | + global $conf,$user,$langs,$db; |
|
280 | + $conf=$this->savconf; |
|
281 | + $user=$this->savuser; |
|
282 | + $langs=$this->savlangs; |
|
283 | + $db=$this->savdb; |
|
284 | 284 | |
285 | - //$localobject->fetch($localobject->id); |
|
285 | + //$localobject->fetch($localobject->id); |
|
286 | 286 | |
287 | 287 | $result=$localobject->getNomUrl(1); |
288 | 288 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
@@ -310,26 +310,26 @@ discard block |
||
310 | 310 | */ |
311 | 311 | public function testContactDelete($id) |
312 | 312 | { |
313 | - global $conf,$user,$langs,$db; |
|
314 | - $conf=$this->savconf; |
|
315 | - $user=$this->savuser; |
|
316 | - $langs=$this->savlangs; |
|
317 | - $db=$this->savdb; |
|
313 | + global $conf,$user,$langs,$db; |
|
314 | + $conf=$this->savconf; |
|
315 | + $user=$this->savuser; |
|
316 | + $langs=$this->savlangs; |
|
317 | + $db=$this->savdb; |
|
318 | 318 | |
319 | - $localobject=new Contact($this->savdb); |
|
320 | - $result=$localobject->fetch($id); |
|
319 | + $localobject=new Contact($this->savdb); |
|
320 | + $result=$localobject->fetch($id); |
|
321 | 321 | |
322 | - $result=$localobject->delete(0); |
|
323 | - print __METHOD__." id=".$id." result=".$result."\n"; |
|
324 | - $this->assertLessThan($result, 0); |
|
322 | + $result=$localobject->delete(0); |
|
323 | + print __METHOD__." id=".$id." result=".$result."\n"; |
|
324 | + $this->assertLessThan($result, 0); |
|
325 | 325 | |
326 | - return $result; |
|
326 | + return $result; |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | /** |
330 | - * testContactStatic |
|
331 | - * |
|
332 | - * @return void |
|
330 | + * testContactStatic |
|
331 | + * |
|
332 | + * @return void |
|
333 | 333 | */ |
334 | 334 | public function testContactStatic() |
335 | 335 | { |
@@ -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'; |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | $user->getrights(); |
44 | 44 | } |
45 | 45 | |
46 | -$conf->global->MAIN_DISABLE_ALL_MAILS=1; |
|
46 | +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
|
47 | 47 | |
48 | 48 | |
49 | 49 | /** |
@@ -71,11 +71,11 @@ discard block |
||
71 | 71 | parent::__construct(); |
72 | 72 | |
73 | 73 | //$this->sharedFixture |
74 | - global $conf,$user,$langs,$db; |
|
75 | - $this->savconf=$conf; |
|
76 | - $this->savuser=$user; |
|
77 | - $this->savlangs=$langs; |
|
78 | - $this->savdb=$db; |
|
74 | + global $conf, $user, $langs, $db; |
|
75 | + $this->savconf = $conf; |
|
76 | + $this->savuser = $user; |
|
77 | + $this->savlangs = $langs; |
|
78 | + $this->savdb = $db; |
|
79 | 79 | |
80 | 80 | print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
81 | 81 | //print " - db ".$db->db; |
@@ -85,9 +85,9 @@ discard block |
||
85 | 85 | // Static methods |
86 | 86 | public static function setUpBeforeClass() |
87 | 87 | { |
88 | - global $conf,$user,$langs,$db; |
|
88 | + global $conf, $user, $langs, $db; |
|
89 | 89 | |
90 | - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
90 | + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
91 | 91 | |
92 | 92 | print __METHOD__."\n"; |
93 | 93 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | // tear down after class |
96 | 96 | public static function tearDownAfterClass() |
97 | 97 | { |
98 | - global $conf,$user,$langs,$db; |
|
98 | + global $conf, $user, $langs, $db; |
|
99 | 99 | $db->rollback(); |
100 | 100 | |
101 | 101 | print __METHOD__."\n"; |
@@ -108,11 +108,11 @@ discard block |
||
108 | 108 | */ |
109 | 109 | protected function setUp() |
110 | 110 | { |
111 | - global $conf,$user,$langs,$db; |
|
112 | - $conf=$this->savconf; |
|
113 | - $user=$this->savuser; |
|
114 | - $langs=$this->savlangs; |
|
115 | - $db=$this->savdb; |
|
111 | + global $conf, $user, $langs, $db; |
|
112 | + $conf = $this->savconf; |
|
113 | + $user = $this->savuser; |
|
114 | + $langs = $this->savlangs; |
|
115 | + $db = $this->savdb; |
|
116 | 116 | |
117 | 117 | print __METHOD__."\n"; |
118 | 118 | } |
@@ -133,15 +133,15 @@ discard block |
||
133 | 133 | */ |
134 | 134 | public function testContactCreate() |
135 | 135 | { |
136 | - global $conf,$user,$langs,$db; |
|
137 | - $conf=$this->savconf; |
|
138 | - $user=$this->savuser; |
|
139 | - $langs=$this->savlangs; |
|
140 | - $db=$this->savdb; |
|
136 | + global $conf, $user, $langs, $db; |
|
137 | + $conf = $this->savconf; |
|
138 | + $user = $this->savuser; |
|
139 | + $langs = $this->savlangs; |
|
140 | + $db = $this->savdb; |
|
141 | 141 | |
142 | - $localobject=new Contact($this->savdb); |
|
142 | + $localobject = new Contact($this->savdb); |
|
143 | 143 | $localobject->initAsSpecimen(); |
144 | - $result=$localobject->create($user); |
|
144 | + $result = $localobject->create($user); |
|
145 | 145 | |
146 | 146 | print __METHOD__." result=".$result."\n"; |
147 | 147 | $this->assertLessThan($result, 0); |
@@ -159,14 +159,14 @@ discard block |
||
159 | 159 | */ |
160 | 160 | public function testContactFetch($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 Contact($this->savdb); |
|
169 | - $result=$localobject->fetch($id); |
|
168 | + $localobject = new Contact($this->savdb); |
|
169 | + $result = $localobject->fetch($id); |
|
170 | 170 | |
171 | 171 | print __METHOD__." id=".$id." result=".$result."\n"; |
172 | 172 | $this->assertLessThan($result, 0); |
@@ -185,45 +185,45 @@ discard block |
||
185 | 185 | */ |
186 | 186 | public function testContactUpdate($localobject) |
187 | 187 | { |
188 | - global $conf,$user,$langs,$db; |
|
189 | - $conf=$this->savconf; |
|
190 | - $user=$this->savuser; |
|
191 | - $langs=$this->savlangs; |
|
192 | - $db=$this->savdb; |
|
188 | + global $conf, $user, $langs, $db; |
|
189 | + $conf = $this->savconf; |
|
190 | + $user = $this->savuser; |
|
191 | + $langs = $this->savlangs; |
|
192 | + $db = $this->savdb; |
|
193 | 193 | |
194 | 194 | $localobject->oldcopy = clone $localobject; |
195 | 195 | |
196 | - $localobject->note_private='New private note after update'; |
|
197 | - $localobject->note_public='New public note after update'; |
|
198 | - $localobject->lastname='New name'; |
|
199 | - $localobject->firstname='New firstname'; |
|
200 | - $localobject->address='New address'; |
|
201 | - $localobject->zip='New zip'; |
|
202 | - $localobject->town='New town'; |
|
203 | - $localobject->country_id=2; |
|
196 | + $localobject->note_private = 'New private note after update'; |
|
197 | + $localobject->note_public = 'New public note after update'; |
|
198 | + $localobject->lastname = 'New name'; |
|
199 | + $localobject->firstname = 'New firstname'; |
|
200 | + $localobject->address = 'New address'; |
|
201 | + $localobject->zip = 'New zip'; |
|
202 | + $localobject->town = 'New town'; |
|
203 | + $localobject->country_id = 2; |
|
204 | 204 | //$localobject->status=0; |
205 | - $localobject->phone_pro='New tel pro'; |
|
206 | - $localobject->phone_perso='New tel perso'; |
|
207 | - $localobject->phone_mobile='New tel mobile'; |
|
208 | - $localobject->fax='New fax'; |
|
209 | - $localobject->email='[email protected]'; |
|
210 | - $localobject->jabberid='New im id'; |
|
211 | - $localobject->default_lang='es_ES'; |
|
212 | - |
|
213 | - $result=$localobject->update($localobject->id,$user); |
|
205 | + $localobject->phone_pro = 'New tel pro'; |
|
206 | + $localobject->phone_perso = 'New tel perso'; |
|
207 | + $localobject->phone_mobile = 'New tel mobile'; |
|
208 | + $localobject->fax = 'New fax'; |
|
209 | + $localobject->email = '[email protected]'; |
|
210 | + $localobject->jabberid = 'New im id'; |
|
211 | + $localobject->default_lang = 'es_ES'; |
|
212 | + |
|
213 | + $result = $localobject->update($localobject->id, $user); |
|
214 | 214 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
215 | 215 | $this->assertLessThan($result, 0, 'Contact::update error'); |
216 | 216 | |
217 | - $result=$localobject->update_note($localobject->note_private,'_private'); |
|
217 | + $result = $localobject->update_note($localobject->note_private, '_private'); |
|
218 | 218 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
219 | 219 | $this->assertLessThan($result, 0, 'Contact::update_note (private) error'); |
220 | 220 | |
221 | - $result=$localobject->update_note($localobject->note_public, '_public'); |
|
221 | + $result = $localobject->update_note($localobject->note_public, '_public'); |
|
222 | 222 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
223 | 223 | $this->assertLessThan($result, 0, 'Contact::update_note (public) error'); |
224 | 224 | |
225 | - $newobject=new Contact($this->savdb); |
|
226 | - $result=$newobject->fetch($localobject->id); |
|
225 | + $newobject = new Contact($this->savdb); |
|
226 | + $result = $newobject->fetch($localobject->id); |
|
227 | 227 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
228 | 228 | $this->assertLessThan($result, 0, 'Contact::fetch error'); |
229 | 229 | |
@@ -276,19 +276,19 @@ discard block |
||
276 | 276 | */ |
277 | 277 | public function testContactOther($localobject) |
278 | 278 | { |
279 | - global $conf,$user,$langs,$db; |
|
280 | - $conf=$this->savconf; |
|
281 | - $user=$this->savuser; |
|
282 | - $langs=$this->savlangs; |
|
283 | - $db=$this->savdb; |
|
279 | + global $conf, $user, $langs, $db; |
|
280 | + $conf = $this->savconf; |
|
281 | + $user = $this->savuser; |
|
282 | + $langs = $this->savlangs; |
|
283 | + $db = $this->savdb; |
|
284 | 284 | |
285 | 285 | //$localobject->fetch($localobject->id); |
286 | 286 | |
287 | - $result=$localobject->getNomUrl(1); |
|
287 | + $result = $localobject->getNomUrl(1); |
|
288 | 288 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
289 | 289 | $this->assertNotEquals($result, ''); |
290 | 290 | |
291 | - $result=$localobject->getFullAddress(1); |
|
291 | + $result = $localobject->getFullAddress(1); |
|
292 | 292 | print __METHOD__." id=".$localobject->id." result=".$result."\n"; |
293 | 293 | $this->assertContains("New address\nNew zip New town\nBelgium", $result); |
294 | 294 | |
@@ -310,16 +310,16 @@ discard block |
||
310 | 310 | */ |
311 | 311 | public function testContactDelete($id) |
312 | 312 | { |
313 | - global $conf,$user,$langs,$db; |
|
314 | - $conf=$this->savconf; |
|
315 | - $user=$this->savuser; |
|
316 | - $langs=$this->savlangs; |
|
317 | - $db=$this->savdb; |
|
313 | + global $conf, $user, $langs, $db; |
|
314 | + $conf = $this->savconf; |
|
315 | + $user = $this->savuser; |
|
316 | + $langs = $this->savlangs; |
|
317 | + $db = $this->savdb; |
|
318 | 318 | |
319 | - $localobject=new Contact($this->savdb); |
|
320 | - $result=$localobject->fetch($id); |
|
319 | + $localobject = new Contact($this->savdb); |
|
320 | + $result = $localobject->fetch($id); |
|
321 | 321 | |
322 | - $result=$localobject->delete(0); |
|
322 | + $result = $localobject->delete(0); |
|
323 | 323 | print __METHOD__." id=".$id." result=".$result."\n"; |
324 | 324 | $this->assertLessThan($result, 0); |
325 | 325 | |
@@ -333,13 +333,13 @@ discard block |
||
333 | 333 | */ |
334 | 334 | public function testContactStatic() |
335 | 335 | { |
336 | - global $conf,$user,$langs,$db; |
|
337 | - $conf=$this->savconf; |
|
338 | - $user=$this->savuser; |
|
339 | - $langs=$this->savlangs; |
|
340 | - $db=$this->savdb; |
|
336 | + global $conf, $user, $langs, $db; |
|
337 | + $conf = $this->savconf; |
|
338 | + $user = $this->savuser; |
|
339 | + $langs = $this->savlangs; |
|
340 | + $db = $this->savdb; |
|
341 | 341 | |
342 | - $localobject=new Contact($db); |
|
342 | + $localobject = new Contact($db); |
|
343 | 343 | |
344 | 344 | |
345 | 345 | return; |
@@ -352,56 +352,56 @@ discard block |
||
352 | 352 | */ |
353 | 353 | public function testContactGetFullAddress() |
354 | 354 | { |
355 | - global $conf,$user,$langs,$db; |
|
356 | - $conf=$this->savconf; |
|
357 | - $user=$this->savuser; |
|
358 | - $langs=$this->savlangs; |
|
359 | - $db=$this->savdb; |
|
355 | + global $conf, $user, $langs, $db; |
|
356 | + $conf = $this->savconf; |
|
357 | + $user = $this->savuser; |
|
358 | + $langs = $this->savlangs; |
|
359 | + $db = $this->savdb; |
|
360 | 360 | |
361 | - $localobjectadd=new Contact($db); |
|
361 | + $localobjectadd = new Contact($db); |
|
362 | 362 | $localobjectadd->initAsSpecimen(); |
363 | 363 | |
364 | 364 | // France |
365 | 365 | unset($localobjectadd->country_code); |
366 | - $localobjectadd->country_id=1; |
|
367 | - $localobjectadd->name='New name'; |
|
368 | - $localobjectadd->address='New address'; |
|
369 | - $localobjectadd->zip='New zip'; |
|
370 | - $localobjectadd->town='New town'; |
|
371 | - $result=$localobjectadd->getFullAddress(1); |
|
366 | + $localobjectadd->country_id = 1; |
|
367 | + $localobjectadd->name = 'New name'; |
|
368 | + $localobjectadd->address = 'New address'; |
|
369 | + $localobjectadd->zip = 'New zip'; |
|
370 | + $localobjectadd->town = 'New town'; |
|
371 | + $result = $localobjectadd->getFullAddress(1); |
|
372 | 372 | print __METHOD__." id=".$localobjectadd->id." result=".$result."\n"; |
373 | 373 | $this->assertContains("New address\nNew zip New town\nFrance", $result); |
374 | 374 | |
375 | 375 | // Belgium |
376 | 376 | unset($localobjectadd->country_code); |
377 | - $localobjectadd->country_id=2; |
|
378 | - $localobjectadd->name='New name'; |
|
379 | - $localobjectadd->address='New address'; |
|
380 | - $localobjectadd->zip='New zip'; |
|
381 | - $localobjectadd->town='New town'; |
|
382 | - $result=$localobjectadd->getFullAddress(1); |
|
377 | + $localobjectadd->country_id = 2; |
|
378 | + $localobjectadd->name = 'New name'; |
|
379 | + $localobjectadd->address = 'New address'; |
|
380 | + $localobjectadd->zip = 'New zip'; |
|
381 | + $localobjectadd->town = 'New town'; |
|
382 | + $result = $localobjectadd->getFullAddress(1); |
|
383 | 383 | print __METHOD__." id=".$localobjectadd->id." result=".$result."\n"; |
384 | 384 | $this->assertContains("New address\nNew zip New town\nBelgium", $result); |
385 | 385 | |
386 | 386 | // Switzerland |
387 | 387 | unset($localobjectadd->country_code); |
388 | - $localobjectadd->country_id=6; |
|
389 | - $localobjectadd->name='New name'; |
|
390 | - $localobjectadd->address='New address'; |
|
391 | - $localobjectadd->zip='New zip'; |
|
392 | - $localobjectadd->town='New town'; |
|
393 | - $result=$localobjectadd->getFullAddress(1); |
|
388 | + $localobjectadd->country_id = 6; |
|
389 | + $localobjectadd->name = 'New name'; |
|
390 | + $localobjectadd->address = 'New address'; |
|
391 | + $localobjectadd->zip = 'New zip'; |
|
392 | + $localobjectadd->town = 'New town'; |
|
393 | + $result = $localobjectadd->getFullAddress(1); |
|
394 | 394 | print __METHOD__." id=".$localobjectadd->id." result=".$result."\n"; |
395 | 395 | $this->assertContains("New address\nNew zip New town\nSwitzerland", $result); |
396 | 396 | |
397 | 397 | // USA |
398 | 398 | unset($localobjectadd->country_code); |
399 | - $localobjectadd->country_id=11; |
|
400 | - $localobjectadd->name='New name'; |
|
401 | - $localobjectadd->address='New address'; |
|
402 | - $localobjectadd->zip='New zip'; |
|
403 | - $localobjectadd->town='New town'; |
|
404 | - $result=$localobjectadd->getFullAddress(1); |
|
399 | + $localobjectadd->country_id = 11; |
|
400 | + $localobjectadd->name = 'New name'; |
|
401 | + $localobjectadd->address = 'New address'; |
|
402 | + $localobjectadd->zip = 'New zip'; |
|
403 | + $localobjectadd->town = 'New town'; |
|
404 | + $result = $localobjectadd->getFullAddress(1); |
|
405 | 405 | print __METHOD__." id=".$localobjectadd->id." result=".$result."\n"; |
406 | 406 | $this->assertContains("New address\nNew town, New zip\nUnited States", $result); |
407 | 407 |
@@ -51,74 +51,74 @@ discard block |
||
51 | 51 | */ |
52 | 52 | class ExportTest extends PHPUnit_Framework_TestCase |
53 | 53 | { |
54 | - protected $savconf; |
|
55 | - protected $savuser; |
|
56 | - protected $savlangs; |
|
57 | - protected $savdb; |
|
58 | - |
|
59 | - /** |
|
60 | - * Constructor |
|
61 | - * We save global variables into local variables |
|
62 | - * |
|
63 | - * @return ExportTest |
|
64 | - */ |
|
65 | - function __construct() |
|
66 | - { |
|
67 | - parent::__construct(); |
|
68 | - |
|
69 | - //$this->sharedFixture |
|
70 | - global $conf,$user,$langs,$db; |
|
71 | - $this->savconf=$conf; |
|
72 | - $this->savuser=$user; |
|
73 | - $this->savlangs=$langs; |
|
74 | - $this->savdb=$db; |
|
75 | - |
|
76 | - print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
|
77 | - //print " - db ".$db->db; |
|
78 | - print "\n"; |
|
79 | - } |
|
80 | - |
|
81 | - // Static methods |
|
82 | - public static function setUpBeforeClass() |
|
54 | + protected $savconf; |
|
55 | + protected $savuser; |
|
56 | + protected $savlangs; |
|
57 | + protected $savdb; |
|
58 | + |
|
59 | + /** |
|
60 | + * Constructor |
|
61 | + * We save global variables into local variables |
|
62 | + * |
|
63 | + * @return ExportTest |
|
64 | + */ |
|
65 | + function __construct() |
|
83 | 66 | { |
84 | - global $conf,$user,$langs,$db; |
|
85 | - //$db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
67 | + parent::__construct(); |
|
86 | 68 | |
87 | - print __METHOD__."\n"; |
|
69 | + //$this->sharedFixture |
|
70 | + global $conf,$user,$langs,$db; |
|
71 | + $this->savconf=$conf; |
|
72 | + $this->savuser=$user; |
|
73 | + $this->savlangs=$langs; |
|
74 | + $this->savdb=$db; |
|
75 | + |
|
76 | + print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
|
77 | + //print " - db ".$db->db; |
|
78 | + print "\n"; |
|
79 | + } |
|
80 | + |
|
81 | + // Static methods |
|
82 | + public static function setUpBeforeClass() |
|
83 | + { |
|
84 | + global $conf,$user,$langs,$db; |
|
85 | + //$db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
86 | + |
|
87 | + print __METHOD__."\n"; |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | // tear down after class |
91 | 91 | public static function tearDownAfterClass() |
92 | 92 | { |
93 | - global $conf,$user,$langs,$db; |
|
94 | - //$db->rollback(); |
|
93 | + global $conf,$user,$langs,$db; |
|
94 | + //$db->rollback(); |
|
95 | 95 | |
96 | - print __METHOD__."\n"; |
|
96 | + print __METHOD__."\n"; |
|
97 | 97 | } |
98 | 98 | |
99 | - /** |
|
100 | - * Init phpunit tests |
|
101 | - * |
|
102 | - * @return void |
|
103 | - */ |
|
99 | + /** |
|
100 | + * Init phpunit tests |
|
101 | + * |
|
102 | + * @return void |
|
103 | + */ |
|
104 | 104 | protected function setUp() |
105 | 105 | { |
106 | - global $conf,$user,$langs,$db; |
|
107 | - $conf=$this->savconf; |
|
108 | - $user=$this->savuser; |
|
109 | - $langs=$this->savlangs; |
|
110 | - $db=$this->savdb; |
|
106 | + global $conf,$user,$langs,$db; |
|
107 | + $conf=$this->savconf; |
|
108 | + $user=$this->savuser; |
|
109 | + $langs=$this->savlangs; |
|
110 | + $db=$this->savdb; |
|
111 | 111 | |
112 | - print __METHOD__."\n"; |
|
112 | + print __METHOD__."\n"; |
|
113 | 113 | } |
114 | - /** |
|
115 | - * End phpunit tests |
|
116 | - * |
|
117 | - * @return void |
|
118 | - */ |
|
114 | + /** |
|
115 | + * End phpunit tests |
|
116 | + * |
|
117 | + * @return void |
|
118 | + */ |
|
119 | 119 | protected function tearDown() |
120 | 120 | { |
121 | - print __METHOD__."\n"; |
|
121 | + print __METHOD__."\n"; |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | * Test export function for a personalized dataset |
212 | 212 | * |
213 | 213 | * @depends testExportOther |
214 | - * @return void |
|
214 | + * @return void |
|
215 | 215 | */ |
216 | 216 | public function testExportPersonalizedExport() |
217 | 217 | { |
@@ -236,21 +236,21 @@ discard block |
||
236 | 236 | |
237 | 237 | // Build export file |
238 | 238 | $result=$objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql); |
239 | - $expectedresult=1; |
|
239 | + $expectedresult=1; |
|
240 | 240 | $this->assertEquals($expectedresult,$result); |
241 | 241 | |
242 | 242 | $model='tsv'; |
243 | 243 | |
244 | 244 | // Build export file |
245 | 245 | $result=$objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql); |
246 | - $expectedresult=1; |
|
246 | + $expectedresult=1; |
|
247 | 247 | $this->assertEquals($expectedresult,$result); |
248 | 248 | |
249 | 249 | $model='excel'; |
250 | 250 | |
251 | 251 | // Build export file |
252 | 252 | $result=$objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql); |
253 | - $expectedresult=1; |
|
253 | + $expectedresult=1; |
|
254 | 254 | $this->assertEquals($expectedresult,$result); |
255 | 255 | |
256 | 256 | return true; |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | */ |
265 | 265 | public function testExportPersonalizedWithFilter() |
266 | 266 | { |
267 | - global $conf,$user,$langs,$db; |
|
267 | + global $conf,$user,$langs,$db; |
|
268 | 268 | /* |
269 | 269 | $sql = "SELECT f.ref as f_ref, f.total as f_total, f.tva as f_tva FROM ".MAIN_DB_PREFIX."facture f"; |
270 | 270 | |
@@ -304,14 +304,14 @@ discard block |
||
304 | 304 | $expectedresult=1; |
305 | 305 | $this->assertEquals($expectedresult,$result); |
306 | 306 | */ |
307 | - return true; |
|
307 | + return true; |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | /** |
311 | 311 | * Test export function for all dataset predefined into modules |
312 | 312 | * |
313 | 313 | * @depends testExportPersonalizedWithFilter |
314 | - * @return void |
|
314 | + * @return void |
|
315 | 315 | */ |
316 | 316 | public function testExportModulesDatasets() |
317 | 317 | { |
@@ -330,26 +330,26 @@ discard block |
||
330 | 330 | // Loop on each dataset |
331 | 331 | foreach($objexport->array_export_code as $key => $datatoexport) |
332 | 332 | { |
333 | - $exportfile=$conf->export->dir_temp.'/'.$user->id.'/export_'.$datatoexport.'.csv'; |
|
334 | - print "Process export for dataset ".$datatoexport." into ".$exportfile."\n"; |
|
335 | - dol_delete_file($exportfile); |
|
336 | - |
|
337 | - // Generate $array_selected |
|
338 | - $i=0; |
|
339 | - $array_selected=array(); |
|
340 | - foreach($objexport->array_export_fields[$key] as $key => $val) |
|
341 | - { |
|
342 | - $array_selected[$key]=$i++; |
|
343 | - } |
|
344 | - //var_dump($array_selected); |
|
345 | - |
|
346 | - // Build export file |
|
347 | - $sql = ""; |
|
348 | - $result=$objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql); |
|
349 | - $expectedresult=1; |
|
350 | - $this->assertEquals($expectedresult, $result, "Call build_file() to export ".$exportfile.' failed'); |
|
351 | - $result=dol_is_file($exportfile); |
|
352 | - $this->assertTrue($result, 'File '.$exportfile.' not found'); |
|
333 | + $exportfile=$conf->export->dir_temp.'/'.$user->id.'/export_'.$datatoexport.'.csv'; |
|
334 | + print "Process export for dataset ".$datatoexport." into ".$exportfile."\n"; |
|
335 | + dol_delete_file($exportfile); |
|
336 | + |
|
337 | + // Generate $array_selected |
|
338 | + $i=0; |
|
339 | + $array_selected=array(); |
|
340 | + foreach($objexport->array_export_fields[$key] as $key => $val) |
|
341 | + { |
|
342 | + $array_selected[$key]=$i++; |
|
343 | + } |
|
344 | + //var_dump($array_selected); |
|
345 | + |
|
346 | + // Build export file |
|
347 | + $sql = ""; |
|
348 | + $result=$objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql); |
|
349 | + $expectedresult=1; |
|
350 | + $this->assertEquals($expectedresult, $result, "Call build_file() to export ".$exportfile.' failed'); |
|
351 | + $result=dol_is_file($exportfile); |
|
352 | + $this->assertTrue($result, 'File '.$exportfile.' not found'); |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | return true; |
@@ -23,23 +23,23 @@ discard block |
||
23 | 23 | * \remarks To run this script as CLI: phpunit filename.php |
24 | 24 | */ |
25 | 25 | |
26 | -global $conf,$user,$langs,$db; |
|
26 | +global $conf, $user, $langs, $db; |
|
27 | 27 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
28 | 28 | //require_once 'PHPUnit/Autoload.php'; |
29 | 29 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
30 | 30 | require_once dirname(__FILE__).'/../../htdocs/exports/class/export.class.php'; |
31 | 31 | require_once dirname(__FILE__).'/../../htdocs/core/lib/files.lib.php'; |
32 | 32 | |
33 | -if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); |
|
34 | -if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); |
|
35 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
36 | -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); |
|
37 | -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); |
|
38 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); |
|
39 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show |
|
40 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php |
|
41 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
42 | -if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) |
|
33 | +if (!defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); |
|
34 | +if (!defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); |
|
35 | +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); |
|
36 | +if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); |
|
37 | +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); |
|
38 | +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); |
|
39 | +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no menu to show |
|
40 | +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php |
|
41 | +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); |
|
42 | +if (!defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) |
|
43 | 43 | |
44 | 44 | |
45 | 45 | /** |
@@ -67,11 +67,11 @@ discard block |
||
67 | 67 | parent::__construct(); |
68 | 68 | |
69 | 69 | //$this->sharedFixture |
70 | - global $conf,$user,$langs,$db; |
|
71 | - $this->savconf=$conf; |
|
72 | - $this->savuser=$user; |
|
73 | - $this->savlangs=$langs; |
|
74 | - $this->savdb=$db; |
|
70 | + global $conf, $user, $langs, $db; |
|
71 | + $this->savconf = $conf; |
|
72 | + $this->savuser = $user; |
|
73 | + $this->savlangs = $langs; |
|
74 | + $this->savdb = $db; |
|
75 | 75 | |
76 | 76 | print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
77 | 77 | //print " - db ".$db->db; |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | // Static methods |
82 | 82 | public static function setUpBeforeClass() |
83 | 83 | { |
84 | - global $conf,$user,$langs,$db; |
|
84 | + global $conf, $user, $langs, $db; |
|
85 | 85 | //$db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
86 | 86 | |
87 | 87 | print __METHOD__."\n"; |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | // tear down after class |
91 | 91 | public static function tearDownAfterClass() |
92 | 92 | { |
93 | - global $conf,$user,$langs,$db; |
|
93 | + global $conf, $user, $langs, $db; |
|
94 | 94 | //$db->rollback(); |
95 | 95 | |
96 | 96 | print __METHOD__."\n"; |
@@ -103,11 +103,11 @@ discard block |
||
103 | 103 | */ |
104 | 104 | protected function setUp() |
105 | 105 | { |
106 | - global $conf,$user,$langs,$db; |
|
107 | - $conf=$this->savconf; |
|
108 | - $user=$this->savuser; |
|
109 | - $langs=$this->savlangs; |
|
110 | - $db=$this->savdb; |
|
106 | + global $conf, $user, $langs, $db; |
|
107 | + $conf = $this->savconf; |
|
108 | + $user = $this->savuser; |
|
109 | + $langs = $this->savlangs; |
|
110 | + $db = $this->savdb; |
|
111 | 111 | |
112 | 112 | print __METHOD__."\n"; |
113 | 113 | } |
@@ -129,12 +129,12 @@ discard block |
||
129 | 129 | */ |
130 | 130 | public function testExportOther() |
131 | 131 | { |
132 | - global $conf,$user,$langs,$db; |
|
132 | + global $conf, $user, $langs, $db; |
|
133 | 133 | |
134 | - $model='csv'; |
|
134 | + $model = 'csv'; |
|
135 | 135 | |
136 | 136 | // Creation of class to export using model ExportXXX |
137 | - $dir = DOL_DOCUMENT_ROOT . "/core/modules/export/"; |
|
137 | + $dir = DOL_DOCUMENT_ROOT."/core/modules/export/"; |
|
138 | 138 | $file = "export_".$model.".modules.php"; |
139 | 139 | $classname = "Export".$model; |
140 | 140 | require_once $dir.$file; |
@@ -143,64 +143,64 @@ discard block |
||
143 | 143 | // First test without option USE_STRICT_CSV_RULES |
144 | 144 | unset($conf->global->USE_STRICT_CSV_RULES); |
145 | 145 | |
146 | - $valtotest='A simple string'; |
|
146 | + $valtotest = 'A simple string'; |
|
147 | 147 | print __METHOD__." valtotest=".$valtotest."\n"; |
148 | 148 | $result = $objmodel->csvClean($valtotest, $langs->charset_output); |
149 | 149 | print __METHOD__." result=".$result."\n"; |
150 | 150 | $this->assertEquals($result, 'A simple string'); |
151 | 151 | |
152 | - $valtotest='A string with , and ; inside'; |
|
152 | + $valtotest = 'A string with , and ; inside'; |
|
153 | 153 | print __METHOD__." valtotest=".$valtotest."\n"; |
154 | 154 | $result = $objmodel->csvClean($valtotest, $langs->charset_output); |
155 | 155 | print __METHOD__." result=".$result."\n"; |
156 | 156 | $this->assertEquals($result, '"A string with , and ; inside"'); |
157 | 157 | |
158 | - $valtotest='A string with " inside'; |
|
158 | + $valtotest = 'A string with " inside'; |
|
159 | 159 | print __METHOD__." valtotest=".$valtotest."\n"; |
160 | 160 | $result = $objmodel->csvClean($valtotest, $langs->charset_output); |
161 | 161 | print __METHOD__." result=".$result."\n"; |
162 | 162 | $this->assertEquals($result, '"A string with "" inside"'); |
163 | 163 | |
164 | - $valtotest='A string with " inside and '."\r\n".' carriage returns'; |
|
164 | + $valtotest = 'A string with " inside and '."\r\n".' carriage returns'; |
|
165 | 165 | print __METHOD__." valtotest=".$valtotest."\n"; |
166 | 166 | $result = $objmodel->csvClean($valtotest, $langs->charset_output); |
167 | 167 | print __METHOD__." result=".$result."\n"; |
168 | 168 | $this->assertEquals($result, '"A string with "" inside and \n carriage returns"'); |
169 | 169 | |
170 | - $valtotest='A string with <a href="aaa"><strong>html<br>content</strong></a> inside<br>'."\n"; |
|
170 | + $valtotest = 'A string with <a href="aaa"><strong>html<br>content</strong></a> inside<br>'."\n"; |
|
171 | 171 | print __METHOD__." valtotest=".$valtotest."\n"; |
172 | 172 | $result = $objmodel->csvClean($valtotest, $langs->charset_output); |
173 | 173 | print __METHOD__." result=".$result."\n"; |
174 | 174 | $this->assertEquals($result, '"A string with <a href=""aaa""><strong>html<br>content</strong></a> inside"'); |
175 | 175 | |
176 | 176 | // Same tests with strict mode |
177 | - $conf->global->USE_STRICT_CSV_RULES=1; |
|
177 | + $conf->global->USE_STRICT_CSV_RULES = 1; |
|
178 | 178 | |
179 | - $valtotest='A simple string'; |
|
179 | + $valtotest = 'A simple string'; |
|
180 | 180 | print __METHOD__." valtotest=".$valtotest."\n"; |
181 | 181 | $result = $objmodel->csvClean($valtotest, $langs->charset_output); |
182 | 182 | print __METHOD__." result=".$result."\n"; |
183 | 183 | $this->assertEquals($result, 'A simple string'); |
184 | 184 | |
185 | - $valtotest='A string with , and ; inside'; |
|
185 | + $valtotest = 'A string with , and ; inside'; |
|
186 | 186 | print __METHOD__." valtotest=".$valtotest."\n"; |
187 | 187 | $result = $objmodel->csvClean($valtotest, $langs->charset_output); |
188 | 188 | print __METHOD__." result=".$result."\n"; |
189 | 189 | $this->assertEquals($result, '"A string with , and ; inside"'); |
190 | 190 | |
191 | - $valtotest='A string with " inside'; |
|
191 | + $valtotest = 'A string with " inside'; |
|
192 | 192 | print __METHOD__." valtotest=".$valtotest."\n"; |
193 | 193 | $result = $objmodel->csvClean($valtotest, $langs->charset_output); |
194 | 194 | print __METHOD__." result=".$result."\n"; |
195 | 195 | $this->assertEquals($result, '"A string with "" inside"'); |
196 | 196 | |
197 | - $valtotest='A string with " inside and '."\r\n".' carriage returns'; |
|
197 | + $valtotest = 'A string with " inside and '."\r\n".' carriage returns'; |
|
198 | 198 | print __METHOD__." valtotest=".$valtotest."\n"; |
199 | 199 | $result = $objmodel->csvClean($valtotest, $langs->charset_output); |
200 | 200 | print __METHOD__." result=".$result."\n"; |
201 | 201 | $this->assertEquals($result, "\"A string with \"\" inside and \r\n carriage returns\""); |
202 | 202 | |
203 | - $valtotest='A string with <a href="aaa"><strong>html<br>content</strong></a> inside<br>'."\n"; |
|
203 | + $valtotest = 'A string with <a href="aaa"><strong>html<br>content</strong></a> inside<br>'."\n"; |
|
204 | 204 | print __METHOD__." valtotest=".$valtotest."\n"; |
205 | 205 | $result = $objmodel->csvClean($valtotest, $langs->charset_output); |
206 | 206 | print __METHOD__." result=".$result."\n"; |
@@ -215,43 +215,43 @@ discard block |
||
215 | 215 | */ |
216 | 216 | public function testExportPersonalizedExport() |
217 | 217 | { |
218 | - global $conf,$user,$langs,$db; |
|
218 | + global $conf, $user, $langs, $db; |
|
219 | 219 | |
220 | 220 | $sql = "SELECT f.ref as f_ref, f.total as f_total, f.tva as f_tva FROM ".MAIN_DB_PREFIX."facture f"; |
221 | 221 | |
222 | - $objexport=new Export($db); |
|
222 | + $objexport = new Export($db); |
|
223 | 223 | //$objexport->load_arrays($user,$datatoexport); |
224 | 224 | |
225 | 225 | // Define properties |
226 | - $datatoexport='test'; |
|
226 | + $datatoexport = 'test'; |
|
227 | 227 | $array_selected = array("f.ref"=>1, "f.total"=>2, "f.tva"=>3); |
228 | 228 | $array_export_fields = array("f.ref"=>"FacNumber", "f.total"=>"FacTotal", "f.tva"=>"FacVat"); |
229 | 229 | $array_alias = array("f_ref"=>"ref", "f_total"=>"total", "f_tva"=>"tva"); |
230 | - $objexport->array_export_fields[0]=$array_export_fields; |
|
231 | - $objexport->array_export_alias[0]=$array_alias; |
|
230 | + $objexport->array_export_fields[0] = $array_export_fields; |
|
231 | + $objexport->array_export_alias[0] = $array_alias; |
|
232 | 232 | |
233 | 233 | dol_mkdir($conf->export->dir_temp); |
234 | 234 | |
235 | - $model='csv'; |
|
235 | + $model = 'csv'; |
|
236 | 236 | |
237 | 237 | // Build export file |
238 | - $result=$objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql); |
|
239 | - $expectedresult=1; |
|
240 | - $this->assertEquals($expectedresult,$result); |
|
238 | + $result = $objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql); |
|
239 | + $expectedresult = 1; |
|
240 | + $this->assertEquals($expectedresult, $result); |
|
241 | 241 | |
242 | - $model='tsv'; |
|
242 | + $model = 'tsv'; |
|
243 | 243 | |
244 | 244 | // Build export file |
245 | - $result=$objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql); |
|
246 | - $expectedresult=1; |
|
247 | - $this->assertEquals($expectedresult,$result); |
|
245 | + $result = $objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql); |
|
246 | + $expectedresult = 1; |
|
247 | + $this->assertEquals($expectedresult, $result); |
|
248 | 248 | |
249 | - $model='excel'; |
|
249 | + $model = 'excel'; |
|
250 | 250 | |
251 | 251 | // Build export file |
252 | - $result=$objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql); |
|
253 | - $expectedresult=1; |
|
254 | - $this->assertEquals($expectedresult,$result); |
|
252 | + $result = $objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql); |
|
253 | + $expectedresult = 1; |
|
254 | + $this->assertEquals($expectedresult, $result); |
|
255 | 255 | |
256 | 256 | return true; |
257 | 257 | } |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | */ |
265 | 265 | public function testExportPersonalizedWithFilter() |
266 | 266 | { |
267 | - global $conf,$user,$langs,$db; |
|
267 | + global $conf, $user, $langs, $db; |
|
268 | 268 | /* |
269 | 269 | $sql = "SELECT f.ref as f_ref, f.total as f_total, f.tva as f_tva FROM ".MAIN_DB_PREFIX."facture f"; |
270 | 270 | |
@@ -315,40 +315,40 @@ discard block |
||
315 | 315 | */ |
316 | 316 | public function testExportModulesDatasets() |
317 | 317 | { |
318 | - global $conf,$user,$langs,$db; |
|
318 | + global $conf, $user, $langs, $db; |
|
319 | 319 | |
320 | - $model='csv'; |
|
320 | + $model = 'csv'; |
|
321 | 321 | |
322 | - $filterdatatoexport=''; |
|
322 | + $filterdatatoexport = ''; |
|
323 | 323 | //$filterdatatoexport=''; |
324 | 324 | //$array_selected = array("s.rowid"=>1, "s.nom"=>2); // Mut be fields found into declaration of dataset |
325 | 325 | |
326 | 326 | // Load properties of arrays to make export |
327 | - $objexport=new Export($db); |
|
328 | - $result=$objexport->load_arrays($user,$filterdatatoexport); // This load ->array_export_xxx properties for datatoexport |
|
327 | + $objexport = new Export($db); |
|
328 | + $result = $objexport->load_arrays($user, $filterdatatoexport); // This load ->array_export_xxx properties for datatoexport |
|
329 | 329 | |
330 | 330 | // Loop on each dataset |
331 | - foreach($objexport->array_export_code as $key => $datatoexport) |
|
331 | + foreach ($objexport->array_export_code as $key => $datatoexport) |
|
332 | 332 | { |
333 | - $exportfile=$conf->export->dir_temp.'/'.$user->id.'/export_'.$datatoexport.'.csv'; |
|
333 | + $exportfile = $conf->export->dir_temp.'/'.$user->id.'/export_'.$datatoexport.'.csv'; |
|
334 | 334 | print "Process export for dataset ".$datatoexport." into ".$exportfile."\n"; |
335 | 335 | dol_delete_file($exportfile); |
336 | 336 | |
337 | 337 | // Generate $array_selected |
338 | - $i=0; |
|
339 | - $array_selected=array(); |
|
340 | - foreach($objexport->array_export_fields[$key] as $key => $val) |
|
338 | + $i = 0; |
|
339 | + $array_selected = array(); |
|
340 | + foreach ($objexport->array_export_fields[$key] as $key => $val) |
|
341 | 341 | { |
342 | - $array_selected[$key]=$i++; |
|
342 | + $array_selected[$key] = $i++; |
|
343 | 343 | } |
344 | 344 | //var_dump($array_selected); |
345 | 345 | |
346 | 346 | // Build export file |
347 | 347 | $sql = ""; |
348 | - $result=$objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql); |
|
349 | - $expectedresult=1; |
|
348 | + $result = $objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql); |
|
349 | + $expectedresult = 1; |
|
350 | 350 | $this->assertEquals($expectedresult, $result, "Call build_file() to export ".$exportfile.' failed'); |
351 | - $result=dol_is_file($exportfile); |
|
351 | + $result = dol_is_file($exportfile); |
|
352 | 352 | $this->assertTrue($result, 'File '.$exportfile.' not found'); |
353 | 353 | } |
354 | 354 |
@@ -30,16 +30,39 @@ |
||
30 | 30 | require_once dirname(__FILE__).'/../../htdocs/exports/class/export.class.php'; |
31 | 31 | require_once dirname(__FILE__).'/../../htdocs/core/lib/files.lib.php'; |
32 | 32 | |
33 | -if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); |
|
34 | -if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); |
|
35 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
36 | -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); |
|
37 | -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); |
|
38 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); |
|
39 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show |
|
40 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php |
|
41 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
42 | -if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) |
|
33 | +if (! defined('NOREQUIREUSER')) { |
|
34 | + define('NOREQUIREUSER','1'); |
|
35 | +} |
|
36 | +if (! defined('NOREQUIREDB')) { |
|
37 | + define('NOREQUIREDB','1'); |
|
38 | +} |
|
39 | +if (! defined('NOREQUIRESOC')) { |
|
40 | + define('NOREQUIRESOC','1'); |
|
41 | +} |
|
42 | +if (! defined('NOREQUIRETRAN')) { |
|
43 | + define('NOREQUIRETRAN','1'); |
|
44 | +} |
|
45 | +if (! defined('NOCSRFCHECK')) { |
|
46 | + define('NOCSRFCHECK','1'); |
|
47 | +} |
|
48 | +if (! defined('NOTOKENRENEWAL')) { |
|
49 | + define('NOTOKENRENEWAL','1'); |
|
50 | +} |
|
51 | +if (! defined('NOREQUIREMENU')) { |
|
52 | + define('NOREQUIREMENU','1'); |
|
53 | +} |
|
54 | +// If there is no menu to show |
|
55 | +if (! defined('NOREQUIREHTML')) { |
|
56 | + define('NOREQUIREHTML','1'); |
|
57 | +} |
|
58 | +// If we don't need to load the html.form.class.php |
|
59 | +if (! defined('NOREQUIREAJAX')) { |
|
60 | + define('NOREQUIREAJAX','1'); |
|
61 | +} |
|
62 | +if (! defined("NOLOGIN")) { |
|
63 | + define("NOLOGIN",'1'); |
|
64 | +} |
|
65 | +// If this page is public (can be called outside logged session) |
|
43 | 66 | |
44 | 67 | |
45 | 68 | /** |