Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
PU_test_dcp_parametermanager.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 
7 namespace Dcp\Pu;
8 /**
9  * @author Anakeen
10  * @package Dcp\Pu
11  */
12 
13 require_once 'PU_testcase_dcp.php';
14 
16 {
17 
18  const appName = "DCPTEST2";
19 
20  /**
21  * Add conf
22  *
23  * @return array
24  */
25  public static function appConfig()
26  {
27  return array(
28  "appRoot" => join(DIRECTORY_SEPARATOR, array(
30  "DCPTEST",
31  "app"
32  )),
33  "appName" => "TST_PARAMETER_MANAGER"
34  );
35  }
36 
37  /**
38  * @param $parameters
39  * @return \Application
40  */
41  private function initTestApplication($parameters)
42  {
43  $appTest = new \Application(self::$dbaccess);
44  $appTest->name = self::appName;
45  $appTest->childof = 'TST_PARAMETER_MANAGER';
46  $err = $appTest->Add();
47 
48  $this->assertEmpty($err, "Cannot create application : $err");
49  $parent = null;
50  $appTest->set(self::appName, $parent);
51 
52  $this->assertTrue($appTest->isAffected() , sprintf("DCPTEST2 app not found"));
53 
54  $appTest->InitAllParam($parameters, $update = false);
55  $a = $this->getAction();
56  // add new parameters in current action
57  $a->parent->param->SetKey($appTest->id, $a->user->id);
58 
60  return $appTest;
61  }
62  /**
63  * @dataProvider dataGetParam
64  */
65  public function testGetParam($parameters, array $expectedValues)
66  {
67 
68  $appTest = $this->initTestApplication($parameters);
69 
70  foreach ($expectedValues as $k => $v) {
71  $this->assertEquals($v, \ParameterManager::getApplicationParameter(self::appName, $k) , sprintf("wrong value for %s", $k));
72  }
73  }
74  /**
75  * @dataProvider dataGetGlobalParam
76  */
77  public function testGetGlobalParam($parameters, array $expectedValues)
78  {
79 
80  $appTest = $this->initTestApplication($parameters);
81 
82  foreach ($expectedValues as $k => $v) {
83  $this->assertEquals($v, \ParameterManager::getParameter($k) , sprintf("wrong value for %s", $k));
84  }
85  }
86  /**
87  * @dataProvider dataSetApplicationParameter
88  */
89  public function testSetApplicationParameter($parameters, array $newValues, array $expectedValues)
90  {
91 
92  $appTest = $this->initTestApplication($parameters);
93 
94  foreach ($newValues as $k => $v) {
95  \ParameterManager::setApplicationParameter(self::appName, $k, $v);
96  }
97  foreach ($expectedValues as $k => $v) {
98  $this->assertEquals($v, \ParameterManager::getApplicationParameter(self::appName, $k) , sprintf("wrong value for %s", $k));
99  }
100  }
101  /**
102  * @dataProvider dataSetGlobalParameter
103  */
104  public function testSetGlobalParameter($parameters, array $newValues, array $expectedValues)
105  {
106 
107  $appTest = $this->initTestApplication($parameters);
108 
109  foreach ($newValues as $k => $v) {
110 
112  }
113  foreach ($expectedValues as $k => $v) {
114  $this->assertEquals($v, \ParameterManager::getParameter($k) , sprintf("wrong value for %s", $k));
115  }
116  }
117  /**
118  * @dataProvider dataSetUserApplicationParameter
119  */
120  public function testSetUserApplicationParameter($parameters, array $newValues, array $expectedValues)
121  {
122 
123  $appTest = $this->initTestApplication($parameters);
124 
125  foreach ($newValues as $k => $v) {
126  \ParameterManager::setUserApplicationParameter(self::appName, $k, $v);
127  }
128  foreach ($expectedValues as $k => $v) {
129  $this->assertEquals($v, \ParameterManager::getApplicationParameter(self::appName, $k) , sprintf("wrong value for %s", $k));
130  }
131  }
132  /**
133  * @dataProvider dataUserSetGlobalParameter
134  */
135  public function testSetUserGlobalParameter($parameters, array $newValues, array $expectedValues)
136  {
137 
138  $appTest = $this->initTestApplication($parameters);
139 
140  foreach ($newValues as $k => $v) {
141 
143  }
144  foreach ($expectedValues as $k => $v) {
145  $this->assertEquals($v, \ParameterManager::getParameter($k) , sprintf("wrong value for %s", $k));
146  }
147  }
148 
149  public function dataUserSetGlobalParameter()
150  {
151  return array(
152  array(
153  "init" => array(
154  "VERSION" => "4.0.8",
155  "TST_NAMEP1" => array(
156  "val" => "Test 2",
157  "descr" => "Name of test one",
158  "global" => "Y",
159  "user" => "Y"
160  ) ,
161  "TST_GLOB2" => array(
162  "val" => "Test global 2",
163  "descr" => "Name of the glob",
164  "global" => "Y",
165  "user" => "Y"
166  )
167  ) ,
168  "set" => array(
169  "TST_NAMEP1" => "Test 3",
170  "TST_GLOB2" => "Test G3",
171  ) ,
172  "expect" => array(
173  "TST_NAMEP1" => "Test 3",
174  "VERSION" => "4.0.8",
175  "TST_GLOB2" => "Test G3"
176  )
177  )
178  );
179  }
180 
182  {
183  return array(
184  array(
185  "init" => array(
186  "VERSION" => "0.3.2-2",
187  "PARENT_USER_PARAMETER" => "128",
188  "TST_NAMEP1" => array(
189  "val" => "Test 2",
190  "descr" => "Name of test one",
191  "global" => "N",
192  "user" => "Y"
193  ) ,
194  "TST_GLOB2" => array(
195  "val" => "Test global 2",
196  "descr" => "Name of the glob",
197  "global" => "Y",
198  "user" => "Y"
199  )
200  ) ,
201  "set" => array(
202  "PARENT_USER_PARAMETER" => "128,127",
203  "TST_NAMEP1" => "Test 3",
204  ) ,
205  "expect" => array(
206  "TST_NAMEP1" => "Test 3",
207  "PARENT_USER_PARAMETER" => "128,127",
208  "TST_GLOB2" => "Test global 2"
209  )
210  )
211  );
212  }
213  public function dataSetGlobalParameter()
214  {
215  return array(
216  array(
217  "init" => array(
218  "VERSION" => "4.0.8",
219  "PARENT_USER_GLOBAL_PARAMETER" => "128",
220  "TST_NAMEP1" => array(
221  "val" => "Test 2",
222  "descr" => "Name of test one",
223  "global" => "Y",
224  "user" => "N"
225  ) ,
226  "TST_GLOB2" => array(
227  "val" => "Test global 2",
228  "descr" => "Name of the glob",
229  "global" => "Y",
230  "user" => "N"
231  )
232  ) ,
233  "set" => array(
234  "TST_NAMEP1" => "Test 3",
235  "TST_GLOB2" => "Test G3",
236  ) ,
237  "expect" => array(
238  "TST_NAMEP1" => "Test 3",
239  "VERSION" => "4.0.8",
240  "TST_GLOB2" => "Test G3"
241  )
242  )
243  );
244  }
245  public function dataSetApplicationParameter()
246  {
247  return array(
248  array(
249  "init" => array(
250  "VERSION" => "0.3.2-2",
251  "PARENT_USER_PARAMETER" => "128",
252  "TST_NAMEP1" => array(
253  "val" => "Test 2",
254  "descr" => "Name of test one",
255  "global" => "N",
256  "user" => "N"
257  ) ,
258  "TST_GLOB2" => array(
259  "val" => "Test global 2",
260  "descr" => "Name of the glob",
261  "global" => "Y",
262  "user" => "N"
263  )
264  ) ,
265  "set" => array(
266  "VERSION" => "4.0.7",
267  "PARENT_USER_PARAMETER" => "128,127",
268  "TST_NAMEP1" => "Test 3",
269  ) ,
270  "expect" => array(
271  "TST_NAMEP1" => "Test 3",
272  "VERSION" => "4.0.7",
273  "PARENT_USER_PARAMETER" => "128,127",
274  "TST_GLOB2" => "Test global 2"
275  )
276  )
277  );
278  }
279 
280  public function dataGetParam()
281  {
282  return array(
283  array(
284  array(
285  "VERSION" => "0.3.2-2",
286  "PARENT_PARAMETER" => "128",
287  "TST_NAMEP1" => array(
288  "val" => "Test 1",
289  "descr" => "Name of test one",
290  "global" => "N",
291  "user" => "N"
292  ) ,
293  "TST_GLOB1" => array(
294  "val" => "Test global 1",
295  "descr" => "Name of the glob",
296  "global" => "Y",
297  "user" => "N"
298  )
299  ) ,
300  array(
301  "TST_NAMEP1" => "Test 1",
302  "VERSION" => "0.3.2-2",
303  "PARENT_PARAMETER" => "128",
304  "TST_GLOB1" => "Test global 1"
305  )
306  )
307  );
308  }
309 
310  public function dataGetGlobalParam()
311  {
312  return array(
313  array(
314  array(
315  "VERSION" => "0.3.2-2",
316  "PARENT_USER_GLOBAL_PARAMETER" => "128",
317  "TST_NAMEP1" => array(
318  "val" => "Test 1",
319  "descr" => "Name of test one",
320  "global" => "N",
321  "user" => "N"
322  ) ,
323  "TST_GLOB1" => array(
324  "val" => "Test global 2",
325  "descr" => "Name of the glob",
326  "global" => "Y",
327  "user" => "N"
328  )
329  ) ,
330  array(
331  "TST_GLOB1" => "Test global 2"
332  )
333  )
334  );
335  }
336 }
337 ?>
static setUserApplicationParameter($appName, $name, $value, $userId=null)
testSetUserApplicationParameter($parameters, array $newValues, array $expectedValues)
print< H1 > Check Database< i > $dbaccess</i ></H1 > $a
Definition: checklist.php:45
static setGlobalParameter($name, $value)
testSetApplicationParameter($parameters, array $newValues, array $expectedValues)
static getApplicationParameter($appName, $name)
static setGlobalUserParameter($name, $value, $userId=null)
const DEFAULT_PUBDIR
Definition: Lib.Prefix.php:28
testSetGlobalParameter($parameters, array $newValues, array $expectedValues)
testGetGlobalParam($parameters, array $expectedValues)
static setApplicationParameter($appName, $name, $value)
$dbaccess
Definition: checkVault.php:17
testGetParam($parameters, array $expectedValues)
if($file) if($subject==""&&$file) if($subject=="") $err
testSetUserGlobalParameter($parameters, array $newValues, array $expectedValues)
← centre documentaire © anakeen